Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1707953

[PATCH 3.18 09/92] KVM: PPC: Book3S HV: Save/restore host values of debug registers

From Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Newsgroups linux.kernel
Subject [PATCH 3.18 09/92] KVM: PPC: Book3S HV: Save/restore host values of debug registers
Date 2017-08-09 23:10 +0200
Message-ID <ucGoN-4hg-9@gated-at.bofh.it> (permalink)
References <ucFVM-3Rs-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


3.18-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Paul Mackerras <paulus@ozlabs.org>

commit 7ceaa6dcd8c6f59588428cec37f3c8093dd1011f upstream.

At present, HV KVM on POWER8 and POWER9 machines loses any instruction
or data breakpoint set in the host whenever a guest is run.
Instruction breakpoints are currently only used by xmon, but ptrace
and the perf_event subsystem can set data breakpoints as well as xmon.

To fix this, we save the host values of the debug registers (CIABR,
DAWR and DAWRX) before entering the guest and restore them on exit.
To provide space to save them in the stack frame, we expand the stack
frame allocated by kvmppc_hv_entry() from 112 to 144 bytes.

[paulus@ozlabs.org - Adjusted stack offsets since we aren't saving
 POWER9-specific registers.]

Fixes: b005255e12a3 ("KVM: PPC: Book3S HV: Context-switch new POWER8 SPRs", 2014-01-08)
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/powerpc/kvm/book3s_hv_rmhandlers.S |   35 +++++++++++++++++++++++++++-----
 1 file changed, 30 insertions(+), 5 deletions(-)

--- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S
+++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
@@ -36,6 +36,12 @@
 #define NAPPING_CEDE	1
 #define NAPPING_NOVCPU	2
 
+/* Stack frame offsets for kvmppc_hv_entry */
+#define SFS			112
+#define STACK_SLOT_CIABR	(SFS-16)
+#define STACK_SLOT_DAWR		(SFS-24)
+#define STACK_SLOT_DAWRX	(SFS-32)
+
 /*
  * Call kvmppc_hv_entry in real mode.
  * Must be called with interrupts hard-disabled.
@@ -360,7 +366,7 @@ kvmppc_hv_entry:
 	 */
 	mflr	r0
 	std	r0, PPC_LR_STKOFF(r1)
-	stdu	r1, -112(r1)
+	stdu	r1, -SFS(r1)
 
 	/* Save R1 in the PACA */
 	std	r1, HSTATE_HOST_R1(r13)
@@ -618,6 +624,16 @@ BEGIN_FTR_SECTION
 	mtspr	SPRN_SPURR,r8
 END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206)
 
+	/* Save host values of some registers */
+BEGIN_FTR_SECTION
+	mfspr	r5, SPRN_CIABR
+	mfspr	r6, SPRN_DAWR
+	mfspr	r7, SPRN_DAWRX
+	std	r5, STACK_SLOT_CIABR(r1)
+	std	r6, STACK_SLOT_DAWR(r1)
+	std	r7, STACK_SLOT_DAWRX(r1)
+END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
+
 BEGIN_FTR_SECTION
 	/* Set partition DABR */
 	/* Do this before re-enabling PMU to avoid P7 DABR corruption bug */
@@ -1180,8 +1196,6 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S)
 	 */
 	li	r0, 0
 	mtspr	SPRN_IAMR, r0
-	mtspr	SPRN_CIABR, r0
-	mtspr	SPRN_DAWRX, r0
 	mtspr	SPRN_PSPB, r0
 	mtspr	SPRN_TCSCR, r0
 	mtspr	SPRN_WORT, r0
@@ -1358,6 +1372,17 @@ hdec_soon:			/* r12 = trap, r13 = paca *
 BEGIN_FTR_SECTION
 	b	32f
 END_FTR_SECTION_IFSET(CPU_FTR_ARCH_201)
+
+	/* Restore host values of some registers */
+BEGIN_FTR_SECTION
+	ld	r5, STACK_SLOT_CIABR(r1)
+	ld	r6, STACK_SLOT_DAWR(r1)
+	ld	r7, STACK_SLOT_DAWRX(r1)
+	mtspr	SPRN_CIABR, r5
+	mtspr	SPRN_DAWR, r6
+	mtspr	SPRN_DAWRX, r7
+END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
+
 	/*
 	 * POWER7 guest -> host partition switch code.
 	 * We don't have to lock against tlbies but we do
@@ -1584,8 +1609,8 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
 	li	r0, KVM_GUEST_MODE_NONE
 	stb	r0, HSTATE_IN_GUEST(r13)
 
-	ld	r0, 112+PPC_LR_STKOFF(r1)
-	addi	r1, r1, 112
+	ld	r0, SFS+PPC_LR_STKOFF(r1)
+	addi	r1, r1, SFS
 	mtlr	r0
 	blr
 

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 3.18 00/92] 3.18.64-stable review - take 2 Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:40 +0200
  [PATCH 3.18 23/92] mailbox: handle empty message in tx_tick Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:40 +0200
  [PATCH 3.18 36/92] pstore: Use dynamic spinlock initializer Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:40 +0200
  [PATCH 3.18 10/92] Revert "powerpc/numa: Fix percpu allocations to be NUMA aware" Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:40 +0200
  [PATCH 3.18 18/92] strscpy: zero any trailing garbage bytes in the destination Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:40 +0200
  [PATCH 3.18 06/92] drm/vmwgfx: Fix gcc-7.1.1 warning Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:40 +0200
  [PATCH 3.18 02/92] pstore: Make spinlock per zone instead of global Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:40 +0200
  [PATCH 3.18 27/92] ipv6: fix possible deadlock in ip6_fl_purge / ip6_fl_gc Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:40 +0200
  [PATCH 3.18 28/92] net: sctp: fix race for one-to-many sockets in sendmsgs auto associate Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:40 +0200
  [PATCH 3.18 11/92] Staging: comedi: comedi_fops: Avoid orphaned proc entry Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:40 +0200
  [PATCH 3.18 16/92] isdn: Fix a sleep-in-atomic bug Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:40 +0200
  [PATCH 3.18 37/92] net: skb_needs_check() accepts CHECKSUM_NONE for tx Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:40 +0200
  [PATCH 3.18 08/92] KVM: PPC: Book3S HV: Reload HTM registers explicitly Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:40 +0200
  [PATCH 3.18 34/92] pstore: Allow prz to control need for locking Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:40 +0200
  [PATCH 3.18 50/92] xfrm: Dont use sk_family for socket policy lookups Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:40 +0200
  [PATCH 3.18 71/92] net: Zero terminate ifr_name in dev_ifname(). Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:40 +0200
  [PATCH 3.18 14/92] Bluetooth: cmtp: cmtp_add_connection() should verify that its dealing with l2cap socket Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:40 +0200
  [PATCH 3.18 03/92] net: reduce skb_warn_bad_offload() noise Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:40 +0200
  [PATCH 3.18 35/92] pstore: Correctly initialize spinlock and flags Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:40 +0200
  [PATCH 3.18 30/92] net, sched: fix soft lockup in tc_classify Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 53/92] Make asm/word-at-a-time.h available on all architectures Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 76/92] packet: fix use-after-free in prb_retire_rx_blk_timer_expired() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 48/92] spi: dw: Make debugfs name unique between instances Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 82/92] wext: handle NULL extra data in iwe_stream_add_point better Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 80/92] net: phy: Correctly process PHY_HALTED in phy_stop_machine() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 64/92] media: platform: davinci: return -EINVAL for VPFE_CMD_S_CCDC_RAW_PARAMS ioctl Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 75/92] mcs7780: Fix initialization when CONFIG_VMAP_STACK is enabled Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 59/92] ASoC: do not close shared backend dailink Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 72/92] ipv6: avoid overflow of offset in ip6_find_1stfragopt Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 46/92] vfio-pci: use 32-bit comparisons for register address for gcc-4.5 Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 49/92] vlan: Propagate MAC address to VLANs Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 88/92] mm, slab: make sure that KMALLOC_MAX_SIZE will fit into MAX_ORDER Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 13/92] Bluetooth: Fix potential NULL dereference Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 39/92] x86/mce/AMD: Make the init code more robust Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 21/92] mailbox: always wait in mbox_send_message for blocking Tx mode Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 68/92] iscsi-target: Fix initial login PDU asynchronous socket close OOPs Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 57/92] workqueue: restore WQ_UNBOUND/max_active==1 to be ordered Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 85/92] x86/boot: Add missing declaration of string functions Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 89/92] lib/Kconfig.debug: fix frv build failure Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 70/92] f2fs: sanity check checkpoint segno and blkoff Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 19/92] isdn/i4l: fix buffer overflow Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 92/92] ipv4: Should use consistent conditional judgement for ip fragment in __ip_append_data and ip_finish_output Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 81/92] xen-netback: correctly schedule rate-limited queues Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 24/92] mpt3sas: Dont overreach ioc->reply_post[] during initialization Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 91/92] mm: dont dereference struct page fields of invalid pages Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 61/92] mm/page_alloc: Remove kernel address exposure in free_reserved_area() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 47/92] ASoC: tlv320aic3x: Mark the RESET register as volatile Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 87/92] ARM: 8632/1: ftrace: fix syscall name matching Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 38/92] tpm: fix a kernel memory leak in tpm-sysfs.c Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 83/92] sh_eth: R8A7740 supports packet shecksumming Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 58/92] ALSA: hda - Fix speaker output from VAIO VPCL14M1R Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 79/92] sctp: fix the check for _sctp_walk_params and _sctp_walk_errors Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 78/92] sctp: dont dereference ptr before leaving _sctp_walk_{params, errors}() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 84/92] tg3: Fix race condition in tg3_get_stats64(). Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 69/92] iscsi-target: Fix delayed logout processing greater than SECONDS_FOR_LOGOUT_COMP Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 86/92] scsi: qla2xxx: Get mutex lock before checking optrom_state Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 54/92] arch/powerpc: provide zero_bytemask() for big-endian Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 63/92] ext4: fix overflow caused by missing cast in ext4_resize_fs() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 44/92] drm/msm: Ensure that the hardware write pointer is valid Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 62/92] ext4: fix SEEK_HOLE/SEEK_DATA for blocksize < pagesize Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 45/92] drm/msm: Verify that MSM_SUBMIT_BO_FLAGS are set Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 07/92] KVM: PPC: Book3S HV: Restore critical SPRs to host values on guest exit Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 90/92] signal: protect SIGNAL_UNKILLABLE from unintentional clearing. Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 66/92] iscsi-target: Always wait for kthread_should_stop() before kthread exit Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 22:50 +0200
  [PATCH 3.18 22/92] mailbox: skip complete wait event if timer expired Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 23:00 +0200
  [PATCH 3.18 56/92] libata: array underflow in ata_find_dev() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 23:00 +0200
  [PATCH 3.18 31/92] ipmi/watchdog: fix watchdog timeout set on reboot Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 23:00 +0200
  [PATCH 3.18 55/92] tile: use global strscpy() rather than private copy Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 23:00 +0200
  [PATCH 3.18 77/92] dccp: fix a memleak for dccp_feat_init err process Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 23:00 +0200
  [PATCH 3.18 73/92] ipv4: initialize fib_trie prior to register_netdev_notifier call. Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 23:00 +0200
  [PATCH 3.18 42/92] ipv6: Should use consistent conditional judgement for ip6 fragment between __ip6_append_data and ip6_finish_output Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 23:00 +0200
  [PATCH 3.18 32/92] dentry name snapshots Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 23:00 +0200
  [PATCH 3.18 17/92] string: provide strscpy() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 23:00 +0200
  [PATCH 3.18 20/92] wil6210: fix deadlock when using fw_no_recovery option Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 23:00 +0200
  [PATCH 3.18 25/92] kaweth: fix firmware download Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 23:00 +0200
  [PATCH 3.18 43/92] net/mlx4: Remove BUG_ON from ICM allocation routine Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 23:00 +0200
  [PATCH 3.18 65/92] target: Avoid mappedlun symlink creation during lun shutdown Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 23:00 +0200
  [PATCH 3.18 67/92] iscsi-target: Fix early sk_data_ready LOGIN_FLAGS_READY race Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 23:00 +0200
  [PATCH 3.18 51/92] tile: add <asm/word-at-a-time.h> and enable support functions Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 23:00 +0200
  [PATCH 3.18 26/92] kaweth: fix oops upon failed memory allocation Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 23:00 +0200
  [PATCH 3.18 33/92] [media] v4l: s5c73m3: fix negation operator Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 23:00 +0200
  [PATCH 3.18 52/92] word-at-a-time.h: support zero_bytemask() on alpha and tile Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 23:00 +0200
  [PATCH 3.18 40/92] r8169: add support for RTL8168 series add-on card. Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 23:00 +0200
  [PATCH 3.18 74/92] rtnetlink: allocate more memory for dev_set_mac_address() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 23:00 +0200
  [PATCH 3.18 04/92] powerpc/pseries: Fix of_node_put() underflow during reconfig remove Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 23:10 +0200
  [PATCH 3.18 09/92] KVM: PPC: Book3S HV: Save/restore host values of debug registers Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 23:10 +0200
  [PATCH 3.18 05/92] md/raid5: add thread_group worker async_tx_issue_pending_all Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 23:10 +0200
  [PATCH 3.18 01/92] af_key: Add lock to key dump Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 23:10 +0200
  [PATCH 3.18 12/92] Bluetooth: bnep: bnep_add_connection() should verify that its dealing with l2cap socket Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-09 23:10 +0200
  Re: [PATCH 3.18 00/92] 3.18.64-stable review - take 2 Shuah Khan <shuahkh@osg.samsung.com> - 2017-08-10 02:00 +0200
    Re: [PATCH 3.18 00/92] 3.18.64-stable review - take 2 Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-10 04:40 +0200
  Re: [PATCH 3.18 00/92] 3.18.64-stable review - take 2 Guenter Roeck <linux@roeck-us.net> - 2017-08-10 02:30 +0200
    Re: [PATCH 3.18 00/92] 3.18.64-stable review - take 2 Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-10 04:40 +0200

csiph-web