Skip to contentSkip to conversation

mini-os: Fix to get netfront running on ia64

PATCH In review Dietmar Hahn 2 participants 7 messages Feb 6, 2007 – Feb 21, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mini-os: Fix to get netfront running on ia64

Hi,

to get the netfront stuff on ia64 architecture running I still need to include the attached patch.
Please have a look and send comments!
Thanks.

Dietmar.

# HG changeset patch
# User [email protected]
# Date 1170687542 -3600
# Node ID 80cd2c0ee40cddec1914542f221159b5911368b3 # Parent 01ec7dba9ff805a5c74a0318997b747d3e3e3327 2 Fixes for supporting netfront on ia64.

extras/mini-os/gnttab.c +5 -0
diff -r 01ec7dba9ff8 -r 80cd2c0ee40c extras/mini-os/gnttab.c
@@ -21,7 +21,12 @@
 
 #define NR_RESERVED_ENTRIES 8
 
+/* NR_GRANT_FRAMES must be less than or equal to that configured in Xen */
+#ifdef __ia64__
+#define NR_GRANT_FRAMES 1
+#else
 #define NR_GRANT_FRAMES 4
+#endif
 #define NR_GRANT_ENTRIES (NR_GRANT_FRAMES * PAGE_SIZE / sizeof(grant_entry_t))
 
 static grant_entry_t *gnttab_table;
extras/mini-os/netfront.c +3 -1
diff -r 01ec7dba9ff8 -r 80cd2c0ee40c extras/mini-os/netfront.c
@@ -349,7 +349,9 @@ done:
     init_rx_buffers();
 
     unsigned char rawmac[6];
-    sscanf(mac,"%x:%x:%x:%x:%x:%x",
+        /* Special conversion specifier 'hh' needed for __ia64__. Without
+           this mini-os panics with 'Unaligned reference'. */
+    sscanf(mac,"%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
             &rawmac[0],
             &rawmac[1],
             &rawmac[2],

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

#1 lore raw

That looks good. Keir could you apply please (if you haven't done so already).

Thanks
Gregor

Quoted 51 lines

Hi,

to get the netfront stuff on ia64 architecture running I still need to include the attached patch. Please have a look and send comments!
Thanks.

Dietmar.

------------------------------------------------------------------------

# HG changeset patch
# User [email protected]
# Date 1170687542 -3600
# Node ID 80cd2c0ee40cddec1914542f221159b5911368b3 # Parent 01ec7dba9ff805a5c74a0318997b747d3e3e3327 2 Fixes for supporting netfront on ia64.

diff -r 01ec7dba9ff8 -r 80cd2c0ee40c extras/mini-os/gnttab.c

extras/mini-os/gnttab.c +5 -0
@@ -21,7 +21,12 @@
 
 #define NR_RESERVED_ENTRIES 8
 
+/* NR_GRANT_FRAMES must be less than or equal to that configured in Xen */
+#ifdef __ia64__
+#define NR_GRANT_FRAMES 1
+#else
 #define NR_GRANT_FRAMES 4
+#endif
 #define NR_GRANT_ENTRIES (NR_GRANT_FRAMES * PAGE_SIZE / sizeof(grant_entry_t))
 
 static grant_entry_t *gnttab_table;

diff -r 01ec7dba9ff8 -r 80cd2c0ee40c extras/mini-os/netfront.c

extras/mini-os/netfront.c +3 -1
@@ -349,7 +349,9 @@ done:
     init_rx_buffers();
 
     unsigned char rawmac[6];
-    sscanf(mac,"%x:%x:%x:%x:%x:%x",
+        /* Special conversion specifier 'hh' needed for __ia64__. Without
+           this mini-os panics with 'Unaligned reference'. */
+    sscanf(mac,"%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
             &rawmac[0],
             &rawmac[1],
             &rawmac[2],
#2 lore raw

PATCH 1/1 mini-os: Small fixes in makerules

In reply to Dietmar Hahn

Hi,

this patch added ARCH_LDFLAGS for architecture specific LDFLAGS to the makerules and fixed not correct handled rebuild dependencies after changing makerule files.
Please have a look and send comments!
Thanks.

Dietmar.

# HG changeset patch
# User [email protected]
# Date 1171276084 -3600
# Node ID adbcaac2e98cd2348265d5f5faf9e8196ae82ca4 # Parent ad9bbd103034cfd566e2801cfd8d51813f1b0f95
- Added ARCH_LDFLAGS for architecture specific LDFLAGS.
- Fixed build dependencies after changing makerule files.

extras/mini-os/Makefile +0 -5
diff -r ad9bbd103034 -r adbcaac2e98c extras/mini-os/Makefile
@@ -44,10 +44,6 @@ ARCH_LINKS =
 # This can be overwritten from arch specific rules.
 EXTRA_INC =
 
-# Special build dependencies.
-# Build all after touching this/these file(s) (see minios.mk)
-SPEC_DEPENDS = minios.mk
-
 # Include the architecture family's special makerules.
 # This must be before include minios.mk!
 include $(TARGET_ARCH_DIR)/arch.mk
@@ -57,7 +53,6 @@ include minios.mk
 
 # Define some default flags for linking.
 LDLIBS := 
-LDFLAGS := 
 LDARCHLIB := -L$(TARGET_ARCH_DIR) -l$(ARCH_LIB_NAME)
 LDFLAGS_FINAL := -N -T $(TARGET_ARCH_DIR)/minios-$(TARGET_ARCH).lds
 
extras/mini-os/arch/x86/Makefile +1 -4
diff -r ad9bbd103034 -r adbcaac2e98c extras/mini-os/arch/x86/Makefile
@@ -2,9 +2,6 @@
 # x86 architecture specific makefiles.
 # It's is used for x86_32, x86_32y and x86_64
 #
-
-# Rebuild all after touching this/these extra file(s) (see mini-os.mk)
-SPEC_DEP = arch.mk
 
 # include arch.mk has to be before mini-os.mk!
 include arch.mk
@@ -25,5 +22,5 @@ all: $(ARCH_LIB)
 	$(AR) rv $(ARCH_LIB) $(ARCH_OBJS)
 
 clean:
-	rm -f $(ARCH_LIB) $(ARCH_OBJS)
+	rm -f $(ARCH_LIB) $(ARCH_OBJS) $(HEAD_ARCH_OBJ)
 
extras/mini-os/arch/x86/arch.mk +0 -1
diff -r ad9bbd103034 -r adbcaac2e98c extras/mini-os/arch/x86/arch.mk
@@ -25,4 +25,3 @@ EXTRA_SRC += arch/$(EXTRA_INC)
 EXTRA_SRC += arch/$(EXTRA_INC)
 endif
 
-
extras/mini-os/minios.mk +7 -0
diff -r ad9bbd103034 -r adbcaac2e98c extras/mini-os/minios.mk
@@ -11,6 +11,7 @@ DEF_CFLAGS += -D__XEN_INTERFACE_VERSION_
 DEF_CFLAGS += -D__XEN_INTERFACE_VERSION__=$(XEN_INTERFACE_VERSION)
 
 DEF_ASFLAGS = -D__ASSEMBLY__
+DEF_LDFLAGS =
 
 ifeq ($(debug),y)
 DEF_CFLAGS += -g
@@ -23,9 +24,15 @@ endif
 # ARCH_... flags may be defined in arch/$(TARGET_ARCH_FAM/rules.mk
 CFLAGS := $(DEF_CFLAGS) $(ARCH_CFLAGS)
 ASFLAGS := $(DEF_ASFLAGS) $(ARCH_ASFLAGS)
+LDFLAGS := $(DEF_LDFLAGS) $(ARCH_LDFLAGS)
 
 # The path pointing to the architecture specific header files.
 ARCH_SPEC_INC := $(MINI-OS_ROOT)/include/$(TARGET_ARCH_FAM)
+
+# Special build dependencies.
+# Rebuild all after touching this/these file(s)
+SPEC_DEPENDS = $(MINI-OS_ROOT)/minios.mk \
+		$(MINI-OS_ROOT)/$(TARGET_ARCH_DIR)/arch.mk
 
 # Find all header files for checking dependencies.
 HDRS := $(wildcard $(MINI-OS_ROOT)/include/*.h)

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

#3 lore raw

Re: [PATCH]mini-os: Small fixes in makerules

That's a good patch, but I've also added a fix to ARCH_CPFLAGS, and renamed couple of variables (I didn't like SPEC_DEPENDS for example). Keir could you apply the revised patch? I hope you don't mind including you in the Signed-off-by line Dietmar.

Patch info:

- Added ARCH_LDFLAGS for architecture specific LDFLAGS
- Fixed build dependencies after changing makerule files
- Fixed ARCH_CFLAGS for 64bit guest, added ARCH_ASFLAGS
- Couple of variable renames

Thanks
Gregor

extras/mini-os/Makefile +0 -5
diff -r 72c225a828da -r 293e6050c164 extras/mini-os/Makefile
@@ -44,10 +44,6 @@ ARCH_LINKS =
 # This can be overwritten from arch specific rules.
 EXTRA_INC =
 
-# Special build dependencies.
-# Build all after touching this/these file(s) (see minios.mk)
-SPEC_DEPENDS = minios.mk
-
 # Include the architecture family's special makerules.
 # This must be before include minios.mk!
 include $(TARGET_ARCH_DIR)/arch.mk
@@ -57,7 +53,6 @@ include minios.mk
 
 # Define some default flags for linking.
 LDLIBS := 
-LDFLAGS := 
 LDARCHLIB := -L$(TARGET_ARCH_DIR) -l$(ARCH_LIB_NAME)
 LDFLAGS_FINAL := -N -T $(TARGET_ARCH_DIR)/minios-$(TARGET_ARCH).lds
 
extras/mini-os/arch/x86/Makefile +1 -4
diff -r 72c225a828da -r 293e6050c164 extras/mini-os/arch/x86/Makefile
@@ -2,9 +2,6 @@
 # x86 architecture specific makefiles.
 # It's is used for x86_32, x86_32y and x86_64
 #
-
-# Rebuild all after touching this/these extra file(s) (see mini-os.mk)
-SPEC_DEP = arch.mk
 
 # include arch.mk has to be before mini-os.mk!
 include arch.mk
@@ -25,5 +22,5 @@ all: $(ARCH_LIB)
 	$(AR) rv $(ARCH_LIB) $(ARCH_OBJS)
 
 clean:
-	rm -f $(ARCH_LIB) $(ARCH_OBJS)
+	rm -f $(ARCH_LIB) $(ARCH_OBJS) $(HEAD_ARCH_OBJ)
 
extras/mini-os/arch/x86/arch.mk +3 -2
diff -r 72c225a828da -r 293e6050c164 extras/mini-os/arch/x86/arch.mk
@@ -6,6 +6,7 @@ ifeq ($(TARGET_ARCH),x86_32)
 ifeq ($(TARGET_ARCH),x86_32)
 ARCH_CFLAGS  := -m32 -march=i686
 ARCH_LDFLAGS := -m elf_i386
+ARCH_ASFLAGS := -m32
 EXTRA_INC += $(TARGET_ARCH_FAM)/$(TARGET_ARCH)
 EXTRA_SRC += arch/$(EXTRA_INC)
 endif
@@ -19,10 +20,10 @@ endif
 
 ifeq ($(TARGET_ARCH),x86_64)
 ARCH_CFLAGS := -m64 -mno-red-zone -fpic -fno-reorder-blocks
-ARCH_CFLAGS := -fno-asynchronous-unwind-tables
+ARCH_CFLAGS += -fno-asynchronous-unwind-tables
+ARCH_ASFLAGS := -m64
 ARCH_LDFLAGS := -m elf_x86_64
 EXTRA_INC += $(TARGET_ARCH_FAM)/$(TARGET_ARCH)
 EXTRA_SRC += arch/$(EXTRA_INC)
 endif
 
-
extras/mini-os/minios.mk +12 -5
diff -r 72c225a828da -r 293e6050c164 extras/mini-os/minios.mk
@@ -11,6 +11,7 @@ DEF_CFLAGS += -D__XEN_INTERFACE_VERSION_
 DEF_CFLAGS += -D__XEN_INTERFACE_VERSION__=$(XEN_INTERFACE_VERSION)
 
 DEF_ASFLAGS = -D__ASSEMBLY__
+DEF_LDFLAGS =
 
 ifeq ($(debug),y)
 DEF_CFLAGS += -g
@@ -23,21 +24,27 @@ endif
 # ARCH_... flags may be defined in arch/$(TARGET_ARCH_FAM/rules.mk
 CFLAGS := $(DEF_CFLAGS) $(ARCH_CFLAGS)
 ASFLAGS := $(DEF_ASFLAGS) $(ARCH_ASFLAGS)
+LDFLAGS := $(DEF_LDFLAGS) $(ARCH_LDFLAGS)
 
 # The path pointing to the architecture specific header files.
-ARCH_SPEC_INC := $(MINI-OS_ROOT)/include/$(TARGET_ARCH_FAM)
+ARCH_INC := $(MINI-OS_ROOT)/include/$(TARGET_ARCH_FAM)
+
+# Special build dependencies.
+# Rebuild all after touching this/these file(s)
+EXTRA_DEPS = $(MINI-OS_ROOT)/minios.mk \
+		$(MINI-OS_ROOT)/$(TARGET_ARCH_DIR)/arch.mk
 
 # Find all header files for checking dependencies.
 HDRS := $(wildcard $(MINI-OS_ROOT)/include/*.h)
 HDRS += $(wildcard $(MINI-OS_ROOT)/include/xen/*.h)
-HDRS += $(wildcard $(ARCH_SPEC_INC)/*.h)
+HDRS += $(wildcard $(ARCH_INC)/*.h)
 # For special wanted header directories.
 extra_heads := $(foreach dir,$(EXTRA_INC),$(wildcard $(dir)/*.h))
 HDRS += $(extra_heads)
 
 # Add the special header directories to the include paths.
 extra_incl := $(foreach dir,$(EXTRA_INC),-I$(MINI-OS_ROOT)/include/$(dir))
-override CPPFLAGS := -I$(MINI-OS_ROOT)/include $(CPPFLAGS) -I$(ARCH_SPEC_INC)	$(extra_incl)
+override CPPFLAGS := -I$(MINI-OS_ROOT)/include $(CPPFLAGS) -I$(ARCH_INC)	$(extra_incl)
 
 # The name of the architecture specific library.
 # This is on x86_32: libx86_32.a
@@ -51,10 +58,10 @@ HEAD_OBJ := $(TARGET_ARCH_DIR)/$(HEAD_AR
 HEAD_OBJ := $(TARGET_ARCH_DIR)/$(HEAD_ARCH_OBJ)
 
 
-%.o: %.c $(HDRS) Makefile $(SPEC_DEPENDS)
+%.o: %.c $(HDRS) Makefile $(EXTRA_DEPS)
 	$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
 
-%.o: %.S $(HDRS) Makefile $(SPEC_DEPENDS)
+%.o: %.S $(HDRS) Makefile $(EXTRA_DEPS)
 	$(CC) $(ASFLAGS) $(CPPFLAGS) -c $< -o $@
 
 
Quoted 10 lines · Dietmar Hahn

Hi,

this patch added ARCH_LDFLAGS for architecture specific LDFLAGS to the makerules and fixed not correct handled rebuild dependencies after changing makerule files.
Please have a look and send comments!
Thanks.

Dietmar.
<mini-os_make.patch>

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

#4 lore raw

PATCH 1/1 mini-os: Bug in allocate_xenbus_id()

Hi Gregor,

in allocate_xenbus_id() the static variable probe never gets reset. Therewidth id's >= NR_REQS are possible, which lead to an overflow in req_info[] and may crash the mini-os.
Thanks.

Dietmar

# HG changeset patch
# User [email protected]
# Date 1171877953 -3600
# Node ID 3d04558ad3d7e3811ac8c827bb876858bbb1c415
# Parent b5fc88aad1b0eb35d12e503982c70fdc27f0544a
Because probe never gets decremented (or reset), id >= NR_REQS is possible, which may lead to a crash.

extras/mini-os/xenbus/xenbus.c Mon Feb 19 10:39:13 2007 +0100 renamed from extras/mini-os/xenbus/xenbus.c Sun Feb 18 15:29:40 2007 +0000 +1 -1
diff -r b5fc88aad1b0 -r 3d04558ad3d7 extras/mini-os/xenbus/xenbus.c
@@ -210,7 +210,7 @@ static int allocate_xenbus_id(void)
     }
     nr_live_reqs++;
     req_info[o_probe].in_use = 1;
-    probe = o_probe + 1;
+    probe = (o_probe + 1) % NR_REQS;
     spin_unlock(&req_lock);
     init_waitqueue_head(&req_info[o_probe].waitq);
#5 lore raw

Re: [PATCH]mini-os: Bug in allocate_xenbus_id()

That's a good catch. Did you see the bug manifesting itself in practice?

Keir could you apply please?
Thanks.
Gregor

Quoted 29 lines · Dietmar Hahn

Hi Gregor,

in allocate_xenbus_id() the static variable probe never gets reset. Therewidth id's >= NR_REQS are possible, which lead to an overflow in req_info[] and may crash the mini-os.
Thanks.

Dietmar

# HG changeset patch
# User [email protected]
# Date 1171877953 -3600
# Node ID 3d04558ad3d7e3811ac8c827bb876858bbb1c415
# Parent b5fc88aad1b0eb35d12e503982c70fdc27f0544a
Because probe never gets decremented (or reset), id >= NR_REQS is possible, which may lead to a crash.

diff -r b5fc88aad1b0 -r 3d04558ad3d7 extras/mini-os/xenbus/xenbus.c

extras/mini-os/xenbus/xenbus.c Mon Feb 19 10:39:13 2007 +0100 renamed from extras/mini-os/xenbus/xenbus.c Sun Feb 18 15:29:40 2007 +0000 +1 -1
@@ -210,7 +210,7 @@ static int allocate_xenbus_id(void)
     }
     nr_live_reqs++;
     req_info[o_probe].in_use = 1;
-    probe = o_probe + 1;
+    probe = (o_probe + 1) % NR_REQS;
     spin_unlock(&req_lock);
     init_waitqueue_head(&req_info[o_probe].waitq);
#6 lore raw

Re: [PATCH]mini-os: Bug in allocate_xenbus_id()

Hi Gregor,

Am Dienstag, 20. Februar 2007 19:53 schrieb Grzegorz Milos:

Quoted 2 lines

That's a good catch. Did you see the bug manifesting itself in practice?

Yes I got a crash with the mini-os on ia64.
In xenbus_msg_reply() the function allocate_xenbus_id() returns value 33 and this leads to a crash in add_waiter().
On x86 this is running fine ;-).

Dietmar.