2021-06-03 15:14:40 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
/*
|
|
|
|
* KVM L1 hypervisor optimizations on Hyper-V for SVM.
|
|
|
|
*/
|
KVM: x86: Unify pr_fmt to use module name for all KVM modules
Define pr_fmt using KBUILD_MODNAME for all KVM x86 code so that printks
use consistent formatting across common x86, Intel, and AMD code. In
addition to providing consistent print formatting, using KBUILD_MODNAME,
e.g. kvm_amd and kvm_intel, allows referencing SVM and VMX (and SEV and
SGX and ...) as technologies without generating weird messages, and
without causing naming conflicts with other kernel code, e.g. "SEV: ",
"tdx: ", "sgx: " etc.. are all used by the kernel for non-KVM subsystems.
Opportunistically move away from printk() for prints that need to be
modified anyways, e.g. to drop a manual "kvm: " prefix.
Opportunistically convert a few SGX WARNs that are similarly modified to
WARN_ONCE; in the very unlikely event that the WARNs fire, odds are good
that they would fire repeatedly and spam the kernel log without providing
unique information in each print.
Note, defining pr_fmt yields undesirable results for code that uses KVM's
printk wrappers, e.g. vcpu_unimpl(). But, that's a pre-existing problem
as SVM/kvm_amd already defines a pr_fmt, and thankfully use of KVM's
wrappers is relatively limited in KVM x86 code.
Signed-off-by: Sean Christopherson <seanjc@google.com>
Reviewed-by: Paul Durrant <paul@xen.org>
Message-Id: <20221130230934.1014142-35-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-11-30 23:09:18 +00:00
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
2021-06-03 15:14:40 +00:00
|
|
|
|
|
|
|
#include <linux/kvm_host.h>
|
|
|
|
|
|
|
|
#include <asm/mshyperv.h>
|
|
|
|
|
|
|
|
#include "svm.h"
|
|
|
|
#include "svm_ops.h"
|
|
|
|
|
|
|
|
#include "hyperv.h"
|
|
|
|
#include "kvm_onhyperv.h"
|
|
|
|
#include "svm_onhyperv.h"
|
|
|
|
|
2022-11-01 14:53:43 +00:00
|
|
|
int svm_hv_enable_l2_tlb_flush(struct kvm_vcpu *vcpu)
|
2021-06-03 15:14:40 +00:00
|
|
|
{
|
2022-11-01 14:53:42 +00:00
|
|
|
struct hv_vmcb_enlightenments *hve;
|
2023-12-05 10:36:16 +00:00
|
|
|
hpa_t partition_assist_page = hv_get_partition_assist_page(vcpu);
|
2021-06-03 15:14:40 +00:00
|
|
|
|
2023-12-05 10:36:16 +00:00
|
|
|
if (partition_assist_page == INVALID_PAGE)
|
2021-06-03 15:14:40 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
|
2022-11-01 14:53:41 +00:00
|
|
|
hve = &to_svm(vcpu)->vmcb->control.hv_enlightenments;
|
2021-06-03 15:14:40 +00:00
|
|
|
|
2023-12-05 10:36:16 +00:00
|
|
|
hve->partition_assist_page = partition_assist_page;
|
2021-06-03 15:14:40 +00:00
|
|
|
hve->hv_vm_id = (unsigned long)vcpu->kvm;
|
|
|
|
if (!hve->hv_enlightenments_control.nested_flush_hypercall) {
|
|
|
|
hve->hv_enlightenments_control.nested_flush_hypercall = 1;
|
2022-11-01 14:53:39 +00:00
|
|
|
vmcb_mark_dirty(to_svm(vcpu)->vmcb, HV_VMCB_NESTED_ENLIGHTENMENTS);
|
2021-06-03 15:14:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|