Correct CPACR reset value for v7 cores
PATCH 1/1 Correct CPACR reset value for v7 cores
In commit f0aff255700 we made cpacr_write() enforce that some CPACR bits are RAZ/WI and some are RAO/WI for ARMv7 cores. Unfortunately we forgot to also update the register's reset value. The effect was that (a) a guest that read CPACR on reset would not see ones in the RAO bits, and (b) if you did a migration before the guest did a write to the CPACR then the migration would fail because the destination would enforce the RAO bits and then complain that they didn't match the zero value from the source.
Implement reset for the CPACR using a custom reset function that just calls cpacr_write(), to avoid having to duplicate the logic for which bits are RAO.
This bug would affect migration for TCG CPUs which are ARMv7 with VFP but without one of Neon or VFPv3.
---
This is sufficient that a save-and-reload while the romulus-bmc machine is in the bootloader will work. On the other hand if I do a save-and-reload after the kernel has started booting then we get the classic "guest hang after reload", so some state is still not being transferred somewhere (probably in a device in the machine model?)
--- target/arm/helper.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
target/arm/helper.c +9 -1
@@ -863,6 +863,14 @@ static void cpacr_write(CPUARMState *env, const ARMCPRegInfo *ri, env->cp15.cpacr_el1 = value; } +static void cpacr_reset (CPUARMState *env,const ARMCPRegInfo *ri) +{ +/* Call cpacr_write() so that we reset with the correct RAO bits set +* for our CPU features. +*/ +cpacr_write (env, ri,0 ); +} +static CPAccessResult cpacr_access (CPUARMState *env,const ARMCPRegInfo *ri,bool isread) {
@@ -920,7 +928,7 @@ static const ARMCPRegInfo v6_cp_reginfo[] = { { .name = "CPACR", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .crn = 1, .crm = 0, .opc1 = 0, .opc2 = 2, .accessfn = cpacr_access, .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.cpacr_el1), - .resetvalue = 0, .writefn = cpacr_write }, + .resetfn = cpacr_reset, .writefn = cpacr_write }, REGINFO_SENTINEL };
Signature · 1 line
2.17.0
Quoted 13 lines · Peter Maydell
In commit
f0aff255700we madecpacr_write()enforce that some CPACR bits are RAZ/WI and some are RAO/WI for ARMv7 cores. Unfortunately we forgot to also update the register's reset value. The effect was that (a) a guest that read CPACR on reset would not see ones in the RAO bits, and (b) if you did a migration before the guest did a write to the CPACR then the migration would fail because the destination would enforce the RAO bits and then complain that they didn't match the zero value from the source.Implement reset for the CPACR using a custom reset function that just calls
cpacr_write(), to avoid having to duplicate the logic for which bits are RAO.
Quoted 5 lines
This bug would affect migration for TCG CPUs which are ARMv7 with VFP but without one of Neon or VFPv3.
Reported-by Cédric Le Goater <[email protected]>Signed-off-by Peter Maydell <[email protected]>
Quoted 7 lines
---
This is sufficient that a save-and-reload while the romulus-bmc machine is in the bootloader will work. On the other hand if I do a save-and-reload after the kernel has started booting then we get the classic "guest hang after reload", so some state is still not being transferred somewhere (probably in a device in the machine model?)
I see the problem. Bizarre.
Thanks,
C.
Quoted 33 lines
--- target/arm/helper.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)target/arm/helper.c +9
-1@@ -863,6 +863,14 @@ static void cpacr_write(CPUARMState *env, const ARMCPRegInfo *ri, env->cp15.cpacr_el1 = value; } +static void cpacr_reset (CPUARMState *env,const ARMCPRegInfo *ri) +{ +/* Call cpacr_write() so that we reset with the correct RAO bits set +* for our CPU features. +*/ +cpacr_write (env, ri,0 ); +} +static CPAccessResult cpacr_access (CPUARMState *env,const ARMCPRegInfo *ri,bool isread) {@@ -920,7 +928,7 @@ static const ARMCPRegInfo v6_cp_reginfo[] = { { .name = "CPACR", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .crn = 1, .crm = 0, .opc1 = 0, .opc2 = 2, .accessfn = cpacr_access, .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.cpacr_el1), - .resetvalue = 0, .writefn = cpacr_write }, + .resetfn = cpacr_reset, .writefn = cpacr_write }, REGINFO_SENTINEL };
Quoted 9 lines · Cédric Le Goater
Quoted 6 lines · Peter Maydell
This is sufficient that a save-and-reload while the romulus-bmc machine is in the bootloader will work. On the other hand if I do a save-and-reload after the kernel has started booting then we get the classic "guest hang after reload", so some state is still not being transferred somewhere (probably in a device in the machine model?)
I see the problem. Bizarre.
Usually it means that something in the path from timer device through to the CPU has failed to save-and-reload the state that it needs to, so that when the timer fires post-reload it doesn't actually cause a CPU interrupt. You can probably debug by putting a breakpoint on whatever looks like a likely timer device's 'set the irq line' function and stepping through to figure out what's happening.
(You're not using trustzone, are you? I know of a bug with migration of cpus with TZ enabled which I'm probably going to look at later this week)
thanks
-- PMM
Quoted 11 lines · Peter Maydell
Quoted 9 lines · Cédric Le Goater
Quoted 6 lines · Peter Maydell
This is sufficient that a save-and-reload while the romulus-bmc machine is in the bootloader will work. On the other hand if I do a save-and-reload after the kernel has started booting then we get the classic "guest hang after reload", so some state is still not being transferred somewhere (probably in a device in the machine model?)
I see the problem. Bizarre.
Quoted 7 lines
Usually it means that something in the path from timer device through to the CPU has failed to save-and-reload the state that it needs to, so that when the timer fires post-reload it doesn't actually cause a CPU interrupt. You can probably debug by putting a breakpoint on whatever looks like a likely timer device's 'set the irq line' function and stepping through to figure out what's happening.
OK. I will take a look.
What is bizarre is that the romulus-bmc and the palmetto-bmc machines use the same timer controller model and the same Linux driver. So only the CPU type would differ.
Quoted 3 lines
(You're not using trustzone, are you? I know of a bug with migration of cpus with TZ enabled which I'm probably going to look at later this week)
The PSR is :
PSR=20000093 --C- A S svc32
'S' for secure. Is that also trustzone ?
Thanks,
C.
Quoted 10 lines · Cédric Le Goater
Quoted 3 lines · Peter Maydell
(You're not using trustzone, are you? I know of a bug with migration of cpus with TZ enabled which I'm probably going to look at later this week)
The PSR is :
PSR=20000093 --C- A S svc32'S' for secure. Is that also trustzone ?
Yes. In that case this very likely is the same bug (we don't migrate the secure-bank registers properly, so if Linux is executing in secure state it doesn't resume right).
thanks
-- PMM