[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] libelf: allow having HYPERCALL_PAGE entry before VIRT_BASE in __xen_guest section.



From: Gregory Herrero <gregory.herrero@xxxxxxxxxx>

When filling __xen_guest section of a guest, user may define
HYPERCALL_PAGE earlier than VIRT_BASE in the section leading to an
incorrect hypercall page address since an undefined virt_base could be
used to compute hypercall page address.
If there is no VIRT_BASE entry in __xen_guest section, default value of
0 is used for virt_base. Thus, setting hypercall page address to
HYPERCALL_PAGE value is correct in this case too.

Signed-off-by: Gregory Herrero <gregory.herrero@xxxxxxxxxx>
---
 xen/common/libelf/libelf-dominfo.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/xen/common/libelf/libelf-dominfo.c 
b/xen/common/libelf/libelf-dominfo.c
index a52900c00cd..b1255acc059 100644
--- a/xen/common/libelf/libelf-dominfo.c
+++ b/xen/common/libelf/libelf-dominfo.c
@@ -330,14 +330,21 @@ elf_errorstatus elf_xen_parse_guest_info(struct 
elf_binary *elf,
 
         /* longs */
         if ( !strcmp(name, "VIRT_BASE") )
+        {
             parms->virt_base = strtoull(value, NULL, 0);
+            if ( parms->virt_hypercall != UNSET_ADDR )
+                params->virt_hypercall += params->virt_base;
+        }
         if ( !strcmp(name, "VIRT_ENTRY") )
             parms->virt_entry = strtoull(value, NULL, 0);
         if ( !strcmp(name, "ELF_PADDR_OFFSET") )
             parms->elf_paddr_offset = strtoull(value, NULL, 0);
         if ( !strcmp(name, "HYPERCALL_PAGE") )
-            parms->virt_hypercall = (strtoull(value, NULL, 0) << 12) +
-                parms->virt_base;
+        {
+            parms->virt_hypercall = (strtoull(value, NULL, 0) << 12);
+            if ( parms->virt_base != UNSET_ADDR )
+                params->virt_hypercall += params->virt_base;
+        }
 
         /* other */
         if ( !strcmp(name, "FEATURES") )
-- 
2.14.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.