target/riscv: Bugfix reserved bits in PTE for RV64
Quoted 21 lines · On Mon, Sep 23, 2019 at 10:01 PM <[email protected]> wrote:
From: Guo Ren <[email protected]>
Highest 10 bits of PTE are reserved in riscv-privileged, ref: [1], so we need to ignore them. They can not be a part of ppn.
1: The RISC-V Instruction Set Manual, Volume II: Privileged Architecture
4.4 Sv39: Page-Based 39-bit Virtual-Memory System
4.5 Sv48: Page-Based 48-bit Virtual-Memory SystemSigned-off-by Guo Ren <[email protected]>Reviewed-by Liu Zhiwei <[email protected]>--- target/riscv/cpu_helper.c | 1 + 1 file changed, 1 insertion(+)target/riscv/cpu_helper.c +0
-0
target/riscv/cpu_helper.c restart: · line 263
Quoted 4 lines
target/riscv/cpu_helper.c +1
-0@@ -260,6 +260,7 @@ restart:target_ulong pte =ldl_phys (cs->as, pte_addr);#elif defined(TARGET_RISCV64 )target_ulong pte =ldq_phys (cs->as, pte_addr); + pte = pte <<10 >>10 ;
You can just AND with a mask instead of shifting both directions.
Alistair
Quoted 6 lines
target/riscv/cpu_helper.c +0
-1#endif hwaddr ppn = pte >>PTE_PPN_SHIFT ; --2.7.4
PATCH 1/1 target/riscv: Bugfix reserved bits in PTE for RV64
From: Guo Ren <[email protected]>
Highest 10 bits of PTE are reserved in riscv-privileged, ref: [1], so we need to ignore them. They can not be a part of ppn.
1: The RISC-V Instruction Set Manual, Volume II: Privileged Architecture
4.4 Sv39: Page-Based 39-bit Virtual-Memory System
4.5 Sv48: Page-Based 48-bit Virtual-Memory System
--- target/riscv/cpu_helper.c | 1 + 1 file changed, 1 insertion(+)
target/riscv/cpu_helper.c +1 -0
@@ -260,6 +260,7 @@ restart:target_ulong pte =ldl_phys (cs->as, pte_addr);#elif defined(TARGET_RISCV64 )target_ulong pte =ldq_phys (cs->as, pte_addr); + pte = pte <<10 >>10 ;#endif hwaddr ppn = pte >>PTE_PPN_SHIFT ;
Signature · 1 line
2.7.4
Ok, In fact it's wrong patch, don't try it. pte is destroyed.
Sorry for that, I'll send V2.
Quoted 38 lines · Alistair Francis
Quoted 21 lines · On Mon, Sep 23, 2019 at 10:01 PM <[email protected]> wrote:
From: Guo Ren <[email protected]>
Highest 10 bits of PTE are reserved in riscv-privileged, ref: [1], so we need to ignore them. They can not be a part of ppn.
1: The RISC-V Instruction Set Manual, Volume II: Privileged Architecture
4.4 Sv39: Page-Based 39-bit Virtual-Memory System
4.5 Sv48: Page-Based 48-bit Virtual-Memory SystemSigned-off-by Guo Ren <[email protected]>Reviewed-by Liu Zhiwei <[email protected]>--- target/riscv/cpu_helper.c | 1 + 1 file changed, 1 insertion(+)target/riscv/cpu_helper.c +0
-0target/riscv/cpu_helper.c restart: · line 263
Quoted 4 lines
target/riscv/cpu_helper.c +1
-0@@ -260,6 +260,7 @@ restart:target_ulong pte =ldl_phys (cs->as, pte_addr);#elif defined(TARGET_RISCV64 )target_ulong pte =ldq_phys (cs->as, pte_addr); + pte = pte <<10 >>10 ;You can just AND with a mask instead of shifting both directions.
Alistair
Quoted 6 lines
target/riscv/cpu_helper.c +0
-1#endif hwaddr ppn = pte >>PTE_PPN_SHIFT ; --2.7.4
Signature · 4 lines
Best Regards Guo Ren ML: https://lore.kernel.org/linux-csky/