Skip to contentSkip to conversation

getting mini-os to compile again

PATCH In review Simon Kagstrom 2 participants 3 messages Oct 25, 2005 – Oct 27, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 getting mini-os to compile again

Hello!

I've created a patch to get the mini-os to compile in Xen-unstable. The patch is pretty big, but this is mostly because I've replaced hypervisor.h with the hypercalls.h header file from Linux (which seems easier to maintain anyway). I've ignored X86_64.

I also had to disable some code in mini-os/xenbus/xenbus_xs.c since XS_WATCH_ACK is no longer available, I'm not sure what the proper fix would be.

With the patch, the mini-os is possible to compile, but unfortunately crashes during startup. Specifically, __sti() called from kernel.c:105 causes a page fault in os.h:83

#define __sti() \
do { \
vcpu_info_t *_vcpu; \
barrier(); \
_vcpu = &HYPERVISOR_shared_info->vcpu_data[smp_processor_id()]; \
_vcpu->evtchn_upcall_mask = 0; \
barrier(); /* unmask then check (avoid races) */ \

   if ( unlikely(_vcpu->evtchn_upcall_pending) )		   \
      force_evtchn_callback();					   \
} while (0)

The problem is the access _vcpu->evtchn_upcall_mask = 0;. (smp_processor_id is defined to 0).

// Simon

extras/mini-os/include/events.h +1 -1
diff -r e47f04c55eb1 extras/mini-os/include/events.h
@@ -47,7 +47,7 @@
 {
     evtchn_op_t op;
     op.cmd = EVTCHNOP_send;
-    op.u.send.local_port = port;
+    op.u.send.port = port;
     return HYPERVISOR_event_channel_op(&op);
 }
 
extras/mini-os/include/hypervisor.h +193 -561

853 lines not on this page · raw message

extras/mini-os/include/os.h +3 -1
diff -r e47f04c55eb1 extras/mini-os/include/os.h
@@ -24,7 +24,7 @@
 #include <xen/xen.h>
 
 
-#define force_evtchn_callback() ((void)HYPERVISOR_xen_version(0))
+#define force_evtchn_callback() ((void)HYPERVISOR_xen_version(0, 0))
 
 #define __KERNEL_CS  FLAT_KERNEL_CS
 #define __KERNEL_DS  FLAT_KERNEL_DS
@@ -55,6 +55,8 @@
 /* Everything below this point is not included by assembler (.S) files. */
 #ifndef __ASSEMBLY__
 
+extern shared_info_t *HYPERVISOR_shared_info;
+
 void trap_init(void);
 
 /* 
extras/mini-os/include/types.h +8 -1
diff -r e47f04c55eb1 extras/mini-os/include/types.h
@@ -54,7 +54,14 @@
 typedef struct { unsigned long pte; } pte_t;
 #endif
 
-
+typedef  u8 uint8_t;
+typedef  s8 int8_t;
+typedef u16 uint16_t;
+typedef s16 int16_t;
+typedef u32 uint32_t;
+typedef s32 int32_t;
+typedef u64 uint64_t;
+typedef s64 int64_t;
 
 
 #define INT_MAX         ((int)(~0U>>1))
extras/mini-os/kernel.c +1 -1
diff -r e47f04c55eb1 extras/mini-os/kernel.c
@@ -150,5 +150,5 @@
 void do_exit(void)
 {
     printk("do_exit called!\n");
-    for ( ;; ) HYPERVISOR_shutdown();
+    for ( ;; ) HYPERVISOR_sched_op(SCHEDOP_shutdown, SHUTDOWN_crash);
 }
extras/mini-os/time.c +1 -1
diff -r e47f04c55eb1 extras/mini-os/time.c
@@ -208,7 +208,7 @@
     struct timeval tv;
     gettimeofday(&tv);
     HYPERVISOR_set_timer_op(monotonic_clock() + 1000000LL * (s64) millisecs);
-    HYPERVISOR_block();
+    HYPERVISOR_sched_op(SCHEDOP_block, 0);
 }
 
 
extras/mini-os/xenbus/xenbus_xs.c +6 -1
diff -r e47f04c55eb1 extras/mini-os/xenbus/xenbus_xs.c
@@ -39,7 +39,7 @@
 #include <wait.h>
 #include <sched.h>
 #include <semaphore.h>
-#include "xenstored.h"
+#include <xen/io/xs_wire.h>
 #include "xenbus_comms.h"
 
 #define streq(a, b) (strcmp((a), (b)) == 0)
@@ -408,7 +408,12 @@
 
 static int xs_acknowledge_watch(const char *token)
 {
+#if 0
 	return xs_error(xs_single(XS_WATCH_ACK, token, NULL));
+#else
+	/* XS_WATCH_ACK is no longer available */
+	return 0;
+#endif
 }
 
 static int xs_unwatch(const char *path, const char *token)

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

#1 lore raw
Quoted 7 lines · Simon Kagstrom

Hello!

I've created a patch to get the mini-os to compile in Xen-unstable. The patch is pretty big, but this is mostly because I've replaced hypervisor.h with the hypercalls.h header file from Linux (which seems easier to maintain anyway). I've ignored X86_64.

Quoted 7 lines

I also had to disable some code in mini-os/xenbus/xenbus_xs.c since XS_WATCH_ACK is no longer available, I'm not sure what the proper fix would be.

With the patch, the mini-os is possible to compile, but unfortunately crashes during startup. Specifically, __sti() called from kernel.c:105 causes a page fault in os.h:83

I'll reply myself on this. This problem turned out to be the __pte() definition in kernel.c which seems incorrect to me - see patch below.

Then the mini-os gets slightly further, but seems to crash in the xenbus code (but again, I don't really know how to fix that).

// Simon

extras/mini-os/kernel.c Tue Oct 25 12:09:32 2005 renamed from extras/mini-os/kernel.c Mon Oct 24 11:57:37 2005 +3 -1
diff -r e47f04c55eb1 extras/mini-os/kernel.c
@@ -61,7 +61,7 @@
 
 extern char shared_info[PAGE_SIZE];
 
-#define __pte(x) ((pte_t) { (0) } )
+#define __pte(x) ((pte_t) { (x) } )
 
 static shared_info_t *map_shared_info(unsigned long pa)
 {
@@ -88,6 +88,8 @@
 
     /* Grab the shared_info pointer and put it in a safe place. */
     HYPERVISOR_shared_info = map_shared_info(start_info.shared_info);
+
+    printf("si: 0x%08x, Hs: 0x%08x, Hsvcpu: 0x%08x", si, HYPERVISOR_shared_info, 

&(HYPERVISOR_shared_info->vcpu_data));

     /* Set up event and failsafe callback addresses. */
 #ifdef __i386__
@@ -150,5 +152,5 @@
 void do_exit(void)
 {
     printk("do_exit called!\n");

- for ( ;; ) HYPERVISOR_shutdown();
+ for ( ;; ) HYPERVISOR_sched_op(SCHEDOP_shutdown, SHUTDOWN_crash);
}

#2 lore raw
In reply to Simon Kagstrom
Quoted 4 lines · Simon Kagstrom

I've created a patch to get the mini-os to compile in Xen-unstable. The patch is pretty big, but this is mostly because I've replaced hypervisor.h with the hypercalls.h header file from Linux (which seems easier to maintain anyway). I've ignored X86_64.

Thanks!

Quoted 3 lines

I also had to disable some code in mini-os/xenbus/xenbus_xs.c since XS_WATCH_ACK is no longer available, I'm not sure what the proper fix would be.

I haven;t looked, but I think xenbus_xs.c is pretty OS-agnostic and the one in minios is probably straight out of linux-2.6-xen-sparse? So a starting point woul dbe to take a fresh snap from the linux sparse tree and make it build.

-- Keir