diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-06 03:01:46 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-06 03:01:46 +0000 |
commit | f8fe689a81f906d1b91bb3220acde2a4ecb14c5b (patch) | |
tree | 26484e9d7e2c67806c2d1760196ff01aaa858e8c /src/VBox/VMM/VMMR3/PATMA.mac | |
parent | Initial commit. (diff) | |
download | virtualbox-upstream.tar.xz virtualbox-upstream.zip |
Adding upstream version 6.0.4-dfsg.upstream/6.0.4-dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/VBox/VMM/VMMR3/PATMA.mac')
-rw-r--r-- | src/VBox/VMM/VMMR3/PATMA.mac | 164 |
1 files changed, 164 insertions, 0 deletions
diff --git a/src/VBox/VMM/VMMR3/PATMA.mac b/src/VBox/VMM/VMMR3/PATMA.mac new file mode 100644 index 00000000..b0423502 --- /dev/null +++ b/src/VBox/VMM/VMMR3/PATMA.mac @@ -0,0 +1,164 @@ +; $Id: PATMA.mac $ +;; @file +; PATM macros & definitions (identical to PATMA.h!). +; + +; +; Copyright (C) 2006-2019 Oracle Corporation +; +; This file is part of VirtualBox Open Source Edition (OSE), as +; available from http://www.virtualbox.org. This file is free software; +; you can redistribute it and/or modify it under the terms of the GNU +; General Public License (GPL) as published by the Free Software +; Foundation, in version 2 as it comes in the "COPYING" file of the +; VirtualBox OSE distribution. VirtualBox OSE is distributed in the +; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. +; + +; hardcoded dependency on single byte int 3 +%define PATM_INT3 int3 + +;; @name Patch Fixup Types +; @remarks These fixups types are part of the saved state. +; @{ +%define PATM_ASMFIX_VMFLAGS 0xF1ABCD00 +%ifdef VBOX_WITH_STATISTICS + %define PATM_ASMFIX_ALLPATCHCALLS 0xF1ABCD01 + %define PATM_ASMFIX_PERPATCHCALLS 0xF1ABCD02 +%endif +%define PATM_ASMFIX_JUMPDELTA 0xF1ABCD03 +%ifdef VBOX_WITH_STATISTICS + %define PATM_ASMFIX_IRETEFLAGS 0xF1ABCD04 + %define PATM_ASMFIX_IRETCS 0xF1ABCD05 + %define PATM_ASMFIX_IRETEIP 0xF1ABCD06 +%endif +%define PATM_ASMFIX_FIXUP 0xF1ABCD07 +%define PATM_ASMFIX_PENDINGACTION 0xF1ABCD08 +%define PATM_ASMFIX_CPUID_STD_PTR 0xF1ABCD09 +%define PATM_ASMFIX_CPUID_EXT_PTR 0xF1ABCD0a +%define PATM_ASMFIX_CPUID_DEF_PTR 0xF1ABCD0b +%define PATM_ASMFIX_STACKBASE 0xF1ABCD0c ;;< Stack to store our private patch return addresses +%define PATM_ASMFIX_STACKBASE_GUEST 0xF1ABCD0d ;;< Stack to store guest return addresses +%define PATM_ASMFIX_STACKPTR 0xF1ABCD0e +%define PATM_ASMFIX_PATCHBASE 0xF1ABCD0f +%define PATM_ASMFIX_INTERRUPTFLAG 0xF1ABCD10 +%define PATM_ASMFIX_INHIBITIRQADDR 0xF1ABCD11 +%define PATM_ASMFIX_VM_FORCEDACTIONS 0xF1ABCD12 +%define PATM_ASMFIX_TEMP_EAX 0xF1ABCD13 ;;< Location for original EAX register +%define PATM_ASMFIX_TEMP_ECX 0xF1ABCD14 ;;< Location for original ECX register +%define PATM_ASMFIX_TEMP_EDI 0xF1ABCD15 ;;< Location for original EDI register +%define PATM_ASMFIX_TEMP_EFLAGS 0xF1ABCD16 ;;< Location for original eflags +%define PATM_ASMFIX_TEMP_RESTORE_FLAGS 0xF1ABCD17 ;;< Which registers to restore +%define PATM_ASMFIX_CALL_PATCH_TARGET_ADDR 0xF1ABCD18 +%define PATM_ASMFIX_CALL_RETURN_ADDR 0xF1ABCD19 +%define PATM_ASMFIX_CPUID_CENTAUR_PTR 0xF1ABCD1a +%define PATM_ASMFIX_REUSE_LATER_0 0xF1ABCD1b +%define PATM_ASMFIX_REUSE_LATER_1 0xF1ABCD1c +%define PATM_ASMFIX_REUSE_LATER_2 0xF1ABCD1d +%define PATM_ASMFIX_REUSE_LATER_3 0xF1ABCD1e +%define PATM_ASMFIX_PATCH_HLP_CPUM_CPUID 0xF1ABCD1f + +;/* Anything larger doesn't require a fixup */ +%define PATM_ASMFIX_NO_FIXUP 0xF1ABCE00 +%define PATM_ASMFIX_CPUID_STD_MAX 0xF1ABCE00 +%define PATM_ASMFIX_CPUID_EXT_MAX 0xF1ABCE01 +%define PATM_ASMFIX_RETURNADDR 0xF1ABCE02 +%define PATM_ASMFIX_PATCHNEXTBLOCK 0xF1ABCE03 +%define PATM_ASMFIX_CALLTARGET 0xF1ABCE04 ;;< relative call target +%define PATM_ASMFIX_NEXTINSTRADDR 0xF1ABCE05 ;;< absolute guest address of the next instruction +%define PATM_ASMFIX_CURINSTRADDR 0xF1ABCE06 ;;< absolute guest address of the current instruction +%define PATM_ASMFIX_LOOKUP_AND_CALL_FUNCTION 0xF1ABCE07 ;;< Relative address of global PATM lookup and call function. +%define PATM_ASMFIX_RETURN_FUNCTION 0xF1ABCE08 ;;< Relative address of global PATM return function. +%define PATM_ASMFIX_LOOKUP_AND_JUMP_FUNCTION 0xF1ABCE09 ;;< Relative address of global PATM lookup and jump function. +%define PATM_ASMFIX_IRET_FUNCTION 0xF1ABCE0A ;;< Relative address of global PATM iret function. +%define PATM_ASMFIX_CPUID_CENTAUR_MAX 0xF1ABCE0B +;; @} + + +;; Everything except IOPL, NT, IF, VM, VIF, VIP and RF +%define PATM_FLAGS_MASK (X86_EFL_CF|X86_EFL_PF|X86_EFL_AF|X86_EFL_ZF|X86_EFL_SF|X86_EFL_TF|X86_EFL_DF|X86_EFL_OF|X86_EFL_AC|X86_EFL_ID) + +; currently only IF & IOPL +%define PATM_VIRTUAL_FLAGS_MASK (X86_EFL_IF|X86_EFL_IOPL) + +; PATM stack size (identical in PATMA.h!!) +%define PATM_STACK_SIZE (4096) +%define PATM_STACK_TOTAL_SIZE (2 * PATM_STACK_SIZE) +%define PATM_MAX_STACK (PATM_STACK_SIZE / RTRCPTR_CB) + +;; @name Patch Manager pending actions (in GCSTATE). +;; @{ +%define PATM_ACTION_LOOKUP_ADDRESS 1 +%define PATM_ACTION_DISPATCH_PENDING_IRQ 2 +%define PATM_ACTION_PENDING_IRQ_AFTER_IRET 3 +%define PATM_ACTION_DO_V86_IRET 4 +%define PATM_ACTION_LOG_IF1 5 +%define PATM_ACTION_LOG_CLI 6 +%define PATM_ACTION_LOG_STI 7 +%define PATM_ACTION_LOG_POPF_IF1 8 +%define PATM_ACTION_LOG_POPF_IF0 9 +%define PATM_ACTION_LOG_PUSHF 10 +%define PATM_ACTION_LOG_IRET 11 +%define PATM_ACTION_LOG_RET 12 +%define PATM_ACTION_LOG_CALL 13 +%define PATM_ACTION_LOG_GATE_ENTRY 14 +;; @} + +;; Magic dword found in ecx for patm pending actions. +%define PATM_ACTION_MAGIC 0xABCD4321 + +;; @name PATM_ASMFIX_TEMP_RESTORE_FLAGS +;; @{ +%define PATM_RESTORE_EAX RT_BIT(0) +%define PATM_RESTORE_ECX RT_BIT(1) +%define PATM_RESTORE_EDI RT_BIT(2) +;; @} + + +;; +; Relocation entry for PATCHASMRECORD. +; +struc PATCHASMRELOC + ;; The relocation type. + .uType resd 1 + ;; Additional information specific to the relocation type. + .uCode resd 1 +endstruc + +;; +; Assembly patch descriptor record. +; +struc PATCHASMRECORD + ;; Pointer to the patch code. + .pbFunction RTCCPTR_RES 1 + ;; Offset of the jump table? + .offJump resd 1 + ;; Used only by loop/loopz/loopnz. + .offRelJump resd 1 + ;; Size override byte position. + .offSizeOverride resd 1 + ;; The size of the patch function. + .cbFunction resd 1 + ;; The number of relocations in aRelocs. + .cRelocs resd 1 + ;; Variable sized relocation table. (put after the iend, so no included) + ;.aRelocs resb PATCHASMRELOC_size +endstruc + +;/* For indirect calls/jump (identical in PATMA.h & PATMA.mac!) */ +%define PATM_MAX_JUMPTABLE_ENTRIES 16 + +struc PATCHJUMPTABLE + .nrSlots resw 1 + .ulInsertPos resw 1 + .cAddresses resd 1 + ; array of pInstrGC and pRelPatchGC pairs (nrSlot times) + .Slot_pInstrGC resd 1 + .Slot_pRelPatchGC resd 1 +endstruc + +;/* Must match structure size!! +%define PATCHJUMPTABLE_SIZE (PATM_MAX_JUMPTABLE_ENTRIES*2*4) +;/* Direct calls need only one lookup slot */ +%define PATCHDIRECTJUMPTABLE_SIZE (2*4) + |