FreeBSD Bugzilla – Attachment 122421 Details for
Bug 165622
[ndis][panic][patch] Unregistered use of FPU in kernel on amd64
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
fpu_patch2.txt
fpu_patch2.txt (text/plain; charset=US-ASCII), 6.39 KB, created by
Vladyslav Movchan
on 2012-03-12 15:20:53 UTC
(
hide
)
Description:
fpu_patch2.txt
Filename:
MIME Type:
Creator:
Vladyslav Movchan
Created:
2012-03-12 15:20:53 UTC
Size:
6.39 KB
patch
obsolete
>Index: /usr/src/sys/compat/ndis/pe_var.h >=================================================================== >--- /usr/src/sys/compat/ndis/pe_var.h (revision 232379) >+++ /usr/src/sys/compat/ndis/pe_var.h (working copy) >@@ -460,22 +460,30 @@ > extern uint64_t x86_64_call6(void *, uint64_t, uint64_t, uint64_t, uint64_t, > uint64_t, uint64_t); > >+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)) >+ _x86_64_call1((fn), (uint64_t)(a)) > #define MSCALL2(fn, a, b) \ >- x86_64_call2((fn), (uint64_t)(a), (uint64_t)(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), \ >+ _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), \ >+ _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), \ >+ _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), \ >+ _x86_64_call6((fn), (uint64_t)(a), (uint64_t)(b), \ > (uint64_t)(c), (uint64_t)(d), (uint64_t)(e), (uint64_t)(f)) > > #endif /* __amd64__ */ >Index: /usr/src/sys/compat/ndis/kern_windrv.c >=================================================================== >--- /usr/src/sys/compat/ndis/kern_windrv.c (revision 232379) >+++ /usr/src/sys/compat/ndis/kern_windrv.c (working copy) >@@ -56,6 +56,10 @@ > #include <machine/segments.h> > #endif > >+#ifdef __amd64__ >+#include <machine/fpu.h> >+#endif >+ > #include <dev/usb/usb.h> > > #include <compat/ndis/pe_var.h> >@@ -66,6 +70,16 @@ > #include <compat/ndis/hal_var.h> > #include <compat/ndis/usbd_var.h> > >+#ifdef __amd64__ >+struct fpu_cc_ent { >+ char used; >+ struct fpu_kern_ctx *ctx; >+ SLIST_ENTRY(fpu_cc_ent) link; >+}; >+static SLIST_HEAD(fpu_ctx_cache, fpu_cc_ent) fpu_cc_head; >+static struct mtx fpu_cache_mtx; >+#endif >+ > static struct mtx drvdb_mtx; > static STAILQ_HEAD(drvdb, drvdb_ent) drvdb_head; > >@@ -96,6 +110,11 @@ > mtx_init(&drvdb_mtx, "Windows driver DB lock", > "Windows internal lock", MTX_DEF); > >+#ifdef __amd64__ >+ SLIST_INIT(&fpu_cc_head); >+ mtx_init(&fpu_cache_mtx, "fpu context cache lock", NULL, MTX_DEF); >+#endif >+ > /* > * PCI and pccard devices don't need to use IRPs to > * interact with their bus drivers (usually), so our >@@ -130,6 +149,9 @@ > windrv_libfini(void) > { > struct drvdb_ent *d; >+#ifdef __amd64__ >+ struct fpu_cc_ent *ent; >+#endif > > mtx_lock(&drvdb_mtx); > while(STAILQ_FIRST(&drvdb_head) != NULL) { >@@ -148,6 +170,15 @@ > smp_rendezvous(NULL, x86_oldldt, NULL, NULL); > ExFreePool(my_tids); > #endif >+#ifdef __amd64__ >+ while ((ent = SLIST_FIRST(&fpu_cc_head)) != NULL) { >+ SLIST_REMOVE_HEAD(&fpu_cc_head, link); >+ fpu_kern_free_ctx(ent->ctx); >+ free(ent, M_DEVBUF); >+ } >+ >+ mtx_destroy(&fpu_cache_mtx); >+#endif > return (0); > } > >@@ -573,6 +604,141 @@ > return (0); > } > >+static struct fpu_cc_ent * >+request_fpu_cc_ent(void) >+{ >+ struct fpu_cc_ent *ent; >+ >+ mtx_lock(&fpu_cache_mtx); >+ SLIST_FOREACH(ent, &fpu_cc_head, link) { >+ if(ent->used == 0) { >+ ent->used = 1; >+ mtx_unlock(&fpu_cache_mtx); >+ return (ent); >+ } >+ } >+ mtx_unlock(&fpu_cache_mtx); >+ >+ if ((ent = malloc(sizeof(struct fpu_cc_ent), M_DEVBUF, M_NOWAIT | >+ M_ZERO)) != NULL) { >+ ent->ctx = fpu_kern_alloc_ctx(FPU_KERN_NORMAL | >+ FPU_KERN_NOWAIT); >+ if (ent->ctx != NULL) { >+ ent->used = 1; >+ mtx_lock(&fpu_cache_mtx); >+ SLIST_INSERT_HEAD(&fpu_cc_head, ent, link); >+ mtx_unlock(&fpu_cache_mtx); >+ } else >+ free(ent, M_DEVBUF); >+ } >+ >+ return (ent); >+} >+ >+static void >+release_fpu_cc_ent(struct fpu_cc_ent *ent) >+{ >+ >+ ent->used = 0; >+} >+ >+uint64_t >+_x86_64_call1(void *fn, uint64_t a) >+{ >+ struct fpu_cc_ent *ent; >+ uint64_t ret; >+ >+ if ((ent = request_fpu_cc_ent()) == NULL) >+ return (ENOMEM); >+ fpu_kern_enter(curthread, ent->ctx, FPU_KERN_NORMAL); >+ ret = x86_64_call1(fn, a); >+ fpu_kern_leave(curthread, ent->ctx); >+ release_fpu_cc_ent(ent); >+ >+ return (ret); >+} >+ >+uint64_t >+_x86_64_call2(void *fn, uint64_t a, uint64_t b) >+{ >+ struct fpu_cc_ent *ent; >+ uint64_t ret; >+ >+ if ((ent = request_fpu_cc_ent()) == NULL) >+ return (ENOMEM); >+ fpu_kern_enter(curthread, ent->ctx, FPU_KERN_NORMAL); >+ ret = x86_64_call2(fn, a, b); >+ fpu_kern_leave(curthread, ent->ctx); >+ release_fpu_cc_ent(ent); >+ >+ return (ret); >+} >+ >+uint64_t >+_x86_64_call3(void *fn, uint64_t a, uint64_t b, uint64_t c) >+{ >+ struct fpu_cc_ent *ent; >+ uint64_t ret; >+ >+ if ((ent = request_fpu_cc_ent()) == NULL) >+ return (ENOMEM); >+ fpu_kern_enter(curthread, ent->ctx, FPU_KERN_NORMAL); >+ ret = x86_64_call3(fn, a, b, c); >+ fpu_kern_leave(curthread, ent->ctx); >+ release_fpu_cc_ent(ent); >+ >+ return (ret); >+} >+ >+uint64_t >+_x86_64_call4(void *fn, uint64_t a, uint64_t b, uint64_t c, uint64_t d) >+{ >+ struct fpu_cc_ent *ent; >+ uint64_t ret; >+ >+ if ((ent = request_fpu_cc_ent()) == NULL) >+ return (ENOMEM); >+ fpu_kern_enter(curthread, ent->ctx, FPU_KERN_NORMAL); >+ ret = x86_64_call4(fn, a, b, c, d); >+ fpu_kern_leave(curthread, ent->ctx); >+ release_fpu_cc_ent(ent); >+ >+ 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_cc_ent *ent; >+ uint64_t ret; >+ >+ if ((ent = request_fpu_cc_ent()) == NULL) >+ return (ENOMEM); >+ fpu_kern_enter(curthread, ent->ctx, FPU_KERN_NORMAL); >+ ret = x86_64_call5(fn, a, b, c, d, e); >+ fpu_kern_leave(curthread, ent->ctx); >+ release_fpu_cc_ent(ent); >+ >+ 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_cc_ent *ent; >+ uint64_t ret; >+ >+ if ((ent = request_fpu_cc_ent()) == NULL) >+ return (ENOMEM); >+ fpu_kern_enter(curthread, ent->ctx, FPU_KERN_NORMAL); >+ ret = x86_64_call6(fn, a, b, c, d, e, f); >+ fpu_kern_leave(curthread, ent->ctx); >+ release_fpu_cc_ent(ent); >+ >+ return (ret); >+} > #ifdef __amd64__ > > extern void x86_64_wrap(void);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 165622
:
122420
|
122421
|
122422
|
153770