Date: Tue, 26 Jul 2005 01:42:08 +0200 From: Juergen Lock <nox@jelal.kn-bremen.de> To: Jung-uk Kim <jkim@FreeBSD.org> Cc: ports@FreeBSD.org, freebsd-emulation@FreeBSD.org, freebsd-amd64@FreeBSD.org Subject: Re: need help with kqemu Message-ID: <20050726014207.A48961@saturn.kn-bremen.de> In-Reply-To: <200507251825.51540.jkim@FreeBSD.org> References: <20050725222608.A42815@saturn.kn-bremen.de> <200507251825.51540.jkim@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Jul 25, 2005 at 06:25:50PM -0400, Jung-uk Kim wrote: > On Monday 25 July 2005 04:26 pm, Juergen Lock wrote: > > Hi! > > > > Fabrice has released a new version of kqemu that now also > > supports amd64 hosts, but as he doesnt know FreeBSD (and my > > kernel foo is far from being good enough, neither do i have > > an amd64 box) we need someone to port the wrapper to amd64. > > Actually the i386 wrapper he has now added to the release > > (kqemu-0.7.1.tar.gz) doesnt work either (not sure what happened > > there, it doesnt even build), so we need someone to fix/update > > that as well. I have made an update for the port that can be > > used as a template (only non-kqemu build works), I'll append it > > below: > > > > Removed files: files/BSDmakefile files/kmod_bsd.c > > New files: files/kqemu-Makefile-patch files/patch-libmath2 > > files/patch-vl.c > > > > (btw patch-vl.c is from Andrey V. Elsukov, it enables kernel > > debugging via virtual serial console, as posted on -ports: > > > > # qemu -hda disk.img -cdrom 6.0-BETA1.iso -serial pty > > # gdb > > (gdb) target remote /dev/ptyp0 > > ....) > > Try the attachment. It seems to build and work on amd64 now, > including kqemu. Hey, nice! So there wasnt actually that much wrong... One question: Does this also work on 4.x? Here's my version: (I disabled a kqemu_vmalloc_to_phys(%p) printf and added back use of the system cc for kqemu) Removed files: files/BSDmakefile, files/kmod_bsd.c New files: files/kqemu-freebsd-patch files/patch-libmath2 files/patch-vl.c Index: Makefile =================================================================== RCS file: /home/ncvs/ports/emulators/qemu/Makefile,v retrieving revision 1.27 diff -u -r1.27 Makefile --- Makefile 19 Jul 2005 06:06:56 -0000 1.27 +++ Makefile 25 Jul 2005 23:00:43 -0000 @@ -6,12 +6,9 @@ # PORTNAME= qemu -PORTVERSION= 0.7.0s.20050717 +PORTVERSION= 0.7.1 CATEGORIES= emulators -MASTER_SITES= http://www.qemu.org/ \ - http://people.fruitsalad.org/nox/qemu/ \ - http://dad-answers.com/qemu/ -DISTNAME= ${PORTNAME}-snapshot-2005-07-17_23 +MASTER_SITES= http://www.qemu.org/ EXTRACT_ONLY= ${DISTNAME}${EXTRACT_SUFX} MAINTAINER= nox@jelal.kn-bremen.de @@ -23,12 +20,12 @@ .endif .if defined(WITH_KQEMU) -DISTKQEMU= kqemu-0.6.2-1.tar.gz +DISTKQEMU= kqemu-0.7.1.tar.gz DISTFILES= ${EXTRACT_ONLY} ${DISTKQEMU} +EXTRA_PATCHES= ${FILESDIR}/kqemu-freebsd-patch .endif HAS_CONFIGURE= yes -USE_BZIP2= yes USE_GMAKE= yes USE_GETOPT_LONG= yes USE_SDL= sdl @@ -40,9 +37,11 @@ ONLY_FOR_ARCHS= amd64 i386 .if defined(WITH_KQEMU) NO_PACKAGE= Depends on kernel, and module not redistributable +CONFIGURE_ARGS+= --enable-kqemu PLIST_SUB= WITH_KQEMU="" PLIST_SUB+= KMODDIR=${KMODDIR} .else +CONFIGURE_ARGS+= --disable-kqemu PLIST_SUB= WITH_KQEMU="@comment " .endif @@ -52,7 +51,7 @@ .if ${ARCH} == "amd64" ARCH= x86_64 -.if ${OSVERSION} >= 502126 +.if ${OSVERSION} >= 502126 && ${OSVERSION} <= 600029 BUILD_DEPENDS+= gcc34:${PORTSDIR}/lang/gcc34 GCCVERSION= 030402 CC= gcc34 @@ -63,16 +62,12 @@ USE_GCC= 3.4 .endif -.if defined(WITH_KQEMU) && ${ARCH} != "i386" -IGNORE= kqemu only supported on i386 -.endif - .if defined(WITH_KQEMU) && !exists(${SRC_BASE}/sys/Makefile) IGNORE= kqemu requires kernel source to be installed .endif pre-everything:: -.if !defined(WITH_KQEMU) && ${ARCH} == "i386" +.if !defined(WITH_KQEMU) @${ECHO_MSG} "Notice: you can build qemu with the (alpha!) kqemu accelerator kernel module" @${ECHO_MSG} "by defining WITH_KQEMU." .endif @@ -85,7 +80,7 @@ .if defined(WITH_KQEMU) post-extract: @cd ${WRKSRC} && ${TAR} xfz ${_DISTDIR}/${DISTKQEMU} - @${CP} ${FILESDIR}/BSDmakefile ${FILESDIR}/kmod_bsd.c ${WRKSRC}/kqemu + @${LN} -s Makefile.freebsd ${WRKSRC}/kqemu/BSDmakefile .endif pre-patch: Index: distinfo =================================================================== RCS file: /home/ncvs/ports/emulators/qemu/distinfo,v retrieving revision 1.20 diff -u -r1.20 distinfo --- distinfo 19 Jul 2005 06:06:56 -0000 1.20 +++ distinfo 25 Jul 2005 23:00:43 -0000 @@ -1,4 +1,4 @@ -MD5 (qemu-snapshot-2005-07-17_23.tar.bz2) = 5d21295c1f328ea00de19a54715ee7c3 -SIZE (qemu-snapshot-2005-07-17_23.tar.bz2) = 1114748 -MD5 (kqemu-0.6.2-1.tar.gz) = c6bb3b40fb3d526d731eb0f1f9dee7ee -SIZE (kqemu-0.6.2-1.tar.gz) = 21002 +MD5 (qemu-0.7.1.tar.gz) = b0c80d2c082049a5b8ccbc7f55fe165b +SIZE (qemu-0.7.1.tar.gz) = 1338521 +MD5 (kqemu-0.7.1.tar.gz) = 8fc7967492b2157521198f6639218420 +SIZE (kqemu-0.7.1.tar.gz) = 76135 Index: files/patch-fbsd =================================================================== RCS file: /home/ncvs/ports/emulators/qemu/files/patch-fbsd,v retrieving revision 1.2 diff -u -r1.2 patch-fbsd --- files/patch-fbsd 5 May 2005 12:41:10 -0000 1.2 +++ files/patch-fbsd 25 Jul 2005 23:00:43 -0000 @@ -13,7 +13,7 @@ $(MAKE) -C kqemu -f Makefile.winnt else - $(MAKE) -C kqemu -+ cd kqemu && $(BSD_MAKE) ++ ( cd kqemu && $(BSD_MAKE) ) endif endif Index: files/kqemu-freebsd-patch @@ -0,0 +1,62 @@ +--- qemu/configure.orig Mon Jul 25 17:58:33 2005 ++++ qemu/configure Mon Jul 25 17:59:55 2005 +@@ -99,7 +99,7 @@ + FreeBSD) + bsd="yes" + oss="yes" +-if [ "$cpu" = "i386" ] ; then ++if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then + kqemu="yes" + fi + ;; +--- qemu/kqemu/Makefile.freebsd.orig Sun Apr 17 13:21:31 2005 ++++ qemu/kqemu/Makefile.freebsd Mon Jul 25 17:32:48 2005 +@@ -1,6 +1,14 @@ + # $Id: Makefile.freebsd,v 1.1 2005/04/17 17:21:31 bellard Exp $ + KMOD= kqemu +-SRCS= kmod-freebsd.c ++SRCS= kqemu-freebsd.c ++.if ${MACHINE_ARCH} == "i386" + OBJS= kqemu-mod-i386.o ++.elif ${MACHINE_ARCH} == "amd64" ++OBJS= kqemu-mod-x86_64.o ++.endif ++.if ${OSVERSION} >= 500000 ++CC= cc ++.endif ++WERROR= + + .include <bsd.kmod.mk> +--- qemu/kqemu/kqemu-freebsd.c.orig Mon Apr 25 18:14:40 2005 ++++ qemu/kqemu/kqemu-freebsd.c Mon Jul 25 17:40:17 2005 +@@ -59,9 +59,9 @@ + // printf("kqemu_unlock_user_page(%08lx)\n", page_index); + va = (vm_offset_t)page; + ret = vm_map_unwire(&vm->vm_map, va, va+PAGE_SIZE, VM_MAP_WIRE_USER); +- if (ret != KERN_SUCCESS) { +- printf("kqemu_unlock_user_page(%08lx) failed, ret=%d\n", page_index, ret); +- } ++ // if (ret != KERN_SUCCESS) { ++ // printf("kqemu_unlock_user_page(%08lx) failed, ret=%d\n", page_index, ret); ++ // } + } + + /* +@@ -88,7 +88,7 @@ + + void CDECL kqemu_free_page(struct kqemu_page *page) + { +- printf("kqemu_free_page(%08lx)\n", page_index); ++ // printf("kqemu_free_page(%08lx)\n", page_index); + /* XXX: do it */ + } + +@@ -138,7 +138,7 @@ + printf("kqemu_vmalloc_to_phys(%p)->error\n", vaddr); + return -1; + } +- printf("kqemu_vmalloc_to_phys(%p)->%08x\n", vaddr, pa); ++ /*printf("kqemu_vmalloc_to_phys(%p)->%08x\n", vaddr, pa);*/ + return pa >> PAGE_SHIFT; + } + Index: files/patch-libmath2 @@ -0,0 +1,67 @@ +Index: qemu/bsd/Makefile +@@ -16,7 +16,8 @@ + ${MACHINE_ARCH}/s_rintl.c \ + ${MACHINE_ARCH}/s_round.c \ + ${MACHINE_ARCH}/s_sinl.S \ +- ${MACHINE_ARCH}/s_tanl.S ++ ${MACHINE_ARCH}/s_tanl.S \ ++ ${MACHINE_ARCH}/s_ldexpl.c + + OBJS= ${SRCS:R:S/$/.o/} + +Index: qemu/bsd/i386/s_ldexpl.c +@@ -0,0 +1,21 @@ ++#include <math.h> ++#include <errno.h> ++#include <sysdep.h> ++ ++long double __ldexpl(long double x, int expn) ++{ ++ long double res; ++ if (!isfinite (x) || x == 0.0L) ++ return x; ++ ++ __asm__ ("fscale" ++ : "=t" (res) ++ : "0" (x), "u" ((long double) expn)); ++ ++ if (!isfinite (res) || res == 0.0L) ++ errno = ERANGE; ++ ++ return res; ++} ++ ++weak_alias(__ldexpl,ldexpl) +Index: qemu/bsd/amd64/s_ldexpl.c +@@ -0,0 +1,21 @@ ++#include <math.h> ++#include <errno.h> ++#include <sysdep.h> ++ ++long double __ldexpl(long double x, int expn) ++{ ++ long double res; ++ if (!isfinite (x) || x == 0.0L) ++ return x; ++ ++ __asm__ ("fscale" ++ : "=t" (res) ++ : "0" (x), "u" ((long double) expn)); ++ ++ if (!isfinite (res) || res == 0.0L) ++ errno = ERANGE; ++ ++ return res; ++} ++ ++weak_alias(__ldexpl,ldexpl) +Index: qemu/target-i386/helper.c +@@ -2886,6 +2886,8 @@ + ST0 = floatx_round_to_int(ST0, &env->fp_status); + } + ++long double ldexpl(long double, int); ++ + void helper_fscale(void) + { + ST0 = ldexp (ST0, (int)(ST1)); Index: files/patch-vl.c @@ -0,0 +1,21 @@ +Index: qemu/vl.c +@@ -40,6 +40,10 @@ + #include <sys/socket.h> + #include <netinet/in.h> + #include <dirent.h> ++#ifdef __FreeBSD__ ++#include <sys/types.h> ++#include <libutil.h> ++#endif + #ifdef _BSD + #include <sys/stat.h> + #ifndef __APPLE__ +@@ -1280,7 +1284,7 @@ + return chr; + } + +-#if defined(__linux__) ++#if defined(__linux__) || defined(__FreeBSD__) + CharDriverState *qemu_chr_open_pty(void) + { + char slave_name[1024];
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050726014207.A48961>