lkml.org 
[lkml]   [2020]   [Dec]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v9 07/18] KVM: x86: Add AMD SEV specific Hypercall3
    Date
    From: Brijesh Singh <brijesh.singh@amd.com>

    KVM hypercall framework relies on alternative framework to patch the
    VMCALL -> VMMCALL on AMD platform. If a hypercall is made before
    apply_alternative() is called then it defaults to VMCALL. The approach
    works fine on non SEV guest. A VMCALL would causes #UD, and hypervisor
    will be able to decode the instruction and do the right things. But
    when SEV is active, guest memory is encrypted with guest key and
    hypervisor will not be able to decode the instruction bytes.

    Add SEV specific hypercall3, it unconditionally uses VMMCALL. The hypercall
    will be used by the SEV guest to notify encrypted pages to the hypervisor.

    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: "H. Peter Anvin" <hpa@zytor.com>
    Cc: Paolo Bonzini <pbonzini@redhat.com>
    Cc: "Radim Krčmář" <rkrcmar@redhat.com>
    Cc: Joerg Roedel <joro@8bytes.org>
    Cc: Borislav Petkov <bp@suse.de>
    Cc: Tom Lendacky <thomas.lendacky@amd.com>
    Cc: x86@kernel.org
    Cc: kvm@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Reviewed-by: Steve Rutherford <srutherford@google.com>
    Reviewed-by: Venu Busireddy <venu.busireddy@oracle.com>
    Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
    Signed-off-by: Ashish Kalra <ashish.kalra@amd.com>
    ---
    arch/x86/include/asm/kvm_para.h | 12 ++++++++++++
    1 file changed, 12 insertions(+)

    diff --git a/arch/x86/include/asm/kvm_para.h b/arch/x86/include/asm/kvm_para.h
    index 338119852512..bc1b11d057fc 100644
    --- a/arch/x86/include/asm/kvm_para.h
    +++ b/arch/x86/include/asm/kvm_para.h
    @@ -85,6 +85,18 @@ static inline long kvm_hypercall4(unsigned int nr, unsigned long p1,
    return ret;
    }

    +static inline long kvm_sev_hypercall3(unsigned int nr, unsigned long p1,
    + unsigned long p2, unsigned long p3)
    +{
    + long ret;
    +
    + asm volatile("vmmcall"
    + : "=a"(ret)
    + : "a"(nr), "b"(p1), "c"(p2), "d"(p3)
    + : "memory");
    + return ret;
    +}
    +
    #ifdef CONFIG_KVM_GUEST
    bool kvm_para_available(void);
    unsigned int kvm_arch_para_features(void);
    --
    2.17.1
    \
     
     \ /
      Last update: 2020-12-08 23:09    [W:4.638 / U:0.084 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site