提交 1155f76a 编写于 作者: A Avi Kivity

KVM: VMX: Read & store IDT_VECTORING_INFO_FIELD

We'll want to write to it in order to fix real-mode irq injection problems,
but it is a read-only field.  Storing it in a variable solves that issue.
Signed-off-by: NAvi Kivity <avi@qumranet.com>
上级 9c5623e3
...@@ -48,6 +48,7 @@ struct vcpu_vmx { ...@@ -48,6 +48,7 @@ struct vcpu_vmx {
struct kvm_vcpu vcpu; struct kvm_vcpu vcpu;
int launched; int launched;
u8 fail; u8 fail;
u32 idt_vectoring_info;
struct kvm_msr_entry *guest_msrs; struct kvm_msr_entry *guest_msrs;
struct kvm_msr_entry *host_msrs; struct kvm_msr_entry *host_msrs;
int nmsrs; int nmsrs;
...@@ -863,9 +864,10 @@ static int set_guest_debug(struct kvm_vcpu *vcpu, struct kvm_debug_guest *dbg) ...@@ -863,9 +864,10 @@ static int set_guest_debug(struct kvm_vcpu *vcpu, struct kvm_debug_guest *dbg)
static int vmx_get_irq(struct kvm_vcpu *vcpu) static int vmx_get_irq(struct kvm_vcpu *vcpu)
{ {
struct vcpu_vmx *vmx = to_vmx(vcpu);
u32 idtv_info_field; u32 idtv_info_field;
idtv_info_field = vmcs_read32(IDT_VECTORING_INFO_FIELD); idtv_info_field = vmx->idt_vectoring_info;
if (idtv_info_field & INTR_INFO_VALID_MASK) { if (idtv_info_field & INTR_INFO_VALID_MASK) {
if (is_external_interrupt(idtv_info_field)) if (is_external_interrupt(idtv_info_field))
return idtv_info_field & VECTORING_INFO_VECTOR_MASK; return idtv_info_field & VECTORING_INFO_VECTOR_MASK;
...@@ -1817,12 +1819,13 @@ static int handle_rmode_exception(struct kvm_vcpu *vcpu, ...@@ -1817,12 +1819,13 @@ static int handle_rmode_exception(struct kvm_vcpu *vcpu,
static int handle_exception(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) static int handle_exception(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
{ {
struct vcpu_vmx *vmx = to_vmx(vcpu);
u32 intr_info, error_code; u32 intr_info, error_code;
unsigned long cr2, rip; unsigned long cr2, rip;
u32 vect_info; u32 vect_info;
enum emulation_result er; enum emulation_result er;
vect_info = vmcs_read32(IDT_VECTORING_INFO_FIELD); vect_info = vmx->idt_vectoring_info;
intr_info = vmcs_read32(VM_EXIT_INTR_INFO); intr_info = vmcs_read32(VM_EXIT_INTR_INFO);
if ((vect_info & VECTORING_INFO_VALID_MASK) && if ((vect_info & VECTORING_INFO_VALID_MASK) &&
...@@ -2171,9 +2174,9 @@ static const int kvm_vmx_max_exit_handlers = ...@@ -2171,9 +2174,9 @@ static const int kvm_vmx_max_exit_handlers =
*/ */
static int kvm_handle_exit(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) static int kvm_handle_exit(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
{ {
u32 vectoring_info = vmcs_read32(IDT_VECTORING_INFO_FIELD);
u32 exit_reason = vmcs_read32(VM_EXIT_REASON); u32 exit_reason = vmcs_read32(VM_EXIT_REASON);
struct vcpu_vmx *vmx = to_vmx(vcpu); struct vcpu_vmx *vmx = to_vmx(vcpu);
u32 vectoring_info = vmx->idt_vectoring_info;
if (unlikely(vmx->fail)) { if (unlikely(vmx->fail)) {
kvm_run->exit_reason = KVM_EXIT_FAIL_ENTRY; kvm_run->exit_reason = KVM_EXIT_FAIL_ENTRY;
...@@ -2228,6 +2231,7 @@ static void enable_irq_window(struct kvm_vcpu *vcpu) ...@@ -2228,6 +2231,7 @@ static void enable_irq_window(struct kvm_vcpu *vcpu)
static void vmx_intr_assist(struct kvm_vcpu *vcpu) static void vmx_intr_assist(struct kvm_vcpu *vcpu)
{ {
struct vcpu_vmx *vmx = to_vmx(vcpu);
u32 idtv_info_field, intr_info_field; u32 idtv_info_field, intr_info_field;
int has_ext_irq, interrupt_window_open; int has_ext_irq, interrupt_window_open;
int vector; int vector;
...@@ -2236,7 +2240,7 @@ static void vmx_intr_assist(struct kvm_vcpu *vcpu) ...@@ -2236,7 +2240,7 @@ static void vmx_intr_assist(struct kvm_vcpu *vcpu)
has_ext_irq = kvm_cpu_has_interrupt(vcpu); has_ext_irq = kvm_cpu_has_interrupt(vcpu);
intr_info_field = vmcs_read32(VM_ENTRY_INTR_INFO_FIELD); intr_info_field = vmcs_read32(VM_ENTRY_INTR_INFO_FIELD);
idtv_info_field = vmcs_read32(IDT_VECTORING_INFO_FIELD); idtv_info_field = vmx->idt_vectoring_info;
if (intr_info_field & INTR_INFO_VALID_MASK) { if (intr_info_field & INTR_INFO_VALID_MASK) {
if (idtv_info_field & INTR_INFO_VALID_MASK) { if (idtv_info_field & INTR_INFO_VALID_MASK) {
/* TODO: fault when IDT_Vectoring */ /* TODO: fault when IDT_Vectoring */
...@@ -2396,6 +2400,8 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) ...@@ -2396,6 +2400,8 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
#endif #endif
); );
vmx->idt_vectoring_info = vmcs_read32(IDT_VECTORING_INFO_FIELD);
vcpu->interrupt_window_open = vcpu->interrupt_window_open =
(vmcs_read32(GUEST_INTERRUPTIBILITY_INFO) & 3) == 0; (vmcs_read32(GUEST_INTERRUPTIBILITY_INFO) & 3) == 0;
...@@ -2413,7 +2419,8 @@ static void vmx_inject_page_fault(struct kvm_vcpu *vcpu, ...@@ -2413,7 +2419,8 @@ static void vmx_inject_page_fault(struct kvm_vcpu *vcpu,
unsigned long addr, unsigned long addr,
u32 err_code) u32 err_code)
{ {
u32 vect_info = vmcs_read32(IDT_VECTORING_INFO_FIELD); struct vcpu_vmx *vmx = to_vmx(vcpu);
u32 vect_info = vmx->idt_vectoring_info;
++vcpu->stat.pf_guest; ++vcpu->stat.pf_guest;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册