Skip to contentSkip to conversation

x86: move alternative.c data fully into .init.*

PATCH New Jan Beulich 1 participant 1 message Jun 24, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: move alternative.c data fully into .init.*

This wasn't done upon the initial addition of the file since the section processing needs some adjustment for this: We can't mark the two arrays needing relocations as either __initdata or __initconst, as both have the potential of creating section conflicts (with -fPIC the compiler may want to mark the section writable due to the necessary relocations, colliding with other __initconst uses, and if the compiler chooses to use the provided section name, __initdata on a constant object might collide with other __initdata uses). However, local data known to be referenced only by init code/data can also safely be moved into .init.*. Hence the respective logic is being tweaked such that it won't complain on non-empty .*.local sections.

While at it also drop the non-local section names from SPECIAL_DATA_SECTIONS - they can't be safely converted.

xen/Rules.mk +2 -1
@@ -167,11 +167,12 @@ _clean_%/: FORCE
 	$(CC) $(AFLAGS) -c $< -o $@
 
 SPECIAL_DATA_SECTIONS := rodata $(foreach n,1 2 4 8,rodata.str1.$(n)) \
-			 $(foreach r,rel rel.ro,data.$(r) data.$(r).local)
+			 $(foreach r,rel rel.ro,data.$(r).local)
 
 $(filter %.init.o,$(obj-y) $(obj-bin-y) $(extra-y)): %.init.o: %.o Makefile
 	$(OBJDUMP) -h $< | sed -n '/[0-9]/{s,00*,0,g;p;}' | while read idx name sz rest; do \
 		case "$$name" in \
+		.*.local) ;; \
 		.text|.text.*|.data|.data.*|.bss) \
 			test $$sz != 0 || continue; \
 			echo "Error: size of $<:$$name is 0x$$sz" >&2; \
xen/arch/x86/Makefile +1 -1
@@ -7,7 +7,7 @@ subdir-y += oprofile
 
 subdir-$(x86_64) += x86_64
 
-obj-y += alternative.o
+obj-bin-y += alternative.init.o
 obj-y += apic.o
 obj-y += bitops.o
 obj-bin-y += bzimage.init.o
xen/arch/x86/alternative.c +2 -2
@@ -39,7 +39,7 @@ static const unsigned char k8nops[] __in
     K8_NOP7,
     K8_NOP8
 };
-static const unsigned char * const k8_nops[ASM_NOP_MAX+1] /*__initconst*/ = {
+static const unsigned char * const k8_nops[ASM_NOP_MAX+1] = {
     NULL,
     k8nops,
     k8nops + 1,
@@ -63,7 +63,7 @@ static const unsigned char p6nops[] __in
     P6_NOP7,
     P6_NOP8
 };
-static const unsigned char * const p6_nops[ASM_NOP_MAX+1] /*__initconst*/ = {
+static const unsigned char * const p6_nops[ASM_NOP_MAX+1] = {
     NULL,
     p6nops,
     p6nops + 1,

x86: move alternative.c data fully into .init.*

This wasn't done upon the initial addition of the file since the section processing needs some adjustment for this: We can't mark the two arrays needing relocations as either __initdata or __initconst, as both have the potential of creating section conflicts (with -fPIC the compiler may want to mark the section writable due to the necessary relocations, colliding with other __initconst uses, and if the compiler chooses to use the provided section name, __initdata on a constant object might collide with other __initdata uses). However, local data known to be referenced only by init code/data can also safely be moved into .init.*. Hence the respective logic is being tweaked such that it won't complain on non-empty .*.local sections.

While at it also drop the non-local section names from SPECIAL_DATA_SECTIONS - they can't be safely converted.

xen/Rules.mk +2 -1
@@ -167,11 +167,12 @@ _clean_%/: FORCE
 	$(CC) $(AFLAGS) -c $< -o $@
 
 SPECIAL_DATA_SECTIONS := rodata $(foreach n,1 2 4 8,rodata.str1.$(n)) \
-			 $(foreach r,rel rel.ro,data.$(r) data.$(r).local)
+			 $(foreach r,rel rel.ro,data.$(r).local)
 
 $(filter %.init.o,$(obj-y) $(obj-bin-y) $(extra-y)): %.init.o: %.o Makefile
 	$(OBJDUMP) -h $< | sed -n '/[0-9]/{s,00*,0,g;p;}' | while read idx name sz rest; do \
 		case "$$name" in \
+		.*.local) ;; \
 		.text|.text.*|.data|.data.*|.bss) \
 			test $$sz != 0 || continue; \
 			echo "Error: size of $<:$$name is 0x$$sz" >&2; \
xen/arch/x86/Makefile +1 -1
@@ -7,7 +7,7 @@ subdir-y += oprofile
 
 subdir-$(x86_64) += x86_64
 
-obj-y += alternative.o
+obj-bin-y += alternative.init.o
 obj-y += apic.o
 obj-y += bitops.o
 obj-bin-y += bzimage.init.o
xen/arch/x86/alternative.c +2 -2
@@ -39,7 +39,7 @@ static const unsigned char k8nops[] __in
     K8_NOP7,
     K8_NOP8
 };
-static const unsigned char * const k8_nops[ASM_NOP_MAX+1] /*__initconst*/ = {
+static const unsigned char * const k8_nops[ASM_NOP_MAX+1] = {
     NULL,
     k8nops,
     k8nops + 1,
@@ -63,7 +63,7 @@ static const unsigned char p6nops[] __in
     P6_NOP7,
     P6_NOP8
 };
-static const unsigned char * const p6_nops[ASM_NOP_MAX+1] /*__initconst*/ = {
+static const unsigned char * const p6_nops[ASM_NOP_MAX+1] = {
     NULL,
     p6nops,
     p6nops + 1,

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel