Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 06 May 2008 21:08:10 +0200
From:      Teufel <bsd@kuehlbox.de>
To:        freebsd-emulation@FreeBSD.org
Subject:   Re: seems I finally found what upset kqemu on amd64 SMP... shared gdt! (please test patch :)
Message-ID:  <4820AC9A.1070803@kuehlbox.de>
In-Reply-To: <20080501101951.GA30274@saturn.kn-bremen.de>
References:  <20080429222458.GA20855@saturn.kn-bremen.de> <20080501101951.GA30274@saturn.kn-bremen.de>

next in thread | previous in thread | raw e-mail | index | archive | help
Juergen Lock wrote:
>  The patch applied with offsets (I still had debug code in when I made it),
> here is a rebased version:
>
> Index: kqemu-freebsd.c
> @@ -33,6 +33,11 @@
>  
>  #include <machine/vmparam.h>
>  #include <machine/stdarg.h>
> +#ifdef __x86_64__
> +#include <sys/pcpu.h>
> +#include <machine/segments.h>
> +#include <machine/tss.h>
> +#endif
>  
>  #include "kqemu-kernel.h"
>  
> @@ -234,6 +239,19 @@
>      va_end(ap);
>  }
>  
> +#ifdef __x86_64__
> +/* called with interrupts disabled */
> +void CDECL kqemu_tss_workaround(void)
> +{
> +    int gsel_tss = GSEL(GPROC0_SEL, SEL_KPL);
> +
> +    gdt_segs[GPROC0_SEL].ssd_base = (long) &common_tss[PCPU_GET(cpuid)];
> +    ssdtosyssd(&gdt_segs[GPROC0_SEL],
> +       (struct system_segment_descriptor *)&gdt[GPROC0_SEL]);
> +    ltr(gsel_tss);
> +}
> +#endif
> +
>  struct kqemu_instance { 
>  #if __FreeBSD_version >= 500000
>      TAILQ_ENTRY(kqemu_instance) kqemu_ent;
> Index: common/kernel.c
> @@ -1025,6 +1025,9 @@
>  #ifdef __x86_64__
>      uint16_t saved_ds, saved_es;
>      unsigned long fs_base, gs_base;
> +#ifdef __FreeBSD__
> +    struct kqemu_global_state *g = s->global_state;
> +#endif
>  #endif
>      
>  #ifdef PROFILE
> @@ -1188,6 +1191,13 @@
>              apic_restore_nmi(s, apic_nmi_mask);
>          }
>          profile_record(s);
> +#ifdef __FreeBSD__
> +#ifdef __x86_64__
> +        spin_lock(&g->lock);
> +        kqemu_tss_workaround();
> +        spin_unlock(&g->lock);
> +#endif
> +#endif
>  
>          if (s->mon_req == MON_REQ_IRQ) {
>              struct kqemu_exception_regs *r;
> Index: kqemu-kernel.h
> @@ -44,4 +44,10 @@
>  
>  void CDECL kqemu_log(const char *fmt, ...);
>  
> +#ifdef __FreeBSD__
> +#ifdef __x86_64__
> +void CDECL kqemu_tss_workaround(void);
> +#endif
> +#endif
> +
>  #endif /* KQEMU_KERNEL_H */
>   
applied the patch and kqemu works now with quad core CPU running
7-stable amd64 smp. However, running a win2k3 guest results in many
"fpudna in kernel mode!" kernel messages, regardless if -kernel-mode is
used or not (but with kqemu-user enabled).
What needs to be done to fix that?

Greetings,

Xat



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4820AC9A.1070803>