Skip to contentSkip to conversation

x86: relocate pvh_info

PATCH Superseded Wei Liu 3 participants 9 messages Jan 22, 2018 – Jan 23, 2018

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Wei Liu

author
#0 lore raw

PATCH v4 1/1 x86: relocate pvh_info

Modify early boot code to relocate pvh info as well, so that we can be sure __va in __start_xen works.

---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Roger Pau Monné <[email protected]>
Cc: Doug Goldstein <[email protected]>

v4: inlcude autoconf.h directly. The code itself is unchanged.

---
 xen/arch/x86/boot/Makefile |  4 +++
 xen/arch/x86/boot/defs.h   |  3 +++
 xen/arch/x86/boot/head.S   | 25 ++++++++++--------
 xen/arch/x86/boot/reloc.c  | 64 +++++++++++++++++++++++++++++++++++++++++-----
 4 files changed, 78 insertions(+), 18 deletions(-)
xen/arch/x86/boot/Makefile +4 -0
index c6246c85d2..1b3f121a2f 100644
@@ -7,6 +7,10 @@ CMDLINE_DEPS = $(DEFS_H_DEPS) video.h
 RELOC_DEPS = $(DEFS_H_DEPS) $(BASEDIR)/include/xen/multiboot.h \
 	     $(BASEDIR)/include/xen/multiboot2.h
 
+ifeq ($(CONFIG_PVH_GUEST),y)
+RELOC_DEPS += $(BASEDIR)/include/public/arch-x86/hvm/start_info.h
+endif
+
 head.o: cmdline.S reloc.S
 
 cmdline.S: cmdline.c $(CMDLINE_DEPS)
xen/arch/x86/boot/defs.h +3 -0
index 6abdc15446..05921a64a3 100644
@@ -51,6 +51,9 @@ typedef unsigned short u16;
 typedef unsigned int u32;
 typedef unsigned long long u64;
 typedef unsigned int size_t;
+typedef u8 uint8_t;
+typedef u32 uint32_t;
+typedef u64 uint64_t;
 
 #define U16_MAX		((u16)(~0U))
 #define UINT_MAX	(~0U)
xen/arch/x86/boot/head.S +14 -11
index 0f652cea11..aa2e2a93c8 100644
@@ -414,6 +414,7 @@ __pvh_start:
 
         /* Set trampoline_phys to use mfn 1 to avoid having a mapping at VA 0 */
         movw    $0x1000, sym_esi(trampoline_phys)
+        movl    (%ebx), %eax /* mov $XEN_HVM_START_MAGIC_VALUE, %eax */
         jmp     trampoline_setup
 
 #endif /* CONFIG_PVH_GUEST */
@@ -578,18 +579,20 @@ trampoline_setup:
         /* Get bottom-most low-memory stack address. */
         add     $TRAMPOLINE_SPACE,%ecx
 
-#ifdef CONFIG_PVH_GUEST
-        cmpb    $0, sym_fs(pvh_boot)
-        jne     1f
-#endif
-
-        /* Save the Multiboot info struct (after relocation) for later use. */
+        /* Save Multiboot / PVH info struct (after relocation) for later use. */
         push    %ecx                /* Bottom-most low-memory stack address. */
-        push    %ebx                /* Multiboot information address. */
-        push    %eax                /* Multiboot magic. */
+        push    %ebx                /* Multiboot / PVH information address. */
+        push    %eax                /* Magic number. */
         call    reloc
-        mov     %eax,sym_fs(multiboot_ptr)
+#ifdef CONFIG_PVH_GUEST
+        cmp     $0,sym_fs(pvh_boot)
+        je      1f
+        mov     %eax,sym_fs(pvh_start_info_pa)
+        jmp     2f
+#endif
 1:
+        mov     %eax,sym_fs(multiboot_ptr)
+2:
 
         /*
          * Now trampoline_phys points to the following structure (lowest address
@@ -598,12 +601,12 @@ trampoline_setup:
          * +------------------------+
          * | TRAMPOLINE_STACK_SPACE |
          * +------------------------+
-         * |        mbi data        |
+         * |     Data (MBI / PVH)   |
          * +- - - - - - - - - - - - +
          * |    TRAMPOLINE_SPACE    |
          * +------------------------+
          *
-         * mbi data grows downwards from the highest address of TRAMPOLINE_SPACE
+         * Data grows downwards from the highest address of TRAMPOLINE_SPACE
          * region to the end of the trampoline. The rest of TRAMPOLINE_SPACE is
          * reserved for trampoline code and data.
          */
xen/arch/x86/boot/reloc.c +57 -7

91 lines not on this page · raw message

Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Reviewed-by on v4 1/1
#1 lore raw
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 22.01.18 at 17:13, <[email protected]> wrote:

Modify early boot code to relocate pvh info as well, so that we can be sure __va in __start_xen works.

As before

with the caveat that this shouldn't go in without Andrew withdrawing his general objection.

Jan

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

#2 lore raw
In reply to Wei Liu
Quoted 23 lines · Wei Liu

Modify early boot code to relocate pvh info as well, so that we can be sure __va in __start_xen works.

---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Roger Pau Monné <[email protected]>
Cc: Doug Goldstein <[email protected]>

v4: inlcude autoconf.h directly. The code itself is unchanged.

---
 xen/arch/x86/boot/Makefile |  4 +++
 xen/arch/x86/boot/defs.h   |  3 +++
 xen/arch/x86/boot/head.S   | 25 ++++++++++--------
 xen/arch/x86/boot/reloc.c  | 64 +++++++++++++++++++++++++++++++++++++++++-----
 4 files changed, 78 insertions(+), 18 deletions(-)
xen/arch/x86/boot/Makefile +0 -0
index c6246c85d2..1b3f121a2f 100644

xen/arch/x86/boot/Makefile CMDLINE_DEPS = $(DEFS_H_DEPS) video.h · line 8

Quoted 2 lines
xen/arch/x86/boot/Makefile +0 -0
@@ -7,6 +7,10 @@ CMDLINE_DEPS = $(DEFS_H_DEPS) video.h
 RELOC_DEPS = $(DEFS_H_DEPS) $(BASEDIR)/include/xen/multiboot.h \
 	     $(BASEDIR)/include/xen/multiboot2.h

+ autoconf.h

However, it would much better to take xen/kconfig.h ...

xen/arch/x86/boot/Makefile CMDLINE_DEPS = $(DEFS_H_DEPS) video.h · line 12

Quoted 4 lines
xen/arch/x86/boot/Makefile +3 -0
+ifeq ($(CONFIG_PVH_GUEST),y)
+RELOC_DEPS += $(BASEDIR)/include/public/arch-x86/hvm/start_info.h
+endif

and this unconditionally, and ...

Quoted 47 lines
xen/arch/x86/boot/Makefile +1 -0
+
 head.o: cmdline.S reloc.S
 
 cmdline.S: cmdline.c $(CMDLINE_DEPS)
xen/arch/x86/boot/defs.h +3 -0
index 6abdc15446..05921a64a3 100644
@@ -51,6 +51,9 @@ typedef unsigned short u16;
 typedef unsigned int u32;
 typedef unsigned long long u64;
 typedef unsigned int size_t;
+typedef u8 uint8_t;
+typedef u32 uint32_t;
+typedef u64 uint64_t;
 
 #define U16_MAX		((u16)(~0U))
 #define UINT_MAX	(~0U)
xen/arch/x86/boot/head.S +4 -8
index 0f652cea11..aa2e2a93c8 100644
@@ -414,6 +414,7 @@ __pvh_start:
 
         /* Set trampoline_phys to use mfn 1 to avoid having a mapping at VA 0 */
         movw    $0x1000, sym_esi(trampoline_phys)
+        movl    (%ebx), %eax /* mov $XEN_HVM_START_MAGIC_VALUE, %eax */
         jmp     trampoline_setup
 
 #endif /* CONFIG_PVH_GUEST */
@@ -578,18 +579,20 @@ trampoline_setup:
         /* Get bottom-most low-memory stack address. */
         add     $TRAMPOLINE_SPACE,%ecx
 
-#ifdef CONFIG_PVH_GUEST
-        cmpb    $0, sym_fs(pvh_boot)
-        jne     1f
-#endif
-
-        /* Save the Multiboot info struct (after relocation) for later use. */
+        /* Save Multiboot / PVH info struct (after relocation) for later use. */
         push    %ecx                /* Bottom-most low-memory stack address. */
-        push    %ebx                /* Multiboot information address. */
-        push    %eax                /* Multiboot magic. */
+        push    %ebx                /* Multiboot / PVH information address. */
+        push    %eax                /* Magic number. */
         call    reloc

xen/arch/x86/boot/head.S trampoline_setup: · line 595

Quoted 10 lines
xen/arch/x86/boot/head.S +8 -1
-        mov     %eax,sym_fs(multiboot_ptr)
+#ifdef CONFIG_PVH_GUEST
+        cmp     $0,sym_fs(pvh_boot)
+        je      1f
+        mov     %eax,sym_fs(pvh_start_info_pa)
+        jmp     2f
+#endif
 1:
+        mov     %eax,sym_fs(multiboot_ptr)
+2:

For new code, please have spaces after commas for readibility.

Quoted 43 lines
xen/arch/x86/boot/head.S +2 -2
         /*
          * Now trampoline_phys points to the following structure (lowest address
@@ -598,12 +601,12 @@ trampoline_setup:
          * +------------------------+
          * | TRAMPOLINE_STACK_SPACE |
          * +------------------------+
-         * |        mbi data        |
+         * |     Data (MBI / PVH)   |
          * +- - - - - - - - - - - - +
          * |    TRAMPOLINE_SPACE    |
          * +------------------------+
          *
-         * mbi data grows downwards from the highest address of TRAMPOLINE_SPACE
+         * Data grows downwards from the highest address of TRAMPOLINE_SPACE
          * region to the end of the trampoline. The rest of TRAMPOLINE_SPACE is
          * reserved for trampoline code and data.
          */
xen/arch/x86/boot/reloc.c +4 -2
index b992678b5e..1fe19294ad 100644
@@ -14,8 +14,8 @@
 
 /*
  * This entry point is entered from xen/arch/x86/boot/head.S with:
- *   - 0x4(%esp) = MULTIBOOT_MAGIC,
- *   - 0x8(%esp) = MULTIBOOT_INFORMATION_ADDRESS,
+ *   - 0x4(%esp) = MAGIC,
+ *   - 0x8(%esp) = INFORMATION_ADDRESS,
  *   - 0xc(%esp) = TOPMOST_LOW_MEMORY_STACK_ADDRESS.
  */
 asm (
@@ -29,6 +29,8 @@ asm (
 #include "../../../include/xen/multiboot.h"
 #include "../../../include/xen/multiboot2.h"
 
+#include "../../../include/generated/autoconf.h"
+
 #define get_mb2_data(tag, type, member)   (((multiboot2_tag_##type##_t *)(tag))->member)
 #define get_mb2_string(tag, type, member) ((u32)get_mb2_data(tag, type, member))
 

xen/arch/x86/boot/reloc.c static u32 copy_string(u32 src) · line 76

Quoted 4 lines
xen/arch/x86/boot/reloc.c +1 -0
@@ -71,6 +73,41 @@ static u32 copy_string(u32 src)
     return copy_mem(src, p - src + 1);
 }
 
+#ifdef CONFIG_PVH_GUEST

... drop this ifdef and ...

Quoted 52 lines
xen/arch/x86/boot/reloc.c +37 -5
+
+#include <public/arch-x86/hvm/start_info.h>
+
+static struct hvm_start_info *pvh_info_reloc(u32 in)
+{
+    struct hvm_start_info *out;
+
+    out = _p(copy_mem(in, sizeof(*out)));
+
+    if ( out->cmdline_paddr )
+        out->cmdline_paddr = copy_string(out->cmdline_paddr);
+
+    if ( out->nr_modules )
+    {
+        unsigned int i;
+        struct hvm_modlist_entry *mods;
+
+        out->modlist_paddr =
+            copy_mem(out->modlist_paddr,
+                     out->nr_modules * sizeof(struct hvm_modlist_entry));
+
+        mods = _p(out->modlist_paddr);
+
+        for ( i = 0; i < out->nr_modules; i++ )
+        {
+            if ( mods[i].cmdline_paddr )
+                mods[i].cmdline_paddr = copy_string(mods[i].cmdline_paddr);
+        }
+    }
+
+    return out;
+}
+#endif
+
 static multiboot_info_t *mbi_reloc(u32 mbi_in)
 {
     int i;
@@ -226,14 +263,27 @@ static multiboot_info_t *mbi2_reloc(u32 mbi_in)
     return mbi_out;
 }
 
-multiboot_info_t __stdcall *reloc(u32 mb_magic, u32 mbi_in, u32 trampoline)
+void __stdcall *reloc(u32 magic, u32 in, u32 trampoline)
 {
     alloc = trampoline;
 
-    if ( mb_magic == MULTIBOOT2_BOOTLOADER_MAGIC )
-        return mbi2_reloc(mbi_in);
-    else
-        return mbi_reloc(mbi_in);
+    switch ( magic )
+    {

xen/arch/x86/boot/reloc.c static multiboot_info_t *mbi2_reloc(u32 mbi_in) · line 281

Quoted 10 lines
xen/arch/x86/boot/reloc.c +10 -0
+    case MULTIBOOT_BOOTLOADER_MAGIC:
+        return mbi_reloc(in);
+
+    case MULTIBOOT2_BOOTLOADER_MAGIC:
+        return mbi2_reloc(in);
+
+#ifdef CONFIG_PVH_GUEST
+    case XEN_HVM_START_MAGIC_VALUE:
+        return pvh_info_reloc(in);
+#endif

Rearrange this as:

case XEN_HVM_START_MAGIC_VALUE:
    if ( IS_ENABLED(CONFIG_PVH_GUEST) )
        return pvh_info_reloc(in);
    /* Fallthrough */

Which drops all of the ifdefary.

~Andrew

xen/arch/x86/boot/reloc.c static multiboot_info_t *mbi2_reloc(u32 mbi_in) · line 289

Quoted 8 lines
xen/arch/x86/boot/reloc.c +5 -0
+
+    default:
+        /* Nothing we can do */
+        return NULL;
+    }
 }
 
 /*

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

author
#3 lore raw
Quoted 29 lines · Andrew Cooper
Quoted 23 lines · Wei Liu

Modify early boot code to relocate pvh info as well, so that we can be sure __va in __start_xen works.

---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Roger Pau Monné <[email protected]>
Cc: Doug Goldstein <[email protected]>

v4: inlcude autoconf.h directly. The code itself is unchanged.

---
 xen/arch/x86/boot/Makefile |  4 +++
 xen/arch/x86/boot/defs.h   |  3 +++
 xen/arch/x86/boot/head.S   | 25 ++++++++++--------
 xen/arch/x86/boot/reloc.c  | 64 +++++++++++++++++++++++++++++++++++++++++-----
 4 files changed, 78 insertions(+), 18 deletions(-)
xen/arch/x86/boot/Makefile +0 -0
index c6246c85d2..1b3f121a2f 100644

xen/arch/x86/boot/Makefile CMDLINE_DEPS = $(DEFS_H_DEPS) video.h · line 8

Quoted 2 lines
xen/arch/x86/boot/Makefile +0 -0
@@ -7,6 +7,10 @@ CMDLINE_DEPS = $(DEFS_H_DEPS) video.h
 RELOC_DEPS = $(DEFS_H_DEPS) $(BASEDIR)/include/xen/multiboot.h \
 	     $(BASEDIR)/include/xen/multiboot2.h

+ autoconf.h

Quoted 2 lines

However, it would much better to take xen/kconfig.h ...

This is fine by me.

Quoted 5 lines
Quoted 4 lines
xen/arch/x86/boot/Makefile +3 -0
+ifeq ($(CONFIG_PVH_GUEST),y)
+RELOC_DEPS += $(BASEDIR)/include/public/arch-x86/hvm/start_info.h
+endif

[...]

Quoted 24 lines
Quoted 24 lines
xen/arch/x86/boot/reloc.c +4 -2
index b992678b5e..1fe19294ad 100644
@@ -14,8 +14,8 @@
 
 /*
  * This entry point is entered from xen/arch/x86/boot/head.S with:
- *   - 0x4(%esp) = MULTIBOOT_MAGIC,
- *   - 0x8(%esp) = MULTIBOOT_INFORMATION_ADDRESS,
+ *   - 0x4(%esp) = MAGIC,
+ *   - 0x8(%esp) = INFORMATION_ADDRESS,
  *   - 0xc(%esp) = TOPMOST_LOW_MEMORY_STACK_ADDRESS.
  */
 asm (
@@ -29,6 +29,8 @@ asm (
 #include "../../../include/xen/multiboot.h"
 #include "../../../include/xen/multiboot2.h"
 
+#include "../../../include/generated/autoconf.h"
+
 #define get_mb2_data(tag, type, member)   (((multiboot2_tag_##type##_t *)(tag))->member)
 #define get_mb2_string(tag, type, member) ((u32)get_mb2_data(tag, type, member))
 
Quoted 8 lines

xen/arch/x86/boot/reloc.c static u32 copy_string(u32 src) · line 76

Quoted 5 lines
xen/arch/x86/boot/reloc.c +1 -0
@@ -71,6 +73,41 @@ static u32 copy_string(u32 src)
     return copy_mem(src, p - src + 1);
 }
 
+#ifdef CONFIG_PVH_GUEST

... drop this ifdef and ...

So you want reloc.o to contain pvh_info_reloc unconditionally?

Fundamentally I don't think I care enough about all the bikeshedding so if Jan and you agree on this I will just make the change.

Wei.

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

#4 lore raw
Quoted 66 lines · Wei Liu
Quoted 28 lines · Andrew Cooper
Quoted 23 lines · Wei Liu

Modify early boot code to relocate pvh info as well, so that we can be sure __va in __start_xen works.

---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Roger Pau Monné <[email protected]>
Cc: Doug Goldstein <[email protected]>

v4: inlcude autoconf.h directly. The code itself is unchanged.

---
 xen/arch/x86/boot/Makefile |  4 +++
 xen/arch/x86/boot/defs.h   |  3 +++
 xen/arch/x86/boot/head.S   | 25 ++++++++++--------
 xen/arch/x86/boot/reloc.c  | 64 +++++++++++++++++++++++++++++++++++++++++-----
 4 files changed, 78 insertions(+), 18 deletions(-)
xen/arch/x86/boot/Makefile +0 -0
index c6246c85d2..1b3f121a2f 100644

xen/arch/x86/boot/Makefile CMDLINE_DEPS = $(DEFS_H_DEPS) video.h · line 8

Quoted 2 lines
xen/arch/x86/boot/Makefile +0 -0
@@ -7,6 +7,10 @@ CMDLINE_DEPS = $(DEFS_H_DEPS) video.h
 RELOC_DEPS = $(DEFS_H_DEPS) $(BASEDIR)/include/xen/multiboot.h \
 	     $(BASEDIR)/include/xen/multiboot2.h

+ autoconf.h

Quoted 2 lines

However, it would much better to take xen/kconfig.h ...

This is fine by me.

Quoted 4 lines
Quoted 4 lines
xen/arch/x86/boot/Makefile +3 -0
+ifeq ($(CONFIG_PVH_GUEST),y)
+RELOC_DEPS += $(BASEDIR)/include/public/arch-x86/hvm/start_info.h
+endif

[...]

Quoted 28 lines
Quoted 28 lines
xen/arch/x86/boot/reloc.c +4 -2
index b992678b5e..1fe19294ad 100644
@@ -14,8 +14,8 @@
 
 /*
  * This entry point is entered from xen/arch/x86/boot/head.S with:
- *   - 0x4(%esp) = MULTIBOOT_MAGIC,
- *   - 0x8(%esp) = MULTIBOOT_INFORMATION_ADDRESS,
+ *   - 0x4(%esp) = MAGIC,
+ *   - 0x8(%esp) = INFORMATION_ADDRESS,
  *   - 0xc(%esp) = TOPMOST_LOW_MEMORY_STACK_ADDRESS.
  */
 asm (
@@ -29,6 +29,8 @@ asm (
 #include "../../../include/xen/multiboot.h"
 #include "../../../include/xen/multiboot2.h"
 
+#include "../../../include/generated/autoconf.h"
+
 #define get_mb2_data(tag, type, member)   (((multiboot2_tag_##type##_t *)(tag))->member)
 #define get_mb2_string(tag, type, member) ((u32)get_mb2_data(tag, type, member))
 
@@ -71,6 +73,41 @@ static u32 copy_string(u32 src)
     return copy_mem(src, p - src + 1);
 }
 
Quoted 7 lines
Quoted 3 lines

xen/arch/x86/boot/reloc.c static u32 copy_string(u32 src) · line 76

Quoted 1 line
xen/arch/x86/boot/reloc.c +1 -0
+#ifdef CONFIG_PVH_GUEST

... drop this ifdef and ...

So you want reloc.o to contain pvh_info_reloc unconditionally?

Fundamentally I don't think I care enough about all the bikeshedding so if Jan and you agree on this I will just make the change.

It wont.  The function will be dropped due to DCE, but we'll spot build breakages far more easily.  (The important bit is that the function call is guarded by the IS_ENABLED())

~Andrew

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

author
#5 lore raw
Quoted 70 lines · Andrew Cooper
Quoted 69 lines · Wei Liu
Quoted 28 lines · Andrew Cooper
Quoted 23 lines · Wei Liu

Modify early boot code to relocate pvh info as well, so that we can be sure __va in __start_xen works.

---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Roger Pau Monné <[email protected]>
Cc: Doug Goldstein <[email protected]>

v4: inlcude autoconf.h directly. The code itself is unchanged.

---
 xen/arch/x86/boot/Makefile |  4 +++
 xen/arch/x86/boot/defs.h   |  3 +++
 xen/arch/x86/boot/head.S   | 25 ++++++++++--------
 xen/arch/x86/boot/reloc.c  | 64 +++++++++++++++++++++++++++++++++++++++++-----
 4 files changed, 78 insertions(+), 18 deletions(-)
xen/arch/x86/boot/Makefile +0 -0
index c6246c85d2..1b3f121a2f 100644

xen/arch/x86/boot/Makefile CMDLINE_DEPS = $(DEFS_H_DEPS) video.h · line 8

Quoted 2 lines
xen/arch/x86/boot/Makefile +0 -0
@@ -7,6 +7,10 @@ CMDLINE_DEPS = $(DEFS_H_DEPS) video.h
 RELOC_DEPS = $(DEFS_H_DEPS) $(BASEDIR)/include/xen/multiboot.h \
 	     $(BASEDIR)/include/xen/multiboot2.h

+ autoconf.h

Quoted 2 lines

However, it would much better to take xen/kconfig.h ...

This is fine by me.

Quoted 4 lines
Quoted 4 lines
xen/arch/x86/boot/Makefile +3 -0
+ifeq ($(CONFIG_PVH_GUEST),y)
+RELOC_DEPS += $(BASEDIR)/include/public/arch-x86/hvm/start_info.h
+endif

[...]

Quoted 31 lines
Quoted 25 lines
xen/arch/x86/boot/reloc.c +4 -2
index b992678b5e..1fe19294ad 100644
@@ -14,8 +14,8 @@
 
 /*
  * This entry point is entered from xen/arch/x86/boot/head.S with:
- *   - 0x4(%esp) = MULTIBOOT_MAGIC,
- *   - 0x8(%esp) = MULTIBOOT_INFORMATION_ADDRESS,
+ *   - 0x4(%esp) = MAGIC,
+ *   - 0x8(%esp) = INFORMATION_ADDRESS,
  *   - 0xc(%esp) = TOPMOST_LOW_MEMORY_STACK_ADDRESS.
  */
 asm (
@@ -29,6 +29,8 @@ asm (
 #include "../../../include/xen/multiboot.h"
 #include "../../../include/xen/multiboot2.h"
 
+#include "../../../include/generated/autoconf.h"
+
 #define get_mb2_data(tag, type, member)   (((multiboot2_tag_##type##_t *)(tag))->member)
 #define get_mb2_string(tag, type, member) ((u32)get_mb2_data(tag, type, member))
 

xen/arch/x86/boot/reloc.c static u32 copy_string(u32 src) · line 76

Quoted 4 lines
xen/arch/x86/boot/reloc.c +1 -0
@@ -71,6 +73,41 @@ static u32 copy_string(u32 src)
     return copy_mem(src, p - src + 1);
 }
 
+#ifdef CONFIG_PVH_GUEST

... drop this ifdef and ...

Quoted 8 lines
Quoted 4 lines

So you want reloc.o to contain pvh_info_reloc unconditionally?

Fundamentally I don't think I care enough about all the bikeshedding so if Jan and you agree on this I will just make the change.

It wont.  The function will be dropped due to DCE, but we'll spot build breakages far more easily.  (The important bit is that the function call is guarded by the IS_ENABLED())

reloc.o will still have that function in non-PVH build on my machine. And that's with the following diff applied.

Again. I don't care to argue one way or the other. I have both versions. You and Jan need to decide which version you like.

---8<---
From 44300edc0e85d841ea2fd1404758d37a46ab0524 Mon Sep 17 00:00:00 2001
From: Wei Liu <[email protected]>
Date: Mon, 22 Jan 2018 18:30:16 +0000
Subject: [PATCH] xxx

---
 xen/arch/x86/boot/Makefile |  7 ++-----
 xen/arch/x86/boot/head.S   |  6 +++---
 xen/arch/x86/boot/reloc.c  | 14 +++++---------
 3 files changed, 10 insertions(+), 17 deletions(-)
xen/arch/x86/boot/Makefile +2 -5
index 1b3f121a2f..e10388282f 100644
@@ -5,11 +5,8 @@ DEFS_H_DEPS = defs.h $(BASEDIR)/include/xen/stdbool.h
 CMDLINE_DEPS = $(DEFS_H_DEPS) video.h
 
 RELOC_DEPS = $(DEFS_H_DEPS) $(BASEDIR)/include/xen/multiboot.h \
-	     $(BASEDIR)/include/xen/multiboot2.h
-
-ifeq ($(CONFIG_PVH_GUEST),y)
-RELOC_DEPS += $(BASEDIR)/include/public/arch-x86/hvm/start_info.h
-endif
+	     $(BASEDIR)/include/xen/multiboot2.h \
+	     $(BASEDIR)/include/public/arch-x86/hvm/start_info.h
 
 head.o: cmdline.S reloc.S
 
xen/arch/x86/boot/head.S +3 -3
index 9219067231..3cb66fc06b 100644
@@ -585,13 +585,13 @@ trampoline_setup:
         push    %eax                /* Magic number. */
         call    reloc
 #ifdef CONFIG_PVH_GUEST
-        cmp     $0,sym_fs(pvh_boot)
+        cmp     $0, sym_fs(pvh_boot)
         je      1f
-        mov     %eax,sym_fs(pvh_start_info_pa)
+        mov     %eax, sym_fs(pvh_start_info_pa)
         jmp     2f
 #endif
 1:
-        mov     %eax,sym_fs(multiboot_ptr)
+        mov     %eax, sym_fs(multiboot_ptr)
 2:
 
         /*
xen/arch/x86/boot/reloc.c +5 -9
index 1fe19294ad..8a66390383 100644
@@ -29,7 +29,8 @@ asm (
 #include "../../../include/xen/multiboot.h"
 #include "../../../include/xen/multiboot2.h"
 
-#include "../../../include/generated/autoconf.h"
+#include "../../../include/xen/kconfig.h"
+#include <public/arch-x86/hvm/start_info.h>
 
 #define get_mb2_data(tag, type, member)   (((multiboot2_tag_##type##_t *)(tag))->member)
 #define get_mb2_string(tag, type, member) ((u32)get_mb2_data(tag, type, member))
@@ -73,10 +74,6 @@ static u32 copy_string(u32 src)
     return copy_mem(src, p - src + 1);
 }
 
-#ifdef CONFIG_PVH_GUEST
-
-#include <public/arch-x86/hvm/start_info.h>
-
 static struct hvm_start_info *pvh_info_reloc(u32 in)
 {
     struct hvm_start_info *out;
@@ -106,7 +103,6 @@ static struct hvm_start_info *pvh_info_reloc(u32 in)
 
     return out;
 }
-#endif
 
 static multiboot_info_t *mbi_reloc(u32 mbi_in)
 {
@@ -275,10 +271,10 @@ void __stdcall *reloc(u32 magic, u32 in, u32 trampoline)
     case MULTIBOOT2_BOOTLOADER_MAGIC:
         return mbi2_reloc(in);
 
-#ifdef CONFIG_PVH_GUEST
     case XEN_HVM_START_MAGIC_VALUE:
-        return pvh_info_reloc(in);
-#endif
+        if ( IS_ENABLED(CONFIG_PVH_GUEST) )
+            return pvh_info_reloc(in);
+        /* Fallthrough */
 
     default:
         /* Nothing we can do */
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#6 lore raw
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 22.01.18 at 19:31, <[email protected]> wrote:
Quoted 6 lines · Andrew Cooper
Quoted 4 lines · Wei Liu

So you want reloc.o to contain pvh_info_reloc unconditionally?

Fundamentally I don't think I care enough about all the bikeshedding so if Jan and you agree on this I will just make the change.

Quoted 6 lines
Quoted 3 lines

It wont. The function will be dropped due to DCE, but we'll spot build breakages far more easily. (The important bit is that the function call is guarded by the IS_ENABLED())

reloc.o will still have that function in non-PVH build on my machine. And that's with the following diff applied.

Well, DCE doesn't make any promises towards what it is able to eliminate, which is why generally I prefer to help the compiler in cases like the one here.

Jan

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

author
#7 lore raw
Quoted 12 lines · Jan Beulich
Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 22.01.18 at 19:31, <[email protected]> wrote:
Quoted 9 lines · Andrew Cooper
Quoted 4 lines · Wei Liu

So you want reloc.o to contain pvh_info_reloc unconditionally?

Fundamentally I don't think I care enough about all the bikeshedding so if Jan and you agree on this I will just make the change.

It wont. The function will be dropped due to DCE, but we'll spot build breakages far more easily. (The important bit is that the function call is guarded by the IS_ENABLED())

Quoted 7 lines
Quoted 2 lines

reloc.o will still have that function in non-PVH build on my machine. And that's with the following diff applied.

Well, DCE doesn't make any promises towards what it is able to eliminate, which is why generally I prefer to help the compiler in cases like the one here.

If I read this correctly, this means you prefer the ifdef CONFIG_PVH_GUEST version?

Wei.

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

#8 lore raw
Quoted 17 lines
Quoted 1 line
Quoted 1 line · On 23.01.18 at 12:44, <[email protected]> wrote:
Quoted 15 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 22.01.18 at 19:31, <[email protected]> wrote:
Quoted 9 lines · Andrew Cooper
Quoted 4 lines · Wei Liu

So you want reloc.o to contain pvh_info_reloc unconditionally?

Fundamentally I don't think I care enough about all the bikeshedding so if Jan and you agree on this I will just make the change.

It wont. The function will be dropped due to DCE, but we'll spot build breakages far more easily. (The important bit is that the function call is guarded by the IS_ENABLED())

reloc.o will still have that function in non-PVH build on my machine. And that's with the following diff applied.

Quoted 6 lines
Quoted 3 lines

Well, DCE doesn't make any promises towards what it is able to eliminate, which is why generally I prefer to help the compiler in cases like the one here.

If I read this correctly, this means you prefer the ifdef CONFIG_PVH_GUEST version?

Well, in an ideal world I'd prefer what Andrew did suggest. If the compiler turns out to be incapable of removing dead code properly, I'd be slightly in favor of the #ifdef approach, but with Andrew apparently strongly feeling the other way around, I wouldn't mind that variant (the more that it's all .init.* contents).

Jan

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