added extra param to debugger phy access callback + cleanup in vmexit functions
This commit is contained in:
parent
f4b49633d4
commit
9461797886
@ -228,8 +228,8 @@ void print_tree(bx_param_c *node, int level = 0);
|
||||
if (bx_guard.report.io) bx_dbg_io_report(port, size, op, val)
|
||||
# define BX_DBG_LIN_MEMORY_ACCESS(cpu, lin, phy, len, pl, rw, data) \
|
||||
bx_dbg_lin_memory_access(cpu, lin, phy, len, pl, rw, data)
|
||||
# define BX_DBG_PHY_MEMORY_ACCESS(cpu, phy, len, rw, data) \
|
||||
bx_dbg_phy_memory_access(cpu, phy, len, rw, data)
|
||||
# define BX_DBG_PHY_MEMORY_ACCESS(cpu, phy, len, rw, attr, data) \
|
||||
bx_dbg_phy_memory_access(cpu, phy, len, rw, attr, data)
|
||||
#else // #if BX_DEBUGGER
|
||||
// debugger not compiled in, use empty stubs
|
||||
# define BX_DBG_ASYNC_INTR 1
|
||||
@ -239,7 +239,7 @@ void print_tree(bx_param_c *node, int level = 0);
|
||||
# define BX_DBG_A20_REPORT(val) /* empty */
|
||||
# define BX_DBG_IO_REPORT(port, size, op, val) /* empty */
|
||||
# define BX_DBG_LIN_MEMORY_ACCESS(cpu, lin, phy, len, pl, rw, data) /* empty */
|
||||
# define BX_DBG_PHY_MEMORY_ACCESS(cpu, phy, len, rw, data) /* empty */
|
||||
# define BX_DBG_PHY_MEMORY_ACCESS(cpu, phy, len, rw, attr, data) /* empty */
|
||||
#endif // #if BX_DEBUGGER
|
||||
|
||||
#define MAGIC_LOGNUM 0x12345678
|
||||
@ -438,27 +438,6 @@ BOCHSAPI extern Bit32u apic_id_mask;
|
||||
#define BX_EXECUTE 2
|
||||
#define BX_RW 3
|
||||
|
||||
// to be used in concatenation with BX_READ/BX_WRITE/BX_EXECUTE/BX_RW
|
||||
#define BX_PDPTR0_ACCESS 0x010
|
||||
#define BX_PDPTR1_ACCESS 0x020
|
||||
#define BX_PDPTR2_ACCESS 0x030
|
||||
#define BX_PDPTR3_ACCESS 0x040
|
||||
#define BX_PTE_ACCESS 0x050
|
||||
#define BX_PDE_ACCESS 0x060
|
||||
#define BX_PDPTE_ACCESS 0x070
|
||||
#define BX_PML4E_ACCESS 0x080
|
||||
#define BX_EPT_PTE_ACCESS 0x090
|
||||
#define BX_EPT_PDE_ACCESS 0x0a0
|
||||
#define BX_EPT_PDPTE_ACCESS 0x0b0
|
||||
#define BX_EPT_PML4E_ACCESS 0x0c0
|
||||
#define BX_VMCS_ACCESS 0x0d0
|
||||
#define BX_MSR_BITMAP_ACCESS 0x0e0
|
||||
#define BX_IO_BITMAP_ACCESS 0x0f0
|
||||
#define BX_VMX_LOAD_MSR_ACCESS 0x100
|
||||
#define BX_VMX_STORE_MSR_ACCESS 0x110
|
||||
#define BX_VMX_VTPR_ACCESS 0x120
|
||||
#define BX_SMRAM_ACCESS 0x130
|
||||
|
||||
// types of reset
|
||||
#define BX_RESET_SOFTWARE 10
|
||||
#define BX_RESET_HARDWARE 11
|
||||
|
@ -2,7 +2,7 @@
|
||||
// $Id$
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2008-2011 Stanislav Shwartsman
|
||||
// Copyright (c) 2008-2012 Stanislav Shwartsman
|
||||
// Written by Stanislav Shwartsman [sshwarts at sourceforge net]
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
@ -1135,7 +1135,7 @@ accessOK:
|
||||
BX_CPU_C::write_RMW_virtual_byte(Bit8u val8)
|
||||
{
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID,
|
||||
BX_CPU_THIS_PTR address_xlation.paddress1, 1, BX_WRITE, (Bit8u*) &val8);
|
||||
BX_CPU_THIS_PTR address_xlation.paddress1, 1, BX_WRITE, 0, (Bit8u*) &val8);
|
||||
|
||||
if (BX_CPU_THIS_PTR address_xlation.pages > 2) {
|
||||
// Pages > 2 means it stores a host address for direct access.
|
||||
@ -1156,28 +1156,28 @@ BX_CPU_C::write_RMW_virtual_word(Bit16u val16)
|
||||
Bit16u *hostAddr = (Bit16u *) BX_CPU_THIS_PTR address_xlation.pages;
|
||||
WriteHostWordToLittleEndian(hostAddr, val16);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID,
|
||||
BX_CPU_THIS_PTR address_xlation.paddress1, 2, BX_WRITE, (Bit8u*) &val16);
|
||||
BX_CPU_THIS_PTR address_xlation.paddress1, 2, BX_WRITE, 0, (Bit8u*) &val16);
|
||||
}
|
||||
else if (BX_CPU_THIS_PTR address_xlation.pages == 1) {
|
||||
access_write_physical(BX_CPU_THIS_PTR address_xlation.paddress1, 2, &val16);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID,
|
||||
BX_CPU_THIS_PTR address_xlation.paddress1, 2, BX_WRITE, (Bit8u*) &val16);
|
||||
BX_CPU_THIS_PTR address_xlation.paddress1, 2, BX_WRITE, 0, (Bit8u*) &val16);
|
||||
}
|
||||
else {
|
||||
#ifdef BX_LITTLE_ENDIAN
|
||||
access_write_physical(BX_CPU_THIS_PTR address_xlation.paddress1, 1, &val16);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID,
|
||||
BX_CPU_THIS_PTR address_xlation.paddress1, 1, BX_WRITE, (Bit8u*) &val16);
|
||||
BX_CPU_THIS_PTR address_xlation.paddress1, 1, BX_WRITE, 0, (Bit8u*) &val16);
|
||||
access_write_physical(BX_CPU_THIS_PTR address_xlation.paddress2, 1, ((Bit8u *) &val16) + 1);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID,
|
||||
BX_CPU_THIS_PTR address_xlation.paddress2, 1, BX_WRITE, ((Bit8u*) &val16)+1);
|
||||
BX_CPU_THIS_PTR address_xlation.paddress2, 1, BX_WRITE, 0, ((Bit8u*) &val16)+1);
|
||||
#else
|
||||
access_write_physical(BX_CPU_THIS_PTR address_xlation.paddress1, 1, ((Bit8u *) &val16) + 1);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID,
|
||||
BX_CPU_THIS_PTR address_xlation.paddress1, 1, BX_WRITE, ((Bit8u*) &val16)+1);
|
||||
BX_CPU_THIS_PTR address_xlation.paddress1, 1, BX_WRITE, 0, ((Bit8u*) &val16)+1);
|
||||
access_write_physical(BX_CPU_THIS_PTR address_xlation.paddress2, 1, &val16);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID,
|
||||
BX_CPU_THIS_PTR address_xlation.paddress2, 1, BX_WRITE, (Bit8u*) &val16);
|
||||
BX_CPU_THIS_PTR address_xlation.paddress2, 1, BX_WRITE, 0, (Bit8u*) &val16);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -1190,12 +1190,12 @@ BX_CPU_C::write_RMW_virtual_dword(Bit32u val32)
|
||||
Bit32u *hostAddr = (Bit32u *) BX_CPU_THIS_PTR address_xlation.pages;
|
||||
WriteHostDWordToLittleEndian(hostAddr, val32);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID,
|
||||
BX_CPU_THIS_PTR address_xlation.paddress1, 4, BX_WRITE, (Bit8u*) &val32);
|
||||
BX_CPU_THIS_PTR address_xlation.paddress1, 4, BX_WRITE, 0, (Bit8u*) &val32);
|
||||
}
|
||||
else if (BX_CPU_THIS_PTR address_xlation.pages == 1) {
|
||||
access_write_physical(BX_CPU_THIS_PTR address_xlation.paddress1, 4, &val32);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID,
|
||||
BX_CPU_THIS_PTR address_xlation.paddress1, 4, BX_WRITE, (Bit8u*) &val32);
|
||||
BX_CPU_THIS_PTR address_xlation.paddress1, 4, BX_WRITE, 0, (Bit8u*) &val32);
|
||||
}
|
||||
else {
|
||||
#ifdef BX_LITTLE_ENDIAN
|
||||
@ -1203,13 +1203,13 @@ BX_CPU_C::write_RMW_virtual_dword(Bit32u val32)
|
||||
BX_CPU_THIS_PTR address_xlation.len1, &val32);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID,
|
||||
BX_CPU_THIS_PTR address_xlation.paddress1,
|
||||
BX_CPU_THIS_PTR address_xlation.len1, BX_WRITE, (Bit8u*) &val32);
|
||||
BX_CPU_THIS_PTR address_xlation.len1, BX_WRITE, 0, (Bit8u*) &val32);
|
||||
access_write_physical(BX_CPU_THIS_PTR address_xlation.paddress2,
|
||||
BX_CPU_THIS_PTR address_xlation.len2,
|
||||
((Bit8u *) &val32) + BX_CPU_THIS_PTR address_xlation.len1);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID,
|
||||
BX_CPU_THIS_PTR address_xlation.paddress2,
|
||||
BX_CPU_THIS_PTR address_xlation.len2, BX_WRITE,
|
||||
BX_CPU_THIS_PTR address_xlation.len2, BX_WRITE, 0,
|
||||
((Bit8u *) &val32) + BX_CPU_THIS_PTR address_xlation.len1);
|
||||
#else
|
||||
access_write_physical(BX_CPU_THIS_PTR address_xlation.paddress1,
|
||||
@ -1217,13 +1217,13 @@ BX_CPU_C::write_RMW_virtual_dword(Bit32u val32)
|
||||
((Bit8u *) &val32) + (4 - BX_CPU_THIS_PTR address_xlation.len1));
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID,
|
||||
BX_CPU_THIS_PTR address_xlation.paddress1,
|
||||
BX_CPU_THIS_PTR address_xlation.len1, BX_WRITE,
|
||||
BX_CPU_THIS_PTR address_xlation.len1, BX_WRITE, 0,
|
||||
((Bit8u *) &val32) + (4 - BX_CPU_THIS_PTR address_xlation.len1));
|
||||
access_write_physical(BX_CPU_THIS_PTR address_xlation.paddress2,
|
||||
BX_CPU_THIS_PTR address_xlation.len2, &val32);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID,
|
||||
BX_CPU_THIS_PTR address_xlation.paddress2,
|
||||
BX_CPU_THIS_PTR address_xlation.len2, BX_WRITE, (Bit8u*) &val32);
|
||||
BX_CPU_THIS_PTR address_xlation.len2, BX_WRITE, 0, (Bit8u*) &val32);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -1236,12 +1236,12 @@ BX_CPU_C::write_RMW_virtual_qword(Bit64u val64)
|
||||
Bit64u *hostAddr = (Bit64u *) BX_CPU_THIS_PTR address_xlation.pages;
|
||||
WriteHostQWordToLittleEndian(hostAddr, val64);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID,
|
||||
BX_CPU_THIS_PTR address_xlation.paddress1, 8, BX_WRITE, (Bit8u*) &val64);
|
||||
BX_CPU_THIS_PTR address_xlation.paddress1, 8, BX_WRITE, 0, (Bit8u*) &val64);
|
||||
}
|
||||
else if (BX_CPU_THIS_PTR address_xlation.pages == 1) {
|
||||
access_write_physical(BX_CPU_THIS_PTR address_xlation.paddress1, 8, &val64);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID,
|
||||
BX_CPU_THIS_PTR address_xlation.paddress1, 8, BX_WRITE, (Bit8u*) &val64);
|
||||
BX_CPU_THIS_PTR address_xlation.paddress1, 8, BX_WRITE, 0, (Bit8u*) &val64);
|
||||
}
|
||||
else {
|
||||
#ifdef BX_LITTLE_ENDIAN
|
||||
@ -1249,13 +1249,13 @@ BX_CPU_C::write_RMW_virtual_qword(Bit64u val64)
|
||||
BX_CPU_THIS_PTR address_xlation.len1, &val64);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID,
|
||||
BX_CPU_THIS_PTR address_xlation.paddress1,
|
||||
BX_CPU_THIS_PTR address_xlation.len1, BX_WRITE, (Bit8u*) &val64);
|
||||
BX_CPU_THIS_PTR address_xlation.len1, BX_WRITE, 0, (Bit8u*) &val64);
|
||||
access_write_physical(BX_CPU_THIS_PTR address_xlation.paddress2,
|
||||
BX_CPU_THIS_PTR address_xlation.len2,
|
||||
((Bit8u *) &val64) + BX_CPU_THIS_PTR address_xlation.len1);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID,
|
||||
BX_CPU_THIS_PTR address_xlation.paddress2,
|
||||
BX_CPU_THIS_PTR address_xlation.len2, BX_WRITE,
|
||||
BX_CPU_THIS_PTR address_xlation.len2, BX_WRITE, 0,
|
||||
((Bit8u *) &val64) + BX_CPU_THIS_PTR address_xlation.len1);
|
||||
#else
|
||||
access_write_physical(BX_CPU_THIS_PTR address_xlation.paddress1,
|
||||
@ -1263,13 +1263,13 @@ BX_CPU_C::write_RMW_virtual_qword(Bit64u val64)
|
||||
((Bit8u *) &val64) + (8 - BX_CPU_THIS_PTR address_xlation.len1));
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID,
|
||||
BX_CPU_THIS_PTR address_xlation.paddress1,
|
||||
BX_CPU_THIS_PTR address_xlation.len1, BX_WRITE,
|
||||
BX_CPU_THIS_PTR address_xlation.len1, BX_WRITE, 0,
|
||||
((Bit8u *) &val64) + (8 - BX_CPU_THIS_PTR address_xlation.len1));
|
||||
access_write_physical(BX_CPU_THIS_PTR address_xlation.paddress2,
|
||||
BX_CPU_THIS_PTR address_xlation.len2, &val64);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID,
|
||||
BX_CPU_THIS_PTR address_xlation.paddress2,
|
||||
BX_CPU_THIS_PTR address_xlation.len2, BX_WRITE, (Bit8u*) &val64);
|
||||
BX_CPU_THIS_PTR address_xlation.len2, BX_WRITE, 0, (Bit8u*) &val64);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -307,6 +307,29 @@
|
||||
|
||||
// <TAG-INSTRUMENTATION_COMMON-END>
|
||||
|
||||
// passed to internal debugger together with BX_READ/BX_WRITE/BX_EXECUTE/BX_RW
|
||||
enum {
|
||||
BX_PDPTR0_ACCESS = 1,
|
||||
BX_PDPTR1_ACCESS,
|
||||
BX_PDPTR2_ACCESS,
|
||||
BX_PDPTR3_ACCESS,
|
||||
BX_PTE_ACCESS,
|
||||
BX_PDE_ACCESS,
|
||||
BX_PDTE_ACCESS,
|
||||
BX_PML4E_ACCESS,
|
||||
BX_EPT_PTE_ACCESS,
|
||||
BX_EPT_PDE_ACCESS,
|
||||
BX_EPT_PDTE_ACCESS,
|
||||
BX_EPT_PML4E_ACCESS,
|
||||
BX_VMCS_ACCESS,
|
||||
BX_MSR_BITMAP_ACCESS,
|
||||
BX_IO_BITMAP_ACCESS,
|
||||
BX_VMX_LOAD_MSR_ACCESS,
|
||||
BX_VMX_STORE_MSR_ACCESS,
|
||||
BX_VMX_VTPR_ACCESS,
|
||||
BX_SMRAM_ACCESS
|
||||
};
|
||||
|
||||
struct BxExceptionInfo {
|
||||
unsigned exception_type;
|
||||
unsigned exception_class;
|
||||
@ -4287,12 +4310,7 @@ public: // for now...
|
||||
BX_SMF void VMexit_TripleFault(void);
|
||||
BX_SMF void VMexit_ExtInterrupt(void);
|
||||
BX_SMF void VMexit_TaskSwitch(bxInstruction_c *i, Bit16u tss_selector, unsigned source) BX_CPP_AttrRegparmN(3);
|
||||
BX_SMF void VMexit_HLT(bxInstruction_c *i) BX_CPP_AttrRegparmN(1);
|
||||
BX_SMF void VMexit_PAUSE(bxInstruction_c *i) BX_CPP_AttrRegparmN(1);
|
||||
BX_SMF void VMexit_INVLPG(bxInstruction_c *i, bx_address laddr) BX_CPP_AttrRegparmN(2);
|
||||
BX_SMF void VMexit_RDTSC(bxInstruction_c *i) BX_CPP_AttrRegparmN(1);
|
||||
BX_SMF void VMexit_RDPMC(bxInstruction_c *i) BX_CPP_AttrRegparmN(1);
|
||||
BX_SMF void VMexit_WBINVD(bxInstruction_c *i) BX_CPP_AttrRegparmN(1);
|
||||
#if BX_SUPPORT_VMX >= 2
|
||||
BX_SMF void VMexit_PreemptionTimerExpired(void);
|
||||
#endif
|
||||
@ -4307,10 +4325,6 @@ public: // for now...
|
||||
BX_SMF void VMexit_CR8_Read(bxInstruction_c *i) BX_CPP_AttrRegparmN(1);
|
||||
BX_SMF void VMexit_CR8_Write(bxInstruction_c *i) BX_CPP_AttrRegparmN(1);
|
||||
BX_SMF void VMexit_DR_Access(bxInstruction_c *i, unsigned read) BX_CPP_AttrRegparmN(2);
|
||||
#if BX_SUPPORT_MONITOR_MWAIT
|
||||
BX_SMF void VMexit_MONITOR(bxInstruction_c *i) BX_CPP_AttrRegparmN(1);
|
||||
BX_SMF void VMexit_MWAIT(bxInstruction_c *i) BX_CPP_AttrRegparmN(1);
|
||||
#endif
|
||||
#if BX_SUPPORT_VMX >= 2
|
||||
BX_SMF void vmfunc_eptp_switching(bxInstruction_c *i) BX_CPP_AttrRegparmN(1);
|
||||
#endif
|
||||
|
@ -482,8 +482,12 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::INVLPG(bxInstruction_c* i)
|
||||
bx_address laddr = get_laddr(i->seg(), eaddr);
|
||||
|
||||
#if BX_SUPPORT_VMX
|
||||
if (BX_CPU_THIS_PTR in_vmx_guest)
|
||||
VMexit_INVLPG(i, laddr);
|
||||
if (BX_CPU_THIS_PTR in_vmx_guest) {
|
||||
if (VMEXIT(VMX_VM_EXEC_CTRL2_INVLPG_VMEXIT)) {
|
||||
BX_ERROR(("VMEXIT: INVLPG 0x" FMT_ADDRX, laddr));
|
||||
VMexit(i, VMX_VMEXIT_INVLPG, laddr);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BX_SUPPORT_SVM
|
||||
@ -693,7 +697,7 @@ bx_phy_address BX_CPU_C::translate_linear_long_mode(bx_address laddr, Bit32u &lp
|
||||
}
|
||||
#endif
|
||||
access_read_physical(entry_addr[leaf], 8, &entry[leaf]);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, entry_addr[leaf], 8, (BX_PTE_ACCESS + (leaf<<4)) | BX_READ, (Bit8u*)(&entry[leaf]));
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, entry_addr[leaf], 8, BX_READ, (BX_PTE_ACCESS + leaf), (Bit8u*)(&entry[leaf]));
|
||||
|
||||
Bit64u curr_entry = entry[leaf];
|
||||
int fault = check_entry_PAE(bx_paging_level[leaf], curr_entry, rw, &nx_fault);
|
||||
@ -759,8 +763,8 @@ bx_phy_address BX_CPU_C::translate_linear_long_mode(bx_address laddr, Bit32u &lp
|
||||
if (!(entry[level] & 0x20)) {
|
||||
entry[level] |= 0x20;
|
||||
access_write_physical(entry_addr[level], 8, &entry[level]);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, entry_addr[level], 8,
|
||||
(BX_PTE_ACCESS + (level<<4)) | BX_WRITE, (Bit8u*)(&entry[level]));
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, entry_addr[level], 8, BX_WRITE,
|
||||
(BX_PTE_ACCESS + level), (Bit8u*)(&entry[level]));
|
||||
}
|
||||
}
|
||||
|
||||
@ -768,8 +772,8 @@ bx_phy_address BX_CPU_C::translate_linear_long_mode(bx_address laddr, Bit32u &lp
|
||||
if (!(entry[leaf] & 0x20) || (isWrite && !(entry[leaf] & 0x40))) {
|
||||
entry[leaf] |= (0x20 | (isWrite<<6)); // Update A and possibly D bits
|
||||
access_write_physical(entry_addr[leaf], 8, &entry[leaf]);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, entry_addr[leaf], 8,
|
||||
(BX_PTE_ACCESS + (leaf<<4)) | BX_WRITE, (Bit8u*)(&entry[leaf]));
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, entry_addr[leaf], 8, BX_WRITE,
|
||||
(BX_PTE_ACCESS + leaf), (Bit8u*)(&entry[leaf]));
|
||||
}
|
||||
|
||||
return ppf;
|
||||
@ -809,8 +813,8 @@ bx_bool BX_CPP_AttrRegparmN(1) BX_CPU_C::CheckPDPTR(bx_phy_address cr3_val)
|
||||
// read and check PDPTE entries
|
||||
bx_phy_address pdpe_entry_addr = (bx_phy_address) (cr3_val | (n << 3));
|
||||
access_read_physical(pdpe_entry_addr, 8, &(pdptr[n]));
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pdpe_entry_addr, 8,
|
||||
(BX_PDPTR0_ACCESS + (n<<4)) | BX_READ, (Bit8u*) &(pdptr[n]));
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pdpe_entry_addr, 8, BX_READ,
|
||||
(BX_PDPTR0_ACCESS + n), (Bit8u*) &(pdptr[n]));
|
||||
|
||||
if (pdptr[n] & 0x1) {
|
||||
if (pdptr[n] & PAGING_PAE_PDPTE_RESERVED_BITS) return 0;
|
||||
@ -875,7 +879,7 @@ bx_phy_address BX_CPU_C::translate_linear_PAE(bx_address laddr, Bit32u &lpf_mask
|
||||
}
|
||||
#endif
|
||||
access_read_physical(entry_addr[leaf], 8, &entry[leaf]);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, entry_addr[leaf], 8, (BX_PTE_ACCESS + (leaf<<4)) | BX_READ, (Bit8u*)(&entry[leaf]));
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, entry_addr[leaf], 8, BX_READ, (BX_PTE_ACCESS + leaf), (Bit8u*)(&entry[leaf]));
|
||||
|
||||
Bit64u curr_entry = entry[leaf];
|
||||
int fault = check_entry_PAE(bx_paging_level[leaf], curr_entry, rw, &nx_fault);
|
||||
@ -923,8 +927,8 @@ bx_phy_address BX_CPU_C::translate_linear_PAE(bx_address laddr, Bit32u &lpf_mask
|
||||
if (!(entry[BX_LEVEL_PDE] & 0x20)) {
|
||||
entry[BX_LEVEL_PDE] |= 0x20;
|
||||
access_write_physical(entry_addr[BX_LEVEL_PDE], 8, &entry[BX_LEVEL_PDE]);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, entry_addr[BX_LEVEL_PDE], 8,
|
||||
(BX_PDE_ACCESS | BX_WRITE), (Bit8u*)(&entry[BX_LEVEL_PDE]));
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, entry_addr[BX_LEVEL_PDE], 8, BX_WRITE,
|
||||
BX_PDE_ACCESS, (Bit8u*)(&entry[BX_LEVEL_PDE]));
|
||||
}
|
||||
}
|
||||
|
||||
@ -932,8 +936,8 @@ bx_phy_address BX_CPU_C::translate_linear_PAE(bx_address laddr, Bit32u &lpf_mask
|
||||
if (!(entry[leaf] & 0x20) || (isWrite && !(entry[leaf] & 0x40))) {
|
||||
entry[leaf] |= (0x20 | (isWrite<<6)); // Update A and possibly D bits
|
||||
access_write_physical(entry_addr[leaf], 8, &entry[leaf]);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, entry_addr[leaf], 8,
|
||||
(BX_PTE_ACCESS + (leaf<<4)) | BX_WRITE, (Bit8u*)(&entry[leaf]));
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, entry_addr[leaf], 8, BX_WRITE,
|
||||
(BX_PTE_ACCESS + leaf), (Bit8u*)(&entry[leaf]));
|
||||
}
|
||||
|
||||
return ppf;
|
||||
@ -979,7 +983,7 @@ bx_phy_address BX_CPU_C::translate_linear_legacy(bx_address laddr, Bit32u &lpf_m
|
||||
}
|
||||
#endif
|
||||
access_read_physical(entry_addr[leaf], 4, &entry[leaf]);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, entry_addr[leaf], 4, (BX_PTE_ACCESS + (leaf<<4)) | BX_READ, (Bit8u*)(&entry[leaf]));
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, entry_addr[leaf], 4, BX_READ, (BX_PTE_ACCESS + leaf), (Bit8u*)(&entry[leaf]));
|
||||
|
||||
Bit32u curr_entry = entry[leaf];
|
||||
if (!(curr_entry & 0x1)) {
|
||||
@ -1036,7 +1040,7 @@ bx_phy_address BX_CPU_C::translate_linear_legacy(bx_address laddr, Bit32u &lpf_m
|
||||
if (!(entry[BX_LEVEL_PDE] & 0x20)) {
|
||||
entry[BX_LEVEL_PDE] |= 0x20;
|
||||
access_write_physical(entry_addr[BX_LEVEL_PDE], 4, &entry[BX_LEVEL_PDE]);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, entry_addr[BX_LEVEL_PDE], 4, BX_PDE_ACCESS | BX_WRITE, (Bit8u*)(&entry[BX_LEVEL_PDE]));
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, entry_addr[BX_LEVEL_PDE], 4, BX_WRITE, BX_PDE_ACCESS, (Bit8u*)(&entry[BX_LEVEL_PDE]));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1044,8 +1048,8 @@ bx_phy_address BX_CPU_C::translate_linear_legacy(bx_address laddr, Bit32u &lpf_m
|
||||
if (!(entry[leaf] & 0x20) || (isWrite && !(entry[leaf] & 0x40))) {
|
||||
entry[leaf] |= (0x20 | (isWrite<<6)); // Update A and possibly D bits
|
||||
access_write_physical(entry_addr[leaf], 4, &entry[leaf]);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, entry_addr[leaf], 4,
|
||||
(BX_PTE_ACCESS + (leaf<<4)) | BX_WRITE, (Bit8u*)(&entry[leaf]));
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, entry_addr[leaf], 4, BX_WRITE,
|
||||
(BX_PTE_ACCESS + leaf), (Bit8u*)(&entry[leaf]));
|
||||
}
|
||||
|
||||
return ppf;
|
||||
@ -1223,8 +1227,8 @@ bx_phy_address BX_CPU_C::translate_guest_physical(bx_phy_address guest_paddr, bx
|
||||
for (leaf = BX_LEVEL_PML4;; --leaf) {
|
||||
entry_addr[leaf] = pbase + ((guest_paddr >> (9 + 9*leaf)) & 0xff8);
|
||||
access_read_physical(entry_addr[leaf], 8, &entry[leaf]);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, entry_addr[leaf], 8,
|
||||
(BX_EPT_PTE_ACCESS + (leaf<<4)) | BX_READ, (Bit8u*)(&entry[leaf]));
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, entry_addr[leaf], 8, BX_READ,
|
||||
(BX_EPT_PTE_ACCESS + leaf), (Bit8u*)(&entry[leaf]));
|
||||
|
||||
Bit64u curr_entry = entry[leaf];
|
||||
Bit32u curr_access_mask = curr_entry & 0x7;
|
||||
|
@ -149,8 +149,12 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::HLT(bxInstruction_c *i)
|
||||
}
|
||||
|
||||
#if BX_SUPPORT_VMX
|
||||
if (BX_CPU_THIS_PTR in_vmx_guest)
|
||||
VMexit_HLT(i);
|
||||
if (BX_CPU_THIS_PTR in_vmx_guest) {
|
||||
if (VMEXIT(VMX_VM_EXEC_CTRL2_HLT_VMEXIT)) {
|
||||
BX_ERROR(("VMEXIT: HLT"));
|
||||
VMexit(i, VMX_VMEXIT_HLT, 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BX_SUPPORT_SVM
|
||||
@ -227,8 +231,12 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::WBINVD(bxInstruction_c *i)
|
||||
}
|
||||
|
||||
#if BX_SUPPORT_VMX
|
||||
if (BX_CPU_THIS_PTR in_vmx_guest)
|
||||
VMexit_WBINVD(i);
|
||||
if (BX_CPU_THIS_PTR in_vmx_guest) {
|
||||
if (SECONDARY_VMEXEC_CONTROL(VMX_VM_EXEC_CTRL3_WBINVD_VMEXIT)) {
|
||||
BX_ERROR(("VMEXIT: WBINVD in VMX non-root operation"));
|
||||
VMexit(i, VMX_VMEXIT_WBINVD, 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BX_SUPPORT_SVM
|
||||
@ -443,8 +451,12 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::RDPMC(bxInstruction_c *i)
|
||||
}
|
||||
|
||||
#if BX_SUPPORT_VMX
|
||||
if (BX_CPU_THIS_PTR in_vmx_guest)
|
||||
VMexit_RDPMC(i);
|
||||
if (BX_CPU_THIS_PTR in_vmx_guest) {
|
||||
if (VMEXIT(VMX_VM_EXEC_CTRL2_RDPMC_VMEXIT)) {
|
||||
BX_ERROR(("VMEXIT: RDPMC"));
|
||||
VMexit(i, VMX_VMEXIT_RDPMC, 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BX_SUPPORT_SVM
|
||||
@ -514,8 +526,12 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::RDTSC(bxInstruction_c *i)
|
||||
}
|
||||
|
||||
#if BX_SUPPORT_VMX
|
||||
if (BX_CPU_THIS_PTR in_vmx_guest)
|
||||
VMexit_RDTSC(i);
|
||||
if (BX_CPU_THIS_PTR in_vmx_guest) {
|
||||
if (VMEXIT(VMX_VM_EXEC_CTRL2_RDTSC_VMEXIT)) {
|
||||
BX_ERROR(("VMEXIT: RDTSC"));
|
||||
VMexit(i, VMX_VMEXIT_RDTSC, 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BX_SUPPORT_SVM
|
||||
@ -555,8 +571,12 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::RDTSCP(bxInstruction_c *i)
|
||||
}
|
||||
|
||||
#if BX_SUPPORT_VMX
|
||||
if (BX_CPU_THIS_PTR in_vmx_guest)
|
||||
VMexit_RDTSC(i);
|
||||
if (BX_CPU_THIS_PTR in_vmx_guest) {
|
||||
if (VMEXIT(VMX_VM_EXEC_CTRL2_RDTSC_VMEXIT)) {
|
||||
BX_ERROR(("VMEXIT: RDTSCP"));
|
||||
VMexit(i, VMX_VMEXIT_RDTSCP, 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BX_SUPPORT_SVM
|
||||
@ -615,8 +635,12 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::MONITOR(bxInstruction_c *i)
|
||||
BX_DEBUG(("MONITOR instruction executed EAX = 0x%08x", EAX));
|
||||
|
||||
#if BX_SUPPORT_VMX
|
||||
if (BX_CPU_THIS_PTR in_vmx_guest)
|
||||
VMexit_MONITOR(i);
|
||||
if (BX_CPU_THIS_PTR in_vmx_guest) {
|
||||
if (VMEXIT(VMX_VM_EXEC_CTRL2_MONITOR_VMEXIT)) {
|
||||
BX_ERROR(("VMEXIT: MONITOR"));
|
||||
VMexit(i, VMX_VMEXIT_MONITOR, 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (RCX != 0) {
|
||||
@ -687,8 +711,12 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::MWAIT(bxInstruction_c *i)
|
||||
BX_DEBUG(("MWAIT instruction executed ECX = 0x%08x", ECX));
|
||||
|
||||
#if BX_SUPPORT_VMX
|
||||
if (BX_CPU_THIS_PTR in_vmx_guest)
|
||||
VMexit_MWAIT(i);
|
||||
if (BX_CPU_THIS_PTR in_vmx_guest) {
|
||||
if (VMEXIT(VMX_VM_EXEC_CTRL2_MWAIT_VMEXIT)) {
|
||||
BX_ERROR(("VMEXIT: MWAIT"));
|
||||
VMexit(i, VMX_VMEXIT_MWAIT, BX_CPU_THIS_PTR monitor.armed);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// only one extension is supported
|
||||
|
@ -96,7 +96,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::RSM(bxInstruction_c *i)
|
||||
for(n=0;n<SMM_SAVE_STATE_MAP_SIZE;n++) {
|
||||
base -= 4;
|
||||
access_read_physical(base, 4, &saved_state[n]);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, base, 4, BX_SMRAM_ACCESS | BX_READ, (Bit8u*)(&saved_state[n]));
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, base, 4, BX_READ, BX_SMRAM_ACCESS, (Bit8u*)(&saved_state[n]));
|
||||
}
|
||||
BX_CPU_THIS_PTR in_smm = 0;
|
||||
|
||||
@ -163,7 +163,7 @@ void BX_CPU_C::enter_system_management_mode(void)
|
||||
for(n=0;n<SMM_SAVE_STATE_MAP_SIZE;n++) {
|
||||
base -= 4;
|
||||
access_write_physical(base, 4, &saved_state[n]);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, base, 4, BX_SMRAM_ACCESS | BX_WRITE, (Bit8u*)(&saved_state[n]));
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, base, 4, BX_WRITE, BX_SMRAM_ACCESS, (Bit8u*)(&saved_state[n]));
|
||||
}
|
||||
|
||||
BX_CPU_THIS_PTR setEFlags(0x2); // Bit1 is always set
|
||||
|
@ -57,7 +57,7 @@ BX_CPP_INLINE Bit8u BX_CPU_C::vmcb_read8(unsigned offset)
|
||||
access_read_physical(pAddr, 1, (Bit8u*)(&val_8));
|
||||
}
|
||||
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 1, BX_VMCS_ACCESS | BX_READ, (Bit8u*)(&val_8));
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 1, BX_READ, BX_VMCS_ACCESS, (Bit8u*)(&val_8));
|
||||
return val_8;
|
||||
}
|
||||
|
||||
@ -74,7 +74,7 @@ BX_CPP_INLINE Bit16u BX_CPU_C::vmcb_read16(unsigned offset)
|
||||
access_read_physical(pAddr, 2, (Bit8u*)(&val_16));
|
||||
}
|
||||
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 2, BX_VMCS_ACCESS | BX_READ, (Bit8u*)(&val_16));
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 2, BX_READ, BX_VMCS_ACCESS, (Bit8u*)(&val_16));
|
||||
return val_16;
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ BX_CPP_INLINE Bit32u BX_CPU_C::vmcb_read32(unsigned offset)
|
||||
access_read_physical(pAddr, 4, (Bit8u*)(&val_32));
|
||||
}
|
||||
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 4, BX_VMCS_ACCESS | BX_READ, (Bit8u*)(&val_32));
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 4, BX_READ, BX_VMCS_ACCESS, (Bit8u*)(&val_32));
|
||||
return val_32;
|
||||
}
|
||||
|
||||
@ -108,7 +108,7 @@ BX_CPP_INLINE Bit64u BX_CPU_C::vmcb_read64(unsigned offset)
|
||||
access_read_physical(pAddr, 8, (Bit8u*)(&val_64));
|
||||
}
|
||||
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 8, BX_VMCS_ACCESS | BX_READ, (Bit8u*)(&val_64));
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 8, BX_READ, BX_VMCS_ACCESS, (Bit8u*)(&val_64));
|
||||
return val_64;
|
||||
}
|
||||
|
||||
@ -125,7 +125,7 @@ BX_CPP_INLINE void BX_CPU_C::vmcb_write8(unsigned offset, Bit8u val_8)
|
||||
access_write_physical(pAddr, 1, (Bit8u*)(&val_8));
|
||||
}
|
||||
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 1, BX_VMCS_ACCESS | BX_WRITE, (Bit8u*)(&val_8));
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 1, BX_WRITE, BX_VMCS_ACCESS, (Bit8u*)(&val_8));
|
||||
}
|
||||
|
||||
BX_CPP_INLINE void BX_CPU_C::vmcb_write16(unsigned offset, Bit16u val_16)
|
||||
@ -141,7 +141,7 @@ BX_CPP_INLINE void BX_CPU_C::vmcb_write16(unsigned offset, Bit16u val_16)
|
||||
access_write_physical(pAddr, 2, (Bit8u*)(&val_16));
|
||||
}
|
||||
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 2, BX_VMCS_ACCESS | BX_WRITE, (Bit8u*)(&val_16));
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 2, BX_WRITE, BX_VMCS_ACCESS, (Bit8u*)(&val_16));
|
||||
}
|
||||
|
||||
BX_CPP_INLINE void BX_CPU_C::vmcb_write32(unsigned offset, Bit32u val_32)
|
||||
@ -157,7 +157,7 @@ BX_CPP_INLINE void BX_CPU_C::vmcb_write32(unsigned offset, Bit32u val_32)
|
||||
access_write_physical(pAddr, 4, (Bit8u*)(&val_32));
|
||||
}
|
||||
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 4, BX_VMCS_ACCESS | BX_WRITE, (Bit8u*)(&val_32));
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 4, BX_WRITE, BX_VMCS_ACCESS, (Bit8u*)(&val_32));
|
||||
}
|
||||
|
||||
BX_CPP_INLINE void BX_CPU_C::vmcb_write64(unsigned offset, Bit64u val_64)
|
||||
@ -173,7 +173,7 @@ BX_CPP_INLINE void BX_CPU_C::vmcb_write64(unsigned offset, Bit64u val_64)
|
||||
access_write_physical(pAddr, 8, (Bit8u*)(&val_64));
|
||||
}
|
||||
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 8, BX_VMCS_ACCESS | BX_WRITE, (Bit8u*)(&val_64));
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 8, BX_WRITE, BX_VMCS_ACCESS, (Bit8u*)(&val_64));
|
||||
}
|
||||
|
||||
BX_CPP_INLINE void BX_CPU_C::svm_segment_read(bx_segment_reg_t *seg, unsigned offset)
|
||||
@ -783,11 +783,11 @@ void BX_CPU_C::SvmInterceptIO(bxInstruction_c *i, unsigned port, unsigned len)
|
||||
// access_read_physical cannot read 2 bytes cross 4K boundary :(
|
||||
pAddr = BX_CPU_THIS_PTR vmcb.ctrls.iopm_base + (port / 8);
|
||||
access_read_physical(pAddr, 1, &bitmap[0]);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 1, BX_IO_BITMAP_ACCESS | BX_READ, &bitmap[0]);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 1, BX_READ, BX_IO_BITMAP_ACCESS, &bitmap[0]);
|
||||
|
||||
pAddr++;
|
||||
access_read_physical(pAddr, 1, &bitmap[1]);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 1, BX_IO_BITMAP_ACCESS | BX_READ, &bitmap[1]);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 1, BX_READ, BX_IO_BITMAP_ACCESS, &bitmap[1]);
|
||||
|
||||
Bit16u combined_bitmap = bitmap[1];
|
||||
combined_bitmap = (combined_bitmap << 8) | bitmap[0];
|
||||
@ -878,7 +878,7 @@ void BX_CPU_C::SvmInterceptMSR(unsigned op, Bit32u msr)
|
||||
|
||||
Bit8u msr_bitmap;
|
||||
access_read_physical(msr_bitmap_addr + (msr_offset / 8), 1, (Bit8u*)(&msr_bitmap));
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, msr_bitmap_addr + (msr_offset / 8), 1, BX_MSR_BITMAP_ACCESS | BX_READ, &msr_bitmap);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, msr_bitmap_addr + (msr_offset / 8), 1, BX_READ, BX_MSR_BITMAP_ACCESS, &msr_bitmap);
|
||||
|
||||
vmexit = (msr_bitmap >> (msr_offset & 7)) & 0x1;
|
||||
}
|
||||
|
@ -140,16 +140,6 @@ void BX_CPP_AttrRegparmN(2) BX_CPU_C::VMexit_Instruction(bxInstruction_c *i, Bit
|
||||
VMexit(i, reason, qualification);
|
||||
}
|
||||
|
||||
void BX_CPP_AttrRegparmN(1) BX_CPU_C::VMexit_HLT(bxInstruction_c *i)
|
||||
{
|
||||
BX_ASSERT(BX_CPU_THIS_PTR in_vmx_guest);
|
||||
|
||||
if (VMEXIT(VMX_VM_EXEC_CTRL2_HLT_VMEXIT)) {
|
||||
BX_ERROR(("VMEXIT: HLT"));
|
||||
VMexit(i, VMX_VMEXIT_HLT, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void BX_CPP_AttrRegparmN(1) BX_CPU_C::VMexit_PAUSE(bxInstruction_c *i)
|
||||
{
|
||||
BX_ASSERT(BX_CPU_THIS_PTR in_vmx_guest);
|
||||
@ -175,58 +165,6 @@ void BX_CPP_AttrRegparmN(1) BX_CPU_C::VMexit_PAUSE(bxInstruction_c *i)
|
||||
#endif
|
||||
}
|
||||
|
||||
void BX_CPP_AttrRegparmN(2) BX_CPU_C::VMexit_INVLPG(bxInstruction_c *i, bx_address laddr)
|
||||
{
|
||||
BX_ASSERT(BX_CPU_THIS_PTR in_vmx_guest);
|
||||
|
||||
if (VMEXIT(VMX_VM_EXEC_CTRL2_INVLPG_VMEXIT)) {
|
||||
BX_ERROR(("VMEXIT: INVLPG 0x" FMT_ADDRX, laddr));
|
||||
VMexit(i, VMX_VMEXIT_INVLPG, laddr);
|
||||
}
|
||||
}
|
||||
|
||||
void BX_CPP_AttrRegparmN(1) BX_CPU_C::VMexit_RDTSC(bxInstruction_c *i)
|
||||
{
|
||||
BX_ASSERT(BX_CPU_THIS_PTR in_vmx_guest);
|
||||
|
||||
if (VMEXIT(VMX_VM_EXEC_CTRL2_RDTSC_VMEXIT)) {
|
||||
BX_ERROR(("VMEXIT: RDTSC"));
|
||||
VMexit(i, (i->getIaOpcode() == BX_IA_RDTSC) ? VMX_VMEXIT_RDTSC : VMX_VMEXIT_RDTSCP, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void BX_CPP_AttrRegparmN(1) BX_CPU_C::VMexit_RDPMC(bxInstruction_c *i)
|
||||
{
|
||||
BX_ASSERT(BX_CPU_THIS_PTR in_vmx_guest);
|
||||
|
||||
if (VMEXIT(VMX_VM_EXEC_CTRL2_RDPMC_VMEXIT)) {
|
||||
BX_ERROR(("VMEXIT: RDPMC"));
|
||||
VMexit(i, VMX_VMEXIT_RDPMC, 0);
|
||||
}
|
||||
}
|
||||
|
||||
#if BX_SUPPORT_MONITOR_MWAIT
|
||||
void BX_CPP_AttrRegparmN(1) BX_CPU_C::VMexit_MONITOR(bxInstruction_c *i)
|
||||
{
|
||||
BX_ASSERT(BX_CPU_THIS_PTR in_vmx_guest);
|
||||
|
||||
if (VMEXIT(VMX_VM_EXEC_CTRL2_MONITOR_VMEXIT)) {
|
||||
BX_ERROR(("VMEXIT: MONITOR"));
|
||||
VMexit(i, VMX_VMEXIT_MONITOR, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void BX_CPP_AttrRegparmN(1) BX_CPU_C::VMexit_MWAIT(bxInstruction_c *i)
|
||||
{
|
||||
BX_ASSERT(BX_CPU_THIS_PTR in_vmx_guest);
|
||||
|
||||
if (VMEXIT(VMX_VM_EXEC_CTRL2_MWAIT_VMEXIT)) {
|
||||
BX_ERROR(("VMEXIT: MWAIT"));
|
||||
VMexit(i, VMX_VMEXIT_MWAIT, BX_CPU_THIS_PTR monitor.armed);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void BX_CPU_C::VMexit_ExtInterrupt(void)
|
||||
{
|
||||
if (! BX_CPU_THIS_PTR in_vmx_guest) return;
|
||||
@ -384,7 +322,7 @@ void BX_CPP_AttrRegparmN(3) BX_CPU_C::VMexit_MSR(bxInstruction_c *i, unsigned op
|
||||
// check MSR-HI bitmaps
|
||||
bx_phy_address pAddr = vm->msr_bitmap_addr + (msr >> 3) + 1024 + ((op == VMX_VMEXIT_RDMSR) ? 0 : 2048);
|
||||
access_read_physical(pAddr, 1, &field);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 1, BX_MSR_BITMAP_ACCESS | BX_READ, &field);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 1, BX_READ, BX_MSR_BITMAP_ACCESS, &field);
|
||||
if (field & (1 << (msr & 7)))
|
||||
vmexit = 1;
|
||||
}
|
||||
@ -395,7 +333,7 @@ void BX_CPP_AttrRegparmN(3) BX_CPU_C::VMexit_MSR(bxInstruction_c *i, unsigned op
|
||||
// check MSR-LO bitmaps
|
||||
bx_phy_address pAddr = vm->msr_bitmap_addr + (msr >> 3) + ((op == VMX_VMEXIT_RDMSR) ? 0 : 2048);
|
||||
access_read_physical(pAddr, 1, &field);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 1, BX_MSR_BITMAP_ACCESS | BX_READ, &field);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 1, BX_READ, BX_MSR_BITMAP_ACCESS, &field);
|
||||
if (field & (1 << (msr & 7)))
|
||||
vmexit = 1;
|
||||
}
|
||||
@ -431,21 +369,21 @@ void BX_CPP_AttrRegparmN(3) BX_CPU_C::VMexit_IO(bxInstruction_c *i, unsigned por
|
||||
// special case - the IO access split cross both I/O bitmaps
|
||||
pAddr = BX_CPU_THIS_PTR vmcs.io_bitmap_addr[0] + 0xfff;
|
||||
access_read_physical(pAddr, 1, &bitmap[0]);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 1, BX_IO_BITMAP_ACCESS | BX_READ, &bitmap[0]);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 1, BX_READ, BX_IO_BITMAP_ACCESS, &bitmap[0]);
|
||||
|
||||
pAddr = BX_CPU_THIS_PTR vmcs.io_bitmap_addr[1];
|
||||
access_read_physical(pAddr, 1, &bitmap[1]);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 1, BX_IO_BITMAP_ACCESS | BX_READ, &bitmap[1]);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 1, BX_READ, BX_IO_BITMAP_ACCESS, &bitmap[1]);
|
||||
}
|
||||
else {
|
||||
// access_read_physical cannot read 2 bytes cross 4K boundary :(
|
||||
pAddr = BX_CPU_THIS_PTR vmcs.io_bitmap_addr[(port >> 15) & 1] + ((port & 0x7fff) / 8);
|
||||
access_read_physical(pAddr, 1, &bitmap[0]);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 1, BX_IO_BITMAP_ACCESS | BX_READ, &bitmap[0]);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 1, BX_READ, BX_IO_BITMAP_ACCESS, &bitmap[0]);
|
||||
|
||||
pAddr++;
|
||||
access_read_physical(pAddr, 1, &bitmap[1]);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 1, BX_IO_BITMAP_ACCESS | BX_READ, &bitmap[1]);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 1, BX_READ, BX_IO_BITMAP_ACCESS, &bitmap[1]);
|
||||
}
|
||||
|
||||
Bit16u combined_bitmap = bitmap[1];
|
||||
@ -720,7 +658,7 @@ Bit32u BX_CPU_C::VMX_Read_VTPR(void)
|
||||
bx_phy_address pAddr = BX_CPU_THIS_PTR vmcs.virtual_apic_page_addr + 0x80;
|
||||
Bit32u vtpr;
|
||||
access_read_physical(pAddr, 4, (Bit8u*)(&vtpr));
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 4, BX_VMX_VTPR_ACCESS | BX_READ, (Bit8u*)(&vtpr));
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 4, BX_READ, BX_VMX_VTPR_ACCESS, (Bit8u*)(&vtpr));
|
||||
return vtpr;
|
||||
}
|
||||
|
||||
@ -731,7 +669,7 @@ void BX_CPU_C::VMX_Write_VTPR(Bit8u vtpr)
|
||||
Bit32u field32 = vtpr;
|
||||
|
||||
access_write_physical(pAddr, 4, (Bit8u*)(&field32));
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 4, BX_VMX_VTPR_ACCESS | BX_WRITE, (Bit8u*)(&field32));
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 4, BX_WRITE, BX_VMX_VTPR_ACCESS, (Bit8u*)(&field32));
|
||||
|
||||
Bit8u tpr_shadow = vtpr >> 4;
|
||||
if (tpr_shadow < vm->vm_tpr_threshold) {
|
||||
@ -800,16 +738,6 @@ void BX_CPU_C::VMX_Virtual_Apic_Write(bx_phy_address paddr, unsigned len, void *
|
||||
|
||||
#endif
|
||||
|
||||
void BX_CPP_AttrRegparmN(1) BX_CPU_C::VMexit_WBINVD(bxInstruction_c *i)
|
||||
{
|
||||
BX_ASSERT(BX_CPU_THIS_PTR in_vmx_guest);
|
||||
|
||||
if (SECONDARY_VMEXEC_CONTROL(VMX_VM_EXEC_CTRL3_WBINVD_VMEXIT)) {
|
||||
BX_ERROR(("VMEXIT: WBINVD in VMX non-root operation"));
|
||||
VMexit(i, VMX_VMEXIT_WBINVD, 0);
|
||||
}
|
||||
}
|
||||
|
||||
#if BX_SUPPORT_VMX >= 2
|
||||
Bit16u BX_CPU_C::VMX_Get_Current_VPID(void)
|
||||
{
|
||||
|
@ -71,7 +71,7 @@ Bit16u BX_CPP_AttrRegparmN(1) BX_CPU_C::VMread16(unsigned encoding)
|
||||
access_read_physical(pAddr, 2, (Bit8u*)(&field));
|
||||
}
|
||||
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 2, BX_VMCS_ACCESS | BX_READ, (Bit8u*)(&field));
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 2, BX_READ, BX_VMCS_ACCESS, (Bit8u*)(&field));
|
||||
|
||||
return field;
|
||||
}
|
||||
@ -95,7 +95,7 @@ void BX_CPP_AttrRegparmN(2) BX_CPU_C::VMwrite16(unsigned encoding, Bit16u val_16
|
||||
access_write_physical(pAddr, 2, (Bit8u*)(&val_16));
|
||||
}
|
||||
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 2, BX_VMCS_ACCESS | BX_WRITE, (Bit8u*)(&val_16));
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 2, BX_WRITE, BX_VMCS_ACCESS, (Bit8u*)(&val_16));
|
||||
}
|
||||
|
||||
Bit32u BX_CPP_AttrRegparmN(1) BX_CPU_C::VMread32(unsigned encoding)
|
||||
@ -115,7 +115,7 @@ Bit32u BX_CPP_AttrRegparmN(1) BX_CPU_C::VMread32(unsigned encoding)
|
||||
access_read_physical(pAddr, 4, (Bit8u*)(&field));
|
||||
}
|
||||
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 4, BX_VMCS_ACCESS | BX_READ, (Bit8u*)(&field));
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 4, BX_READ, BX_VMCS_ACCESS, (Bit8u*)(&field));
|
||||
|
||||
return field;
|
||||
}
|
||||
@ -137,7 +137,7 @@ void BX_CPP_AttrRegparmN(2) BX_CPU_C::VMwrite32(unsigned encoding, Bit32u val_32
|
||||
access_write_physical(pAddr, 4, (Bit8u*)(&val_32));
|
||||
}
|
||||
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 4, BX_VMCS_ACCESS | BX_WRITE, (Bit8u*)(&val_32));
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 4, BX_WRITE, BX_VMCS_ACCESS, (Bit8u*)(&val_32));
|
||||
}
|
||||
|
||||
Bit64u BX_CPP_AttrRegparmN(1) BX_CPU_C::VMread64(unsigned encoding)
|
||||
@ -159,7 +159,7 @@ Bit64u BX_CPP_AttrRegparmN(1) BX_CPU_C::VMread64(unsigned encoding)
|
||||
access_read_physical(pAddr, 8, (Bit8u*)(&field));
|
||||
}
|
||||
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 8, BX_VMCS_ACCESS | BX_READ, (Bit8u*)(&field));
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 8, BX_READ, BX_VMCS_ACCESS, (Bit8u*)(&field));
|
||||
|
||||
return field;
|
||||
}
|
||||
@ -183,7 +183,7 @@ void BX_CPP_AttrRegparmN(2) BX_CPU_C::VMwrite64(unsigned encoding, Bit64u val_64
|
||||
access_write_physical(pAddr, 8, (Bit8u*)(&val_64));
|
||||
}
|
||||
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 8, BX_VMCS_ACCESS | BX_WRITE, (Bit8u*)(&val_64));
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 8, BX_WRITE, BX_VMCS_ACCESS, (Bit8u*)(&val_64));
|
||||
}
|
||||
|
||||
#if BX_SUPPORT_X86_64
|
||||
@ -238,7 +238,7 @@ void BX_CPU_C::VMabort(VMX_vmabort_code error_code)
|
||||
Bit32u abort = error_code;
|
||||
bx_phy_address pAddr = BX_CPU_THIS_PTR vmcsptr + VMCS_VMX_ABORT_FIELD_ADDR;
|
||||
access_write_physical(pAddr, 4, &abort);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 4, BX_VMCS_ACCESS | BX_WRITE, (Bit8u*)(&abort));
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 4, BX_WRITE, BX_VMCS_ACCESS, (Bit8u*)(&abort));
|
||||
|
||||
#if BX_SUPPORT_VMX >= 2
|
||||
// Deactivate VMX preemtion timer
|
||||
@ -253,7 +253,7 @@ unsigned BX_CPU_C::VMXReadRevisionID(bx_phy_address pAddr)
|
||||
Bit32u revision;
|
||||
access_read_physical(pAddr + VMCS_REVISION_ID_FIELD_ADDR, 4, &revision);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr + VMCS_REVISION_ID_FIELD_ADDR, 4,
|
||||
BX_VMCS_ACCESS | BX_READ, (Bit8u*)(&revision));
|
||||
BX_READ, BX_VMCS_ACCESS, (Bit8u*)(&revision));
|
||||
|
||||
return revision;
|
||||
}
|
||||
@ -1703,9 +1703,9 @@ Bit32u BX_CPU_C::LoadMSRs(Bit32u msr_cnt, bx_phy_address pAddr)
|
||||
|
||||
for (Bit32u msr = 1; msr <= msr_cnt; msr++) {
|
||||
access_read_physical(pAddr, 8, &msr_lo);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 8, BX_VMX_LOAD_MSR_ACCESS | BX_READ, (Bit8u*)(&msr_lo));
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 8, BX_READ, BX_VMX_LOAD_MSR_ACCESS, (Bit8u*)(&msr_lo));
|
||||
access_read_physical(pAddr + 8, 8, &msr_hi);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr + 8, 8, BX_VMX_LOAD_MSR_ACCESS | BX_READ, (Bit8u*)(&msr_hi));
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr + 8, 8, BX_READ, BX_VMX_LOAD_MSR_ACCESS, (Bit8u*)(&msr_hi));
|
||||
|
||||
if (GET32H(msr_lo))
|
||||
return msr;
|
||||
@ -1737,7 +1737,7 @@ Bit32u BX_CPU_C::StoreMSRs(Bit32u msr_cnt, bx_phy_address pAddr)
|
||||
|
||||
for (Bit32u msr = 1; msr <= msr_cnt; msr++) {
|
||||
access_read_physical(pAddr, 8, &msr_lo);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 8, BX_VMX_STORE_MSR_ACCESS | BX_READ, (Bit8u*)(&msr_lo));
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 8, BX_READ, BX_VMX_STORE_MSR_ACCESS, (Bit8u*)(&msr_lo));
|
||||
|
||||
if (GET32H(msr_lo))
|
||||
return msr;
|
||||
@ -1753,7 +1753,7 @@ Bit32u BX_CPU_C::StoreMSRs(Bit32u msr_cnt, bx_phy_address pAddr)
|
||||
return msr;
|
||||
|
||||
access_write_physical(pAddr + 8, 8, &msr_hi);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr + 8, 8, BX_VMX_STORE_MSR_ACCESS | BX_WRITE, (Bit8u*)(&msr_hi));
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr + 8, 8, BX_WRITE, BX_VMX_STORE_MSR_ACCESS, (Bit8u*)(&msr_hi));
|
||||
|
||||
pAddr += 16; // to next MSR
|
||||
}
|
||||
@ -2316,7 +2316,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::VMCALL(bxInstruction_c *i)
|
||||
Bit32u launch_state;
|
||||
access_read_physical(BX_CPU_THIS_PTR vmcsptr + VMCS_LAUNCH_STATE_FIELD_ADDR, 4, &launch_state);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, BX_CPU_THIS_PTR vmcsptr + VMCS_LAUNCH_STATE_FIELD_ADDR, 4,
|
||||
BX_VMCS_ACCESS | BX_READ, (Bit8u*)(&launch_state));
|
||||
BX_READ, BX_VMCS_ACCESS, (Bit8u*)(&launch_state));
|
||||
|
||||
if (launch_state != VMCS_STATE_CLEAR) {
|
||||
BX_ERROR(("VMFAIL: VMCALL with launched VMCS"));
|
||||
@ -2393,7 +2393,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::VMLAUNCH(bxInstruction_c *i)
|
||||
Bit32u launch_state;
|
||||
access_read_physical(BX_CPU_THIS_PTR vmcsptr + VMCS_LAUNCH_STATE_FIELD_ADDR, 4, &launch_state);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, BX_CPU_THIS_PTR vmcsptr + VMCS_LAUNCH_STATE_FIELD_ADDR, 4,
|
||||
BX_VMCS_ACCESS | BX_READ, (Bit8u*)(&launch_state));
|
||||
BX_READ, BX_VMCS_ACCESS, (Bit8u*)(&launch_state));
|
||||
|
||||
if (vmlaunch) {
|
||||
if (launch_state != VMCS_STATE_CLEAR) {
|
||||
@ -2457,7 +2457,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::VMLAUNCH(bxInstruction_c *i)
|
||||
launch_state = VMCS_STATE_LAUNCHED;
|
||||
bx_phy_address pAddr = BX_CPU_THIS_PTR vmcsptr + VMCS_LAUNCH_STATE_FIELD_ADDR;
|
||||
access_write_physical(pAddr, 4, &launch_state);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 4, BX_VMCS_ACCESS | BX_WRITE, (Bit8u*)(&launch_state));
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr, 4, BX_WRITE, BX_VMCS_ACCESS, (Bit8u*)(&launch_state));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2839,7 +2839,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::VMCLEAR(bxInstruction_c *i)
|
||||
Bit32u launch_state = VMCS_STATE_CLEAR;
|
||||
access_write_physical(pAddr + VMCS_LAUNCH_STATE_FIELD_ADDR, 4, &launch_state);
|
||||
BX_DBG_PHY_MEMORY_ACCESS(BX_CPU_ID, pAddr + VMCS_LAUNCH_STATE_FIELD_ADDR, 4,
|
||||
BX_VMCS_ACCESS | BX_WRITE, (Bit8u*)(&launch_state));
|
||||
BX_WRITE, BX_VMCS_ACCESS, (Bit8u*)(&launch_state));
|
||||
|
||||
if (pAddr == BX_CPU_THIS_PTR vmcsptr) {
|
||||
BX_CPU_THIS_PTR vmcsptr = BX_INVALID_VMCSPTR;
|
||||
|
Loading…
Reference in New Issue
Block a user