xen/arm64: fix section shift when mapping 2MB block in boot page table
PATCH 1/1 xen/arm64: fix section shift when mapping 2MB block in boot page table
Section shift for level-2 page table should be #21 rather than #20.
--- xen/arch/arm/arm64/head.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
xen/arch/arm/arm64/head.S +2 -2
@@ -292,8 +292,8 @@ skip_bss: ldr x4, =boot_second add x4, x4, x20 /* x4 := paddr (boot_second) */ - lsr x2, x19, #20 /* Base address for 2MB mapping */ - lsl x2, x2, #20 + lsr x2, x19, #21 /* Base address for 2MB mapping */ + lsl x2, x2, #21 mov x3, #PT_MEM /* x2 := Section map */ orr x2, x2, x3
Signature · 1 line
1.8.4.3
Quoted 1 line · Chen Baozi
Section shift for level-2 page table should be #21 rather than #20.
Thanks, are you finding these issues on actual hardware or just by inspection?
I think this change is correct, also arm32 has:
1: /* Setup boot_second: */
ldr r4, =boot_second
add r4, r4, r10 /* r1 := paddr (boot_second) */
lsr r2, r9, #20 /* Base address for 2MB mapping */
lsl r2, r2, #20
orr r2, r2, #PT_UPPER(MEM) /* r2:r3 := section map */
orr r2, r2, #PT_LOWER(MEM)Either they are both wrong or both right (I think both wrong).
The effect of this error is that bit #20 of paddr(boot_second) is preserved as bit #20 of the PTE, rather than being cleared. bit #20 of an entry at this level is UNK/SBZP -- so we survive this mistake even if paddr(boot_second) happens to have bit #20 set.
Really this code should use {FIRST,SECOND,THIRD}_SHIFT, and this file already includes asm/page.h so they should be available...
Quoted 21 lines
Signed-off-by Chen Baozi <[email protected]>--- xen/arch/arm/arm64/head.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)xen/arch/arm/arm64/head.S +2
-2@@ -292,8 +292,8 @@ skip_bss: ldr x4, =boot_second add x4, x4, x20 /* x4 := paddr (boot_second) */ - lsr x2, x19, #20 /* Base address for 2MB mapping */ - lsl x2, x2, #20 + lsr x2, x19, #21 /* Base address for 2MB mapping */ + lsl x2, x2, #21 mov x3, #PT_MEM /* x2 := Section map */ orr x2, x2, x3
Quoted 5 lines · Ian Campbell
Quoted 1 line · Chen Baozi
Section shift for level-2 page table should be #21 rather than #20.
Thanks, are you finding these issues on actual hardware or just by inspection?
Oh, I noticed this because I was inspecting my Mini-OS’s code by comparing with this. :-)
Quoted 14 lines
I think this change is correct, also arm32 has:
1: /* Setup boot_second: */ ldr r4, =boot_second add r4, r4, r10 /* r1 := paddr (boot_second) */ lsr r2, r9, #20 /* Base address for 2MB mapping */ lsl r2, r2, #20 orr r2, r2, #PT_UPPER(MEM) /* r2:r3 := section map */ orr r2, r2, #PT_LOWER(MEM)Either they are both wrong or both right (I think both wrong).
Quoted 7 lines
The effect of this error is that bit #20 of
paddr(boot_second)is preserved as bit #20 of the PTE, rather than being cleared. bit #20 of an entry at this level is UNK/SBZP -- so we survive this mistake even ifpaddr(boot_second)happens to have bit #20 set.Really this code should use {FIRST,SECOND,THIRD}_SHIFT, and this file already includes
asm/page.hso they should be available…
Ok, I’ll write the V2 to fix them all.
Cheers,
Baozi
Quoted 24 lines
Quoted 22 lines
Signed-off-by Chen Baozi <[email protected]>---
xen/arch/arm/arm64/head.S| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)xen/arch/arm/arm64/head.S +2
-2@@ -292,8 +292,8 @@ skip_bss: ldr x4, =boot_second add x4, x4, x20 /* x4 := paddr (boot_second) */ - lsr x2, x19, #20 /* Base address for 2MB mapping */ - lsl x2, x2, #20 + lsr x2, x19, #21 /* Base address for 2MB mapping */ + lsl x2, x2, #21 mov x3, #PT_MEM /* x2 := Section map */ orr x2, x2, x3
Quoted 10 lines · Chen Baozi
Quoted 5 lines · Ian Campbell
Quoted 1 line · Chen Baozi
Section shift for level-2 page table should be #21 rather than #20.
Thanks, are you finding these issues on actual hardware or just by inspection?
Oh, I noticed this because I was inspecting my Mini-OS’s code by comparing with this. :-)
Ah, I see!
Quoted 18 lines
Quoted 18 lines
I think this change is correct, also arm32 has:
1: /* Setup boot_second: */ ldr r4, =boot_second add r4, r4, r10 /* r1 := paddr (boot_second) */ lsr r2, r9, #20 /* Base address for 2MB mapping */ lsl r2, r2, #20 orr r2, r2, #PT_UPPER(MEM) /* r2:r3 := section map */ orr r2, r2, #PT_LOWER(MEM)Either they are both wrong or both right (I think both wrong).
The effect of this error is that bit #20 of
paddr(boot_second)is preserved as bit #20 of the PTE, rather than being cleared. bit #20 of an entry at this level is UNK/SBZP -- so we survive this mistake even ifpaddr(boot_second)happens to have bit #20 set.
Quoted 4 lines
Quoted 2 lines
Really this code should use {FIRST,SECOND,THIRD}_SHIFT, and this file already includes
asm/page.hso they should be available…Ok, I’ll write the V2 to fix them all.
Thanks!
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel