1 | /* $Id: memuserkernel-r0drv-solaris.c 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * IPRT - User & Kernel Memory, Ring-0 Driver, Solaris.
|
---|
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-solaris-kernel.h"
|
---|
42 | #include "internal/iprt.h"
|
---|
43 | #include <iprt/mem.h>
|
---|
44 |
|
---|
45 | #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
|
---|
46 | # include <iprt/asm-amd64-x86.h>
|
---|
47 | #endif
|
---|
48 | #include <iprt/assert.h>
|
---|
49 | #include <iprt/errcore.h>
|
---|
50 |
|
---|
51 |
|
---|
52 | RTR0DECL(int) RTR0MemUserCopyFrom(void *pvDst, RTR3PTR R3PtrSrc, size_t cb)
|
---|
53 | {
|
---|
54 | int rc;
|
---|
55 | RT_ASSERT_INTS_ON();
|
---|
56 |
|
---|
57 | rc = ddi_copyin((const char *)R3PtrSrc, pvDst, cb, 0 /*flags*/);
|
---|
58 | if (RT_LIKELY(rc == 0))
|
---|
59 | return VINF_SUCCESS;
|
---|
60 | return VERR_ACCESS_DENIED;
|
---|
61 | }
|
---|
62 |
|
---|
63 |
|
---|
64 | RTR0DECL(int) RTR0MemUserCopyTo(RTR3PTR R3PtrDst, void const *pvSrc, size_t cb)
|
---|
65 | {
|
---|
66 | int rc;
|
---|
67 | RT_ASSERT_INTS_ON();
|
---|
68 |
|
---|
69 | rc = ddi_copyout(pvSrc, (void *)R3PtrDst, cb, 0 /*flags*/);
|
---|
70 | if (RT_LIKELY(rc == 0))
|
---|
71 | return VINF_SUCCESS;
|
---|
72 | return VERR_ACCESS_DENIED;
|
---|
73 | }
|
---|
74 |
|
---|
75 |
|
---|
76 | RTR0DECL(bool) RTR0MemUserIsValidAddr(RTR3PTR R3Ptr)
|
---|
77 | {
|
---|
78 | return R3Ptr < kernelbase;
|
---|
79 | }
|
---|
80 |
|
---|
81 |
|
---|
82 | RTR0DECL(bool) RTR0MemKernelIsValidAddr(void *pv)
|
---|
83 | {
|
---|
84 | return (uintptr_t)pv >= kernelbase;
|
---|
85 | }
|
---|
86 |
|
---|
87 |
|
---|
88 | RTR0DECL(bool) RTR0MemAreKrnlAndUsrDifferent(void)
|
---|
89 | {
|
---|
90 | return true;
|
---|
91 | }
|
---|
92 |
|
---|
93 |
|
---|
94 | RTR0DECL(int) RTR0MemKernelCopyFrom(void *pvDst, void const *pvSrc, size_t cb)
|
---|
95 | {
|
---|
96 | int rc = kcopy(pvSrc, pvDst, cb);
|
---|
97 | if (RT_LIKELY(rc == 0))
|
---|
98 | return VINF_SUCCESS;
|
---|
99 | return VERR_ACCESS_DENIED;
|
---|
100 | }
|
---|
101 |
|
---|
102 |
|
---|
103 | RTR0DECL(int) RTR0MemKernelCopyTo(void *pvDst, void const *pvSrc, size_t cb)
|
---|
104 | {
|
---|
105 | int rc = kcopy(pvSrc, pvDst, cb);
|
---|
106 | if (RT_LIKELY(rc == 0))
|
---|
107 | return VINF_SUCCESS;
|
---|
108 | return VERR_ACCESS_DENIED;
|
---|
109 | }
|
---|
110 |
|
---|