Skip to contentSkip to conversation

x86/boot: fix reloc.S build dependencies

PATCH In review Daniel Kiper 2 participants 6 messages Oct 21, 2014 – Oct 22, 2014

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 x86/boot: fix reloc.S build dependencies

reloc.S is not rebuild if header included in reloc.c is updated. Fix this issue.

Additionally, remove reloc.S build dependency on head.S because anything from reloc.S does not depend on head.S.

Add reloc.c dependency to reloc.o build rule for consistency.

---
v2 - suggestions/fixes:
- do not use export and pass variable to make command line directly (suggested by Jan Beulich),
- improve commit message
(suggested by Jan Beulich).

---
 xen/arch/x86/boot/Makefile   |    8 ++++----
 xen/arch/x86/boot/build32.mk |    3 ++-
 2 files changed, 6 insertions(+), 5 deletions(-)
xen/arch/x86/boot/Makefile +4 -4
index 13f4a66..5fdb5ae 100644
@@ -1,8 +1,8 @@
 obj-bin-y += head.o
 
-head.o: reloc.S
+RELOC_DEPS = $(BASEDIR)/include/asm-x86/config.h $(BASEDIR)/include/xen/multiboot.h
 
-%.S: %.c
-	$(MAKE) -f build32.mk $@
+head.o: reloc.S
 
-reloc.S: head.S
+reloc.S: reloc.c $(RELOC_DEPS)
+	$(MAKE) -f build32.mk $@ RELOC_DEPS="$(RELOC_DEPS)"
xen/arch/x86/boot/build32.mk +2 -1
index a36f620..c208249 100644
@@ -30,5 +30,6 @@ CFLAGS := $(filter-out -flto,$(CFLAGS))
 			esac; \
 		done
 
-reloc.o: $(BASEDIR)/include/asm-x86/config.h
+reloc.o: reloc.c $(RELOC_DEPS)
+
 .PRECIOUS: %.bin %.lnk
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH v2 1/1 x86/boot: use constant in head.S instead of hardcoded value

..to access multiboot.mem_lower data.

---
v2 - suggestions/fixes:
- align constant name to currently used convention (suggested by Andrew Cooper and Jan Beulich).

---
 xen/arch/x86/boot/head.S          |    2 +-
 xen/arch/x86/x86_64/asm-offsets.c |    1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
xen/arch/x86/boot/head.S +1 -1
index cd43952..c99f739 100644
@@ -101,7 +101,7 @@ __start:
          */
         testb   $MBI_MEMLIMITS,(%ebx)
         jz      2f                  /* not available? BDA value will be fine */
-        mov     4(%ebx),%edx
+        mov     MB_mem_lower(%ebx),%edx
         cmp     $0x100,%edx         /* is the multiboot value too small? */
         jb      2f                  /* if so, do not use it */
         shl     $10-4,%edx
xen/arch/x86/x86_64/asm-offsets.c +1 -0
index 3994f4d..447c650 100644
@@ -165,4 +165,5 @@ void __dummy__(void)
 
     OFFSET(MB_flags, multiboot_info_t, flags);
     OFFSET(MB_cmdline, multiboot_info_t, cmdline);
+    OFFSET(MB_mem_lower, multiboot_info_t, mem_lower);
 }
Signature · 1 line
1.7.10.4
#3 lore raw

PATCH 1/1 x86/boot/reloc: add memory to clobber list

In reply to Daniel Kiper

Assembly inline in reloc_mbi_struct() clobbers
memory so tell compiler about that.

---
 xen/arch/x86/boot/reloc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/boot/reloc.c +1 -1
index 4609e55..f971920 100644
@@ -46,7 +46,7 @@ static void *reloc_mbi_struct(void *old, unsigned int bytes)
     "    mov  %0,%%edi                \n"
     "    rep  movsb                   \n"
        : "=&r" (new), "+c" (bytes), "+S" (old)
-	: : "edx", "edi");
+	: : "edx", "edi", "memory");
     return new;
 }
 
Signature · 1 line
1.7.10.4
Reviewed-by on v2 1/1
#5 lore raw
In reply to Daniel Kiper
Quoted 10 lines · Daniel Kiper

reloc.S is not rebuild if header included in reloc.c is updated. Fix this issue.

Additionally, remove reloc.S build dependency on head.S because anything from reloc.S does not depend on head.S.

Add reloc.c dependency to reloc.o build rule for consistency.

Quoted 40 lines

---
v2 - suggestions/fixes:
- do not use export and pass variable to make command line directly (suggested by Jan Beulich),
- improve commit message
(suggested by Jan Beulich).

---
 xen/arch/x86/boot/Makefile   |    8 ++++----
 xen/arch/x86/boot/build32.mk |    3 ++-
 2 files changed, 6 insertions(+), 5 deletions(-)
xen/arch/x86/boot/Makefile +4 -4
index 13f4a66..5fdb5ae 100644
@@ -1,8 +1,8 @@
 obj-bin-y += head.o
 
-head.o: reloc.S
+RELOC_DEPS = $(BASEDIR)/include/asm-x86/config.h $(BASEDIR)/include/xen/multiboot.h
 
-%.S: %.c
-	$(MAKE) -f build32.mk $@
+head.o: reloc.S
 
-reloc.S: head.S
+reloc.S: reloc.c $(RELOC_DEPS)
+	$(MAKE) -f build32.mk $@ RELOC_DEPS="$(RELOC_DEPS)"
xen/arch/x86/boot/build32.mk +2 -1
index a36f620..c208249 100644
@@ -30,5 +30,6 @@ CFLAGS := $(filter-out -flto,$(CFLAGS))
 			esac; \
 		done
 
-reloc.o: $(BASEDIR)/include/asm-x86/config.h
+reloc.o: reloc.c $(RELOC_DEPS)
+
 .PRECIOUS: %.bin %.lnk
Reviewed-by on v2 1/1
#2 lore raw

Re: [PATCH v2] x86/boot: use constant in head.S instead of hardcoded value

In reply to Daniel Kiper
Quoted 3 lines · Daniel Kiper

..to access multiboot.mem_lower data.

Quoted 32 lines

---
v2 - suggestions/fixes:
- align constant name to currently used convention (suggested by Andrew Cooper and Jan Beulich).

---
 xen/arch/x86/boot/head.S          |    2 +-
 xen/arch/x86/x86_64/asm-offsets.c |    1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
xen/arch/x86/boot/head.S +1 -1
index cd43952..c99f739 100644
@@ -101,7 +101,7 @@ __start:
          */
         testb   $MBI_MEMLIMITS,(%ebx)
         jz      2f                  /* not available? BDA value will be fine */
-        mov     4(%ebx),%edx
+        mov     MB_mem_lower(%ebx),%edx
         cmp     $0x100,%edx         /* is the multiboot value too small? */
         jb      2f                  /* if so, do not use it */
         shl     $10-4,%edx
xen/arch/x86/x86_64/asm-offsets.c +1 -0
index 3994f4d..447c650 100644
@@ -165,4 +165,5 @@ void __dummy__(void)
 
     OFFSET(MB_flags, multiboot_info_t, flags);
     OFFSET(MB_cmdline, multiboot_info_t, cmdline);
+    OFFSET(MB_mem_lower, multiboot_info_t, mem_lower);
 }
Reviewed-by on v1 1/1
#4 lore raw

Re: [PATCH] x86/boot/reloc: add memory to clobber list

In reply to Daniel Kiper
Quoted 4 lines · Daniel Kiper

Assembly inline in reloc_mbi_struct() clobbers
memory so tell compiler about that.

Quoted 17 lines
---
 xen/arch/x86/boot/reloc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/boot/reloc.c +1 -1
index 4609e55..f971920 100644
@@ -46,7 +46,7 @@ static void *reloc_mbi_struct(void *old, unsigned int bytes)
     "    mov  %0,%%edi                \n"
     "    rep  movsb                   \n"
        : "=&r" (new), "+c" (bytes), "+S" (old)
-	: : "edx", "edi");
+	: : "edx", "edi", "memory");
     return new;
 }