VirtualBox

source: vbox/trunk/src/VBox/Runtime/r0drv/darwin/memuserkernel-r0drv-darwin.cpp@ 98263

Last change on this file since 98263 was 98103, checked in by vboxsync, 23 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.7 KB
Line 
1/* $Id: memuserkernel-r0drv-darwin.cpp 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * IPRT - User & Kernel Memory, Ring-0 Driver, Darwin.
4 */
5
6/*
7 * Copyright (C) 2009-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * The contents of this file may alternatively be used under the terms
26 * of the Common Development and Distribution License Version 1.0
27 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28 * in the VirtualBox distribution, in which case the provisions of the
29 * CDDL are applicable instead of those of the GPL.
30 *
31 * You may elect to license modified versions of this file under the
32 * terms and conditions of either the GPL or the CDDL or both.
33 *
34 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35 */
36
37
38/*********************************************************************************************************************************
39* Header Files *
40*********************************************************************************************************************************/
41#include "the-darwin-kernel.h"
42#include "internal/iprt.h"
43#include <iprt/mem.h>
44#include <iprt/assert.h>
45
46#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
47# include <iprt/asm-amd64-x86.h>
48#endif
49#include <iprt/errcore.h>
50
51
52RTR0DECL(int) RTR0MemUserCopyFrom(void *pvDst, RTR3PTR R3PtrSrc, size_t cb)
53{
54 RT_ASSERT_INTS_ON();
55 IPRT_DARWIN_SAVE_EFL_AC();
56 int rc = copyin((const user_addr_t)R3PtrSrc, pvDst, cb);
57 IPRT_DARWIN_RESTORE_EFL_AC();
58 if (RT_LIKELY(rc == 0))
59 return VINF_SUCCESS;
60 return VERR_ACCESS_DENIED;
61}
62
63
64RTR0DECL(int) RTR0MemUserCopyTo(RTR3PTR R3PtrDst, void const *pvSrc, size_t cb)
65{
66 RT_ASSERT_INTS_ON();
67 IPRT_DARWIN_SAVE_EFL_AC();
68 int rc = copyout(pvSrc, R3PtrDst, cb);
69 IPRT_DARWIN_RESTORE_EFL_AC();
70 if (RT_LIKELY(rc == 0))
71 return VINF_SUCCESS;
72 return VERR_ACCESS_DENIED;
73}
74
75
76RTR0DECL(bool) RTR0MemUserIsValidAddr(RTR3PTR R3Ptr)
77{
78 /* the commpage is above this. */
79#ifdef RT_ARCH_X86
80 return R3Ptr < VM_MAX_ADDRESS;
81#else
82 return R3Ptr < VM_MAX_PAGE_ADDRESS;
83#endif
84}
85
86
87RTR0DECL(bool) RTR0MemKernelIsValidAddr(void *pv)
88{
89 /* Found no public #define or symbol for checking this, so we'll
90 have to make do with thing found in the debugger and the sources. */
91#ifdef RT_ARCH_X86
92 NOREF(pv);
93 return true; /* Almost anything is a valid kernel address here. */
94
95#elif defined(RT_ARCH_AMD64)
96 return (uintptr_t)pv >= UINT64_C(0xffff800000000000);
97
98#else
99# error "PORTME"
100#endif
101}
102
103
104RTR0DECL(bool) RTR0MemAreKrnlAndUsrDifferent(void)
105{
106 /* As mentioned in RTR0MemKernelIsValidAddr, found no way of checking
107 this at compiler or runtime. */
108#ifdef RT_ARCH_X86
109 return false;
110#else
111 return true;
112#endif
113}
114
115
116RTR0DECL(int) RTR0MemKernelCopyFrom(void *pvDst, void const *pvSrc, size_t cb)
117{
118 RT_NOREF(pvDst, pvSrc, cb);
119 return VERR_NOT_SUPPORTED;
120}
121
122
123RTR0DECL(int) RTR0MemKernelCopyTo(void *pvDst, void const *pvSrc, size_t cb)
124{
125 RT_NOREF(pvDst, pvSrc, cb);
126 return VERR_NOT_SUPPORTED;
127}
128
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette