VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/Support/freebsd/SUPDrv-freebsd.c@ 95087

Last change on this file since 95087 was 95087, checked in by vboxsync, 2 years ago

SUPDrv: bugref:10209: Added stubs for host FPU begin/end operations.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 19.3 KB
Line 
1/* $Id: SUPDrv-freebsd.c 95087 2022-05-25 05:56:47Z vboxsync $ */
2/** @file
3 * VBoxDrv - The VirtualBox Support Driver - FreeBSD specifics.
4 */
5
6/*
7 * Copyright (c) 2007 knut st. osmundsen <bird-src-spam@anduin.net>
8 *
9 * Permission is hereby granted, free of charge, to any person
10 * obtaining a copy of this software and associated documentation
11 * files (the "Software"), to deal in the Software without
12 * restriction, including without limitation the rights to use,
13 * copy, modify, merge, publish, distribute, sublicense, and/or sell
14 * copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following
16 * conditions:
17 *
18 * The above copyright notice and this permission notice shall be
19 * included in all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
23 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
26 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28 * OTHER DEALINGS IN THE SOFTWARE.
29 */
30
31
32/*********************************************************************************************************************************
33* Header Files *
34*********************************************************************************************************************************/
35#define LOG_GROUP LOG_GROUP_SUP_DRV
36/* Deal with conflicts first. */
37#include <sys/param.h>
38#undef PVM
39#include <sys/types.h>
40#include <sys/module.h>
41#include <sys/systm.h>
42#include <sys/errno.h>
43#include <sys/kernel.h>
44#include <sys/fcntl.h>
45#include <sys/conf.h>
46#include <sys/uio.h>
47#include <vm/pmap.h> /* for pmap_map() */
48
49#include "../SUPDrvInternal.h"
50#include <VBox/version.h>
51#include <iprt/initterm.h>
52#include <iprt/string.h>
53#include <iprt/spinlock.h>
54#include <iprt/process.h>
55#include <iprt/assert.h>
56#include <iprt/uuid.h>
57#include <VBox/log.h>
58#include <iprt/alloc.h>
59#include <iprt/err.h>
60#include <iprt/asm.h>
61
62#ifdef VBOX_WITH_HARDENING
63# define VBOXDRV_PERM 0600
64#else
65# define VBOXDRV_PERM 0666
66#endif
67
68
69/*********************************************************************************************************************************
70* Internal Functions *
71*********************************************************************************************************************************/
72static int VBoxDrvFreeBSDModuleEvent(struct module *pMod, int enmEventType, void *pvArg);
73static int VBoxDrvFreeBSDLoad(void);
74static int VBoxDrvFreeBSDUnload(void);
75
76static d_open_t VBoxDrvFreeBSDOpenUsr;
77static d_open_t VBoxDrvFreeBSDOpenSys;
78static void vboxdrvFreeBSDDtr(void *pvData);
79static d_ioctl_t VBoxDrvFreeBSDIOCtl;
80static int VBoxDrvFreeBSDIOCtlSlow(PSUPDRVSESSION pSession, u_long ulCmd, caddr_t pvData, struct thread *pTd);
81
82
83/*********************************************************************************************************************************
84* Global Variables *
85*********************************************************************************************************************************/
86/**
87 * Module info structure used by the kernel.
88 */
89static moduledata_t g_VBoxDrvFreeBSDModule =
90{
91 "vboxdrv",
92 VBoxDrvFreeBSDModuleEvent,
93 NULL
94};
95
96/** Declare the module as a pseudo device. */
97DECLARE_MODULE(vboxdrv, g_VBoxDrvFreeBSDModule, SI_SUB_PSEUDO, SI_ORDER_ANY);
98MODULE_VERSION(vboxdrv, 1);
99
100/**
101 * The /dev/vboxdrv character device entry points.
102 */
103static struct cdevsw g_VBoxDrvFreeBSDChrDevSwSys =
104{
105 .d_version = D_VERSION,
106 .d_open = VBoxDrvFreeBSDOpenSys,
107 .d_ioctl = VBoxDrvFreeBSDIOCtl,
108 .d_name = "vboxdrv"
109};
110/** The /dev/vboxdrv character device. */
111static struct cdev *g_pVBoxDrvFreeBSDChrDevSys;
112
113/**
114 * The /dev/vboxdrvu character device entry points.
115 */
116static struct cdevsw g_VBoxDrvFreeBSDChrDevSwUsr =
117{
118 .d_version = D_VERSION,
119 .d_open = VBoxDrvFreeBSDOpenUsr,
120 .d_ioctl = VBoxDrvFreeBSDIOCtl,
121 .d_name = "vboxdrvu"
122};
123/** The /dev/vboxdrvu character device. */
124static struct cdev *g_pVBoxDrvFreeBSDChrDevUsr;
125
126/** Reference counter. */
127static volatile uint32_t g_cUsers;
128
129/** The device extention. */
130static SUPDRVDEVEXT g_VBoxDrvFreeBSDDevExt;
131
132/**
133 * Module event handler.
134 *
135 * @param pMod The module structure.
136 * @param enmEventType The event type (modeventtype_t).
137 * @param pvArg Module argument. NULL.
138 *
139 * @return 0 on success, errno.h status code on failure.
140 */
141static int VBoxDrvFreeBSDModuleEvent(struct module *pMod, int enmEventType, void *pvArg)
142{
143 int rc;
144 switch (enmEventType)
145 {
146 case MOD_LOAD:
147 rc = VBoxDrvFreeBSDLoad();
148 break;
149
150 case MOD_UNLOAD:
151 mtx_unlock(&Giant);
152 rc = VBoxDrvFreeBSDUnload();
153 mtx_lock(&Giant);
154 break;
155
156 case MOD_SHUTDOWN:
157 case MOD_QUIESCE:
158 default:
159 return EOPNOTSUPP;
160 }
161
162 if (RT_SUCCESS(rc))
163 return 0;
164 return RTErrConvertToErrno(rc);
165}
166
167
168static int VBoxDrvFreeBSDLoad(void)
169{
170 g_cUsers = 0;
171
172 /*
173 * Initialize the runtime.
174 */
175 int rc = RTR0Init(0);
176 if (RT_SUCCESS(rc))
177 {
178 Log(("VBoxDrvFreeBSDLoad:\n"));
179
180 /*
181 * Initialize the device extension.
182 */
183 rc = supdrvInitDevExt(&g_VBoxDrvFreeBSDDevExt, sizeof(SUPDRVSESSION));
184 if (RT_SUCCESS(rc))
185 {
186 /*
187 * Configure character devices. Add symbolic links for compatibility.
188 */
189 g_pVBoxDrvFreeBSDChrDevSys = make_dev(&g_VBoxDrvFreeBSDChrDevSwSys, 0, UID_ROOT, GID_WHEEL, VBOXDRV_PERM, "vboxdrv");
190 g_pVBoxDrvFreeBSDChrDevUsr = make_dev(&g_VBoxDrvFreeBSDChrDevSwUsr, 1, UID_ROOT, GID_WHEEL, 0666, "vboxdrvu");
191 return VINF_SUCCESS;
192 }
193
194 printf("vboxdrv: supdrvInitDevExt failed, rc=%d\n", rc);
195 RTR0Term();
196 }
197 else
198 printf("vboxdrv: RTR0Init failed, rc=%d\n", rc);
199 return rc;
200}
201
202static int VBoxDrvFreeBSDUnload(void)
203{
204 Log(("VBoxDrvFreeBSDUnload:\n"));
205
206 if (g_cUsers > 0)
207 return VERR_RESOURCE_BUSY;
208
209 /*
210 * Reserve what we did in VBoxDrvFreeBSDInit.
211 */
212 destroy_dev(g_pVBoxDrvFreeBSDChrDevUsr);
213 destroy_dev(g_pVBoxDrvFreeBSDChrDevSys);
214
215 supdrvDeleteDevExt(&g_VBoxDrvFreeBSDDevExt);
216
217 RTR0TermForced();
218
219 memset(&g_VBoxDrvFreeBSDDevExt, 0, sizeof(g_VBoxDrvFreeBSDDevExt));
220 return VINF_SUCCESS;
221}
222
223
224/**
225 *
226 * @returns 0 on success, errno on failure.
227 * EBUSY if the device is used by someone else.
228 * @param pDev The device node.
229 * @param fOpen The open flags.
230 * @param iDevType Some device type thing we don't use.
231 * @param pTd The thread.
232 * @param fUnrestricted Set if opening /dev/vboxdrv, clear if /dev/vboxdrvu.
233 */
234static int vboxdrvFreeBSDOpenCommon(struct cdev *pDev, int fOpen, int iDevType, struct thread *pTd, bool fUnrestricted)
235{
236 PSUPDRVSESSION pSession;
237 int rc;
238
239 /*
240 * Let's be a bit picky about the flags...
241 */
242 if (fOpen != (FREAD | FWRITE /*=O_RDWR*/))
243 {
244 Log(("VBoxDrvFreeBSDOpen: fOpen=%#x expected %#x\n", fOpen, O_RDWR));
245 return EINVAL;
246 }
247
248 /*
249 * Create a new session.
250 */
251 rc = supdrvCreateSession(&g_VBoxDrvFreeBSDDevExt, true /* fUser */, fUnrestricted, &pSession);
252 if (RT_SUCCESS(rc))
253 {
254 /** @todo get (r)uid and (r)gid.
255 pSession->Uid = stuff;
256 pSession->Gid = stuff; */
257 rc = devfs_set_cdevpriv(pSession, vboxdrvFreeBSDDtr); Assert(rc == 0);
258 Log(("VBoxDrvFreeBSDOpen: pSession=%p\n", pSession));
259 ASMAtomicIncU32(&g_cUsers);
260 return 0;
261 }
262
263 return RTErrConvertToErrno(rc);
264}
265
266
267/** For vboxdrv. */
268static int VBoxDrvFreeBSDOpenSys(struct cdev *pDev, int fOpen, int iDevType, struct thread *pTd)
269{
270 return vboxdrvFreeBSDOpenCommon(pDev, fOpen, iDevType, pTd, true);
271}
272
273
274/** For vboxdrvu. */
275static int VBoxDrvFreeBSDOpenUsr(struct cdev *pDev, int fOpen, int iDevType, struct thread *pTd)
276{
277 return vboxdrvFreeBSDOpenCommon(pDev, fOpen, iDevType, pTd, false);
278}
279
280
281/**
282 * Close a file device previously opened by VBoxDrvFreeBSDOpen.
283 *
284 * @returns 0 on success.
285 * @param pvData The session being closed.
286 */
287static void vboxdrvFreeBSDDtr(void *pvData)
288{
289 PSUPDRVSESSION pSession = pvData;
290 Log(("vboxdrvFreeBSDDtr: pSession=%p\n", pSession));
291
292 /*
293 * Close the session.
294 */
295 supdrvSessionRelease(pSession);
296 ASMAtomicDecU32(&g_cUsers);
297}
298
299
300/**
301 * I/O control request.
302 *
303 * @returns depends...
304 * @param pDev The device.
305 * @param ulCmd The command.
306 * @param pvData Pointer to the data.
307 * @param fFile The file descriptor flags.
308 * @param pTd The calling thread.
309 */
310static int VBoxDrvFreeBSDIOCtl(struct cdev *pDev, u_long ulCmd, caddr_t pvData, int fFile, struct thread *pTd)
311{
312 PSUPDRVSESSION pSession;
313 devfs_get_cdevpriv((void **)&pSession);
314
315 /*
316 * Deal with the fast ioctl path first.
317 */
318 AssertCompile((SUP_IOCTL_FAST_DO_FIRST & 0xff) == (SUP_IOCTL_FLAG | 64));
319 if ( (uintptr_t)(ulCmd - SUP_IOCTL_FAST_DO_FIRST) < (uintptr_t)32
320 && pSession->fUnrestricted)
321 return supdrvIOCtlFast(ulCmd - SUP_IOCTL_FAST_DO_FIRST, *(uint32_t *)pvData, &g_VBoxDrvFreeBSDDevExt, pSession);
322
323 return VBoxDrvFreeBSDIOCtlSlow(pSession, ulCmd, pvData, pTd);
324}
325
326
327/**
328 * Deal with the 'slow' I/O control requests.
329 *
330 * @returns 0 on success, appropriate errno on failure.
331 * @param pSession The session.
332 * @param ulCmd The command.
333 * @param pvData The request data.
334 * @param pTd The calling thread.
335 */
336static int VBoxDrvFreeBSDIOCtlSlow(PSUPDRVSESSION pSession, u_long ulCmd, caddr_t pvData, struct thread *pTd)
337{
338 PSUPREQHDR pHdr;
339 uint32_t cbReq = IOCPARM_LEN(ulCmd);
340 void *pvUser = NULL;
341
342 /*
343 * Buffered request?
344 */
345 if ((IOC_DIRMASK & ulCmd) == IOC_INOUT)
346 {
347 pHdr = (PSUPREQHDR)pvData;
348 if (RT_UNLIKELY(cbReq < sizeof(*pHdr)))
349 {
350 OSDBGPRINT(("VBoxDrvFreeBSDIOCtlSlow: cbReq=%#x < %#x; ulCmd=%#lx\n", cbReq, (int)sizeof(*pHdr), ulCmd));
351 return EINVAL;
352 }
353 if (RT_UNLIKELY((pHdr->fFlags & SUPREQHDR_FLAGS_MAGIC_MASK) != SUPREQHDR_FLAGS_MAGIC))
354 {
355 OSDBGPRINT(("VBoxDrvFreeBSDIOCtlSlow: bad magic fFlags=%#x; ulCmd=%#lx\n", pHdr->fFlags, ulCmd));
356 return EINVAL;
357 }
358 if (RT_UNLIKELY( RT_MAX(pHdr->cbIn, pHdr->cbOut) != cbReq
359 || pHdr->cbIn < sizeof(*pHdr)
360 || pHdr->cbOut < sizeof(*pHdr)))
361 {
362 OSDBGPRINT(("VBoxDrvFreeBSDIOCtlSlow: max(%#x,%#x) != %#x; ulCmd=%#lx\n", pHdr->cbIn, pHdr->cbOut, cbReq, ulCmd));
363 return EINVAL;
364 }
365 }
366 /*
367 * Big unbuffered request?
368 */
369 else if ((IOC_DIRMASK & ulCmd) == IOC_VOID && !cbReq)
370 {
371 /*
372 * Read the header, validate it and figure out how much that needs to be buffered.
373 */
374 SUPREQHDR Hdr;
375 pvUser = *(void **)pvData;
376 int rc = copyin(pvUser, &Hdr, sizeof(Hdr));
377 if (RT_UNLIKELY(rc))
378 {
379 OSDBGPRINT(("VBoxDrvFreeBSDIOCtlSlow: copyin(%p,Hdr,) -> %#x; ulCmd=%#lx\n", pvUser, rc, ulCmd));
380 return rc;
381 }
382 if (RT_UNLIKELY((Hdr.fFlags & SUPREQHDR_FLAGS_MAGIC_MASK) != SUPREQHDR_FLAGS_MAGIC))
383 {
384 OSDBGPRINT(("VBoxDrvFreeBSDIOCtlSlow: bad magic fFlags=%#x; ulCmd=%#lx\n", Hdr.fFlags, ulCmd));
385 return EINVAL;
386 }
387 cbReq = RT_MAX(Hdr.cbIn, Hdr.cbOut);
388 if (RT_UNLIKELY( Hdr.cbIn < sizeof(Hdr)
389 || Hdr.cbOut < sizeof(Hdr)
390 || cbReq > _1M*16))
391 {
392 OSDBGPRINT(("VBoxDrvFreeBSDIOCtlSlow: max(%#x,%#x); ulCmd=%#lx\n", Hdr.cbIn, Hdr.cbOut, ulCmd));
393 return EINVAL;
394 }
395
396 /*
397 * Allocate buffer and copy in the data.
398 */
399 pHdr = (PSUPREQHDR)RTMemTmpAlloc(cbReq);
400 if (RT_UNLIKELY(!pHdr))
401 {
402 OSDBGPRINT(("VBoxDrvFreeBSDIOCtlSlow: failed to allocate buffer of %d bytes; ulCmd=%#lx\n", cbReq, ulCmd));
403 return ENOMEM;
404 }
405 rc = copyin(pvUser, pHdr, Hdr.cbIn);
406 if (RT_UNLIKELY(rc))
407 {
408 OSDBGPRINT(("VBoxDrvFreeBSDIOCtlSlow: copyin(%p,%p,%#x) -> %#x; ulCmd=%#lx\n",
409 pvUser, pHdr, Hdr.cbIn, rc, ulCmd));
410 RTMemTmpFree(pHdr);
411 return rc;
412 }
413 if (Hdr.cbIn < cbReq)
414 RT_BZERO((uint8_t *)pHdr + Hdr.cbIn, cbReq - Hdr.cbIn);
415 }
416 else
417 {
418 Log(("VBoxDrvFreeBSDIOCtlSlow: huh? cbReq=%#x ulCmd=%#lx\n", cbReq, ulCmd));
419 return EINVAL;
420 }
421
422 /*
423 * Process the IOCtl.
424 */
425 int rc = supdrvIOCtl(ulCmd, &g_VBoxDrvFreeBSDDevExt, pSession, pHdr, cbReq);
426 if (RT_LIKELY(!rc))
427 {
428 /*
429 * If unbuffered, copy back the result before returning.
430 */
431 if (pvUser)
432 {
433 uint32_t cbOut = pHdr->cbOut;
434 if (cbOut > cbReq)
435 {
436 OSDBGPRINT(("VBoxDrvFreeBSDIOCtlSlow: too much output! %#x > %#x; uCmd=%#lx!\n", cbOut, cbReq, ulCmd));
437 cbOut = cbReq;
438 }
439 rc = copyout(pHdr, pvUser, cbOut);
440 if (RT_UNLIKELY(rc))
441 OSDBGPRINT(("VBoxDrvFreeBSDIOCtlSlow: copyout(%p,%p,%#x) -> %d; uCmd=%#lx!\n", pHdr, pvUser, cbOut, rc, ulCmd));
442
443 Log(("VBoxDrvFreeBSDIOCtlSlow: returns %d / %d ulCmd=%lx\n", 0, pHdr->rc, ulCmd));
444
445 /* cleanup */
446 RTMemTmpFree(pHdr);
447 }
448 }
449 else
450 {
451 /*
452 * The request failed, just clean up.
453 */
454 if (pvUser)
455 RTMemTmpFree(pHdr);
456
457 Log(("VBoxDrvFreeBSDIOCtlSlow: ulCmd=%lx pData=%p failed, rc=%d\n", ulCmd, pvData, rc));
458 rc = EINVAL;
459 }
460
461 return rc;
462}
463
464
465/**
466 * The SUPDRV IDC entry point.
467 *
468 * @returns VBox status code, see supdrvIDC.
469 * @param uReq The request code.
470 * @param pReq The request.
471 */
472int VBOXCALL SUPDrvFreeBSDIDC(uint32_t uReq, PSUPDRVIDCREQHDR pReq)
473{
474 PSUPDRVSESSION pSession;
475
476 /*
477 * Some quick validations.
478 */
479 if (RT_UNLIKELY(!RT_VALID_PTR(pReq)))
480 return VERR_INVALID_POINTER;
481
482 pSession = pReq->pSession;
483 if (pSession)
484 {
485 if (RT_UNLIKELY(!RT_VALID_PTR(pReq->pSession)))
486 return VERR_INVALID_PARAMETER;
487 if (RT_UNLIKELY(pSession->pDevExt != &g_VBoxDrvFreeBSDDevExt))
488 return VERR_INVALID_PARAMETER;
489 }
490 else if (RT_UNLIKELY(uReq != SUPDRV_IDC_REQ_CONNECT))
491 return VERR_INVALID_PARAMETER;
492
493 /*
494 * Do the job.
495 */
496 return supdrvIDC(uReq, &g_VBoxDrvFreeBSDDevExt, pSession, pReq);
497}
498
499
500void VBOXCALL supdrvOSCleanupSession(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession)
501{
502 NOREF(pDevExt);
503 NOREF(pSession);
504}
505
506
507void VBOXCALL supdrvOSSessionHashTabInserted(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, void *pvUser)
508{
509 NOREF(pDevExt); NOREF(pSession); NOREF(pvUser);
510}
511
512
513void VBOXCALL supdrvOSSessionHashTabRemoved(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, void *pvUser)
514{
515 NOREF(pDevExt); NOREF(pSession); NOREF(pvUser);
516}
517
518
519void VBOXCALL supdrvOSObjInitCreator(PSUPDRVOBJ pObj, PSUPDRVSESSION pSession)
520{
521 NOREF(pObj);
522 NOREF(pSession);
523}
524
525
526bool VBOXCALL supdrvOSObjCanAccess(PSUPDRVOBJ pObj, PSUPDRVSESSION pSession, const char *pszObjName, int *prc)
527{
528 NOREF(pObj);
529 NOREF(pSession);
530 NOREF(pszObjName);
531 NOREF(prc);
532 return false;
533}
534
535
536bool VBOXCALL supdrvOSGetForcedAsyncTscMode(PSUPDRVDEVEXT pDevExt)
537{
538 return false;
539}
540
541
542bool VBOXCALL supdrvOSAreCpusOfflinedOnSuspend(void)
543{
544 /** @todo verify this. */
545 return false;
546}
547
548
549bool VBOXCALL supdrvOSAreTscDeltasInSync(void)
550{
551 return false;
552}
553
554
555int VBOXCALL supdrvOSLdrOpen(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, const char *pszFilename)
556{
557 NOREF(pDevExt); NOREF(pImage); NOREF(pszFilename);
558 return VERR_NOT_SUPPORTED;
559}
560
561
562int VBOXCALL supdrvOSLdrValidatePointer(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, void *pv,
563 const uint8_t *pbImageBits, const char *pszSymbol)
564{
565 NOREF(pDevExt); NOREF(pImage); NOREF(pv); NOREF(pbImageBits); NOREF(pszSymbol);
566 return VERR_NOT_SUPPORTED;
567}
568
569
570int VBOXCALL supdrvOSLdrLoad(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, const uint8_t *pbImageBits, PSUPLDRLOAD pReq)
571{
572 NOREF(pDevExt); NOREF(pImage); NOREF(pbImageBits); NOREF(pReq);
573 return VERR_NOT_SUPPORTED;
574}
575
576
577void VBOXCALL supdrvOSLdrUnload(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage)
578{
579 NOREF(pDevExt); NOREF(pImage);
580}
581
582
583void VBOXCALL supdrvOSLdrNotifyOpened(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, const char *pszFilename)
584{
585 NOREF(pDevExt); NOREF(pImage); NOREF(pszFilename);
586}
587
588
589void VBOXCALL supdrvOSLdrNotifyUnloaded(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage)
590{
591 NOREF(pDevExt); NOREF(pImage);
592}
593
594
595int VBOXCALL supdrvOSLdrQuerySymbol(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage,
596 const char *pszSymbol, size_t cchSymbol, void **ppvSymbol)
597{
598 RT_NOREF(pDevExt, pImage, pszSymbol, cchSymbol, ppvSymbol);
599 return VERR_WRONG_ORDER;
600}
601
602
603void VBOXCALL supdrvOSLdrRetainWrapperModule(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage)
604{
605 RT_NOREF(pDevExt, pImage);
606 AssertFailed();
607}
608
609
610void VBOXCALL supdrvOSLdrReleaseWrapperModule(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage)
611{
612 RT_NOREF(pDevExt, pImage);
613 AssertFailed();
614}
615
616#ifdef SUPDRV_WITH_MSR_PROBER
617
618int VBOXCALL supdrvOSMsrProberRead(uint32_t uMsr, RTCPUID idCpu, uint64_t *puValue)
619{
620 NOREF(uMsr); NOREF(idCpu); NOREF(puValue);
621 return VERR_NOT_SUPPORTED;
622}
623
624
625int VBOXCALL supdrvOSMsrProberWrite(uint32_t uMsr, RTCPUID idCpu, uint64_t uValue)
626{
627 NOREF(uMsr); NOREF(idCpu); NOREF(uValue);
628 return VERR_NOT_SUPPORTED;
629}
630
631
632int VBOXCALL supdrvOSMsrProberModify(RTCPUID idCpu, PSUPMSRPROBER pReq)
633{
634 NOREF(idCpu); NOREF(pReq);
635 return VERR_NOT_SUPPORTED;
636}
637
638#endif /* SUPDRV_WITH_MSR_PROBER */
639
640
641#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_ARM64)
642SUPR0DECL(int) SUPR0HCPhysToVirt(RTHCPHYS HCPhys, void **ppv)
643{
644 AssertReturn(!(HCPhys & PAGE_OFFSET_MASK), VERR_INVALID_POINTER);
645 AssertReturn(HCPhys != NIL_RTHCPHYS, VERR_INVALID_POINTER);
646 *ppv = (void *)(uintptr_t)pmap_map(NULL, HCPhys, (HCPhys | PAGE_OFFSET_MASK) + 1, VM_PROT_WRITE | VM_PROT_READ);
647 return VINF_SUCCESS;
648}
649#endif
650
651
652SUPR0DECL(int) SUPR0PrintfV(const char *pszFormat, va_list va)
653{
654 char szMsg[256];
655 RTStrPrintfV(szMsg, sizeof(szMsg), pszFormat, va);
656 szMsg[sizeof(szMsg) - 1] = '\0';
657
658 printf("%s", szMsg);
659 return 0;
660}
661
662
663SUPR0DECL(uint32_t) SUPR0GetKernelFeatures(void)
664{
665 return 0;
666}
667
668
669SUPR0DECL(bool) SUPR0FpuBegin(bool fCtxHook)
670{
671 RT_NOREF(fCtxHook);
672 return false;
673}
674
675
676SUPR0DECL(void) SUPR0FpuEnd(bool fCtxHook)
677{
678 RT_NOREF(fCtxHook);
679}
680
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use