cleanups and code updates before thinking of INIT redirection implementation for AMD SVM
This commit is contained in:
parent
61a35063c5
commit
e4deec2aca
@ -327,7 +327,8 @@ enum BX_Exception {
|
||||
BX_MC_EXCEPTION = 18,
|
||||
BX_XM_EXCEPTION = 19,
|
||||
BX_VE_EXCEPTION = 20,
|
||||
BX_CP_EXCEPTION = 21 // Control Protection (fault)
|
||||
BX_CP_EXCEPTION = 21, // Control Protection (fault)
|
||||
BX_SX_EXCEPTION = 30 // SVM Security Exception (fault)
|
||||
};
|
||||
|
||||
enum CP_Exception_Error_Code {
|
||||
@ -4446,6 +4447,8 @@ public: // for now...
|
||||
#if BX_SUPPORT_X86_64
|
||||
BX_SMF void long_mode_int(Bit8u vector, bool soft_int, bool push_error, Bit16u error_code);
|
||||
#endif
|
||||
BX_SMF bool exception_push_error(unsigned vector);
|
||||
BX_SMF int get_exception_type(unsigned vector);
|
||||
BX_SMF void exception(unsigned vector, Bit16u error_code)
|
||||
BX_CPP_AttrNoReturn();
|
||||
BX_SMF void init_SMRAM(void);
|
||||
|
@ -262,12 +262,12 @@ bool BX_CPU_C::handleAsyncEvent(void)
|
||||
}
|
||||
|
||||
if (is_unmasked_event_pending(BX_EVENT_INIT) && SVM_GIF) {
|
||||
clear_event(BX_EVENT_INIT);
|
||||
#if BX_SUPPORT_SVM
|
||||
if (BX_CPU_THIS_PTR in_svm_guest) {
|
||||
if (SVM_INTERCEPT(SVM_INTERCEPT0_INIT)) Svm_Vmexit(SVM_VMEXIT_INIT);
|
||||
if (SVM_INTERCEPT(SVM_INTERCEPT0_INIT)) Svm_Vmexit(SVM_VMEXIT_INIT); // INIT is still pending
|
||||
}
|
||||
#endif
|
||||
clear_event(BX_EVENT_INIT);
|
||||
#if BX_SUPPORT_VMX
|
||||
if (BX_CPU_THIS_PTR in_vmx_guest) {
|
||||
VMexit(VMX_VMEXIT_INIT, 0);
|
||||
|
@ -857,7 +857,7 @@ struct BxExceptionInfo {
|
||||
bool push_error;
|
||||
};
|
||||
|
||||
static struct BxExceptionInfo exceptions_info[BX_CPU_HANDLED_EXCEPTIONS] = {
|
||||
static const struct BxExceptionInfo exceptions_info[BX_CPU_HANDLED_EXCEPTIONS] = {
|
||||
/* DE */ { BX_ET_CONTRIBUTORY, BX_EXCEPTION_CLASS_FAULT, 0 },
|
||||
/* DB */ { BX_ET_BENIGN, BX_EXCEPTION_CLASS_FAULT, 0 },
|
||||
/* 02 */ { BX_ET_BENIGN, BX_EXCEPTION_CLASS_FAULT, 0 }, // NMI
|
||||
@ -889,7 +889,7 @@ static struct BxExceptionInfo exceptions_info[BX_CPU_HANDLED_EXCEPTIONS] = {
|
||||
/* 27 */ { BX_ET_BENIGN, BX_EXCEPTION_CLASS_FAULT, 0 },
|
||||
/* 28 */ { BX_ET_BENIGN, BX_EXCEPTION_CLASS_FAULT, 0 },
|
||||
/* 29 */ { BX_ET_BENIGN, BX_EXCEPTION_CLASS_FAULT, 0 },
|
||||
/* 30 */ { BX_ET_BENIGN, BX_EXCEPTION_CLASS_FAULT, 0 }, // FIXME: SVM #SF
|
||||
/* SX */ { BX_ET_CONTRIBUTORY, BX_EXCEPTION_CLASS_FAULT, 1 }, // SVM #SX is here and pushes error code
|
||||
/* 31 */ { BX_ET_BENIGN, BX_EXCEPTION_CLASS_FAULT, 0 }
|
||||
};
|
||||
|
||||
@ -901,18 +901,30 @@ int get_exception_class(unsigned vector)
|
||||
return BX_EXCEPTION_CLASS_FAULT;
|
||||
}
|
||||
|
||||
int get_exception_type(unsigned vector)
|
||||
int BX_CPU_C::get_exception_type(unsigned vector)
|
||||
{
|
||||
if (vector < BX_CPU_HANDLED_EXCEPTIONS)
|
||||
if (vector < BX_CPU_HANDLED_EXCEPTIONS) {
|
||||
if (vector == BX_CP_EXCEPTION)
|
||||
if (! BX_CPUID_SUPPORT_ISA_EXTENSION(BX_ISA_CET))
|
||||
return BX_ET_BENIGN;
|
||||
if (vector == BX_SX_EXCEPTION)
|
||||
if (! BX_CPUID_SUPPORT_ISA_EXTENSION(BX_ISA_SVM))
|
||||
return BX_ET_BENIGN;
|
||||
return exceptions_info[vector].exception_type;
|
||||
}
|
||||
else
|
||||
return BX_ET_BENIGN;
|
||||
}
|
||||
|
||||
bool exception_push_error(unsigned vector)
|
||||
bool BX_CPU_C::exception_push_error(unsigned vector)
|
||||
{
|
||||
if (vector < BX_CPU_HANDLED_EXCEPTIONS)
|
||||
return exceptions_info[vector].push_error;
|
||||
if (vector < BX_CPU_HANDLED_EXCEPTIONS) {
|
||||
if (vector == BX_CP_EXCEPTION)
|
||||
if (! BX_CPUID_SUPPORT_ISA_EXTENSION(BX_ISA_CET)) return false;
|
||||
if (vector == BX_SX_EXCEPTION)
|
||||
if (! BX_CPUID_SUPPORT_ISA_EXTENSION(BX_ISA_SVM)) return false;
|
||||
return exceptions_info[vector].push_error;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
@ -1000,10 +1000,6 @@ VMX_error_code BX_CPU_C::VMenterLoadCheckVmControls(void)
|
||||
if (event_type == BX_HARDWARE_EXCEPTION && vector < BX_CPU_HANDLED_EXCEPTIONS)
|
||||
push_error_reference = exception_push_error(vector);
|
||||
|
||||
if (! BX_CPUID_SUPPORT_ISA_EXTENSION(BX_ISA_CET)) {
|
||||
if (vector == BX_CP_EXCEPTION) push_error_reference = false;
|
||||
}
|
||||
|
||||
if (vm->vmentry_interr_info & 0x7ffff000) {
|
||||
BX_ERROR(("VMFAIL: VMENTRY broken interruption info field"));
|
||||
return VMXERR_VMENTRY_INVALID_VM_CONTROL_FIELD;
|
||||
|
Loading…
Reference in New Issue
Block a user