Skip to contentSkip to conversation

qemu fixes

PATCH Applied Christoph Egger 3 participants 4 messages Nov 28, 2008 – Dec 5, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/6 qemu fixes

Hi,

This is a series of four patches which improve support for qemu on NetBSD.

Attached patch contains warning fixes + make cpu-exec.c compile on NetBSD.

Signature · 12 lines
AMD Saxony, Dresden, Germany
Operating System Research Center

Legal Information:
AMD Saxony Limited Liability Company & Co. KG
Sitz (Geschäftsanschrift):
   Wilschdorfer Landstr. 101, 01109 Dresden, Deutschland
Registergericht Dresden: HRA 4896
vertretungsberechtigter Komplementär:
   AMD Saxony LLC (Sitz Wilmington, Delaware, USA)
Geschäftsführer der AMD Saxony LLC:
   Dr. Hans-R. Deppe, Thomas McCoy
block-vvfat.c +1 -1
Index: block-vvfat.c
===================================================================
@@ -1780,7 +1780,7 @@
 	}
 
 	for (i = 0; i < 0x10 * s->sectors_per_cluster; i++) {
-	    int cluster_count;
+	    int cluster_count = 0;
 
 DLOG(fprintf(stderr, "check direntry %d: \n", i); print_direntry(direntries + i));
 	    if (is_volume_label(direntries + i) || is_dot(direntries + i) ||
usb-bsd.c +3 -3
Index: usb-bsd.c
===================================================================
@@ -68,7 +68,7 @@
     ep = UE_GET_ADDR(ep);
 
     if (dev->ep_fd[ep] < 0) {
-#if __FreeBSD__
+#ifdef __FreeBSD__
         snprintf(buf, sizeof(buf) - 1, "%s.%d", dev->devpath, ep);
 #else
         snprintf(buf, sizeof(buf) - 1, "%s.%02d", dev->devpath, ep);
@@ -321,7 +321,7 @@
         return NULL;
     }
 
-#if __FreeBSD__
+#ifdef __FreeBSD__
     snprintf(ctlpath, PATH_MAX, "/dev/%s", bus_info.udi_devnames[0]);
 #else
     snprintf(ctlpath, PATH_MAX, "/dev/%s.00", bus_info.udi_devnames[0]);
@@ -413,7 +413,7 @@
             if (strncmp(bus_info.udi_devnames[0], "ugen", 4) != 0)
                 continue;
 
-#if __FreeBSD__
+#ifdef __FreeBSD__
             snprintf(devbuf, sizeof(devbuf) - 1, "/dev/%s", bus_info.udi_devnames[0]);
 #else
             snprintf(devbuf, sizeof(devbuf) - 1, "/dev/%s.00", bus_info.udi_devnames[0]);
cpu-exec.c +19 -4
Index: cpu-exec.c
===================================================================
@@ -1188,17 +1188,32 @@
 
 #elif defined(__x86_64__)
 
+#ifdef __NetBSD__
+#define REG_ERR _REG_ERR
+#define REG_TRAPNO _REG_TRAPNO
+
+#define QEMU_UC_MCONTEXT_GREGS(uc, reg)	(uc)->uc_mcontext.__gregs[(reg)]
+#define QEMU_UC_MACHINE_PC(uc)		_UC_MACHINE_PC(uc)
+#else
+#define QEMU_UC_MCONTEXT_GREGS(uc, reg)	(uc)->uc_mcontext.gregs[(reg)]
+#define QEMU_UC_MACHINE_PC(uc)		QEMU_UC_MCONTEXT_GREGS(uc, REG_RIP)
+#endif
+
 int cpu_signal_handler(int host_signum, void *pinfo,
                        void *puc)
 {
     siginfo_t *info = pinfo;
+    unsigned long pc;
+#ifdef __NetBSD__
+    ucontext_t *uc = puc;
+#else
     struct ucontext *uc = puc;
-    unsigned long pc;
+#endif
 
-    pc = uc->uc_mcontext.gregs[REG_RIP];
+    pc = QEMU_UC_MACHINE_PC(uc);
     return handle_cpu_signal(pc, (unsigned long)info->si_addr,
-                             uc->uc_mcontext.gregs[REG_TRAPNO] == 0xe ?
-                             (uc->uc_mcontext.gregs[REG_ERR] >> 1) & 1 : 0,
+                             QEMU_UC_MCONTEXT_GREGS(uc, REG_TRAPNO) == 0xe ?
+                             (QEMU_UC_MCONTEXT_GREGS(uc, REG_ERR) >> 1) & 1 : 0,
                              &uc->uc_sigmask, puc);
 }
 
block.c +2 -2
Index: block.c
===================================================================
@@ -760,7 +764,7 @@
     int ret, i, heads, sectors, cylinders;
     struct partition *p;
     uint32_t nr_sects;
-    int64_t nb_sectors;
+    uint64_t nb_sectors;
 
     bdrv_get_geometry(bs, &nb_sectors);
 
@@ -800,7 +804,7 @@
 {
     int translation, lba_detected = 0;
     int cylinders, heads, secs;
-    int64_t nb_sectors;
+    uint64_t nb_sectors;
 
     /* if a geometry hint is available, use it */
     bdrv_get_geometry(bs, &nb_sectors);
mpcore.c +2 -0
Index: hw/mpcore.c
===================================================================
@@ -105,6 +105,8 @@
         return s->control;
     case 12: /* Interrupt status.  */
         return s->status;
+    default:
+        return 0;
     }
 }
 
#1 lore raw
Quoted 4 lines · Christoph Egger

Hi,

This is a series of four patches which improve support for qemu on NetBSD.

...and all patches come with the same subject plus these two identical lines of introduction. Please adopt them to the common scheme of laying out patch series.

Quoted 6 lines

Attached patch contains warning fixes + make cpu-exec.c compile on NetBSD.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT SE 2 ES-OS
Corporate Competence Center Embedded Linux
#2 lore raw
In reply to Christoph Egger
Quoted 7 lines · Christoph Egger

Hi,

This is a series of four patches which improve support for qemu on NetBSD.

Quoted 5 lines

Attached patch contains warning fixes + make cpu-exec.c

compile on NetBSD.

These look pretty reasonable to me, I'll commit them (splitting to more patches) unless there are objections.