Hi,
This patch should fix panic on amd64 when using ndis with drivers which make use of fpu registers.
diff --git a/sys/compat/ndis/kern_windrv.c b/sys/compat/ndis/kern_windrv.c index 5572988..1a93b54 100644 --- a/sys/compat/ndis/kern_windrv.c +++ b/sys/compat/ndis/kern_windrv.c @@ -55,6 +55,9 @@ __FBSDID("$FreeBSD$"); #ifdef __i386__ #include <machine/segments.h> #endif +#ifdef __amd64__ +#include <machine/fpu.h> +#endif #include <dev/usb/usb.h> @@ -613,6 +616,86 @@ windrv_wrap(func, wrap, argcnt, ftype) return (0); } + +uint64_t +_x86_64_call1(void *fn, uint64_t a) +{ + struct fpu_kern_ctx fpu_ctx_save; + uint64_t ret; + + fpu_kern_enter(curthread, &fpu_ctx_save, FPU_KERN_NORMAL); + ret = x86_64_call1(fn, a); + fpu_kern_leave(curthread, &fpu_ctx_save); + + return (ret); +} + +uint64_t +_x86_64_call2(void *fn, uint64_t a, uint64_t b) +{ + struct fpu_kern_ctx fpu_ctx_save; + uint64_t ret; + + fpu_kern_enter(curthread, &fpu_ctx_save, FPU_KERN_NORMAL); + ret = x86_64_call2(fn, a, b); + fpu_kern_leave(curthread, &fpu_ctx_save); + + return (ret); +} + +uint64_t +_x86_64_call3(void *fn, uint64_t a, uint64_t b, uint64_t c) +{ + struct fpu_kern_ctx fpu_ctx_save; + uint64_t ret; + + fpu_kern_enter(curthread, &fpu_ctx_save, FPU_KERN_NORMAL); + ret = x86_64_call3(fn, a, b, c); + fpu_kern_leave(curthread, &fpu_ctx_save); + + return (ret); +} + +uint64_t +_x86_64_call4(void *fn, uint64_t a, uint64_t b, uint64_t c, uint64_t d) +{ + struct fpu_kern_ctx fpu_ctx_save; + uint64_t ret; + + fpu_kern_enter(curthread, &fpu_ctx_save, FPU_KERN_NORMAL); + ret = x86_64_call4(fn, a, b, c, d); + fpu_kern_leave(curthread, &fpu_ctx_save); + + return (ret); +} + +uint64_t +_x86_64_call5(void *fn, uint64_t a, uint64_t b, uint64_t c, uint64_t d, + uint64_t e) +{ + struct fpu_kern_ctx fpu_ctx_save; + uint64_t ret; + + fpu_kern_enter(curthread, &fpu_ctx_save, FPU_KERN_NORMAL); + ret = x86_64_call5(fn, a, b, c, d, e); + fpu_kern_leave(curthread, &fpu_ctx_save); + + return (ret); +} + +uint64_t +_x86_64_call6(void *fn, uint64_t a, uint64_t b, uint64_t c, uint64_t d, + uint64_t e, uint64_t f) +{ + struct fpu_kern_ctx fpu_ctx_save; + uint64_t ret; + + fpu_kern_enter(curthread, &fpu_ctx_save, FPU_KERN_NORMAL); + ret = x86_64_call6(fn, a, b, c, d, e, f); + fpu_kern_leave(curthread, &fpu_ctx_save); + + return (ret); +} #endif /* __amd64__ */ diff --git a/sys/compat/ndis/pe_var.h b/sys/compat/ndis/pe_var.h index 84e0162..276ad1c 100644 --- a/sys/compat/ndis/pe_var.h +++ b/sys/compat/ndis/pe_var.h @@ -460,22 +460,29 @@ extern uint64_t x86_64_call5(void *, uint64_t, uint64_t, uint64_t, uint64_t, extern uint64_t x86_64_call6(void *, uint64_t, uint64_t, uint64_t, uint64_t, uint64_t, uint64_t); - -#define MSCALL1(fn, a) \ - x86_64_call1((fn), (uint64_t)(a)) -#define MSCALL2(fn, a, b) \ - x86_64_call2((fn), (uint64_t)(a), (uint64_t)(b)) -#define MSCALL3(fn, a, b, c) \ - x86_64_call3((fn), (uint64_t)(a), (uint64_t)(b), \ - (uint64_t)(c)) -#define MSCALL4(fn, a, b, c, d) \ - x86_64_call4((fn), (uint64_t)(a), (uint64_t)(b), \ +uint64_t _x86_64_call1(void *, uint64_t); +uint64_t _x86_64_call2(void *, uint64_t, uint64_t); +uint64_t _x86_64_call3(void *, uint64_t, uint64_t, uint64_t); +uint64_t _x86_64_call4(void *, uint64_t, uint64_t, uint64_t, uint64_t); +uint64_t _x86_64_call5(void *, uint64_t, uint64_t, uint64_t, uint64_t, + uint64_t); +uint64_t _x86_64_call6(void *, uint64_t, uint64_t, uint64_t, uint64_t, + uint64_t, uint64_t); + +#define MSCALL1(fn, a) \ + _x86_64_call1((fn), (uint64_t)(a)) +#define MSCALL2(fn, a, b) \ + _x86_64_call2((fn), (uint64_t)(a), (uint64_t)(b)) +#define MSCALL3(fn, a, b, c) \ + _x86_64_call3((fn), (uint64_t)(a), (uint64_t)(b), (uint64_t)(c)) +#define MSCALL4(fn, a, b, c, d) \ + _x86_64_call4((fn), (uint64_t)(a), (uint64_t)(b), \ (uint64_t)(c), (uint64_t)(d)) -#define MSCALL5(fn, a, b, c, d, e) \ - x86_64_call5((fn), (uint64_t)(a), (uint64_t)(b), \ +#define MSCALL5(fn, a, b, c, d, e) \ + _x86_64_call5((fn), (uint64_t)(a), (uint64_t)(b), \ (uint64_t)(c), (uint64_t)(d), (uint64_t)(e)) -#define MSCALL6(fn, a, b, c, d, e, f) \ - x86_64_call6((fn), (uint64_t)(a), (uint64_t)(b), \ +#define MSCALL6(fn, a, b, c, d, e, f) \ + _x86_64_call6((fn), (uint64_t)(a), (uint64_t)(b), \ (uint64_t)(c), (uint64_t)(d), (uint64_t)(e), (uint64_t)(f)) #endif /* __amd64__ */
_______________________________________________ freebsd-net@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-net To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"