Skip to contentSkip to conversation

x86/HyperV: correct hv_hcall_page for xen.efi build

PATCH In review Jan Beulich 3 participants 4 messages Apr 30, 2020 – May 1, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/HyperV: correct hv_hcall_page for xen.efi build

Along the lines of what the not reverted part of 3c4b2eef4941 ("x86:
refine link time stub area related assertion") did, we need to transform the absolute HV_HCALL_PAGE into the image base relative hv_hcall_page (or else there'd be no need for two distinct symbols). Otherwise mkreloc, as used for generating the base relocations of xen.efi, will spit out warnings like "Difference at .text:0009b74f is 0xc0000000 (expected 0x40000000)". As long as the offending relocations are PC relative ones, the generated binary is correct afaict, but if there ever was the absolute address stored, xen.efi would miss a fixup for it.

---
Build tested only (and generated binary inspected) - Wei, please check that this doesn't break things.

xen/arch/x86/xen.lds.S +1 -1
@@ -327,7 +327,7 @@ SECTIONS
 #endif
 
 #ifdef CONFIG_HYPERV_GUEST
-  hv_hcall_page = ABSOLUTE(HV_HCALL_PAGE);
+  hv_hcall_page = ABSOLUTE(HV_HCALL_PAGE - XEN_VIRT_START + __XEN_VIRT_START);
 #endif
 
   /* Sections to be discarded */
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Jan Beulich

Along the lines of what the not reverted part of 3c4b2eef4941 ("x86:
refine link time stub area related assertion") did, we need to transform the absolute HV_HCALL_PAGE into the image base relative hv_hcall_page (or else there'd be no need for two distinct symbols). Otherwise mkreloc, as used for generating the base relocations of xen.efi, will spit out warnings like "Difference at .text:0009b74f is 0xc0000000 (expected 0x40000000)". As long as the offending relocations are PC relative ones, the generated binary is correct afaict, but if there ever was the absolute address stored, xen.efi would miss a fixup for it.

Quoted 2 lines
Quoted 4 lines

---
Build tested only (and generated binary inspected) - Wei, please check that this doesn't break things.

I don't have time to verify this in next couple of weeks, but I will surely notice if there is a breakage.

Quoted 11 lines
xen/arch/x86/xen.lds.S +1 -1
@@ -327,7 +327,7 @@ SECTIONS
 #endif
 
 #ifdef CONFIG_HYPERV_GUEST
-  hv_hcall_page = ABSOLUTE(HV_HCALL_PAGE);
+  hv_hcall_page = ABSOLUTE(HV_HCALL_PAGE - XEN_VIRT_START + __XEN_VIRT_START);
 #endif
 
   /* Sections to be discarded */
#2 lore raw
Quoted 13 lines · Wei Liu
Quoted 10 lines · Jan Beulich

Along the lines of what the not reverted part of 3c4b2eef4941 ("x86:
refine link time stub area related assertion") did, we need to transform the absolute HV_HCALL_PAGE into the image base relative hv_hcall_page (or else there'd be no need for two distinct symbols). Otherwise mkreloc, as used for generating the base relocations of xen.efi, will spit out warnings like "Difference at .text:0009b74f is 0xc0000000 (expected 0x40000000)". As long as the offending relocations are PC relative ones, the generated binary is correct afaict, but if there ever was the absolute address stored, xen.efi would miss a fixup for it.

Quoted 2 lines
Quoted 8 lines
Quoted 4 lines

---
Build tested only (and generated binary inspected) - Wei, please check that this doesn't break things.

I don't have time to verify this in next couple of weeks, but I will surely notice if there is a breakage.

FWIW, the resulting assembly is identical, so it surely will be as fine as it was previously.

~Andrew

#3 lore raw
Quoted 20 lines · Andrew Cooper
Quoted 19 lines · Wei Liu
Quoted 10 lines · Jan Beulich

Along the lines of what the not reverted part of 3c4b2eef4941 ("x86:
refine link time stub area related assertion") did, we need to transform the absolute HV_HCALL_PAGE into the image base relative hv_hcall_page (or else there'd be no need for two distinct symbols). Otherwise mkreloc, as used for generating the base relocations of xen.efi, will spit out warnings like "Difference at .text:0009b74f is 0xc0000000 (expected 0x40000000)". As long as the offending relocations are PC relative ones, the generated binary is correct afaict, but if there ever was the absolute address stored, xen.efi would miss a fixup for it.

Quoted 2 lines
Quoted 4 lines

---
Build tested only (and generated binary inspected) - Wei, please check that this doesn't break things.

Quoted 5 lines
Quoted 2 lines

I don't have time to verify this in next couple of weeks, but I will surely notice if there is a breakage.

FWIW, the resulting assembly is identical, so it surely will be as fine as it was previously.

Thanks. That should be okay.

Wei.

Quoted 2 lines

~Andrew