linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc: Fix definition of SIAR and SDAR registers
@ 2016-05-12 11:26 Thomas Huth
  2016-05-13  3:35 ` Paul Mackerras
  2016-05-31 10:17 ` Michael Ellerman
  0 siblings, 2 replies; 5+ messages in thread
From: Thomas Huth @ 2016-05-12 11:26 UTC (permalink / raw)
  To: Michael Ellerman, Paul Mackerras, linuxppc-dev
  Cc: Benjamin Herrenschmidt, kvm-ppc, Alexander Graf,
	Madhavan Srinivasan

The SIAR and SDAR registers are available twice, one time as SPRs
780 / 781 (unprivileged, but read-only), and one time as the SPRs
796 / 797 (privileged, but read and write). The Linux kernel code
currently uses the unprivileged  SPRs - while this is OK for reading,
writing to that register of course does not work.
Since the KVM code tries to write to this register, too (see the mtspr
in book3s_hv_rmhandlers.S), the contents of this register sometimes get
lost for the guests, e.g. during migration of a VM.
To fix this issue, simply switch to the privileged SPR numbers instead.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 arch/powerpc/include/asm/reg.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
index f5f4c66..ce3e1b7 100644
--- a/arch/powerpc/include/asm/reg.h
+++ b/arch/powerpc/include/asm/reg.h
@@ -752,13 +752,13 @@
 #define SPRN_PMC6	792
 #define SPRN_PMC7	793
 #define SPRN_PMC8	794
-#define SPRN_SIAR	780
-#define SPRN_SDAR	781
 #define SPRN_SIER	784
 #define   SIER_SIPR		0x2000000	/* Sampled MSR_PR */
 #define   SIER_SIHV		0x1000000	/* Sampled MSR_HV */
 #define   SIER_SIAR_VALID	0x0400000	/* SIAR contents valid */
 #define   SIER_SDAR_VALID	0x0200000	/* SDAR contents valid */
+#define SPRN_SIAR	796
+#define SPRN_SDAR	797
 #define SPRN_TACR	888
 #define SPRN_TCSCR	889
 #define SPRN_CSIGR	890
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] powerpc: Fix definition of SIAR and SDAR registers
  2016-05-12 11:26 [PATCH] powerpc: Fix definition of SIAR and SDAR registers Thomas Huth
@ 2016-05-13  3:35 ` Paul Mackerras
  2016-05-30  8:04   ` Thomas Huth
  2016-05-31 10:17 ` Michael Ellerman
  1 sibling, 1 reply; 5+ messages in thread
From: Paul Mackerras @ 2016-05-13  3:35 UTC (permalink / raw)
  To: Thomas Huth
  Cc: Michael Ellerman, linuxppc-dev, Benjamin Herrenschmidt, kvm-ppc,
	Alexander Graf, Madhavan Srinivasan

On Thu, May 12, 2016 at 01:26:44PM +0200, Thomas Huth wrote:
> The SIAR and SDAR registers are available twice, one time as SPRs
> 780 / 781 (unprivileged, but read-only), and one time as the SPRs
> 796 / 797 (privileged, but read and write). The Linux kernel code
> currently uses the unprivileged  SPRs - while this is OK for reading,
> writing to that register of course does not work.
> Since the KVM code tries to write to this register, too (see the mtspr
> in book3s_hv_rmhandlers.S), the contents of this register sometimes get
> lost for the guests, e.g. during migration of a VM.
> To fix this issue, simply switch to the privileged SPR numbers instead.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>

Acked-by: Paul Mackerras <paulus@ozlabs.org>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] powerpc: Fix definition of SIAR and SDAR registers
  2016-05-13  3:35 ` Paul Mackerras
@ 2016-05-30  8:04   ` Thomas Huth
  2016-05-30 23:27     ` Michael Ellerman
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Huth @ 2016-05-30  8:04 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Paul Mackerras, linuxppc-dev, Benjamin Herrenschmidt, kvm-ppc,
	Alexander Graf, Madhavan Srinivasan

On 13.05.2016 05:35, Paul Mackerras wrote:
> On Thu, May 12, 2016 at 01:26:44PM +0200, Thomas Huth wrote:
>> The SIAR and SDAR registers are available twice, one time as SPRs
>> 780 / 781 (unprivileged, but read-only), and one time as the SPRs
>> 796 / 797 (privileged, but read and write). The Linux kernel code
>> currently uses the unprivileged  SPRs - while this is OK for reading,
>> writing to that register of course does not work.
>> Since the KVM code tries to write to this register, too (see the mtspr
>> in book3s_hv_rmhandlers.S), the contents of this register sometimes get
>> lost for the guests, e.g. during migration of a VM.
>> To fix this issue, simply switch to the privileged SPR numbers instead.
>>
>> Signed-off-by: Thomas Huth <thuth@redhat.com>
> 
> Acked-by: Paul Mackerras <paulus@ozlabs.org>

*ping*

Michael, could you please pick this patch up? I think it should rather
go through the generic powerpc tree instead of kvm-ppc, since it also
affects other parts than just KVM...

Thanks,
 Thomas

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] powerpc: Fix definition of SIAR and SDAR registers
  2016-05-30  8:04   ` Thomas Huth
@ 2016-05-30 23:27     ` Michael Ellerman
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Ellerman @ 2016-05-30 23:27 UTC (permalink / raw)
  To: Thomas Huth
  Cc: Paul Mackerras, linuxppc-dev, Benjamin Herrenschmidt, kvm-ppc,
	Alexander Graf, Madhavan Srinivasan

On Mon, 2016-05-30 at 10:04 +0200, Thomas Huth wrote:
> On 13.05.2016 05:35, Paul Mackerras wrote:
> > On Thu, May 12, 2016 at 01:26:44PM +0200, Thomas Huth wrote:
> > > The SIAR and SDAR registers are available twice, one time as SPRs
> > > 780 / 781 (unprivileged, but read-only), and one time as the SPRs
> > > 796 / 797 (privileged, but read and write). The Linux kernel code
> > > currently uses the unprivileged  SPRs - while this is OK for reading,
> > > writing to that register of course does not work.
> > > Since the KVM code tries to write to this register, too (see the mtspr
> > > in book3s_hv_rmhandlers.S), the contents of this register sometimes get
> > > lost for the guests, e.g. during migration of a VM.
> > > To fix this issue, simply switch to the privileged SPR numbers instead.
> > > 
> > > Signed-off-by: Thomas Huth <thuth@redhat.com>
> > 
> > Acked-by: Paul Mackerras <paulus@ozlabs.org>
> 
> *ping*
> 
> Michael, could you please pick this patch up? I think it should rather
> go through the generic powerpc tree instead of kvm-ppc, since it also
> affects other parts than just KVM...

Yeah that's actually why I hesitated to merge it, because I want to know what
the broader implications are ...

I have also gone back and confirmed that the 796/797 numbers exist and are
correct on all CPUs we support, which involved a lot of digging through PDFs.

cheers

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: powerpc: Fix definition of SIAR and SDAR registers
  2016-05-12 11:26 [PATCH] powerpc: Fix definition of SIAR and SDAR registers Thomas Huth
  2016-05-13  3:35 ` Paul Mackerras
@ 2016-05-31 10:17 ` Michael Ellerman
  1 sibling, 0 replies; 5+ messages in thread
From: Michael Ellerman @ 2016-05-31 10:17 UTC (permalink / raw)
  To: Thomas Huth, Paul Mackerras, linuxppc-dev
  Cc: Madhavan Srinivasan, Alexander Graf, kvm-ppc

On Thu, 2016-12-05 at 11:26:44 UTC, Thomas Huth wrote:
> The SIAR and SDAR registers are available twice, one time as SPRs
> 780 / 781 (unprivileged, but read-only), and one time as the SPRs
> 796 / 797 (privileged, but read and write). The Linux kernel code
> currently uses the unprivileged  SPRs - while this is OK for reading,
> writing to that register of course does not work.
> Since the KVM code tries to write to this register, too (see the mtspr
> in book3s_hv_rmhandlers.S), the contents of this register sometimes get
> lost for the guests, e.g. during migration of a VM.
> To fix this issue, simply switch to the privileged SPR numbers instead.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> Acked-by: Paul Mackerras <paulus@ozlabs.org>

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/d23fac2b27d94aeb7b65536a50

cheers

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-05-31 10:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-12 11:26 [PATCH] powerpc: Fix definition of SIAR and SDAR registers Thomas Huth
2016-05-13  3:35 ` Paul Mackerras
2016-05-30  8:04   ` Thomas Huth
2016-05-30 23:27     ` Michael Ellerman
2016-05-31 10:17 ` Michael Ellerman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).