[PATCH] allow enabling/disabling NPT by reloading only the architecture module - Kernel

This is a discussion on [PATCH] allow enabling/disabling NPT by reloading only the architecture module - Kernel ; If NPT is enabled after loading both KVM modules on AMD and it should be disabled, both KVM modules must be reloaded. If only the architecture module is reloaded the behavior is undefined. With this patch it is possible to ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: [PATCH] allow enabling/disabling NPT by reloading only the architecture module

  1. [PATCH] allow enabling/disabling NPT by reloading only the architecture module

    If NPT is enabled after loading both KVM modules on AMD and it should be
    disabled, both KVM modules must be reloaded. If only the architecture module is
    reloaded the behavior is undefined. With this patch it is possible to disable
    NPT only by reloading the kvm_amd module.

    Signed-off-by: Joerg Roedel
    ---
    arch/x86/kvm/mmu.c | 6 ++++++
    arch/x86/kvm/svm.c | 3 ++-
    include/asm-x86/kvm_host.h | 1 +
    3 files changed, 9 insertions(+), 1 deletions(-)

    diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
    index bcd0adb..6376e50 100644
    --- a/arch/x86/kvm/mmu.c
    +++ b/arch/x86/kvm/mmu.c
    @@ -1874,6 +1874,12 @@ void kvm_enable_tdp(void)
    }
    EXPORT_SYMBOL_GPL(kvm_enable_tdp);

    +void kvm_disable_tdp(void)
    +{
    + tdp_enabled = false;
    +}
    +EXPORT_SYMBOL_GPL(kvm_disable_tdp);
    +
    static void free_mmu_pages(struct kvm_vcpu *vcpu)
    {
    struct kvm_mmu_page *sp;
    diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
    index 0c3320e..09e753f 100644
    --- a/arch/x86/kvm/svm.c
    +++ b/arch/x86/kvm/svm.c
    @@ -452,7 +452,8 @@ static __init int svm_hardware_setup(void)
    if (npt_enabled) {
    printk(KERN_INFO "kvm: Nested Paging enabled\n");
    kvm_enable_tdp();
    - }
    + } else
    + kvm_disable_tdp();

    return 0;

    diff --git a/include/asm-x86/kvm_host.h b/include/asm-x86/kvm_host.h
    index b893a85..f760749 100644
    --- a/include/asm-x86/kvm_host.h
    +++ b/include/asm-x86/kvm_host.h
    @@ -567,6 +567,7 @@ int kvm_fix_hypercall(struct kvm_vcpu *vcpu);
    int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t gva, u32 error_code);

    void kvm_enable_tdp(void);
    +void kvm_disable_tdp(void);

    int load_pdptrs(struct kvm_vcpu *vcpu, unsigned long cr3);
    int complete_pio(struct kvm_vcpu *vcpu);
    --
    1.5.3.7


    --
    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/

  2. Re: [PATCH] allow enabling/disabling NPT by reloading only the architecture module

    Joerg Roedel wrote:
    > If NPT is enabled after loading both KVM modules on AMD and it should be
    > disabled, both KVM modules must be reloaded. If only the architecture module is
    > reloaded the behavior is undefined. With this patch it is possible to disable
    > NPT only by reloading the kvm_amd module.
    >
    >


    Applied, thanks.

    --
    Do not meddle in the internals of kernels, for they are subtle and quick to panic.

    --
    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/

+ Reply to Thread