lkml.org 
[lkml]   [2007]   [Aug]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Date
    Subject[2.6.20.17 review 13/58] KVM: SVM: Reliably detect if SVM was disabled by BIOS
    This patch adds an implementation to the svm is_disabled function to
    detect reliably if the BIOS disabled the SVM feature in the CPU. This
    fixes the issues with kernel panics when loading the kvm-amd module on
    machines where SVM is available but disabled.

    Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
    Signed-off-by: Avi Kivity <avi@qumranet.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
    Signed-off-by: Willy Tarreau <w@1wt.eu>
    ---
    drivers/kvm/svm.c | 6 ++++++
    drivers/kvm/svm.h | 3 +++
    2 files changed, 9 insertions(+), 0 deletions(-)

    diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c
    index c79df79..1e90401 100644
    --- a/drivers/kvm/svm.c
    +++ b/drivers/kvm/svm.c
    @@ -1655,6 +1655,12 @@ static void svm_inject_page_fault(struct kvm_vcpu *vcpu,

    static int is_disabled(void)
    {
    + u64 vm_cr;
    +
    + rdmsrl(MSR_VM_CR, vm_cr);
    + if (vm_cr & (1 << SVM_VM_CR_SVM_DISABLE))
    + return 1;
    +
    return 0;
    }

    diff --git a/drivers/kvm/svm.h b/drivers/kvm/svm.h
    index df731c3..e8f0349 100644
    --- a/drivers/kvm/svm.h
    +++ b/drivers/kvm/svm.h
    @@ -172,8 +172,11 @@ struct __attribute__ ((__packed__)) vmcb {
    #define SVM_CPUID_FUNC 0x8000000a

    #define MSR_EFER_SVME_MASK (1ULL << 12)
    +#define MSR_VM_CR 0xc0010114
    #define MSR_VM_HSAVE_PA 0xc0010117ULL

    +#define SVM_VM_CR_SVM_DISABLE 4
    +
    #define SVM_SELECTOR_S_SHIFT 4
    #define SVM_SELECTOR_DPL_SHIFT 5
    #define SVM_SELECTOR_P_SHIFT 7
    --
    1.5.2.5
    --
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2007-08-22 10:59    [W:0.019 / U:246.052 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site