diff mbox

powerpc: Fix definition of SIAR and SDAR registers

Message ID 1463052404-18092-1-git-send-email-thuth@redhat.com (mailing list archive)
State Accepted
Headers show

Commit Message

Thomas Huth May 12, 2016, 11:26 a.m. UTC
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(-)

Comments

Paul Mackerras May 13, 2016, 3:35 a.m. UTC | #1
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>
Thomas Huth May 30, 2016, 8:04 a.m. UTC | #2
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
Michael Ellerman May 30, 2016, 11:27 p.m. UTC | #3
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
Michael Ellerman May 31, 2016, 10:17 a.m. UTC | #4
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
diff mbox

Patch

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