Changeset 109189 in vbox
- Timestamp:
- May 7, 2025 11:24:03 AM (21 hours ago)
- svn:sync-xref-src-repo-rev:
- 168758
- Location:
- trunk
- Files:
-
- 1 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR3/CPUM-armv8.cpp
r108968 r109189 48 48 #define CPUM_WITH_NONCONST_HOST_FEATURES 49 49 #include <VBox/vmm/cpum.h> 50 #include <VBox/vmm/cpumdis.h>51 50 #include <VBox/vmm/pgm.h> 52 51 #include <VBox/vmm/mm.h> -
trunk/src/VBox/VMM/VMMR3/CPUM.cpp
r107807 r109189 119 119 #define CPUM_WITH_NONCONST_HOST_FEATURES 120 120 #include <VBox/vmm/cpum.h> 121 #include <VBox/vmm/cpumdis.h>122 121 #include <VBox/vmm/cpumctx-v1_6.h> 123 122 #include <VBox/vmm/pgm.h> … … 5163 5162 5164 5163 /** 5165 * Structure used when disassembling and instructions in DBGF.5166 * This is used so the reader function can get the stuff it needs.5167 */5168 typedef struct CPUMDISASSTATE5169 {5170 /** Pointer to the CPU structure. */5171 PDISSTATE pDis;5172 /** Pointer to the VM. */5173 PVM pVM;5174 /** Pointer to the VMCPU. */5175 PVMCPU pVCpu;5176 /** Pointer to the first byte in the segment. */5177 RTGCUINTPTR GCPtrSegBase;5178 /** Pointer to the byte after the end of the segment. (might have wrapped!) */5179 RTGCUINTPTR GCPtrSegEnd;5180 /** The size of the segment minus 1. */5181 RTGCUINTPTR cbSegLimit;5182 /** Pointer to the current page - R3 Ptr. */5183 void const *pvPageR3;5184 /** Pointer to the current page - GC Ptr. */5185 RTGCPTR pvPageGC;5186 /** The lock information that PGMPhysReleasePageMappingLock needs. */5187 PGMPAGEMAPLOCK PageMapLock;5188 /** Whether the PageMapLock is valid or not. */5189 bool fLocked;5190 /** 64 bits mode or not. */5191 bool f64Bits;5192 } CPUMDISASSTATE, *PCPUMDISASSTATE;5193 5194 5195 /**5196 * @callback_method_impl{FNDISREADBYTES}5197 */5198 static DECLCALLBACK(int) cpumR3DisasInstrRead(PDISSTATE pDis, uint8_t offInstr, uint8_t cbMinRead, uint8_t cbMaxRead)5199 {5200 PCPUMDISASSTATE pState = (PCPUMDISASSTATE)pDis->pvUser;5201 for (;;)5202 {5203 RTGCUINTPTR GCPtr = pDis->uInstrAddr + offInstr + pState->GCPtrSegBase;5204 5205 /*5206 * Need to update the page translation?5207 */5208 if ( !pState->pvPageR35209 || (GCPtr >> GUEST_PAGE_SHIFT) != (pState->pvPageGC >> GUEST_PAGE_SHIFT))5210 {5211 /* translate the address */5212 pState->pvPageGC = GCPtr & ~(RTGCPTR)GUEST_PAGE_OFFSET_MASK;5213 5214 /* Release mapping lock previously acquired. */5215 if (pState->fLocked)5216 PGMPhysReleasePageMappingLock(pState->pVM, &pState->PageMapLock);5217 int rc = PGMPhysGCPtr2CCPtrReadOnly(pState->pVCpu, pState->pvPageGC, &pState->pvPageR3, &pState->PageMapLock);5218 if (RT_SUCCESS(rc))5219 pState->fLocked = true;5220 else5221 {5222 pState->fLocked = false;5223 pState->pvPageR3 = NULL;5224 return rc;5225 }5226 }5227 5228 /*5229 * Check the segment limit.5230 */5231 if (!pState->f64Bits && pDis->uInstrAddr + offInstr > pState->cbSegLimit)5232 return VERR_OUT_OF_SELECTOR_BOUNDS;5233 5234 /*5235 * Calc how much we can read.5236 */5237 uint32_t cb = GUEST_PAGE_SIZE - (GCPtr & GUEST_PAGE_OFFSET_MASK);5238 if (!pState->f64Bits)5239 {5240 RTGCUINTPTR cbSeg = pState->GCPtrSegEnd - GCPtr;5241 if (cb > cbSeg && cbSeg)5242 cb = cbSeg;5243 }5244 if (cb > cbMaxRead)5245 cb = cbMaxRead;5246 5247 /*5248 * Read and advance or exit.5249 */5250 memcpy(&pDis->Instr.ab[offInstr], (uint8_t *)pState->pvPageR3 + (GCPtr & GUEST_PAGE_OFFSET_MASK), cb);5251 offInstr += (uint8_t)cb;5252 if (cb >= cbMinRead)5253 {5254 pDis->cbCachedInstr = offInstr;5255 return VINF_SUCCESS;5256 }5257 cbMinRead -= (uint8_t)cb;5258 cbMaxRead -= (uint8_t)cb;5259 }5260 }5261 5262 5263 /**5264 * Disassemble an instruction and return the information in the provided structure.5265 *5266 * @returns VBox status code.5267 * @param pVM The cross context VM structure.5268 * @param pVCpu The cross context virtual CPU structure.5269 * @param pCtx Pointer to the guest CPU context.5270 * @param GCPtrPC Program counter (relative to CS) to disassemble from.5271 * @param pDis Disassembly state.5272 * @param pszPrefix String prefix for logging (debug only).5273 *5274 */5275 VMMR3DECL(int) CPUMR3DisasmInstrCPU(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx, RTGCPTR GCPtrPC, PDISSTATE pDis,5276 const char *pszPrefix)5277 {5278 CPUMDISASSTATE State;5279 int rc;5280 5281 const PGMMODE enmMode = PGMGetGuestMode(pVCpu);5282 State.pDis = pDis;5283 State.pvPageGC = 0;5284 State.pvPageR3 = NULL;5285 State.pVM = pVM;5286 State.pVCpu = pVCpu;5287 State.fLocked = false;5288 State.f64Bits = false;5289 5290 /*5291 * Get selector information.5292 */5293 DISCPUMODE enmDisCpuMode;5294 if ( (pCtx->cr0 & X86_CR0_PE)5295 && pCtx->eflags.Bits.u1VM == 0)5296 {5297 if (!CPUMSELREG_ARE_HIDDEN_PARTS_VALID(pVCpu, &pCtx->cs))5298 return VERR_CPUM_HIDDEN_CS_LOAD_ERROR;5299 State.f64Bits = enmMode >= PGMMODE_AMD64 && pCtx->cs.Attr.n.u1Long;5300 State.GCPtrSegBase = pCtx->cs.u64Base;5301 State.GCPtrSegEnd = pCtx->cs.u32Limit + 1 + (RTGCUINTPTR)pCtx->cs.u64Base;5302 State.cbSegLimit = pCtx->cs.u32Limit;5303 enmDisCpuMode = (State.f64Bits)5304 ? DISCPUMODE_64BIT5305 : pCtx->cs.Attr.n.u1DefBig5306 ? DISCPUMODE_32BIT5307 : DISCPUMODE_16BIT;5308 }5309 else5310 {5311 /* real or V86 mode */5312 enmDisCpuMode = DISCPUMODE_16BIT;5313 State.GCPtrSegBase = pCtx->cs.Sel * 16;5314 State.GCPtrSegEnd = 0xFFFFFFFF;5315 State.cbSegLimit = 0xFFFFFFFF;5316 }5317 5318 /*5319 * Disassemble the instruction.5320 */5321 uint32_t cbInstr;5322 #ifndef LOG_ENABLED5323 RT_NOREF_PV(pszPrefix);5324 rc = DISInstrWithReader(GCPtrPC, enmDisCpuMode, cpumR3DisasInstrRead, &State, pDis, &cbInstr);5325 if (RT_SUCCESS(rc))5326 {5327 #else5328 char szOutput[160];5329 rc = DISInstrToStrWithReader(GCPtrPC, enmDisCpuMode, cpumR3DisasInstrRead, &State,5330 pDis, &cbInstr, szOutput, sizeof(szOutput));5331 if (RT_SUCCESS(rc))5332 {5333 /* log it */5334 if (pszPrefix)5335 Log(("%s-CPU%d: %s", pszPrefix, pVCpu->idCpu, szOutput));5336 else5337 Log(("%s", szOutput));5338 #endif5339 rc = VINF_SUCCESS;5340 }5341 else5342 Log(("CPUMR3DisasmInstrCPU: DISInstr failed for %04X:%RGv rc=%Rrc\n", pCtx->cs.Sel, GCPtrPC, rc));5343 5344 /* Release mapping lock acquired in cpumR3DisasInstrRead. */5345 if (State.fLocked)5346 PGMPhysReleasePageMappingLock(pVM, &State.PageMapLock);5347 5348 return rc;5349 }5350 5351 5352 /**5353 5164 * Called when the ring-3 init phase completes. 5354 5165 * -
trunk/src/VBox/VMM/VMMR3/EM.cpp
r107227 r109189 68 68 #include <VBox/vmm/vm.h> 69 69 #include <VBox/vmm/uvm.h> 70 #include <VBox/vmm/cpumdis.h>71 70 #include <VBox/dis.h> 72 71 #include <VBox/err.h> -
trunk/src/VBox/VMM/VMMR3/EMHM.cpp
r107194 r109189 50 50 #include <VBox/vmm/vm.h> 51 51 #include <VBox/vmm/gim.h> 52 #include <VBox/vmm/cpumdis.h>53 52 #include <VBox/dis.h> 54 53 #include <VBox/err.h> -
trunk/src/VBox/VMM/VMMR3/EMR3Nem.cpp
r107227 r109189 50 50 #include <VBox/vmm/vm.h> 51 51 #include <VBox/vmm/gim.h> 52 #include <VBox/vmm/cpumdis.h>53 52 #include <VBox/dis.h> 54 53 #include <VBox/err.h>
Note:
See TracChangeset
for help on using the changeset viewer.