target/riscv/cpu.c: fix veyron-v1 CPU properties
PATCH 1/1 target/riscv/cpu.c: fix veyron-v1 CPU properties
Commit 7f0bdfb5bfc2 ("target/riscv/cpu.c: remove cfg setup from riscv_cpu_init()") removed code that was enabling mmu, pmp, ext_ifencei and ext_icsr from riscv_cpu_init(), the init() function of TYPE_RISCV_CPU, parent type of all RISC-V CPUss. This was done to force CPUs to explictly enable all extensions and features it requires, without any 'magic values' that were inherited by the parent type.
This commit failed to make appropriate changes in the 'veyron-v1' CPU, added earlier by commit e1d084a8524a. The result is that the veyron-v1 CPU has ext_ifencei, ext_icsr and pmp set to 'false', which is not the case.
The reason why it took this long to notice (thanks LIU Zhiwei for reporting it) is because Linux doesn't mind 'ifencei' and 'icsr' being absent in the 'riscv,isa' DT, implying that they're both present if the 'i' extension is enabled. OpenSBI also doesn't error out or warns about the lack of 'pmp', it'll just not protect memory pages.
Fix it by setting them to 'true' in rv64_veyron_v1_cpu_init() like 7f0bdfb5bfc2 already did with other CPUs.
--- target/riscv/cpu.c | 3 +++ 1 file changed, 3 insertions(+)
target/riscv/cpu.c +3 -0
@@ -444,6 +444,9 @@ static void rv64_veyron_v1_cpu_init(Object *obj)/* Enable ISA extensions */ cpu->cfg.mmu = true; + cpu->cfg.ext_ifencei = true; + cpu->cfg.ext_icsr = true; + cpu->cfg.pmp = true; cpu->cfg.ext_icbom = true; cpu->cfg.cbom_blocksize =64 ; cpu->cfg.cboz_blocksize =64 ;
Signature · 1 line
2.41.0
Quoted 19 lines · Daniel Henrique Barboza
Commit
7f0bdfb5bfc2("target/riscv/cpu.c: remove cfg setup fromriscv_cpu_init()") removed code that was enabling mmu, pmp,ext_ifenceiandext_icsrfromriscv_cpu_init(), theinit()function ofTYPE_RISCV_CPU, parent type of all RISC-V CPUss. This was done to force CPUs to explictly enable all extensions and features it requires, without any 'magic values' that were inherited by the parent type.This commit failed to make appropriate changes in the 'veyron-v1' CPU, added earlier by commit
e1d084a8524a. The result is that the veyron-v1 CPU hasext_ifencei,ext_icsrand pmp set to 'false', which is not the case.The reason why it took this long to notice (thanks LIU Zhiwei for reporting it) is because Linux doesn't mind 'ifencei' and 'icsr' being absent in the 'riscv,isa' DT, implying that they're both present if the 'i' extension is enabled. OpenSBI also doesn't error out or warns about the lack of 'pmp', it'll just not protect memory pages.
Quoted 6 lines
Fix it by setting them to 'true' in
rv64_veyron_v1_cpu_init()like7f0bdfb5bfc2already did with other CPUs.Reported-by LIU Zhiwei <[email protected]>Fixes 7f0bdfb5bfc2 ("target/riscv/cpu.c: remove cfg setup from riscv_cpu_init()")Signed-off-by Daniel Henrique Barboza <[email protected]>
Alistair
Quoted 22 lines
--- target/riscv/cpu.c | 3 +++ 1 file changed, 3 insertions(+)target/riscv/cpu.c +3
-1@@ -444,6 +444,9 @@ static void rv64_veyron_v1_cpu_init(Object *obj)/* Enable ISA extensions */ cpu->cfg.mmu = true; + cpu->cfg.ext_ifencei = true; + cpu->cfg.ext_icsr = true; + cpu->cfg.pmp = true; cpu->cfg.ext_icbom = true; cpu->cfg.cbom_blocksize =64 ; cpu->cfg.cboz_blocksize =64 ; --2.41.0
Quoted 33 lines · Daniel Henrique Barboza
Commit
7f0bdfb5bfc2("target/riscv/cpu.c: remove cfg setup fromriscv_cpu_init()") removed code that was enabling mmu, pmp,ext_ifenceiandext_icsrfromriscv_cpu_init(), theinit()function ofTYPE_RISCV_CPU, parent type of all RISC-V CPUss. This was done to force CPUs to explictly enable all extensions and features it requires, without any 'magic values' that were inherited by the parent type.This commit failed to make appropriate changes in the 'veyron-v1' CPU, added earlier by commit
e1d084a8524a. The result is that the veyron-v1 CPU hasext_ifencei,ext_icsrand pmp set to 'false', which is not the case.The reason why it took this long to notice (thanks LIU Zhiwei for reporting it) is because Linux doesn't mind 'ifencei' and 'icsr' being absent in the 'riscv,isa' DT, implying that they're both present if the 'i' extension is enabled. OpenSBI also doesn't error out or warns about the lack of 'pmp', it'll just not protect memory pages.
Fix it by setting them to 'true' in
rv64_veyron_v1_cpu_init()like7f0bdfb5bfc2already did with other CPUs.Reported-by LIU Zhiwei <[email protected]>Fixes 7f0bdfb5bfc2 ("target/riscv/cpu.c: remove cfg setup from riscv_cpu_init()")Signed-off-by Daniel Henrique Barboza <[email protected]>--- target/riscv/cpu.c | 3 +++ 1 file changed, 3 insertions(+)target/riscv/cpu.c +0
-0
target/riscv/cpu.c static void rv64_veyron_v1_cpu_init(Object *obj) · line 449
Quoted 6 lines
target/riscv/cpu.c +3
-0@@ -444,6 +444,9 @@ static void rv64_veyron_v1_cpu_init(Object *obj)/* Enable ISA extensions */ cpu->cfg.mmu = true; + cpu->cfg.ext_ifencei = true; + cpu->cfg.ext_icsr = true; + cpu->cfg.pmp = true;
Zhiwei
Quoted 3 lines
target/riscv/cpu.c +0
-0cpu->cfg.ext_icbom = true; cpu->cfg.cbom_blocksize =64 ; cpu->cfg.cboz_blocksize =64 ;
Alistair Francis
AppliedQuoted 19 lines · Daniel Henrique Barboza
Commit
7f0bdfb5bfc2("target/riscv/cpu.c: remove cfg setup fromriscv_cpu_init()") removed code that was enabling mmu, pmp,ext_ifenceiandext_icsrfromriscv_cpu_init(), theinit()function ofTYPE_RISCV_CPU, parent type of all RISC-V CPUss. This was done to force CPUs to explictly enable all extensions and features it requires, without any 'magic values' that were inherited by the parent type.This commit failed to make appropriate changes in the 'veyron-v1' CPU, added earlier by commit
e1d084a8524a. The result is that the veyron-v1 CPU hasext_ifencei,ext_icsrand pmp set to 'false', which is not the case.The reason why it took this long to notice (thanks LIU Zhiwei for reporting it) is because Linux doesn't mind 'ifencei' and 'icsr' being absent in the 'riscv,isa' DT, implying that they're both present if the 'i' extension is enabled. OpenSBI also doesn't error out or warns about the lack of 'pmp', it'll just not protect memory pages.
Quoted 6 lines
Fix it by setting them to 'true' in
rv64_veyron_v1_cpu_init()like7f0bdfb5bfc2already did with other CPUs.Reported-by LIU Zhiwei <[email protected]>Fixes 7f0bdfb5bfc2 ("target/riscv/cpu.c: remove cfg setup from riscv_cpu_init()")Signed-off-by Daniel Henrique Barboza <[email protected]>
Thanks!
Applied to riscv-to-apply.next
Alistair
Quoted 22 lines
--- target/riscv/cpu.c | 3 +++ 1 file changed, 3 insertions(+)target/riscv/cpu.c +3
-1@@ -444,6 +444,9 @@ static void rv64_veyron_v1_cpu_init(Object *obj)/* Enable ISA extensions */ cpu->cfg.mmu = true; + cpu->cfg.ext_ifencei = true; + cpu->cfg.ext_icsr = true; + cpu->cfg.pmp = true; cpu->cfg.ext_icbom = true; cpu->cfg.cbom_blocksize =64 ; cpu->cfg.cboz_blocksize =64 ; --2.41.0