Skip to contentSkip to conversation

x86: get the offset at compile time instead of raw value

PATCH New Xiao Guangrong 1 participant 2 messages May 7, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 x86: get the offset at compile time instead of raw value

Get the offset form the struct instead of raw value

xen/arch/x86/boot/cmdline.S +0 -4
diff -r 632487ba7f63 -r 5ca49b1a6077 xen/arch/x86/boot/cmdline.S
@@ -147,10 +147,6 @@
 3:      pop     %ebx
         ret
 
-/* multiboot_info structure offsets. */
-#define MB_flags   0
-#define MB_cmdline 16
-
 cmdline_parse_early:
         pusha
 
xen/arch/x86/x86_32/asm-offsets.c +5 -0
diff -r 632487ba7f63 -r 5ca49b1a6077 xen/arch/x86/x86_32/asm-offsets.c
@@ -9,6 +9,7 @@
 #include <xen/sched.h>
 #include <asm/fixmap.h>
 #include <asm/hardirq.h>
+#include <xen/multiboot.h>
 
 #define DEFINE(_sym, _val) \
     __asm__ __volatile__ ( "\n->" #_sym " %0 " #_val : : "i" (_val) )
@@ -127,4 +128,8 @@
     BLANK();
 
     OFFSET(CPUINFO_ext_features, struct cpuinfo_x86, x86_capability[1]);
+    BLANK();
+
+    OFFSET(MB_flags, multiboot_info_t, flags);
+    OFFSET(MB_cmdline, multiboot_info_t, cmdline);
 }
xen/arch/x86/x86_64/asm-offsets.c +5 -0
diff -r 632487ba7f63 -r 5ca49b1a6077 xen/arch/x86/x86_64/asm-offsets.c
@@ -10,6 +10,7 @@
 #include <compat/xen.h>
 #include <asm/fixmap.h>
 #include <asm/hardirq.h>
+#include <xen/multiboot.h>
 
 #define DEFINE(_sym, _val) \
     __asm__ __volatile__ ( "\n->" #_sym " %0 " #_val : : "i" (_val) )
@@ -151,4 +152,8 @@
     BLANK();
 
     OFFSET(CPUINFO_ext_features, struct cpuinfo_x86, x86_capability[1]);
+    BLANK();
+
+    OFFSET(MB_flags, multiboot_info_t, flags);
+    OFFSET(MB_cmdline, multiboot_info_t, cmdline);
 }
#1 lore raw

PATCH 2/2 small cleanup for domain_create()

'struct domain' is always set to zero when it allocated, the only exception is not defined 'CONFIG_IA64_PICKLE_DOMAIN' in ia64 architecture, so we set it to zero in this case instead of in domain_create() function.

xen/arch/ia64/xen/domain.c +5 -4
diff -r ccae861f52f7 -r 632487ba7f63 xen/arch/ia64/xen/domain.c
@@ -407,20 +407,21 @@
 
 struct domain *alloc_domain_struct(void)
 {
+	struct domain *d;
 #ifdef CONFIG_IA64_PICKLE_DOMAIN
-	struct domain *d;
 	/*
 	 * We pack the MFN of the domain structure into a 32-bit field within
 	 * the page_info structure. Hence the MEMF_bits() restriction.
 	 */
 	d = alloc_xenheap_pages(get_order_from_bytes(sizeof(*d)),
 				MEMF_bits(32 + PAGE_SHIFT));
+#else
+	d = xmalloc(struct domain);
+#endif
+
 	if ( d != NULL )
 		memset(d, 0, sizeof(*d));
 	return d;
-#else
-	return xmalloc(struct domain);
-#endif
 }
 
 void free_domain_struct(struct domain *d)
xen/common/domain.c +0 -1
diff -r ccae861f52f7 -r 632487ba7f63 xen/common/domain.c
@@ -223,7 +223,6 @@
     if ( (d = alloc_domain_struct()) == NULL )
         return NULL;
 
-    memset(d, 0, sizeof(*d));
     d->domain_id = domid;
 
     lock_profile_register_struct(LOCKPROF_TYPE_PERDOM, d, domid, "Domain");