* [Qemu-devel] testing qemu svn r6082 on FreeBSD - virtio-net, hpet, vmmouse/vga, got bsd-user to build, and an updated version of the FreeBSD -clock dynticks patch
@ 2008-12-18 23:17 Juergen Lock
2008-12-20 21:21 ` Blue Swirl
0 siblings, 1 reply; 3+ messages in thread
From: Juergen Lock @ 2008-12-18 23:17 UTC (permalink / raw)
To: freebsd-emulation, qemu-devel
Hi!
I have made another experimental FreeBSD qemu-devel port update,
http://people.freebsd.org/~nox/qemu/qemu-devel-20081218.patch
and can report that the new aio code, hpet and virtio-net all seem
to work so far at least for the two guests I tried:
sidux-2008-04-pontos-pre1-kde-lite-i386-200812141731.iso
and
7.1-RC1-i386-dvd1.iso
(tho both only in livecd resp. livefs i.e. fixit->cdrom mode.)
Also with _this_ sidux iso even vmmouse works with cirrus emulation
(and userland kqemu), the earlier vmmouse breakage I saw was in fact due
to a bug in sidux. (it also wasn't enabled by default there for cirrus
before.) I also was able to run this sidux iso with vmware vga emulation
after disabling HW_MOUSE_ACCEL in my version of qemu/hw/vmware_vga.c,
otherwise keeping the same patch as posted before. (With HW_MOUSE_ACCEL
enabled my host mouse cursor still disappeared completely as soon as
the guest xserver started, and either the guest hung soon after that too
or I didn't wait long enough.)
vmmouse as well as the vmware vga emulation itself still don't work with
-kernel-kqemu tho, but I've since been told this is a known problem
(something to do with userspace pio.)
Oh and usb still is slow at least with sidux guests, no change there...
Now bsd-user - I have no sparc64 guest, but the following patches
got it to at least build on FreeBSD 6.3/i386 and 7.1pre/amd64:
(the -Wl,-shared hack in qemu/Makefile.target causes the resulting
binary not to start and if I try qemu's i386.ld I get a link error with
libm iirc, so I guess at least the i386 case needs more work before
it can actually work...)
Index: qemu/cpu-exec.c
@@ -1158,6 +1158,12 @@
# define EIP_sig(context) (*((unsigned long*)&(context)->uc_mcontext->ss.eip))
# define TRAP_sig(context) ((context)->uc_mcontext->es.trapno)
# define ERROR_sig(context) ((context)->uc_mcontext->es.err)
+#elif defined(__FreeBSD__)
+# include <sys/ucontext.h>
+
+# define EIP_sig(context) (*((unsigned long*)&(context)->uc_mcontext.mc_eip))
+# define TRAP_sig(context) ((context)->uc_mcontext.mc_trapno)
+# define ERROR_sig(context) ((context)->uc_mcontext.mc_err)
#else
# define EIP_sig(context) ((context)->uc_mcontext.gregs[REG_EIP])
# define TRAP_sig(context) ((context)->uc_mcontext.gregs[REG_TRAPNO])
@@ -1168,7 +1174,11 @@
void *puc)
{
siginfo_t *info = pinfo;
+#ifdef __FreeBSD__
+ ucontext_t *uc = puc;
+#else
struct ucontext *uc = puc;
+#endif
unsigned long pc;
int trapno;
@@ -1194,6 +1204,12 @@
#define QEMU_UC_MCONTEXT_GREGS(uc, reg) (uc)->uc_mcontext.__gregs[(reg)]
#define QEMU_UC_MACHINE_PC(uc) _UC_MACHINE_PC(uc)
+#elif defined(__FreeBSD__)
+# include <sys/ucontext.h>
+
+# define RIP_sig(context) (*((unsigned long*)&(context)->uc_mcontext.mc_rip))
+# define TRAP_sig(context) ((context)->uc_mcontext.mc_trapno)
+# define ERROR_sig(context) ((context)->uc_mcontext.mc_err)
#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)
@@ -1204,17 +1220,25 @@
{
siginfo_t *info = pinfo;
unsigned long pc;
-#ifdef __NetBSD__
+#if defined(__NetBSD__) || defined(__FreeBSD__)
ucontext_t *uc = puc;
#else
struct ucontext *uc = puc;
#endif
+#ifdef __FreeBSD__
+ pc = RIP_sig(uc);
+ return handle_cpu_signal(pc, (unsigned long)info->si_addr,
+ TRAP_sig(uc) == 0xe ?
+ (ERROR_sig(uc) >> 1) & 1 : 0,
+ &uc->uc_sigmask, puc);
+#else
pc = QEMU_UC_MACHINE_PC(uc);
return handle_cpu_signal(pc, (unsigned long)info->si_addr,
QEMU_UC_MCONTEXT_GREGS(uc, REG_TRAPNO) == 0xe ?
(QEMU_UC_MCONTEXT_GREGS(uc, REG_ERR) >> 1) & 1 : 0,
&uc->uc_sigmask, puc);
+#endif
}
#elif defined(__powerpc__)
Index: qemu/Makefile.target
@@ -472,7 +472,7 @@
# WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object
# that the kernel ELF loader considers as an executable. I think this
# is the simplest way to make it self virtualizable!
-LDFLAGS+=-Wl,-shared
+#LDFLAGS+=-Wl,-shared
endif
endif
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: */
@@ -59,8 +59,6 @@
.rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
.rodata1 : { *(.rodata1) }
.eh_frame_hdr : { *(.eh_frame_hdr) }
- .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) }
- .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table) }
/* Adjust the address for the data segment. We want to adjust up to
the same address within the page on the next page up. */
. = ALIGN (0x100000) - ((0x100000 - .) & (0x100000 - 1)); . = DATA_SEGMENT_ALIGN (0x100000, 0x1000);
@@ -86,8 +84,8 @@
.data1 : { *(.data1) }
.tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
.tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
- .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) }
- .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table) }
+ .eh_frame : { KEEP (*(.eh_frame)) }
+ .gcc_except_table : { *(.gcc_except_table) }
.dynamic : { *(.dynamic) }
.ctors :
{
And finally the updated dynticks patch:
Index: qemu/configure
@@ -1025,11 +1025,26 @@
rt=yes
fi
+##########################################
+# posix timer probe
+cat > $TMPC <<EOF
+#include <time.h>
+int main(void) { timer_create(CLOCK_REALTIME, (struct sigevent *)NULL, (timer_t *)NULL); return 0; }
+EOF
+posixtimer=no
+if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
+ posixtimer=yes
+elif $cc $ARCH_CFLAGS -o $TMPE $TMPC -lrt 2> /dev/null ; then
+ posixtimer=yes
+ rt=yes
+fi
+
if test "$rt" = "yes" ; then
# Hack, we should have a general purpose LIBS for this sort of thing
AIOLIBS="$AIOLIBS -lrt"
fi
+
if test "$mingw32" = "yes" ; then
if test -z "$prefix" ; then
prefix="c:\\\\Program Files\\\\Qemu"
@@ -1403,6 +1418,9 @@
echo "#define HAVE_FDT 1" >> $config_h
echo "FDT_LIBS=-lfdt" >> $config_mak
fi
+if test "$posixtimer" = "yes" ; then
+ echo "#define HAVE_POSIX_TIMER 1" >> $config_h
+fi
# XXX: suppress that
if [ "$bsd" = "yes" ] ; then
Index: qemu/vl.c
@@ -918,12 +918,16 @@
static int unix_start_timer(struct qemu_alarm_timer *t);
static void unix_stop_timer(struct qemu_alarm_timer *t);
-#ifdef __linux__
+#ifdef HAVE_POSIX_TIMER
static int dynticks_start_timer(struct qemu_alarm_timer *t);
static void dynticks_stop_timer(struct qemu_alarm_timer *t);
static void dynticks_rearm_timer(struct qemu_alarm_timer *t);
+#endif
+
+#ifdef __linux__
+
static int hpet_start_timer(struct qemu_alarm_timer *t);
static void hpet_stop_timer(struct qemu_alarm_timer *t);
@@ -1001,9 +1005,11 @@
static struct qemu_alarm_timer alarm_timers[] = {
#ifndef _WIN32
-#ifdef __linux__
+#ifdef HAVE_POSIX_TIMER
{"dynticks", ALARM_FLAG_DYNTICKS, dynticks_start_timer,
dynticks_stop_timer, dynticks_rearm_timer, NULL},
+#endif
+#ifdef __linux__
/* HPET - if available - is preferred */
{"hpet", 0, hpet_start_timer, hpet_stop_timer, NULL, NULL},
/* ...otherwise try RTC */
@@ -1361,7 +1367,7 @@
return delta;
}
-#if defined(__linux__) || defined(_WIN32)
+#if defined(HAVE_POSIX_TIMER) || defined(_WIN32)
static uint64_t qemu_next_deadline_dyntick(void)
{
int64_t delta;
@@ -1506,6 +1512,10 @@
close(rtc_fd);
}
+#endif /* defined(__linux__) */
+
+#ifdef HAVE_POSIX_TIMER
+
static int dynticks_start_timer(struct qemu_alarm_timer *t)
{
struct sigevent ev;
@@ -1577,7 +1587,7 @@
}
}
-#endif /* defined(__linux__) */
+#endif /* defined(HAVE_POSIX_TIMER) */
static int unix_start_timer(struct qemu_alarm_timer *t)
{
Thanx,
Juergen
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] testing qemu svn r6082 on FreeBSD - virtio-net, hpet, vmmouse/vga, got bsd-user to build, and an updated version of the FreeBSD -clock dynticks patch
2008-12-18 23:17 [Qemu-devel] testing qemu svn r6082 on FreeBSD - virtio-net, hpet, vmmouse/vga, got bsd-user to build, and an updated version of the FreeBSD -clock dynticks patch Juergen Lock
@ 2008-12-20 21:21 ` Blue Swirl
2008-12-20 23:45 ` Juergen Lock
0 siblings, 1 reply; 3+ messages in thread
From: Blue Swirl @ 2008-12-20 21:21 UTC (permalink / raw)
To: qemu-devel, freebsd-emulation
On 12/19/08, Juergen Lock <nox@jelal.kn-bremen.de> wrote:
> +#elif defined(__FreeBSD__)
> +# include <sys/ucontext.h>
> +
> +# define RIP_sig(context) (*((unsigned long*)&(context)->uc_mcontext.mc_rip))
> +# define TRAP_sig(context) ((context)->uc_mcontext.mc_trapno)
> +# define ERROR_sig(context) ((context)->uc_mcontext.mc_err)
> #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)
> +#ifdef __FreeBSD__
> + pc = RIP_sig(uc);
> + return handle_cpu_signal(pc, (unsigned long)info->si_addr,
> + TRAP_sig(uc) == 0xe ?
> + (ERROR_sig(uc) >> 1) & 1 : 0,
> + &uc->uc_sigmask, puc);
> +#else
> pc = QEMU_UC_MACHINE_PC(uc);
> return handle_cpu_signal(pc, (unsigned long)info->si_addr,
> QEMU_UC_MCONTEXT_GREGS(uc, REG_TRAPNO) == 0xe ?
> (QEMU_UC_MCONTEXT_GREGS(uc, REG_ERR) >> 1) & 1 : 0,
> &uc->uc_sigmask, puc);
> +#endif
The idea here was that all OS define macros with same names so that
the code below does not get any more complex. Maybe the GREGS macro
was too generic, and should be replaced with one that only returns the
trap and error values.
> And finally the updated dynticks patch:
This looks OK, please submit separately.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] testing qemu svn r6082 on FreeBSD - virtio-net, hpet, vmmouse/vga, got bsd-user to build, and an updated version of the FreeBSD -clock dynticks patch
2008-12-20 21:21 ` Blue Swirl
@ 2008-12-20 23:45 ` Juergen Lock
0 siblings, 0 replies; 3+ messages in thread
From: Juergen Lock @ 2008-12-20 23:45 UTC (permalink / raw)
To: blauwirbel; +Cc: freebsd-emulation, qemu-devel
In article <f43fc5580812201321u6478cb85qa33a7bb2ec4e9038@mail.gmail.com> you write:
>On 12/19/08, Juergen Lock <nox@jelal.kn-bremen.de> wrote:
>> +#elif defined(__FreeBSD__)
>> +# include <sys/ucontext.h>
>> +
>> +# define RIP_sig(context) (*((unsigned long*)&(context)->uc_mcontext.mc_rip))
>> +# define TRAP_sig(context) ((context)->uc_mcontext.mc_trapno)
>> +# define ERROR_sig(context) ((context)->uc_mcontext.mc_err)
>> #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)
>
>> +#ifdef __FreeBSD__
>> + pc = RIP_sig(uc);
>> + return handle_cpu_signal(pc, (unsigned long)info->si_addr,
>> + TRAP_sig(uc) == 0xe ?
>> + (ERROR_sig(uc) >> 1) & 1 : 0,
>> + &uc->uc_sigmask, puc);
>> +#else
>> pc = QEMU_UC_MACHINE_PC(uc);
>> return handle_cpu_signal(pc, (unsigned long)info->si_addr,
>> QEMU_UC_MCONTEXT_GREGS(uc, REG_TRAPNO) == 0xe ?
>> (QEMU_UC_MCONTEXT_GREGS(uc, REG_ERR) >> 1) & 1 : 0,
>> &uc->uc_sigmask, puc);
>> +#endif
>
>The idea here was that all OS define macros with same names so that
>the code below does not get any more complex. Maybe the GREGS macro
>was too generic, and should be replaced with one that only returns the
>trap and error values.
>
Yeah I was too lazy to figure out the preprocessor magic needed
to get the GREGS way working so I simply reused the macros from the
i386 case. :)
>> And finally the updated dynticks patch:
>
>This looks OK, please submit separately.
OK will do.
Thanx,
Juergen
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-12-20 23:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-18 23:17 [Qemu-devel] testing qemu svn r6082 on FreeBSD - virtio-net, hpet, vmmouse/vga, got bsd-user to build, and an updated version of the FreeBSD -clock dynticks patch Juergen Lock
2008-12-20 21:21 ` Blue Swirl
2008-12-20 23:45 ` Juergen Lock
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).