KVM: ppc: Fix size of the PSPB register
Subsystems (3)
PATCH 1/1 KVM: ppc: Fix size of the PSPB register
The size of the Problem State Priority Boost Register is only 32 bits, so let's change the type of the corresponding variable accordingly to avoid future trouble.
--- arch/powerpc/include/asm/kvm_host.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/include/asm/kvm_host.h +1 -1
@@ -473,7 +473,7 @@ struct kvm_vcpu_arch {ulong ciabr;ulong cfar;ulong ppr; -ulong pspb; +u32 pspb;ulong fscr;ulong shadow_fscr;ulong ebbhr;
Signature · 1 line
1.8.3.1
Quoted 3 lines · Thomas Huth
The size of the Problem State Priority Boost Register is only 32 bits, so let's change the type of the corresponding variable accordingly to avoid future trouble.
Since we're already using lwz/stw in the assembly code in book3s_hv_rmhandlers.S, this is actually a bug fix, isn't it? How did you find it? Did you observe a failure of some kind, or did you just find it by code inspection?
Paul.
Quoted 3 lines · Thomas Huth
The size of the Problem State Priority Boost Register is only 32 bits, so let's change the type of the corresponding variable accordingly to avoid future trouble.
It's not future trouble, it's broken today for LE and this should fix it BUT ....
The asm accesses it using lwz/stw and C accesses it as a ulong. On LE that will mean that userspace will see the value << 32
Now "fixing" it might break migration if that field is already stored/loaded in its "broken" form. We may have to keep the "broken" behaviour and document that qemu sees a value shifted by 32.
Cheers,
Ben.
Quoted 19 lines
Signed-off-by Thomas Huth <[email protected]>--- arch/powerpc/include/asm/kvm_host.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/powerpc/include/asm/kvm_host.h +1
-1@@ -473,7 +473,7 @@ struct kvm_vcpu_arch {ulong ciabr;ulong cfar;ulong ppr; -ulong pspb; +u32 pspb;ulong fscr;ulong shadow_fscr;ulong ebbhr;
Quoted 9 lines · Paul Mackerras
Quoted 3 lines · Thomas Huth
The size of the Problem State Priority Boost Register is only 32 bits, so let's change the type of the corresponding variable accordingly to avoid future trouble.
Since we're already using lwz/stw in the assembly code in
book3s_hv_rmhandlers.S, this is actually a bug fix, isn't it? How did you find it? Did you observe a failure of some kind, or did you just find it by code inspection?
Won't the fix break migration ? Unless qemu doens't migrate it ...
Quoted 5 lines
Paul.
_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev
Quoted 7 lines · Benjamin Herrenschmidt
Quoted 3 lines · Thomas Huth
The size of the Problem State Priority Boost Register is only 32 bits, so let's change the type of the corresponding variable accordingly to avoid future trouble.
It's not future trouble, it's broken today for LE and this should fix it BUT ....
No, it's broken today for BE hosts, which will always see 0 for the PSPB register value. LE hosts are fine.
Quoted 2 lines
The asm accesses it using lwz/stw and C accesses it as a ulong. On LE that will mean that userspace will see the value << 32
No, that will happen on BE, and since KVM_REG_PPC_PSPB says it's a 32-bit register, we'll just pass 0 back to userspace when it reads it.
Quoted 3 lines
Now "fixing" it might break migration if that field is already stored/loaded in its "broken" form. We may have to keep the "broken" behaviour and document that qemu sees a value shifted by 32.
It will be being set to 0 on BE hosts across migration today (fortunately 0 is a benign value for PSPB). If we fix this on both the source and destination host, then the value will get migrated across correctly.
I think Thomas's patch is fine, it just needs a stronger patch description saying that it fixes an actual bug.
Paul.
_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev
Quoted 7 lines · Paul Mackerras
Quoted 5 lines · Benjamin Herrenschmidt
Quoted 3 lines · Thomas Huth
The size of the Problem State Priority Boost Register is only 32 bits, so let's change the type of the corresponding variable accordingly to avoid future trouble.
Quoted 6 lines
Quoted 3 lines
It's not future trouble, it's broken today for LE and this should fix
it BUT ....No, it's broken today for BE hosts, which will always see 0 for the PSPB register value. LE hosts are fine.
0 or PSPB << 32 ?
Quoted 7 lines
Quoted 3 lines
The asm accesses it using lwz/stw and C accesses it as a ulong. On LE
that will mean that userspace will see the value << 32No, that will happen on BE, and since
KVM_REG_PPC_PSPBsays it's a 32-bit register, we'll just pass 0 back to userspace when it reads it.
Ah ok, I missed that bit about KVM_REG_PPC_PSPB
Quoted 9 lines
Quoted 4 lines
Now "fixing" it might break migration if that field is already stored/loaded in its "broken" form. We may have to keep the "broken"
behaviour and document that qemu sees a value shifted by 32.It will be being set to 0 on BE hosts across migration today (fortunately 0 is a benign value for PSPB). If we fix this on both the source and destination host, then the value will get migrated across correctly.
Ok, I missed the part where KVM_REG_PPC_PSPB passed it down as a 32 -bit. That means Thomas patch should work indeed.
Quoted 2 lines
I think Thomas's patch is fine, it just needs a stronger patch description saying that it fixes an actual bug.
Right.
Cheers,
Ben.
Quoted 9 lines · Paul Mackerras
Quoted 3 lines · Thomas Huth
The size of the Problem State Priority Boost Register is only 32 bits, so let's change the type of the corresponding variable accordingly to avoid future trouble.
Since we're already using lwz/stw in the assembly code in
book3s_hv_rmhandlers.S, this is actually a bug fix, isn't it? How did you find it? Did you observe a failure of some kind, or did you just find it by code inspection?
Code inspection. I was looking for similar problems like the issue with the XER register that we've hit recently
(https://patchwork.ozlabs.org/patch/476872/) while I was trying to debug a similar problem.
Thomas
Quoted 8 lines · Benjamin Herrenschmidt
Quoted 7 lines · Paul Mackerras
Quoted 5 lines · Benjamin Herrenschmidt
Quoted 3 lines · Thomas Huth
The size of the Problem State Priority Boost Register is only 32 bits, so let's change the type of the corresponding variable accordingly to avoid future trouble.
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
It's not future trouble, it's broken today for LE and this should fix
it BUT ....No, it's broken today for BE hosts, which will always see 0 for the PSPB register value. LE hosts are fine.
Right ... I just meant that nobody really experienced trouble with this today yet, but the bug is already present now already of course.
Quoted 15 lines
Quoted 7 lines
Quoted 3 lines
The asm accesses it using lwz/stw and C accesses it as a ulong. On LE
that will mean that userspace will see the value << 32No, that will happen on BE, and since
KVM_REG_PPC_PSPBsays it's a 32-bit register, we'll just pass 0 back to userspace when it reads it.Ah ok, I missed that bit about
KVM_REG_PPC_PSPBQuoted 5 lines
Quoted 4 lines
Now "fixing" it might break migration if that field is already stored/loaded in its "broken" form. We may have to keep the "broken"
behaviour and document that qemu sees a value shifted by 32.
Quoted 7 lines
Quoted 4 lines
It will be being set to 0 on BE hosts across migration today (fortunately 0 is a benign value for PSPB). If we fix this on both the source and destination host, then the value will get migrated across correctly.
Ok, I missed the part where
KVM_REG_PPC_PSPBpassed it down as a 32 -bit. That means Thomas patch should work indeed.
... and if I get the QEMU source code right, the register is currently not migrated at all - or at least I was not able to find the spot in the source code that migrates this register.
Quoted 2 lines
Quoted 2 lines
I think Thomas's patch is fine, it just needs a stronger patch description saying that it fixes an actual bug.
Ok, I'll resend with a better patch description.
Thomas
Quoted 17 lines
Am 02.09.2015 um 09:26 schrieb Thomas Huth <[email protected]>:
Quoted 13 lines · Benjamin Herrenschmidt
Quoted 12 lines · Paul Mackerras
Quoted 8 lines · Benjamin Herrenschmidt
Quoted 3 lines · Thomas Huth
The size of the Problem State Priority Boost Register is only 32 bits, so let's change the type of the corresponding variable accordingly to avoid future trouble.
It's not future trouble, it's broken today for LE and this should fix
it BUT ....
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
No, it's broken today for BE hosts, which will always see 0 for the PSPB register value. LE hosts are fine.
Right ... I just meant that nobody really experienced trouble with this today yet, but the bug is already present now already of course.
Sounds like a great candidate for kvm-unit-tests then, no? ;)
Alex
Quoted 16 lines · Alexander Graf
Quoted 16 lines
Am 02.09.2015 um 09:26 schrieb Thomas Huth <[email protected]>:
Quoted 13 lines · Benjamin Herrenschmidt
Quoted 12 lines · Paul Mackerras
Quoted 8 lines · Benjamin Herrenschmidt
Quoted 3 lines · Thomas Huth
The size of the Problem State Priority Boost Register is only 32 bits, so let's change the type of the corresponding variable accordingly to avoid future trouble.
It's not future trouble, it's broken today for LE and this should fix
it BUT ....
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
No, it's broken today for BE hosts, which will always see 0 for the PSPB register value. LE hosts are fine.
Right ... I just meant that nobody really experienced trouble with this today yet, but the bug is already present now already of course.
Sounds like a great candidate for kvm-unit-tests then, no? ;)
I'm certainly looking forward to seeing powerpc support in there :-)
Thomas