From owner-freebsd-emulation@FreeBSD.ORG Sat Sep 27 20:50:48 2008 Return-Path: Delivered-To: freebsd-emulation@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5D42F106568C for ; Sat, 27 Sep 2008 20:50:48 +0000 (UTC) (envelope-from nox@saturn.kn-bremen.de) Received: from gwyn.kn-bremen.de (gwyn.kn-bremen.de [212.63.36.242]) by mx1.freebsd.org (Postfix) with ESMTP id D88628FC15 for ; Sat, 27 Sep 2008 20:50:47 +0000 (UTC) (envelope-from nox@saturn.kn-bremen.de) Received: by gwyn.kn-bremen.de (Postfix, from userid 10) id A2497191AB7; Sat, 27 Sep 2008 22:50:46 +0200 (CEST) Received: from saturn.kn-bremen.de (noident@localhost [127.0.0.1]) by saturn.kn-bremen.de (8.14.2/8.13.8) with ESMTP id m8RKlW6H052857; Sat, 27 Sep 2008 22:47:32 +0200 (CEST) (envelope-from nox@saturn.kn-bremen.de) Received: (from nox@localhost) by saturn.kn-bremen.de (8.14.2/8.13.6/Submit) id m8RKlUDc052856; Sat, 27 Sep 2008 22:47:30 +0200 (CEST) (envelope-from nox) From: Juergen Lock Date: Sat, 27 Sep 2008 22:47:29 +0200 To: Anthony Liguori , qemu-devel@nongnu.org, freebsd-emulation@freebsd.org Message-ID: <20080927204729.GA52209@saturn.kn-bremen.de> Mail-Followup-To: Anthony Liguori , qemu-devel@nongnu.org, freebsd-emulation@freebsd.org References: <20080921204025.GA81055@saturn.kn-bremen.de> <200809242210.m8OMAcSZ021572@saturn.kn-bremen.de> <48DCF9FC.2070708@codemonkey.ws> <20080926220445.GA13099@saturn.kn-bremen.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20080926220445.GA13099@saturn.kn-bremen.de> User-Agent: Mutt/1.5.17 (2007-11-01) Cc: Subject: Re: [Qemu-devel] Re: qemu svn r5281 on FreeBSD - slow usb, vmwarevga, screen updates... (now updated to r5331) X-BeenThere: freebsd-emulation@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Development of Emulators of other operating systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Sep 2008 20:50:48 -0000 On Sat, Sep 27, 2008 at 12:04:45AM +0200, I wrote: >[...] > I'll see if I can prepare another update over the weekend and then go > thru more of the patches that have accumulated in the port... OK, here we go :) First the update: (at r5331 now) http://people.freebsd.org/~nox/qemu/qemu-devel-20080927.patch 1. FreeBSD also has clock_gettime: Index: qemu/vl.c @@ -541,7 +541,7 @@ static void init_get_clock(void) { use_rt_clock = 0; -#if defined(__linux__) +#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) { @@ -553,7 +553,7 @@ static int64_t get_clock(void) { -#if defined(__linux__) +#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000) if (use_rt_clock) { struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); 2. open() can also return EPERM for O_RDWR on a readonly device (I think the case where this happened was a cdrom:) Index: qemu/block.c @@ -381,7 +381,7 @@ else open_flags = flags & ~(BDRV_O_FILE | BDRV_O_SNAPSHOT); ret = drv->bdrv_open(bs, filename, open_flags); - if (ret == -EACCES && !(flags & BDRV_O_FILE)) { + if ((ret == -EACCES || ret == -EPERM) && !(flags & BDRV_O_FILE)) { ret = drv->bdrv_open(bs, filename, BDRV_O_RDONLY); bs->read_only = 1; } 3. the following bugfix is needed at least for FreeBSD/amd64 guests: (original patch from http://www.nabble.com/-PATCH--i386-hard-interrupt-generation-bug-fix-p14921171.html ) Index: qemu/cpu-exec.c @@ -394,16 +394,18 @@ (env->eflags & IF_MASK && !(env->hflags & HF_INHIBIT_IRQ_MASK))))) { int intno; - svm_check_intercept(SVM_EXIT_INTR); env->interrupt_request &= ~(CPU_INTERRUPT_HARD | CPU_INTERRUPT_VIRQ); intno = cpu_get_pic_interrupt(env); - if (loglevel & CPU_LOG_TB_IN_ASM) { - fprintf(logfile, "Servicing hardware INT=0x%02x\n", intno); + if (intno>=0) { + svm_check_intercept(SVM_EXIT_INTR); + if (loglevel & CPU_LOG_TB_IN_ASM) { + fprintf(logfile, "Servicing hardware INT=0x%02x\n", intno); + } + do_interrupt(intno, 0, 0, 0, 1); + /* ensure that no TB jump will be modified as + the program flow was changed */ + next_tb = 0; } - do_interrupt(intno, 0, 0, 0, 1); - /* ensure that no TB jump will be modified as - the program flow was changed */ - next_tb = 0; #if !defined(CONFIG_USER_ONLY) } else if ((interrupt_request & CPU_INTERRUPT_VIRQ) && (env->eflags & IF_MASK) && 4. this is also needed for (some?) amd64 guests on i386 hosts: Index: qemu/exec-all.h @@ -30,7 +30,7 @@ struct TranslationBlock; /* XXX: make safe guess about sizes */ -#define MAX_OP_PER_INSTR 64 +#define MAX_OP_PER_INSTR 128 /* 64 */ /* A Call op needs up to 6 + 2N parameters (N = number of arguments). */ #define MAX_OPC_PARAM 10 #define OPC_BUF_SIZE 512 5. no need (?) for a dummy file on FreeBSD too: (like on OpenBSD) Index: qemu/osdep.c @@ -75,8 +75,10 @@ #include #include #else +#ifndef __FreeBSD__ #include #endif +#endif #include #include @@ -87,7 +87,7 @@ static int phys_ram_size = 0; void *ptr; -#ifdef __OpenBSD__ /* no need (?) for a dummy file on OpenBSD */ +#if defined(__OpenBSD__) || defined(__FreeBSD__) /* no need (?) for a dummy file on OpenBSD/FreeBSD */ int map_anon = MAP_ANON; #else int map_anon = 0; @@ -154,7 +154,7 @@ } size = (size + 4095) & ~4095; ftruncate(phys_ram_fd, phys_ram_size + size); -#endif /* !__OpenBSD__ */ +#endif /* !(__OpenBSD__ || __FreeBSD__) */ ptr = mmap(NULL, size, PROT_WRITE | PROT_READ, map_anon | MAP_SHARED, 6. correct lib search path on FreeBSD/amd64 hosts (tho this needs to be conditionally applied if its to go into qemu svn:) Index: qemu/x86_64.ld @@ -2,7 +2,7 @@ OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64") OUTPUT_ARCH(i386:x86-64) ENTRY(_start) -SEARCH_DIR("/lib64"); SEARCH_DIR("/usr/lib64"); SEARCH_DIR("/usr/local/lib64"); +SEARCH_DIR("/lib"); SEARCH_DIR("/usr/lib"); SEARCH_DIR("/usr/local/lib"); SECTIONS { /* Read-only sections, merged into text segment: */ I think thats it for now... more maybe later. Juergen Signed-off-by: Juergen Lock