Skip to contentSkip to conversation

x86: refine link time stub area related assertion

PATCH Superseded Jan Beulich 3 participants 6 messages Jan 15, 2020

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: refine link time stub area related assertion

While it has been me to introduce this, the use of | there has become (and perhaps was from the very beginning) misleading. Rather than avoiding the right side of it when linking the xen.efi intermediate file at a different base address, make the expression cope with that case, thus verifying placement on every step.

xen/arch/x86/xen.lds.S +2 -2
@@ -351,8 +351,8 @@ SECTIONS
   .comment 0 : { *(.comment) }
 }
 
-ASSERT(__image_base__ > XEN_VIRT_START |
-       __2M_rwdata_end <= XEN_VIRT_END - NR_CPUS * PAGE_SIZE,
+ASSERT(__2M_rwdata_end <= XEN_VIRT_END - XEN_VIRT_START + __XEN_VIRT_START -
+                          NR_CPUS * PAGE_SIZE,
        "Xen image overlaps stubs area")
 
 #ifdef CONFIG_KEXEC

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Jan Beulich

While it has been me to introduce this, the use of | there has become (and perhaps was from the very beginning) misleading. Rather than avoiding the right side of it when linking the xen.efi intermediate file at a different base address, make the expression cope with that case, thus verifying placement on every step.

rearranging, but...

xen/arch/x86/xen.lds.S SECTIONS · line 355

Quoted 11 lines
xen/arch/x86/xen.lds.S +2 -2
@@ -351,8 +351,8 @@ SECTIONS
   .comment 0 : { *(.comment) }
 }
 
-ASSERT(__image_base__ > XEN_VIRT_START |
-       __2M_rwdata_end <= XEN_VIRT_END - NR_CPUS * PAGE_SIZE,
+ASSERT(__2M_rwdata_end <= XEN_VIRT_END - XEN_VIRT_START + __XEN_VIRT_START -
+                          NR_CPUS * PAGE_SIZE,

... doesn't this want a stubs_per_page term?  We don't have 4k per cpu.

Wei: FYI, if you do introduce executable fixmap entries, this ASSERT() wants adjusting by NR_X_FIXMAP * PAGE_SIZE as well.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
Quoted 26 lines · Andrew Cooper
Quoted 7 lines · Jan Beulich

While it has been me to introduce this, the use of | there has become (and perhaps was from the very beginning) misleading. Rather than avoiding the right side of it when linking the xen.efi intermediate file at a different base address, make the expression cope with that case, thus verifying placement on every step.

rearranging, but...

xen/arch/x86/xen.lds.S SECTIONS · line 355

Quoted 11 lines
xen/arch/x86/xen.lds.S +2 -2
@@ -351,8 +351,8 @@ SECTIONS
   .comment 0 : { *(.comment) }
 }
 
-ASSERT(__image_base__ > XEN_VIRT_START |
-       __2M_rwdata_end <= XEN_VIRT_END - NR_CPUS * PAGE_SIZE,
+ASSERT(__2M_rwdata_end <= XEN_VIRT_END - XEN_VIRT_START + __XEN_VIRT_START -
+                          NR_CPUS * PAGE_SIZE,

... doesn't this want a stubs_per_page term?  We don't have 4k per cpu.

Quoted 2 lines

Wei: FYI, if you do introduce executable fixmap entries, this ASSERT() wants adjusting by NR_X_FIXMAP * PAGE_SIZE as well.

It is a bit problematic to do that if NR_X_FIXMAP is calculated from the last enum element (see FIXADDR_SIZE)

I can expose a constant for the largest possible numbers of executable fixed mappings to put in the ASSERT.

Wei.

Quoted 2 lines

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw
In reply to Andrew Cooper
Quoted 19 lines · Andrew Cooper
Quoted 7 lines · Jan Beulich

While it has been me to introduce this, the use of | there has become (and perhaps was from the very beginning) misleading. Rather than avoiding the right side of it when linking the xen.efi intermediate file at a different base address, make the expression cope with that case, thus verifying placement on every step.

rearranging, but...

Quoted 7 lines
xen/arch/x86/xen.lds.S +0 -0
@@ -351,8 +351,8 @@ SECTIONS
   .comment 0 : { *(.comment) }
 }
 
Quoted 6 lines

xen/arch/x86/xen.lds.S SECTIONS · line 355

Quoted 4 lines
xen/arch/x86/xen.lds.S +2 -2
-ASSERT(__image_base__ > XEN_VIRT_START |
-       __2M_rwdata_end <= XEN_VIRT_END - NR_CPUS * PAGE_SIZE,
+ASSERT(__2M_rwdata_end <= XEN_VIRT_END - XEN_VIRT_START + __XEN_VIRT_START -
+                          NR_CPUS * PAGE_SIZE,

... doesn't this want a stubs_per_page term?  We don't have 4k per cpu.

Good point - let me see if I can fix this at this same occasion. I guess when introducing these pages I had one per CPU initially, and then forgot to update the assertion here (it being too strict of course is better than it being too lax).

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#4 lore raw
Quoted 23 lines · Jan Beulich
Quoted 17 lines · Andrew Cooper
Quoted 7 lines · Jan Beulich

While it has been me to introduce this, the use of | there has become (and perhaps was from the very beginning) misleading. Rather than avoiding the right side of it when linking the xen.efi intermediate file at a different base address, make the expression cope with that case, thus verifying placement on every step.

rearranging, but...

Quoted 6 lines
xen/arch/x86/xen.lds.S +0 -0
@@ -351,8 +351,8 @@ SECTIONS
   .comment 0 : { *(.comment) }
 }
 
Quoted 5 lines

xen/arch/x86/xen.lds.S SECTIONS · line 355

Quoted 4 lines
xen/arch/x86/xen.lds.S +2 -2
-ASSERT(__image_base__ > XEN_VIRT_START |
-       __2M_rwdata_end <= XEN_VIRT_END - NR_CPUS * PAGE_SIZE,
+ASSERT(__2M_rwdata_end <= XEN_VIRT_END - XEN_VIRT_START + __XEN_VIRT_START -
+                          NR_CPUS * PAGE_SIZE,

... doesn't this want a stubs_per_page term?  We don't have 4k per cpu.

Quoted 4 lines

Good point - let me see if I can fix this at this same occasion. I guess when introducing these pages I had one per CPU initially, and then forgot to update the assertion here (it being too strict of course is better than it being too lax).

With some suitable term, feel free to up my A-by to R-by.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#5 lore raw
Quoted 24 lines · Andrew Cooper
Quoted 23 lines · Jan Beulich
Quoted 22 lines · Andrew Cooper
Quoted 7 lines · Jan Beulich

While it has been me to introduce this, the use of | there has become (and perhaps was from the very beginning) misleading. Rather than avoiding the right side of it when linking the xen.efi intermediate file at a different base address, make the expression cope with that case, thus verifying placement on every step.

rearranging, but...

xen/arch/x86/xen.lds.S SECTIONS · line 355

Quoted 10 lines
xen/arch/x86/xen.lds.S +2 -2
@@ -351,8 +351,8 @@ SECTIONS
   .comment 0 : { *(.comment) }
 }
 
-ASSERT(__image_base__ > XEN_VIRT_START |
-       __2M_rwdata_end <= XEN_VIRT_END - NR_CPUS * PAGE_SIZE,
+ASSERT(__2M_rwdata_end <= XEN_VIRT_END - XEN_VIRT_START + __XEN_VIRT_START -
+                          NR_CPUS * PAGE_SIZE,

... doesn't this want a stubs_per_page term?  We don't have 4k per cpu.

Quoted 6 lines
Quoted 4 lines

Good point - let me see if I can fix this at this same occasion. I guess when introducing these pages I had one per CPU initially, and then forgot to update the assertion here (it being too strict of course is better than it being too lax).

With some suitable term, feel free to up my A-by to R-by.

Let me rather post what I have, because there's going to be some ugliness (and hence room for mistakes) because of the rounding needed. But thanks for the offer.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel