lkml.org 
[lkml]   [2009]   [Feb]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 01/40] KVM: SVM: Clean up VINTR setting
    Date
    From: Alexander Graf <agraf@suse.de>

    The current VINTR intercept setters don't look clean to me. To make
    the code easier to read and enable the possibilty to trap on a VINTR
    set, this uses a helper function to set the VINTR intercept.

    v2 uses two distinct functions for setting and clearing the bit

    Acked-by: Joerg Roedel <joro@8bytes.org>
    Signed-off-by: Alexander Graf <agraf@suse.de>
    Signed-off-by: Avi Kivity <avi@redhat.com>
    ---
    arch/x86/kvm/svm.c | 20 +++++++++++++++-----
    1 files changed, 15 insertions(+), 5 deletions(-)

    diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
    index a9e769e..33407d9 100644
    --- a/arch/x86/kvm/svm.c
    +++ b/arch/x86/kvm/svm.c
    @@ -718,6 +718,16 @@ static void svm_set_rflags(struct kvm_vcpu *vcpu, unsigned long rflags)
    to_svm(vcpu)->vmcb->save.rflags = rflags;
    }

    +static void svm_set_vintr(struct vcpu_svm *svm)
    +{
    + svm->vmcb->control.intercept |= 1ULL << INTERCEPT_VINTR;
    +}
    +
    +static void svm_clear_vintr(struct vcpu_svm *svm)
    +{
    + svm->vmcb->control.intercept &= ~(1ULL << INTERCEPT_VINTR);
    +}
    +
    static struct vmcb_seg *svm_seg(struct kvm_vcpu *vcpu, int seg)
    {
    struct vmcb_save_area *save = &to_svm(vcpu)->vmcb->save;
    @@ -1380,7 +1390,7 @@ static int interrupt_window_interception(struct vcpu_svm *svm,
    {
    KVMTRACE_0D(PEND_INTR, &svm->vcpu, handler);

    - svm->vmcb->control.intercept &= ~(1ULL << INTERCEPT_VINTR);
    + svm_clear_vintr(svm);
    svm->vmcb->control.int_ctl &= ~V_IRQ_MASK;
    /*
    * If the user space waits to inject interrupts, exit as soon as
    @@ -1593,7 +1603,7 @@ static void svm_intr_assist(struct kvm_vcpu *vcpu)
    (vmcb->control.int_state & SVM_INTERRUPT_SHADOW_MASK) ||
    (vmcb->control.event_inj & SVM_EVTINJ_VALID)) {
    /* unable to deliver irq, set pending irq */
    - vmcb->control.intercept |= (1ULL << INTERCEPT_VINTR);
    + svm_set_vintr(svm);
    svm_inject_irq(svm, 0x0);
    goto out;
    }
    @@ -1652,9 +1662,9 @@ static void do_interrupt_requests(struct kvm_vcpu *vcpu,
    */
    if (!svm->vcpu.arch.interrupt_window_open &&
    (svm->vcpu.arch.irq_summary || kvm_run->request_interrupt_window))
    - control->intercept |= 1ULL << INTERCEPT_VINTR;
    - else
    - control->intercept &= ~(1ULL << INTERCEPT_VINTR);
    + svm_set_vintr(svm);
    + else
    + svm_clear_vintr(svm);
    }

    static int svm_set_tss_addr(struct kvm *kvm, unsigned int addr)
    --
    1.6.0.6


    \
     
     \ /
      Last update: 2009-02-26 15:21    [W:0.031 / U:32.088 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site