Skip to contentSkip to conversation

powerpc: Fix definition of SIAR register

PATCH In review Thomas Huth 5 participants 16 messages Apr 8, 2016 – May 31, 2016 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc: Fix definition of SIAR register

The SIAR register is available twice, one time as SPR 780 (unprivileged, but read-only), and one time as SPR 796 (privileged, but read and write). The Linux kernel code currently uses SPR 780 - and 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 other SPR numer 796 instead.

---
Note: The perf code in core-book3s.c also seems to write to the SIAR
SPR, so that might be affected by this issue, too - but I did not test the perf code, so I'm not sure about that part.

 arch/powerpc/include/asm/reg.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/include/asm/reg.h +1 -1
index f5f4c66..6630420 100644
@@ -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_TACR	888
 #define SPRN_TCSCR	889
 #define SPRN_CSIGR	890
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 27 lines · Thomas Huth

The SIAR register is available twice, one time as SPR 780 (unprivileged, but read-only), and one time as SPR 796 (privileged, but read and write). The Linux kernel code currently uses SPR 780 - and 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 other SPR numer 796 instead.

---
Note: The perf code in core-book3s.c also seems to write to the SIAR
SPR, so that might be affected by this issue, too - but I did not test the perf code, so I'm not sure about that part.

 arch/powerpc/include/asm/reg.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/include/asm/reg.h +0 -1
index f5f4c66..6630420 100644
@@ -752,13 +752,13 @@
 #define SPRN_PMC6	792
 #define SPRN_PMC7	793
 #define SPRN_PMC8	794
-#define SPRN_SIAR	780

arch/powerpc/include/asm/reg.h line 764

Quoted 10 lines
arch/powerpc/include/asm/reg.h +1 -0
 #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_TACR	888
 #define SPRN_TCSCR	889
 #define SPRN_CSIGR	890

Ping!

Anybody any comments?

Thomas

#2 lore raw
In reply to Thomas Huth
Quoted 8 lines · Thomas Huth

The SIAR register is available twice, one time as SPR 780 (unprivileged, but read-only), and one time as SPR 796 (privileged, but read and write). The Linux kernel code currently uses SPR 780 - and 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 other SPR numer 796 instead.

IIUC, SIAR and SDAR are updated by hardware when we take a pmu exception with sampling mode enabled (based on instr). And these register contents are mainly for OS consumption. So, we dont need to restore these register values at all, kindly correct me if I missing something here.

Maddy

Quoted 29 lines

---
Note: The perf code in core-book3s.c also seems to write to the SIAR
SPR, so that might be affected by this issue, too - but I did not test the perf code, so I'm not sure about that part.

 arch/powerpc/include/asm/reg.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/include/asm/reg.h +1 -1
index f5f4c66..6630420 100644
@@ -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_TACR	888
 #define SPRN_TCSCR	889
 #define SPRN_CSIGR	890
#3 lore raw
Quoted 16 lines

Am 25.04.2016 um 10:08 schrieb Madhavan Srinivasan <[email protected]>:

Quoted 9 lines · Thomas Huth

The SIAR register is available twice, one time as SPR 780 (unprivileged, but read-only), and one time as SPR 796 (privileged, but read and write). The Linux kernel code currently uses SPR 780 - and 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 other SPR numer 796 instead.

Quoted 5 lines

IIUC, SIAR and SDAR are updated by hardware when we take a pmu exception with sampling mode enabled (based on instr). And these register contents are mainly for OS consumption. So, we dont need to restore these register values at all, kindly correct me if I missing something here.

What if you migrate between a pmu event firing and the os reading siar? Or what if the host gets pmu events? Or we migrate the guest to a different pcpu? In all those cases we need to ensure the register contents are consistent.

Quoted 9 lines

Maddy

Quoted 6 lines

---
Note: The perf code in core-book3s.c also seems to write to the SIAR
SPR, so that might be affected by this issue, too - but I did not test the perf code, so I'm not sure about that part.

Please write a small unit test that fires off pmu events constantly and checks whtether they arrive correctly. Run perf in parallel on the host to increase the chance for breakage.

Quoted 4 lines
Quoted 4 lines

arch/powerpc/include/asm/reg.h | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines
Quoted 6 lines
arch/powerpc/include/asm/reg.h +0 -0
index f5f4c66..6630420 100644
@@ -752,13 +752,13 @@
 #define SPRN_PMC6    792

arch/powerpc/include/asm/reg.h line 761

Quoted 10 lines
arch/powerpc/include/asm/reg.h +1 -1
 #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

I'm sure there's a reason (iSeries?) we used the r/o version before. Better introduce a new constant that gives us rw access and use that in the kvm entry/exit code.

Alex

Quoted 8 lines

arch/powerpc/include/asm/reg.h line 764

Quoted 3 lines
arch/powerpc/include/asm/reg.h +0 -0
 #define SPRN_TACR    888
 #define SPRN_TCSCR    889
 #define SPRN_CSIGR    890

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
Quoted 16 lines · Alexander Graf
Quoted 16 lines

Am 25.04.2016 um 10:08 schrieb Madhavan Srinivasan <[email protected]>:

Quoted 9 lines · Thomas Huth

The SIAR register is available twice, one time as SPR 780 (unprivileged, but read-only), and one time as SPR 796 (privileged, but read and write). The Linux kernel code currently uses SPR 780 - and 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 other SPR numer 796 instead.

Quoted 7 lines
Quoted 5 lines

IIUC, SIAR and SDAR are updated by hardware when we take a pmu exception with sampling mode enabled (based on instr). And these register contents are mainly for OS consumption. So, we dont need to restore these register values at all, kindly correct me if I missing something here.

What if you migrate between a pmu event firing and the os reading siar? Or what if the host gets pmu events? Or we migrate the guest to a different pcpu? In all those cases we need to ensure the register contents are consistent.

Right. Or a guest could use the SIAR as a temporary scratch register while not using the performance monitoring stuff. In that case the contents of the register of course have to be preserved, too.

Quoted 7 lines
Quoted 5 lines
Quoted 5 lines

---
Note: The perf code in core-book3s.c also seems to write to the SIAR
SPR, so that might be affected by this issue, too - but I did not test the perf code, so I'm not sure about that part.

Please write a small unit test that fires off pmu events constantly and checks whtether they arrive correctly. Run perf in parallel on the host to increase the chance for breakage.

I'm not very familiar with that PMU stuff yet, but I can have a try...

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines

arch/powerpc/include/asm/reg.h | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/include/asm/reg.h +0 -1
index f5f4c66..6630420 100644
@@ -752,13 +752,13 @@
 #define SPRN_PMC6    792
 #define SPRN_PMC7    793
 #define SPRN_PMC8    794
-#define SPRN_SIAR    780
 #define SPRN_SDAR    781
Quoted 8 lines
Quoted 6 lines

arch/powerpc/include/asm/reg.h line 761

Quoted 6 lines
arch/powerpc/include/asm/reg.h +1 -0
 #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

I'm sure there's a reason (iSeries?) we used the r/o version before. Better introduce a new constant that gives us rw access and use that in the kvm entry/exit code.

Sure. Any suggestions on the naming? I could either rename the current SPRN_SIAR to SPRN_USIAR (so that it is named similar to other registers that behave that way, like SPRN_USPRG3 - and also QEMU uses USIAR for this already). Or I could leave the old name untouched and use something like "SPRN_SIAR_WR" for the 796 register. What do you prefer?

By the way, I just noticed that SPRN_SDAR (781) seems to suffer from the same problem, too!

Thomas

#5 lore raw
Quoted 53 lines · Thomas Huth
Quoted 14 lines · Alexander Graf
Quoted 14 lines

Am 25.04.2016 um 10:08 schrieb Madhavan Srinivasan <[email protected]>:

Quoted 9 lines · Thomas Huth

The SIAR register is available twice, one time as SPR 780 (unprivileged, but read-only), and one time as SPR 796 (privileged, but read and write). The Linux kernel code currently uses SPR 780 - and 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 other SPR numer 796 instead.

Quoted 6 lines
Quoted 5 lines

IIUC, SIAR and SDAR are updated by hardware when we take a pmu exception with sampling mode enabled (based on instr). And these register contents are mainly for OS consumption. So, we dont need to restore these register values at all, kindly correct me if I missing something here.

What if you migrate between a pmu event firing and the os reading siar? Or what if the host gets pmu events? Or we migrate the guest to a different pcpu? In all those cases we need to ensure the register contents are consistent.

Right. Or a guest could use the SIAR as a temporary scratch register while not using the performance monitoring stuff. In that case the contents of the register of course have to be preserved, too.

Quoted 6 lines
Quoted 5 lines
Quoted 5 lines

---
Note: The perf code in core-book3s.c also seems to write to the SIAR
SPR, so that might be affected by this issue, too - but I did not test the perf code, so I'm not sure about that part.

Please write a small unit test that fires off pmu events constantly and checks whtether they arrive correctly. Run perf in parallel on the host to increase the chance for breakage.

I'm not very familiar with that PMU stuff yet, but I can have a try...

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines

arch/powerpc/include/asm/reg.h | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/include/asm/reg.h +0 -1
index f5f4c66..6630420 100644
@@ -752,13 +752,13 @@
 #define SPRN_PMC6    792
 #define SPRN_PMC7    793
 #define SPRN_PMC8    794
-#define SPRN_SIAR    780
Quoted 8 lines
Quoted 7 lines

arch/powerpc/include/asm/reg.h line 761

Quoted 7 lines
arch/powerpc/include/asm/reg.h +1 -0
 #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

I'm sure there's a reason (iSeries?) we used the r/o version before. Better introduce a new constant that gives us rw access and use that in the kvm entry/exit code.

Quoted 5 lines

Sure. Any suggestions on the naming? I could either rename the current SPRN_SIAR to SPRN_USIAR (so that it is named similar to other registers that behave that way, like SPRN_USPRG3 - and also QEMU uses USIAR for this already). Or I could leave the old name untouched and use something like "SPRN_SIAR_WR" for the 796 register. What do you prefer?

I'd defer that decision to Michael :).

Quoted 2 lines

By the way, I just noticed that SPRN_SDAR (781) seems to suffer from the same problem, too!

Great! The more the merrier :)

Alex

#6 lore raw
In reply to Alexander Graf
Quoted 14 lines · Alexander Graf
Quoted 14 lines

Am 25.04.2016 um 10:08 schrieb Madhavan Srinivasan <[email protected]>:

Quoted 9 lines · Thomas Huth

The SIAR register is available twice, one time as SPR 780 (unprivileged, but read-only), and one time as SPR 796 (privileged, but read and write). The Linux kernel code currently uses SPR 780 - and 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 other SPR numer 796 instead.

Quoted 6 lines
Quoted 5 lines

IIUC, SIAR and SDAR are updated by hardware when we take a pmu exception with sampling mode enabled (based on instr). And these register contents are mainly for OS consumption. So, we dont need to restore these register values at all, kindly correct me if I missing something here.

What if you migrate between a pmu event firing and the os reading siar? Or what if the host gets pmu events? Or we migrate the guest to a different pcpu? In all those cases we need to ensure the register contents are consistent.

Ok got it. Let me try perf record with sample_addr type.

Maddy

Quoted 40 lines
Quoted 8 lines

Maddy

Quoted 5 lines

---
Note: The perf code in core-book3s.c also seems to write to the SIAR
SPR, so that might be affected by this issue, too - but I did not test the perf code, so I'm not sure about that part.

Please write a small unit test that fires off pmu events constantly and checks whtether they arrive correctly. Run perf in parallel on the host to increase the chance for breakage.

Quoted 19 lines
Quoted 9 lines

arch/powerpc/include/asm/reg.h | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/include/asm/reg.h +0 -0
index f5f4c66..6630420 100644
@@ -752,13 +752,13 @@
 #define SPRN_PMC6    792

arch/powerpc/include/asm/reg.h line 761

Quoted 10 lines
arch/powerpc/include/asm/reg.h +1 -1
 #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

I'm sure there's a reason (iSeries?) we used the r/o version before. Better introduce a new constant that gives us rw access and use that in the kvm entry/exit code.

Alex

Quoted 7 lines

arch/powerpc/include/asm/reg.h line 764

Quoted 3 lines
arch/powerpc/include/asm/reg.h +0 -0
 #define SPRN_TACR    888
 #define SPRN_TCSCR    889
 #define SPRN_CSIGR    890

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#10 lore raw
In reply to Thomas Huth
Quoted 9 lines · Thomas Huth

The SIAR register is available twice, one time as SPR 780 (unprivileged, but read-only), and one time as SPR 796 (privileged, but read and write). The Linux kernel code currently uses SPR 780 - and 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 other SPR numer 796 instead.

Quoted 5 lines

---
Note: The perf code in core-book3s.c also seems to write to the SIAR
SPR, so that might be affected by this issue, too - but I did not test the perf code, so I'm not sure about that part.

EBBs mean we need to context-switch the SIAR between user tasks (among other registers).

I notice that SDAR is also wrong, and the MMCR2 definition is also using the user-accessible number (though it at least is writable as well as readable).

Paul.

#7 lore raw
In reply to Alexander Graf
Quoted 4 lines · Alexander Graf
Quoted 2 lines
Quoted 2 lines

+#define SPRN_SIAR 796

I'm sure there's a reason (iSeries?) we used the r/o version before. Better introduce a new constant that gives us rw access and use that in the kvm entry/exit code.

I don't think we ever did any performance monitoring on iSeries, and in any case, we have removed the iSeries code. I think we should just use the privileged, read/write number (i.e. 796).

Paul.

#8 lore raw
Quoted 9 lines · Paul Mackerras
Quoted 4 lines · Alexander Graf
Quoted 2 lines
Quoted 2 lines

+#define SPRN_SIAR 796

I'm sure there's a reason (iSeries?) we used the r/o version before. Better introduce a new constant that gives us rw access and use that in the kvm entry/exit code.

I don't think we ever did any performance monitoring on iSeries, and in any case, we have removed the iSeries code. I think we should just use the privileged, read/write number (i.e. 796).

Ok, then I'll simply add the fix for SDAR to my patch as well, test it and submit it again.

Thomas

#9 lore raw
Quoted 5 lines · Thomas Huth
Quoted 4 lines · Paul Mackerras
Quoted 3 lines · Alexander Graf
Quoted 2 lines
Quoted 2 lines

+#define SPRN_SIAR 796

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

I'm sure there's a reason (iSeries?) we used the r/o version before. Better introduce a new constant that gives us rw access and use that in the kvm entry/exit code.

I don't think we ever did any performance monitoring on iSeries, and in any case, we have removed the iSeries code. I think we should just use the privileged, read/write number (i.e. 796).

Ok, then I'll simply add the fix for SDAR to my patch as well, test it and submit it again.

Great! Could you switch MMCR2 to the privileged number as well while you're at it?

Thanks,
Paul.

#11 lore raw

PATCH 1/1 powerpc: Fix definition of SIAR and SDAR registers

In reply to Thomas Huth

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.

---
 arch/powerpc/include/asm/reg.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/reg.h +2 -2
index f5f4c66..ce3e1b7 100644
@@ -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
Signature · 1 line
1.8.3.1
Acked-by on v1 1/1
#12 lore raw

Re: [PATCH] powerpc: Fix definition of SIAR and SDAR registers

Quoted 11 lines · Thomas Huth

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.

#13 lore raw

Re: [PATCH] powerpc: Fix definition of SIAR and SDAR registers

Quoted 11 lines · Paul Mackerras
Quoted 10 lines · Thomas Huth

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.

Quoted 3 lines
Quoted 1 line

*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

#14 lore raw

Re: [PATCH] powerpc: Fix definition of SIAR and SDAR registers

Quoted 14 lines · Thomas Huth
Quoted 13 lines · Paul Mackerras
Quoted 11 lines · Thomas Huth

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.

Quoted 7 lines
Quoted 1 line

*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

reviewer Applied
#15 lore raw

Re: powerpc: Fix definition of SIAR and SDAR registers

In reply to Thomas Huth
Quoted 10 lines · Thomas Huth

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.

Quoted 2 lines

Applied to powerpc fixes, thanks.

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

cheers