lkml.org 
[lkml]   [2021]   [Oct]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH Part2 v5 21/45] KVM: SVM: Make AVIC backing, VMSA and VMCB memory allocation SNP safe
    On Fri, Aug 20, 2021, Brijesh Singh wrote:
    > Implement a workaround for an SNP erratum where the CPU will incorrectly
    > signal an RMP violation #PF if a hugepage (2mb or 1gb) collides with the
    > RMP entry of a VMCB, VMSA or AVIC backing page.

    ...

    > @@ -4539,6 +4539,16 @@ static int svm_vm_init(struct kvm *kvm)
    > return 0;
    > }
    >
    > +static void *svm_alloc_apic_backing_page(struct kvm_vcpu *vcpu)
    > +{
    > + struct page *page = snp_safe_alloc_page(vcpu);
    > +
    > + if (!page)
    > + return NULL;
    > +
    > + return page_address(page);
    > +}
    > +
    > static struct kvm_x86_ops svm_x86_ops __initdata = {
    > .hardware_unsetup = svm_hardware_teardown,
    > .hardware_enable = svm_hardware_enable,
    > @@ -4667,6 +4677,8 @@ static struct kvm_x86_ops svm_x86_ops __initdata = {
    > .complete_emulated_msr = svm_complete_emulated_msr,
    >
    > .vcpu_deliver_sipi_vector = svm_vcpu_deliver_sipi_vector,
    > +
    > + .alloc_apic_backing_page = svm_alloc_apic_backing_page,

    IMO, this should be guarded by a module param or X86_BUG_* to make it clear that
    this is a bug and not working as intended.

    And doesn't the APIC page need these shenanigans iff AVIC is enabled? (the module
    param, not necessarily in the VM)

    > };
    >
    > static struct kvm_x86_init_ops svm_init_ops __initdata = {
    > diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h
    > index d1f1512a4b47..e40800e9c998 100644
    > --- a/arch/x86/kvm/svm/svm.h
    > +++ b/arch/x86/kvm/svm/svm.h
    > @@ -575,6 +575,7 @@ void sev_es_create_vcpu(struct vcpu_svm *svm);
    > void sev_vcpu_deliver_sipi_vector(struct kvm_vcpu *vcpu, u8 vector);
    > void sev_es_prepare_guest_switch(struct vcpu_svm *svm, unsigned int cpu);
    > void sev_es_unmap_ghcb(struct vcpu_svm *svm);
    > +struct page *snp_safe_alloc_page(struct kvm_vcpu *vcpu);
    >
    > /* vmenter.S */
    >
    > --
    > 2.17.1
    >

    \
     
     \ /
      Last update: 2021-10-12 22:45    [W:4.201 / U:0.004 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site