[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1457124368-2025-5-git-send-email-Suravee.Suthikulpanit@amd.com>
Date: Fri, 4 Mar 2016 14:46:02 -0600
From: Suravee Suthikulpanit <Suravee.Suthikulpanit@....com>
To: <pbonzini@...hat.com>, <rkrcmar@...hat.com>, <joro@...tes.org>,
<bp@...en8.de>, <gleb@...nel.org>, <alex.williamson@...hat.com>
CC: <kvm@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<wei@...hat.com>, <sherry.hurwitz@....com>,
Suravee Suthikulpanit <suravee.suthikulpanit@....com>
Subject: [PART1 RFC v2 04/10] svm: clean up V_TPR, V_IRQ, V_INTR_PRIO, and V_INTR_MASKING
From: Suravee Suthikulpanit <suravee.suthikulpanit@....com>
Now that we have defined the bit field, use them to replace existing
macros. This patch should not have functional change.
Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@....com>
---
arch/x86/include/asm/svm.h | 9 ---------
arch/x86/kvm/svm.c | 24 ++++++++++++------------
2 files changed, 12 insertions(+), 21 deletions(-)
diff --git a/arch/x86/include/asm/svm.h b/arch/x86/include/asm/svm.h
index db5d7af..7bb34c9 100644
--- a/arch/x86/include/asm/svm.h
+++ b/arch/x86/include/asm/svm.h
@@ -118,18 +118,9 @@ struct __attribute__ ((__packed__)) vmcb_control_area {
#define V_TPR_MASK 0x0f
-#define V_IRQ_SHIFT 8
-#define V_IRQ_MASK (1 << V_IRQ_SHIFT)
-
-#define V_INTR_PRIO_SHIFT 16
-#define V_INTR_PRIO_MASK (0x0f << V_INTR_PRIO_SHIFT)
-
#define V_IGN_TPR_SHIFT 20
#define V_IGN_TPR_MASK (1 << V_IGN_TPR_SHIFT)
-#define V_INTR_MASKING_SHIFT 24
-#define V_INTR_MASKING_MASK (1 << V_INTR_MASKING_SHIFT)
-
#define SVM_INTERRUPT_SHADOW_MASK 1
#define SVM_IOIO_STR_SHIFT 2
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 28f8618..6ab66d0 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -1052,7 +1052,7 @@ static void init_vmcb(struct vcpu_svm *svm)
control->iopm_base_pa = iopm_base;
control->msrpm_base_pa = __pa(svm->msrpm);
- control->int_ctl = V_INTR_MASKING_MASK;
+ control->v_intr_masking = 1;
init_seg(&save->es);
init_seg(&save->ss);
@@ -2316,7 +2316,7 @@ static int nested_svm_vmexit(struct vcpu_svm *svm)
/* We always set V_INTR_MASKING and remember the old value in hflags */
if (!(svm->vcpu.arch.hflags & HF_VINTR_MASK))
- nested_vmcb->control.int_ctl &= ~V_INTR_MASKING_MASK;
+ nested_vmcb->control.v_intr_masking = 0;
/* Restore the original control entries */
copy_vmcb_control_area(vmcb, hsave);
@@ -2526,8 +2526,9 @@ static bool nested_svm_vmrun(struct vcpu_svm *svm)
svm->nested.intercept = nested_vmcb->control.intercept;
svm_flush_tlb(&svm->vcpu);
- svm->vmcb->control.int_ctl = nested_vmcb->control.int_ctl | V_INTR_MASKING_MASK;
- if (nested_vmcb->control.int_ctl & V_INTR_MASKING_MASK)
+ svm->vmcb->control.int_ctl = nested_vmcb->control.int_ctl;
+ svm->vmcb->control.v_intr_masking = 1;
+ if (nested_vmcb->control.v_intr_masking)
svm->vcpu.arch.hflags |= HF_VINTR_MASK;
else
svm->vcpu.arch.hflags &= ~HF_VINTR_MASK;
@@ -2680,7 +2681,7 @@ static int clgi_interception(struct vcpu_svm *svm)
/* After a CLGI no interrupts should come */
svm_clear_vintr(svm);
- svm->vmcb->control.int_ctl &= ~V_IRQ_MASK;
+ svm->vmcb->control.v_irq = 0;
mark_dirty(svm->vmcb, VMCB_INTR);
@@ -3257,7 +3258,7 @@ static int interrupt_window_interception(struct vcpu_svm *svm)
{
kvm_make_request(KVM_REQ_EVENT, &svm->vcpu);
svm_clear_vintr(svm);
- svm->vmcb->control.int_ctl &= ~V_IRQ_MASK;
+ svm->vmcb->control.v_irq = 0;
mark_dirty(svm->vmcb, VMCB_INTR);
++svm->vcpu.stat.irq_window_exits;
return 1;
@@ -3568,11 +3569,11 @@ static inline void svm_inject_irq(struct vcpu_svm *svm, int irq)
{
struct vmcb_control_area *control;
+
control = &svm->vmcb->control;
control->int_vector = irq;
- control->int_ctl &= ~V_INTR_PRIO_MASK;
- control->int_ctl |= V_IRQ_MASK |
- ((/*control->int_vector >> 4*/ 0xf) << V_INTR_PRIO_SHIFT);
+ control->v_intr_prio = 0xf;
+ control->v_irq = 1;
mark_dirty(svm->vmcb, VMCB_INTR);
}
@@ -3738,7 +3739,7 @@ static inline void sync_cr8_to_lapic(struct kvm_vcpu *vcpu)
return;
if (!is_cr_intercept(svm, INTERCEPT_CR8_WRITE)) {
- int cr8 = svm->vmcb->control.int_ctl & V_TPR_MASK;
+ int cr8 = svm->vmcb->control.v_tpr & V_TPR_MASK;
kvm_set_cr8(vcpu, cr8);
}
}
@@ -3752,8 +3753,7 @@ static inline void sync_lapic_to_cr8(struct kvm_vcpu *vcpu)
return;
cr8 = kvm_get_cr8(vcpu);
- svm->vmcb->control.int_ctl &= ~V_TPR_MASK;
- svm->vmcb->control.int_ctl |= cr8 & V_TPR_MASK;
+ svm->vmcb->control.v_tpr = cr8 & V_TPR_MASK;
}
static void svm_complete_interrupts(struct vcpu_svm *svm)
--
1.9.1
Powered by blists - more mailing lists