ast2600: Disable NEON and VFPv4-D32
cover ast2600: Disable NEON and VFPv4-D32
Hello,
Currently, the CPU features exposed to the AST2600 QEMU machines are :
half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
But, the features of the Cortex A7 CPU on the Aspeed AST2600 A3 SoC are :
half thumb fastmult vfp edsp vfpv3 vfpv3d16 tls vfpv4 idiva idivt lpae evtstrm
NEON support should be dropped and, in that case, QEMU should advertise a VFPv4 unit with 16 double-precision registers, and not 32 registers.
This problem was raised by a buildroot rootfs compiled with vfpv4. Boot went fine under QEMU but on real HW, user space binaries had issues with output. Compiling buildroot with vfpv4d16 fixed it and I didn't dig further. Nevertheless, it would be nice to catch such issues with QEMU.
Thanks,
C.
Cédric Le Goater (2):
target/arm: Disable VFPv4-D32 when NEON is not available
ast2600: Drop NEON from the CPU features
hw/arm/aspeed_ast2600.c | 2 ++ target/arm/cpu.c | 4 ++++ 2 files changed, 6 insertions(+)
Signature · 1 line
2.37.3
PATCH 1/2 target/arm: Disable VFPv4-D32 when NEON is not available
As the Cortex A7 MPCore Technical reference says :
"When FPU option is selected without NEON, the FPU is VFPv4-D16 and uses 16 double-precision registers. When the FPU is implemented with NEON, the FPU is VFPv4-D32 and uses 32 double-precision registers. This register bank is shared with NEON."
Modify the mvfr0 register value of the cortex A7 to advertise only 16 registers when NEON is not available, and not 32 registers.
--- target/arm/cpu.c | 4 ++++ 1 file changed, 4 insertions(+)
target/arm/cpu.c +4 -0
@@ -1684,6 +1684,10 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) cpu->isar.id_isar6 = u;if (!arm_feature (env,ARM_FEATURE_M )) { + u = cpu->isar.mvfr0; + u =FIELD_DP32 (u,MVFR0 ,SIMDREG ,1 );/* 16 registers */ + cpu->isar.mvfr0 = u; + u = cpu->isar.mvfr1; u =FIELD_DP32 (u,MVFR1 ,SIMDLS ,0 ); u =FIELD_DP32 (u,MVFR1 ,SIMDINT ,0 );
Signature · 1 line
2.37.3
Re: [PATCH 1/2] target/arm: Disable VFPv4-D32 when NEON is not available
Quoted 9 lines · Cédric Le Goater
As the Cortex A7 MPCore Technical reference says :
"When FPU option is selected without NEON, the FPU is VFPv4-D16 and uses 16 double-precision registers. When the FPU is implemented with NEON, the FPU is VFPv4-D32 and uses 32 double-precision registers. This register bank is shared with NEON."
Modify the mvfr0 register value of the cortex A7 to advertise only 16 registers when NEON is not available, and not 32 registers.
Looks like A5 has the same language, while A15 says that NEON cannot be enabled without VFP (which is the same as all aarch64 cores). I guess this is a decent compromise.
r~
Re: [PATCH 1/2] target/arm: Disable VFPv4-D32 when NEON is not available
In reply to Cédric Le GoaterQuoted 24 lines · Cédric Le Goater
As the Cortex A7 MPCore Technical reference says :
"When FPU option is selected without NEON, the FPU is VFPv4-D16 and uses 16 double-precision registers. When the FPU is implemented with NEON, the FPU is VFPv4-D32 and uses 32 double-precision registers. This register bank is shared with NEON."
Modify the mvfr0 register value of the cortex A7 to advertise only 16 registers when NEON is not available, and not 32 registers.
Signed-off-by Cédric Le Goater <[email protected]>--- target/arm/cpu.c | 4 ++++ 1 file changed, 4 insertions(+)target/arm/cpu.c +0
-0
target/arm/cpu.c static void arm_cpu_realizefn(DeviceState *dev, Error **errp) · line 1686
Quoted 3 lines
target/arm/cpu.c +0
-0@@ -1684,6 +1684,10 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) cpu->isar.id_isar6 = u;if (!arm_feature (env,ARM_FEATURE_M )) {
Can you explain why the test is put behind the !ARM_FEATURE_M check?
Quoted 10 lines
target/arm/cpu.c +4
-1+ u = cpu->isar.mvfr0; + u =FIELD_DP32 (u,MVFR0 ,SIMDREG ,1 );/* 16 registers */ + cpu->isar.mvfr0 = u; + u = cpu->isar.mvfr1; u =FIELD_DP32 (u,MVFR1 ,SIMDLS ,0 ); u =FIELD_DP32 (u,MVFR1 ,SIMDINT ,0 ); --2.37.3
Re: [PATCH 1/2] target/arm: Disable VFPv4-D32 when NEON is not available
Quoted 27 lines · Joel Stanley
Quoted 26 lines · Cédric Le Goater
As the Cortex A7 MPCore Technical reference says :
"When FPU option is selected without NEON, the FPU is VFPv4-D16 and uses 16 double-precision registers. When the FPU is implemented with NEON, the FPU is VFPv4-D32 and uses 32 double-precision registers. This register bank is shared with NEON."
Modify the mvfr0 register value of the cortex A7 to advertise only 16 registers when NEON is not available, and not 32 registers.
Signed-off-by Cédric Le Goater <[email protected]>--- target/arm/cpu.c | 4 ++++ 1 file changed, 4 insertions(+)target/arm/cpu.c +0
-0@@ -1684,6 +1684,10 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) cpu->isar.id_isar6 = u;
Quoted 3 lines
target/arm/cpu.c static void arm_cpu_realizefn(DeviceState *dev, Error **errp) · line 1686
Quoted 1 line
target/arm/cpu.c +0
-0if (!arm_feature (env,ARM_FEATURE_M )) {Can you explain why the test is put behind the !ARM_FEATURE_M check?
Do you mean the setting of MVFR0 ?
because it was close to the code clearing the SIMD bits (NEON) of MVFR1 and it seemed more in sync with the specs :
"When FPU option is selected without NEON, the FPU is VFPv4-D16 and
uses 16 double-precision registers. When the FPU is implemented with NEON, the FPU is VFPv4-D32 and uses 32 double-precision registers. This register bank is shared with NEON."
(That said, M processors don't have NEON, so this part of the code should never be reached )
It could be done outside of this test also because SIMDREG = 1 is a valid value for M processors and the code path :
if (!cpu->has_neon && !cpu->has_vfp) {will set MVFR0 to 0 later on if needed.
M55 seems to be a special case though :
cpu->isar.mvfr1 = 0x12100211
these are the FPU and MVE bits.
C.
Quoted 13 lines
Reviewed-by Joel Stanley <[email protected]>Quoted 10 lines
target/arm/cpu.c +4
-1+ u = cpu->isar.mvfr0; + u =FIELD_DP32 (u,MVFR0 ,SIMDREG ,1 );/* 16 registers */ + cpu->isar.mvfr0 = u; + u = cpu->isar.mvfr1; u =FIELD_DP32 (u,MVFR1 ,SIMDLS ,0 ); u =FIELD_DP32 (u,MVFR1 ,SIMDINT ,0 ); --2.37.3
Re: [PATCH 1/2] target/arm: Disable VFPv4-D32 when NEON is not available
Quoted 15 lines · Cédric Le Goater
Quoted 7 lines · Joel Stanley
target/arm/cpu.c static void arm_cpu_realizefn(DeviceState *dev, Error **errp) · line 1686
Quoted 4 lines · Cédric Le Goater
target/arm/cpu.c +0
-0@@ -1684,6 +1684,10 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) cpu->isar.id_isar6 = u;if (!arm_feature (env,ARM_FEATURE_M )) {Can you explain why the test is put behind the !ARM_FEATURE_M check?
Do you mean the setting of MVFR0 ?
because it was close to the code clearing the SIMD bits (NEON) of MVFR1 and it seemed more in sync with the specs :
Quoted 7 lines
"When FPU option is selected without NEON, the FPU is VFPv4-D16 and
uses 16 double-precision registers. When the FPU is implemented with NEON, the FPU is VFPv4-D32 and uses 32 double-precision registers. This register bank is shared with NEON."(That said, M processors don't have NEON, so this part of the code should never be reached )
They don't have Neon, but that means that cpu->has_neon is false, so this part of the code *will* be reached. The reason this sub-part of the "disable Neon" handling is inside a not-M check is because M-profile has a different assignment for some of the MVFR1 fields (check the comments in the FIELD definitions in cpu.h), and zeroing things out based on the A-profile meanings would be wrong.
thanks
-- PMM
Re: [PATCH 1/2] target/arm: Disable VFPv4-D32 when NEON is not available
In reply to Cédric Le GoaterQuoted 21 lines · Cédric Le Goater
As the Cortex A7 MPCore Technical reference says :
"When FPU option is selected without NEON, the FPU is VFPv4-D16 and uses 16 double-precision registers. When the FPU is implemented with NEON, the FPU is VFPv4-D32 and uses 32 double-precision registers. This register bank is shared with NEON."
Modify the mvfr0 register value of the cortex A7 to advertise only 16 registers when NEON is not available, and not 32 registers.
Signed-off-by Cédric Le Goater <[email protected]>--- target/arm/cpu.c | 4 ++++ 1 file changed, 4 insertions(+)target/arm/cpu.c +0
-0
target/arm/cpu.c static void arm_cpu_realizefn(DeviceState *dev, Error **errp) · line 1690
Quoted 7 lines
target/arm/cpu.c +4
-0@@ -1684,6 +1684,10 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) cpu->isar.id_isar6 = u;if (!arm_feature (env,ARM_FEATURE_M )) { + u = cpu->isar.mvfr0; + u =FIELD_DP32 (u,MVFR0 ,SIMDREG ,1 );/* 16 registers */ + cpu->isar.mvfr0 = u; +
Architecturally, Neon implies that you must have 32 dp registers, but not having Neon does not imply that you must only have 16. In particular, the Cortex-A15 always implements VFPv4-D32 whether Neon is enabled or not.
If you want to be able to turn off D32 and restrict to 16 registers, I think you need to add a separate property to control that.
thanks
-- PMM
Re: [PATCH 1/2] target/arm: Disable VFPv4-D32 when NEON is not available
Quoted 4 lines · Peter Maydell
Architecturally, Neon implies that you must have 32 dp registers, but not having Neon does not imply that you must only have 16. In particular, the Cortex-A15 always implements VFPv4-D32 whether Neon is enabled or not.
A15 requires VFP == NEON in its configuration.
r~
Re: [PATCH 1/2] target/arm: Disable VFPv4-D32 when NEON is not available
Quoted 8 lines · Richard Henderson
Quoted 4 lines · Peter Maydell
Architecturally, Neon implies that you must have 32 dp registers, but not having Neon does not imply that you must only have 16. In particular, the Cortex-A15 always implements VFPv4-D32 whether Neon is enabled or not.
A15 requires VFP == NEON in its configuration.
No, it requires that if you have Neon then you have VFP; but it allows all of:
* no VFP or Neon
* VFP, no Neon
* VFP and Neon
https://developer.arm.com/documentation/ddi0438/i/neon-and-vfp-unit/about-neon-and-vfp-unit
-- PMM
Re: [PATCH 1/2] target/arm: Disable VFPv4-D32 when NEON is not available
In reply to Peter MaydellQuoted 35 lines · Peter Maydell
Quoted 21 lines · Cédric Le Goater
As the Cortex A7 MPCore Technical reference says :
"When FPU option is selected without NEON, the FPU is VFPv4-D16 and uses 16 double-precision registers. When the FPU is implemented with NEON, the FPU is VFPv4-D32 and uses 32 double-precision registers. This register bank is shared with NEON."
Modify the mvfr0 register value of the cortex A7 to advertise only 16 registers when NEON is not available, and not 32 registers.
Signed-off-by Cédric Le Goater <[email protected]>--- target/arm/cpu.c | 4 ++++ 1 file changed, 4 insertions(+)target/arm/cpu.c +0
-0target/arm/cpu.c static void arm_cpu_realizefn(DeviceState *dev, Error **errp) · line 1690
Quoted 7 lines
target/arm/cpu.c +4
-0@@ -1684,6 +1684,10 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) cpu->isar.id_isar6 = u;if (!arm_feature (env,ARM_FEATURE_M )) { + u = cpu->isar.mvfr0; + u =FIELD_DP32 (u,MVFR0 ,SIMDREG ,1 );/* 16 registers */ + cpu->isar.mvfr0 = u; +Architecturally, Neon implies that you must have 32 dp registers, but not having Neon does not imply that you must only have 16. In particular, the Cortex-A15 always implements VFPv4-D32 whether Neon is enabled or not.
Quoted 3 lines
If you want to be able to turn off D32 and restrict to 16 registers, I think you need to add a separate property to control that.
Something like "vfp-d16" ?
Thanks,
C.
Re: [PATCH 1/2] target/arm: Disable VFPv4-D32 when NEON is not available
Quoted 7 lines · Cédric Le Goater
Quoted 3 lines · Peter Maydell
If you want to be able to turn off D32 and restrict to 16 registers, I think you need to add a separate property to control that.
Something like "vfp-d16" ?
That ends up being a sort of negative-polarity feature. Maybe "vfp-d32" for "have 32 dregs", with 'no' meaning "only 16" ?
thanks
-- PMM
PATCH 2/2 ast2600: Drop NEON from the CPU features
In reply to Cédric Le GoaterCurrently, the CPU features exposed to the AST2600 QEMU machines are :
half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
But, the features of the Cortex A7 CPU on the Aspeed AST2600 A3 SoC are :
half thumb fastmult vfp edsp vfpv3 vfpv3d16 tls vfpv4 idiva idivt lpae evtstrm
Drop NEON support in the Aspeed AST2600 SoC.
--- hw/arm/aspeed_ast2600.c | 2 ++ 1 file changed, 2 insertions(+)
hw/arm/aspeed_ast2600.c +2 -0
@@ -330,6 +330,8 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)object_property_set_int (OBJECT (&s->cpu[i]),"cntfrq" ,1125000000 , &error_abort); +object_property_set_bool (OBJECT (&s->cpu[i]),"neon" , false, + &error_abort);object_property_set_link (OBJECT (&s->cpu[i]),"memory" ,OBJECT (s->memory), &error_abort);
Signature · 1 line
2.37.3
Re: [PATCH 2/2] ast2600: Drop NEON from the CPU features
Quoted 9 lines · Cédric Le Goater
Currently, the CPU features exposed to the AST2600 QEMU machines are :
half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
But, the features of the Cortex A7 CPU on the Aspeed AST2600 A3 SoC are :
Quoted 6 lines
half thumb fastmult vfp edsp vfpv3 vfpv3d16 tls vfpv4 idiva idivt lpae evtstrm
Drop NEON support in the Aspeed AST2600 SoC.
Signed-off-by Cédric Le Goater <[email protected]>