From: Maxim Levitsky <mlevitsk@redhat.com>
To: kvm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Wanpeng Li <wanpengli@tencent.com>,
Borislav Petkov <bp@alien8.de>,
Paolo Bonzini <pbonzini@redhat.com>,
Joerg Roedel <joro@8bytes.org>, Jim Mattson <jmattson@google.com>,
"H. Peter Anvin" <hpa@zytor.com>,
Sean Christopherson <seanjc@google.com>,
x86@kernel.org (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)),
Thomas Gleixner <tglx@linutronix.de>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
Ingo Molnar <mingo@redhat.com>,
Maxim Levitsky <mlevitsk@redhat.com>
Subject: [PATCH 3/7] KVM: x86: add .complete_mmu_init arch callback
Date: Wed, 17 Feb 2021 16:57:14 +0200 [thread overview]
Message-ID: <20210217145718.1217358-4-mlevitsk@redhat.com> (raw)
In-Reply-To: <20210217145718.1217358-1-mlevitsk@redhat.com>
This callback will be used to tweak the mmu context
in arch specific code after it was reset.
Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
---
arch/x86/include/asm/kvm-x86-ops.h | 1 +
arch/x86/include/asm/kvm_host.h | 2 ++
arch/x86/kvm/mmu/mmu.c | 2 ++
arch/x86/kvm/svm/svm.c | 6 ++++++
arch/x86/kvm/vmx/vmx.c | 6 ++++++
5 files changed, 17 insertions(+)
diff --git a/arch/x86/include/asm/kvm-x86-ops.h b/arch/x86/include/asm/kvm-x86-ops.h
index 355a2ab8fc09..041e5765dc67 100644
--- a/arch/x86/include/asm/kvm-x86-ops.h
+++ b/arch/x86/include/asm/kvm-x86-ops.h
@@ -86,6 +86,7 @@ KVM_X86_OP(set_tss_addr)
KVM_X86_OP(set_identity_map_addr)
KVM_X86_OP(get_mt_mask)
KVM_X86_OP(load_mmu_pgd)
+KVM_X86_OP(complete_mmu_init)
KVM_X86_OP_NULL(has_wbinvd_exit)
KVM_X86_OP(write_l1_tsc_offset)
KVM_X86_OP(get_exit_info)
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index a8e1b57b1532..01a08f936781 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -1251,6 +1251,8 @@ struct kvm_x86_ops {
void (*load_mmu_pgd)(struct kvm_vcpu *vcpu, unsigned long pgd,
int pgd_level);
+ void (*complete_mmu_init) (struct kvm_vcpu *vcpu);
+
bool (*has_wbinvd_exit)(void);
/* Returns actual tsc_offset set in active VMCS */
diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
index e507568cd55d..00bf9ff2e469 100644
--- a/arch/x86/kvm/mmu/mmu.c
+++ b/arch/x86/kvm/mmu/mmu.c
@@ -4774,6 +4774,8 @@ void kvm_init_mmu(struct kvm_vcpu *vcpu, bool reset_roots)
init_kvm_tdp_mmu(vcpu);
else
init_kvm_softmmu(vcpu);
+
+ static_call(kvm_x86_complete_mmu_init)(vcpu);
}
EXPORT_SYMBOL_GPL(kvm_init_mmu);
diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index 754e07538b4a..74a334c9902a 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -3913,6 +3913,11 @@ static void svm_load_mmu_pgd(struct kvm_vcpu *vcpu, unsigned long root,
vmcb_mark_dirty(svm->vmcb, VMCB_CR);
}
+static void svm_complete_mmu_init(struct kvm_vcpu *vcpu)
+{
+
+}
+
static int is_disabled(void)
{
u64 vm_cr;
@@ -4522,6 +4527,7 @@ static struct kvm_x86_ops svm_x86_ops __initdata = {
.write_l1_tsc_offset = svm_write_l1_tsc_offset,
.load_mmu_pgd = svm_load_mmu_pgd,
+ .complete_mmu_init = svm_complete_mmu_init,
.check_intercept = svm_check_intercept,
.handle_exit_irqoff = svm_handle_exit_irqoff,
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index e428d69e21c0..bf6ef674d688 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -3252,6 +3252,11 @@ static void vmx_load_mmu_pgd(struct kvm_vcpu *vcpu, unsigned long pgd,
vmcs_writel(GUEST_CR3, guest_cr3);
}
+static void vmx_complete_mmu_init(struct kvm_vcpu *vcpu)
+{
+
+}
+
static bool vmx_is_valid_cr4(struct kvm_vcpu *vcpu, unsigned long cr4)
{
/*
@@ -7849,6 +7854,7 @@ static struct kvm_x86_ops vmx_x86_ops __initdata = {
.write_l1_tsc_offset = vmx_write_l1_tsc_offset,
.load_mmu_pgd = vmx_load_mmu_pgd,
+ .complete_mmu_init = vmx_complete_mmu_init,
.check_intercept = vmx_check_intercept,
.handle_exit_irqoff = vmx_handle_exit_irqoff,
--
2.26.2
next prev parent reply other threads:[~2021-02-17 15:00 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-17 14:57 [PATCH 0/7] KVM: random nested fixes Maxim Levitsky
2021-02-17 14:57 ` [PATCH 1/7] KVM: VMX: read idt_vectoring_info a bit earlier Maxim Levitsky
2021-02-17 16:06 ` Paolo Bonzini
2021-02-17 16:18 ` Maxim Levitsky
2021-02-17 16:21 ` Sean Christopherson
2021-02-17 16:29 ` Paolo Bonzini
2021-02-17 14:57 ` [PATCH 2/7] KVM: nSVM: move nested vmrun tracepoint to enter_svm_guest_mode Maxim Levitsky
2021-02-17 14:57 ` Maxim Levitsky [this message]
2021-02-17 14:57 ` [PATCH 4/7] KVM: nVMX: move inject_page_fault tweak to .complete_mmu_init Maxim Levitsky
2021-02-17 17:29 ` Sean Christopherson
2021-02-17 17:37 ` Paolo Bonzini
2021-02-17 17:57 ` Sean Christopherson
2021-02-17 18:00 ` Paolo Bonzini
2021-02-17 18:49 ` Maxim Levitsky
2021-02-17 18:43 ` Maxim Levitsky
2021-02-18 9:45 ` Paolo Bonzini
2021-02-17 14:57 ` [PATCH 5/7] KVM: nSVM: fix running nested guests when npt=0 Maxim Levitsky
2021-02-17 15:27 ` Maxim Levitsky
2021-02-17 14:57 ` [PATCH 6/7] KVM: nVMX: don't load PDPTRS right after nested state set Maxim Levitsky
2021-02-17 17:52 ` Sean Christopherson
2021-02-17 18:06 ` Paolo Bonzini
2021-02-17 14:57 ` [PATCH 7/7] KVM: nSVM: call nested_svm_load_cr3 on nested state load Maxim Levitsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210217145718.1217358-4-mlevitsk@redhat.com \
--to=mlevitsk@redhat.com \
--cc=bp@alien8.de \
--cc=hpa@zytor.com \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).