KVM: remove kvm_arch_gmem_prepare_needed()
It is enough to return 0 if a guest need not do any preparation. This is in fact how sev_gmem_prepare() works for non-SNP guests, and it extends naturally to Intel hosts: the x86 callback for gmem_prepare is optional and returns 0 if not defined. Reviewed-by: Michael Roth <michael.roth@amd.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
6dd761d92f
commit
7239ed7467
@ -13645,11 +13645,6 @@ bool kvm_arch_no_poll(struct kvm_vcpu *vcpu)
|
||||
EXPORT_SYMBOL_GPL(kvm_arch_no_poll);
|
||||
|
||||
#ifdef CONFIG_HAVE_KVM_ARCH_GMEM_PREPARE
|
||||
bool kvm_arch_gmem_prepare_needed(struct kvm *kvm)
|
||||
{
|
||||
return kvm->arch.vm_type == KVM_X86_SNP_VM;
|
||||
}
|
||||
|
||||
int kvm_arch_gmem_prepare(struct kvm *kvm, gfn_t gfn, kvm_pfn_t pfn, int max_order)
|
||||
{
|
||||
return kvm_x86_call(gmem_prepare)(kvm, pfn, gfn, max_order);
|
||||
|
@ -2447,7 +2447,6 @@ static inline int kvm_gmem_get_pfn(struct kvm *kvm,
|
||||
|
||||
#ifdef CONFIG_HAVE_KVM_ARCH_GMEM_PREPARE
|
||||
int kvm_arch_gmem_prepare(struct kvm *kvm, gfn_t gfn, kvm_pfn_t pfn, int max_order);
|
||||
bool kvm_arch_gmem_prepare_needed(struct kvm *kvm);
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -29,16 +29,9 @@ static int __kvm_gmem_prepare_folio(struct kvm *kvm, struct kvm_memory_slot *slo
|
||||
pgoff_t index, struct folio *folio)
|
||||
{
|
||||
#ifdef CONFIG_HAVE_KVM_ARCH_GMEM_PREPARE
|
||||
kvm_pfn_t pfn;
|
||||
gfn_t gfn;
|
||||
int rc;
|
||||
|
||||
if (!kvm_arch_gmem_prepare_needed(kvm))
|
||||
return 0;
|
||||
|
||||
pfn = folio_file_pfn(folio, index);
|
||||
gfn = slot->base_gfn + index - slot->gmem.pgoff;
|
||||
rc = kvm_arch_gmem_prepare(kvm, gfn, pfn, folio_order(folio));
|
||||
kvm_pfn_t pfn = folio_file_pfn(folio, index);
|
||||
gfn_t gfn = slot->base_gfn + index - slot->gmem.pgoff;
|
||||
int rc = kvm_arch_gmem_prepare(kvm, gfn, pfn, folio_order(folio));
|
||||
if (rc) {
|
||||
pr_warn_ratelimited("gmem: Failed to prepare folio for index %lx GFN %llx PFN %llx error %d.\n",
|
||||
index, gfn, pfn, rc);
|
||||
|
Loading…
Reference in New Issue
Block a user