Skip to contentSkip to conversation

xen/arm64: correct comments

PATCH In review Peng Fan 2 participants 7 messages Apr 20, 2016 – Apr 23, 2016

lore
Share & tools
lore

Peng Fan

author
#0 lore raw

PATCH 1/2 xen/arm64: correct comments

The 'Base address for 4K mapping' is '(x19 >> THIRD_SHIFT) << THIRD_SHIFT'. Also we are building 4K page mapping, not section mapping.

Cc Stefano Stabellini <[email protected]>
Cc Julien Grall <[email protected]>
---
 xen/arch/arm/arm64/head.S | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
xen/arch/arm/arm64/head.S +4 -4
index 946e2c9..05e3db0 100644
@@ -471,10 +471,10 @@ skip_bss:
         ldr   x4, =boot_third
         add   x4, x4, x20            /* x4 := paddr (boot_third) */
 
-        lsr   x2, x19, #THIRD_SHIFT  /* Base address for 4K mapping */
-        lsl   x2, x2, #THIRD_SHIFT
-        mov   x3, #PT_MEM_L3         /* x2 := Section map */
-        orr   x2, x2, x3
+        lsr   x2, x19, #THIRD_SHIFT
+        lsl   x2, x2, #THIRD_SHIFT  /* Base address for 4K mapping */
+        mov   x3, #PT_MEM_L3
+        orr   x2, x2, x3            /* x2 := Page map */
 
         /* ... map of vaddr(start) in boot_third */
         mov   x1, xzr
Signature · 7 lines
2.6.2


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
author
#1 lore raw

PATCH 2/2 xen/arm64: use shift operator

Use shift operator, but not muliplication.
No function change.

Cc Stefano Stabellini <[email protected]>
Cc Julien Grall <[email protected]>
---
 xen/arch/arm/arm64/head.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/arm64/head.S +1 -1
index 05e3db0..ad6e593 100644
@@ -524,7 +524,7 @@ paging:
         lsl   x2, x2, #THIRD_SHIFT   /* 4K aligned paddr of UART */
         mov   x3, #PT_DEV_L3
         orr   x2, x2, x3             /* x2 := 4K dev map including UART */
-        str   x2, [x1, #(FIXMAP_CONSOLE*8)] /* Map it in the first fixmap's slot */
+        str   x2, [x1, #(FIXMAP_CONSOLE << 3)] /* Map it in the first fixmap's slot */
 1:
 
         /* Map fixmap into boot_second */
Signature · 7 lines
2.6.2


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#2 lore raw

Re: [PATCH 2/2] xen/arm64: use shift operator

Hello Peng,

Quoted 2 lines · Peng Fan

Use shift operator, but not muliplication.
No function change.

Why? The compiler will calculate the address at compilation time.

Regards,

Quoted 21 lines
Cc Stefano Stabellini <[email protected]>
Cc Julien Grall <[email protected]>
---
  xen/arch/arm/arm64/head.S | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/arm64/head.S +1 -1
index 05e3db0..ad6e593 100644
@@ -524,7 +524,7 @@ paging:
          lsl   x2, x2, #THIRD_SHIFT   /* 4K aligned paddr of UART */
          mov   x3, #PT_DEV_L3
          orr   x2, x2, x3             /* x2 := 4K dev map including UART */
-        str   x2, [x1, #(FIXMAP_CONSOLE*8)] /* Map it in the first fixmap's slot */
+        str   x2, [x1, #(FIXMAP_CONSOLE << 3)] /* Map it in the first fixmap's slot */
  1:
 
          /* Map fixmap into boot_second */
Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
author
#3 lore raw

Re: [PATCH 2/2] xen/arm64: use shift operator

Hi Julien,

Quoted 7 lines · Julien Grall

Hello Peng,

Quoted 2 lines · Peng Fan

Use shift operator, but not muliplication.
No function change.

Why? The compiler will calculate the address at compilation time.

Yeah. The compiler will do this. I just think in asm, we rarely use
multiplication. In this file, there is "cmp x1, #(LPAE_ENTRIES<<3)",
here use shift operator but not multiplication.

Thanks,
Peng.

Quoted 22 lines

Regards,

Quoted 19 lines
Cc Stefano Stabellini <[email protected]>
Cc Julien Grall <[email protected]>
---
 xen/arch/arm/arm64/head.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/arm64/head.S +1 -1
index 05e3db0..ad6e593 100644
@@ -524,7 +524,7 @@ paging:
         lsl   x2, x2, #THIRD_SHIFT   /* 4K aligned paddr of UART */
         mov   x3, #PT_DEV_L3
         orr   x2, x2, x3             /* x2 := 4K dev map including UART */
-        str   x2, [x1, #(FIXMAP_CONSOLE*8)] /* Map it in the first fixmap's slot */
+        str   x2, [x1, #(FIXMAP_CONSOLE << 3)] /* Map it in the first fixmap's slot */
 1:
 
Quoted 5 lines
Quoted 2 lines
xen/arch/arm/arm64/head.S +0 -0
         /* Map fixmap into boot_second */
Signature · 1 line
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#4 lore raw

Re: [PATCH 2/2] xen/arm64: use shift operator

Quoted 1 line · Peng Fan

Hi Julien,

Hello Peng,

Quoted 12 lines · Julien Grall
Quoted 7 lines

Hello Peng,

Quoted 2 lines · Peng Fan

Use shift operator, but not muliplication.
No function change.

Why? The compiler will calculate the address at compilation time.

Yeah. The compiler will do this. I just think in asm, we rarely use
multiplication. In this file, there is "cmp x1, #(LPAE_ENTRIES<<3)",
here use shift operator but not multiplication.

It took me a bit of time to understand that 8 is the number of byte of an LPAE entries. IMHO the "<< 3" would be more confusing.

So I would introduce a macro to get the slot based of an index. Something like:

LPAE_SLOT(slot) ((slot) * 8)

And add a comment to explain why 8. You could even introduce LPAE_ENTRY_SIZE.

Regards,

Quoted 31 lines

Thanks,
Peng.

Quoted 27 lines

Regards,

Quoted 13 lines
Cc Stefano Stabellini <[email protected]>
Cc Julien Grall <[email protected]>
---
  xen/arch/arm/arm64/head.S | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/arm64/head.S +0 -0
index 05e3db0..ad6e593 100644

xen/arch/arm/arm64/head.S paging: · line 530

Quoted 8 lines
xen/arch/arm/arm64/head.S +1 -1
@@ -524,7 +524,7 @@ paging:
          lsl   x2, x2, #THIRD_SHIFT   /* 4K aligned paddr of UART */
          mov   x3, #PT_DEV_L3
          orr   x2, x2, x3             /* x2 := 4K dev map including UART */
-        str   x2, [x1, #(FIXMAP_CONSOLE*8)] /* Map it in the first fixmap's slot */
+        str   x2, [x1, #(FIXMAP_CONSOLE << 3)] /* Map it in the first fixmap's slot */
  1:
 
          /* Map fixmap into boot_second */

--
Julien Grall

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
author
#5 lore raw

Re: [PATCH 2/2] xen/arm64: use shift operator

Hi Julien,

Quoted 21 lines · Julien Grall
Quoted 1 line · Peng Fan

Hi Julien,

Hello Peng,

Quoted 12 lines · Julien Grall
Quoted 7 lines

Hello Peng,

Quoted 2 lines · Peng Fan

Use shift operator, but not muliplication.
No function change.

Why? The compiler will calculate the address at compilation time.

Yeah. The compiler will do this. I just think in asm, we rarely use
multiplication. In this file, there is "cmp x1, #(LPAE_ENTRIES<<3)",
here use shift operator but not multiplication.

It took me a bit of time to understand that 8 is the number of byte of an LPAE entries. IMHO the "<< 3" would be more confusing.

Quoted 6 lines

So I would introduce a macro to get the slot based of an index. Something like:

LPAE_SLOT(slot) ((slot) * 8)

And add a comment to explain why 8. You could even introduce LPAE_ENTRY_SIZE.

Thanks for comments. I'll try to submit a new patch following your suggestion.

Thanks,
Peng.

Quoted 28 lines

Regards,

Quoted 25 lines

Thanks,
Peng.

Quoted 22 lines

Regards,

Quoted 19 lines
Cc Stefano Stabellini <[email protected]>
Cc Julien Grall <[email protected]>
---
 xen/arch/arm/arm64/head.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/arm64/head.S +1 -1
index 05e3db0..ad6e593 100644
@@ -524,7 +524,7 @@ paging:
         lsl   x2, x2, #THIRD_SHIFT   /* 4K aligned paddr of UART */
         mov   x3, #PT_DEV_L3
         orr   x2, x2, x3             /* x2 := 4K dev map including UART */
-        str   x2, [x1, #(FIXMAP_CONSOLE*8)] /* Map it in the first fixmap's slot */
+        str   x2, [x1, #(FIXMAP_CONSOLE << 3)] /* Map it in the first fixmap's slot */
 1:
 
Quoted 9 lines
Quoted 6 lines
Quoted 5 lines

xen/arch/arm/arm64/head.S paging: · line 530

Quoted 2 lines
xen/arch/arm/arm64/head.S +0 -0
         /* Map fixmap into boot_second */

--
Julien Grall

Signature · 1 line
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#6 lore raw
In reply to Peng Fan

Hello Peng,

I would specific the file modified in the title.

Quoted 1 line · Peng Fan

The 'Base address for 4K mapping' is '(x19 >> THIRD_SHIFT) << THIRD_SHIFT'.

The computation is a sequence of 2 instructions. I gave a look to the rest of the file and the comments are usually put on the first instruction.

So I would much prefer to stay consistent with the rest of the code.

Quoted 1 line

Also we are building 4K page mapping, not section mapping.

To be fair, a page is a specialized section.

Quoted 13 lines
Cc Stefano Stabellini <[email protected]>
Cc Julien Grall <[email protected]>
---
  xen/arch/arm/arm64/head.S | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)
xen/arch/arm/arm64/head.S +0 -0
index 946e2c9..05e3db0 100644
@@ -471,10 +471,10 @@ skip_bss:
          ldr   x4, =boot_third

xen/arch/arm/arm64/head.S skip_bss: · line 477

Quoted 10 lines
xen/arch/arm/arm64/head.S +4 -4
          add   x4, x4, x20            /* x4 := paddr (boot_third) */
 
-        lsr   x2, x19, #THIRD_SHIFT  /* Base address for 4K mapping */
-        lsl   x2, x2, #THIRD_SHIFT
-        mov   x3, #PT_MEM_L3         /* x2 := Section map */
-        orr   x2, x2, x3
+        lsr   x2, x19, #THIRD_SHIFT
+        lsl   x2, x2, #THIRD_SHIFT  /* Base address for 4K mapping */
+        mov   x3, #PT_MEM_L3
+        orr   x2, x2, x3            /* x2 := Page map */

The section map is the combination of 2 instructions. With this change we don't know quickly what the purpose of "mov x3, #PT_MEM_L3".

xen/arch/arm/arm64/head.S skip_bss:

Quoted 4 lines
xen/arch/arm/arm64/head.S +0 -0
          /* ... map of vaddr(start) in boot_third */
          mov   x1, xzr
 

Regards,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel