1 | /* $Id: IEMAll-armv8.cpp 108791 2025-03-28 21:58:31Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * IEM - Interpreted Execution Manager - ARMv8 target, miscellaneous.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2011-2024 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 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 |
|
---|
29 | /*********************************************************************************************************************************
|
---|
30 | * Header Files *
|
---|
31 | *********************************************************************************************************************************/
|
---|
32 | #define LOG_GROUP LOG_GROUP_IEM
|
---|
33 | #define VMCPU_INCL_CPUM_GST_CTX
|
---|
34 | #include <VBox/vmm/iem.h>
|
---|
35 | #include <VBox/vmm/cpum.h>
|
---|
36 | #include <VBox/vmm/dbgf.h>
|
---|
37 | #include "IEMInternal.h"
|
---|
38 | #include <VBox/vmm/vmcc.h>
|
---|
39 | #include <VBox/log.h>
|
---|
40 | #include <iprt/assert.h>
|
---|
41 | #include <iprt/armv8.h>
|
---|
42 |
|
---|
43 |
|
---|
44 |
|
---|
45 | /**
|
---|
46 | * Slow iemCalcExecDbgFlags() code path.
|
---|
47 | */
|
---|
48 | uint32_t iemCalcExecDbgFlagsSlow(PVMCPUCC pVCpu)
|
---|
49 | {
|
---|
50 | uint32_t fExec = 0;
|
---|
51 |
|
---|
52 | #if 0 /** @todo ARM hardware breakpoints/watchpoints. */
|
---|
53 | /*
|
---|
54 | * Helper for invalidate the data TLB for breakpoint addresses.
|
---|
55 | *
|
---|
56 | * This is to make sure any access to the page will always trigger a TLB
|
---|
57 | * load for as long as the breakpoint is enabled.
|
---|
58 | */
|
---|
59 | #ifdef IEM_WITH_DATA_TLB
|
---|
60 | # define INVALID_TLB_ENTRY_FOR_BP(a_uValue) do { \
|
---|
61 | RTGCPTR uTagNoRev = (a_uValue); \
|
---|
62 | uTagNoRev = IEMTLB_CALC_TAG_NO_REV(pVCpu, uTagNoRev); \
|
---|
63 | /** @todo do large page accounting */ \
|
---|
64 | uintptr_t const idxEven = IEMTLB_TAG_TO_EVEN_INDEX(uTagNoRev); \
|
---|
65 | if (pVCpu->iem.s.DataTlb.aEntries[idxEven].uTag == (uTagNoRev | pVCpu->iem.s.DataTlb.uTlbRevision)) \
|
---|
66 | pVCpu->iem.s.DataTlb.aEntries[idxEven].uTag = 0; \
|
---|
67 | if (pVCpu->iem.s.DataTlb.aEntries[idxEven + 1].uTag == (uTagNoRev | pVCpu->iem.s.DataTlb.uTlbRevisionGlobal)) \
|
---|
68 | pVCpu->iem.s.DataTlb.aEntries[idxEven + 1].uTag = 0; \
|
---|
69 | } while (0)
|
---|
70 | #else
|
---|
71 | # define INVALID_TLB_ENTRY_FOR_BP(a_uValue) do { } while (0)
|
---|
72 | #endif
|
---|
73 |
|
---|
74 | /*
|
---|
75 | * Process guest breakpoints.
|
---|
76 | */
|
---|
77 | #define PROCESS_ONE_BP(a_fDr7, a_iBp, a_uValue) do { \
|
---|
78 | if (a_fDr7 & X86_DR7_L_G(a_iBp)) \
|
---|
79 | { \
|
---|
80 | switch (X86_DR7_GET_RW(a_fDr7, a_iBp)) \
|
---|
81 | { \
|
---|
82 | case X86_DR7_RW_EO: \
|
---|
83 | fExec |= IEM_F_PENDING_BRK_INSTR; \
|
---|
84 | break; \
|
---|
85 | case X86_DR7_RW_WO: \
|
---|
86 | case X86_DR7_RW_RW: \
|
---|
87 | fExec |= IEM_F_PENDING_BRK_DATA; \
|
---|
88 | INVALID_TLB_ENTRY_FOR_BP(a_uValue); \
|
---|
89 | break; \
|
---|
90 | case X86_DR7_RW_IO: \
|
---|
91 | fExec |= IEM_F_PENDING_BRK_X86_IO; \
|
---|
92 | break; \
|
---|
93 | } \
|
---|
94 | } \
|
---|
95 | } while (0)
|
---|
96 |
|
---|
97 | uint32_t const fGstDr7 = (uint32_t)pVCpu->cpum.GstCtx.dr[7];
|
---|
98 | if (fGstDr7 & X86_DR7_ENABLED_MASK)
|
---|
99 | {
|
---|
100 | /** @todo extract more details here to simplify matching later. */
|
---|
101 | #ifdef IEM_WITH_DATA_TLB
|
---|
102 | IEM_CTX_IMPORT_NORET(pVCpu, CPUMCTX_EXTRN_DR0_DR3);
|
---|
103 | #endif
|
---|
104 | PROCESS_ONE_BP(fGstDr7, 0, pVCpu->cpum.GstCtx.dr[0]);
|
---|
105 | PROCESS_ONE_BP(fGstDr7, 1, pVCpu->cpum.GstCtx.dr[1]);
|
---|
106 | PROCESS_ONE_BP(fGstDr7, 2, pVCpu->cpum.GstCtx.dr[2]);
|
---|
107 | PROCESS_ONE_BP(fGstDr7, 3, pVCpu->cpum.GstCtx.dr[3]);
|
---|
108 | }
|
---|
109 |
|
---|
110 | /*
|
---|
111 | * Process hypervisor breakpoints.
|
---|
112 | */
|
---|
113 | PVMCC const pVM = pVCpu->CTX_SUFF(pVM);
|
---|
114 | uint32_t const fHyperDr7 = DBGFBpGetDR7(pVM);
|
---|
115 | if (fHyperDr7 & X86_DR7_ENABLED_MASK)
|
---|
116 | {
|
---|
117 | /** @todo extract more details here to simplify matching later. */
|
---|
118 | PROCESS_ONE_BP(fHyperDr7, 0, DBGFBpGetDR0(pVM));
|
---|
119 | PROCESS_ONE_BP(fHyperDr7, 1, DBGFBpGetDR1(pVM));
|
---|
120 | PROCESS_ONE_BP(fHyperDr7, 2, DBGFBpGetDR2(pVM));
|
---|
121 | PROCESS_ONE_BP(fHyperDr7, 3, DBGFBpGetDR3(pVM));
|
---|
122 | }
|
---|
123 | #else
|
---|
124 | RT_NOREF(pVCpu);
|
---|
125 | #endif
|
---|
126 |
|
---|
127 | return fExec;
|
---|
128 | }
|
---|
129 |
|
---|