From: Sean Christopherson <seanjc@google.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Sean Christopherson <seanjc@google.com>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
Wanpeng Li <wanpengli@tencent.com>,
Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Like Xu <like.xu.linux@gmail.com>
Subject: [PATCH 22/22] KVM: SVM: Use kvm-x86-ops.h to fill svm_x86_ops
Date: Fri, 28 Jan 2022 00:52:08 +0000 [thread overview]
Message-ID: <20220128005208.4008533-23-seanjc@google.com> (raw)
In-Reply-To: <20220128005208.4008533-1-seanjc@google.com>
Fill svm_x86_ops by including kvm-x86-ops.h and defining the appropriate
macros. Document the handful of exceptions where svm_x86_ops deviates
from the "default" (mostly due to lack of hardware support for a related
feature).
No functional change intended.
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
arch/x86/kvm/svm/svm.c | 156 +++++++++--------------------------------
1 file changed, 32 insertions(+), 124 deletions(-)
diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index 7f70f456a5a5..b3761073fa81 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -4464,138 +4464,46 @@ static int svm_vm_init(struct kvm *kvm)
return 0;
}
+/*
+ * SVM unconditionally flushes between nested transition and so doesn't provide
+ * a "flush all" variant, and a guest's ASID is tied to both guest and NPT
+ * translations, thus there's no "flush guest" variant.
+ */
+#define svm_flush_tlb_all svm_flush_tlb_current
+#define svm_flush_tlb_guest svm_flush_tlb_current
+
+/* APICv hooks not needed/implemented for AVIC. */
+#define avic_guest_apic_has_interrupt NULL
+#define avic_set_apic_access_page_addr NULL
+#define avic_sync_pir_to_irr NULL
+#define avic_pi_start_assignment NULL
+
+/* SVM has no hyperversior debug trap (VMX's Monitor Trap Flag). */
+#define svm_update_emulated_instruction NULL
+
+/* SVM has no CPU assisted dirty logging (VMX's Page Modification Logging). */
+#define svm_update_cpu_dirty_logging NULL
+
+/* SVM has no hypervisor timer (VMX's preemption timer). */
+#define svm_set_hv_timer NULL
+#define svm_cancel_hv_timer NULL
+#define svm_migrate_timers NULL
+#define svm_request_immediate_exit __kvm_request_immediate_exit
+
static struct kvm_x86_ops svm_x86_ops __initdata = {
.name = "kvm_amd",
-
- .hardware_unsetup = svm_hardware_unsetup,
- .hardware_enable = svm_hardware_enable,
- .hardware_disable = svm_hardware_disable,
- .cpu_has_accelerated_tpr = svm_cpu_has_accelerated_tpr,
- .has_emulated_msr = svm_has_emulated_msr,
-
- .vcpu_create = svm_vcpu_create,
- .vcpu_free = svm_vcpu_free,
- .vcpu_reset = svm_vcpu_reset,
-
.vm_size = sizeof(struct kvm_svm),
- .vm_init = svm_vm_init,
- .vm_destroy = svm_vm_destroy,
-
- .prepare_switch_to_guest = svm_prepare_switch_to_guest,
- .vcpu_load = svm_vcpu_load,
- .vcpu_put = svm_vcpu_put,
- .vcpu_blocking = avic_vcpu_blocking,
- .vcpu_unblocking = avic_vcpu_unblocking,
-
- .update_exception_bitmap = svm_update_exception_bitmap,
- .get_msr_feature = svm_get_msr_feature,
- .get_msr = svm_get_msr,
- .set_msr = svm_set_msr,
- .get_segment_base = svm_get_segment_base,
- .get_segment = svm_get_segment,
- .set_segment = svm_set_segment,
- .get_cpl = svm_get_cpl,
- .get_cs_db_l_bits = svm_get_cs_db_l_bits,
- .set_cr0 = svm_set_cr0,
- .post_set_cr3 = sev_post_set_cr3,
- .is_valid_cr4 = svm_is_valid_cr4,
- .set_cr4 = svm_set_cr4,
- .set_efer = svm_set_efer,
- .get_idt = svm_get_idt,
- .set_idt = svm_set_idt,
- .get_gdt = svm_get_gdt,
- .set_gdt = svm_set_gdt,
- .set_dr7 = svm_set_dr7,
- .sync_dirty_debug_regs = svm_sync_dirty_debug_regs,
- .cache_reg = svm_cache_reg,
- .get_rflags = svm_get_rflags,
- .set_rflags = svm_set_rflags,
- .get_if_flag = svm_get_if_flag,
-
- .flush_tlb_all = svm_flush_tlb_current,
- .flush_tlb_current = svm_flush_tlb_current,
- .flush_tlb_gva = svm_flush_tlb_gva,
- .flush_tlb_guest = svm_flush_tlb_current,
-
- .vcpu_pre_run = svm_vcpu_pre_run,
- .vcpu_run = svm_vcpu_run,
- .handle_exit = svm_handle_exit,
- .skip_emulated_instruction = svm_skip_emulated_instruction,
- .update_emulated_instruction = NULL,
- .set_interrupt_shadow = svm_set_interrupt_shadow,
- .get_interrupt_shadow = svm_get_interrupt_shadow,
- .patch_hypercall = svm_patch_hypercall,
- .inject_irq = svm_inject_irq,
- .inject_nmi = svm_inject_nmi,
- .queue_exception = svm_queue_exception,
- .cancel_injection = svm_cancel_injection,
- .interrupt_allowed = svm_interrupt_allowed,
- .nmi_allowed = svm_nmi_allowed,
- .get_nmi_mask = svm_get_nmi_mask,
- .set_nmi_mask = svm_set_nmi_mask,
- .enable_nmi_window = svm_enable_nmi_window,
- .enable_irq_window = svm_enable_irq_window,
- .update_cr8_intercept = svm_update_cr8_intercept,
- .set_virtual_apic_mode = avic_set_virtual_apic_mode,
- .refresh_apicv_exec_ctrl = avic_refresh_apicv_exec_ctrl,
- .check_apicv_inhibit_reasons = avic_check_apicv_inhibit_reasons,
- .load_eoi_exitmap = avic_load_eoi_exitmap,
- .hwapic_irr_update = avic_hwapic_irr_update,
- .hwapic_isr_update = avic_hwapic_isr_update,
- .apicv_post_state_restore = avic_apicv_post_state_restore,
-
- .set_tss_addr = svm_set_tss_addr,
- .set_identity_map_addr = svm_set_identity_map_addr,
- .get_mt_mask = svm_get_mt_mask,
-
- .get_exit_info = svm_get_exit_info,
-
- .vcpu_after_set_cpuid = svm_vcpu_after_set_cpuid,
-
- .has_wbinvd_exit = svm_has_wbinvd_exit,
-
- .get_l2_tsc_offset = svm_get_l2_tsc_offset,
- .get_l2_tsc_multiplier = svm_get_l2_tsc_multiplier,
- .write_tsc_offset = svm_write_tsc_offset,
- .write_tsc_multiplier = svm_write_tsc_multiplier,
-
- .load_mmu_pgd = svm_load_mmu_pgd,
-
- .check_intercept = svm_check_intercept,
- .handle_exit_irqoff = svm_handle_exit_irqoff,
-
- .request_immediate_exit = __kvm_request_immediate_exit,
-
- .sched_in = svm_sched_in,
.pmu_ops = &amd_pmu_ops,
.nested_ops = &svm_nested_ops,
- .deliver_interrupt = svm_deliver_interrupt,
- .dy_apicv_has_pending_interrupt = avic_dy_apicv_has_pending_interrupt,
- .pi_update_irte = avic_pi_update_irte,
- .setup_mce = svm_setup_mce,
+#define KVM_X86_OP(func) .func = svm_##func,
+#define KVM_X86_APICV_OP(func) .func = avic_##func,
+#define KVM_X86_CVM_OP(func) .func = sev_##func,
- .smi_allowed = svm_smi_allowed,
- .enter_smm = svm_enter_smm,
- .leave_smm = svm_leave_smm,
- .enable_smi_window = svm_enable_smi_window,
-
- .mem_enc_ioctl = sev_mem_enc_ioctl,
- .mem_enc_register_region = sev_mem_enc_register_region,
- .mem_enc_unregister_region = sev_mem_enc_unregister_region,
-
- .vm_copy_enc_context_from = sev_vm_copy_enc_context_from,
- .vm_move_enc_context_from = sev_vm_move_enc_context_from,
-
- .can_emulate_instruction = svm_can_emulate_instruction,
-
- .apic_init_signal_blocked = svm_apic_init_signal_blocked,
-
- .msr_filter_changed = svm_msr_filter_changed,
- .complete_emulated_msr = svm_complete_emulated_msr,
-
- .vcpu_deliver_sipi_vector = svm_vcpu_deliver_sipi_vector,
+/* Hyper-V hooks are filled at runtime. */
+#define KVM_X86_HYPERV_OP(func) .func = NULL,
+#include <asm/kvm-x86-ops.h>
};
/*
--
2.35.0.rc0.227.g00780c9af4-goog
prev parent reply other threads:[~2022-01-28 0:54 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-28 0:51 [PATCH 00/22] KVM: x86: Fill *_x86_ops via kvm-x86-ops.h Sean Christopherson
2022-01-28 0:51 ` [PATCH 01/22] KVM: x86: Drop unnecessary and confusing KVM_X86_OP_NULL macro Sean Christopherson
2022-01-28 10:11 ` Paolo Bonzini
2022-01-28 15:42 ` Sean Christopherson
2022-01-31 14:56 ` Paolo Bonzini
2022-01-31 15:19 ` Maxim Levitsky
2022-01-31 16:48 ` Sean Christopherson
2022-01-28 0:51 ` [PATCH 02/22] KVM: x86: Move delivery of non-APICv interrupt into vendor code Sean Christopherson
2022-01-28 0:51 ` [PATCH 03/22] KVM: x86: Drop export for .tlb_flush_current() static_call key Sean Christopherson
2022-01-28 0:51 ` [PATCH 04/22] KVM: x86: Rename kvm_x86_ops pointers to align w/ preferred vendor names Sean Christopherson
2022-01-28 0:51 ` [PATCH 05/22] KVM: x86: Use static_call() for .vcpu_deliver_sipi_vector() Sean Christopherson
2022-01-28 0:51 ` [PATCH 06/22] KVM: VMX: Call vmx_get_cpl() directly in handle_dr() Sean Christopherson
2022-01-28 0:51 ` [PATCH 07/22] KVM: xen: Use static_call() for invoking kvm_x86_ops hooks Sean Christopherson
2022-01-28 0:51 ` [PATCH 08/22] KVM: nVMX: Refactor PMU refresh to avoid referencing kvm_x86_ops.pmu_ops Sean Christopherson
2022-01-28 0:51 ` [PATCH 09/22] KVM: x86: Uninline and export hv_track_root_tdp() Sean Christopherson
2022-01-31 16:19 ` Vitaly Kuznetsov
2022-01-28 0:51 ` [PATCH 10/22] KVM: x86: Unexport kvm_x86_ops Sean Christopherson
2022-01-28 0:51 ` [PATCH 11/22] KVM: x86: Use static_call() for copy/move encryption context ioctls() Sean Christopherson
2022-01-28 0:51 ` [PATCH 12/22] KVM: x86: Allow different macros for APICv, CVM, and Hyper-V kvm_x86_ops Sean Christopherson
2022-01-28 0:51 ` [PATCH 13/22] KVM: VMX: Rename VMX functions to conform to kvm_x86_ops names Sean Christopherson
2022-01-28 0:52 ` [PATCH 14/22] KVM: VMX: Use kvm-x86-ops.h to fill vmx_x86_ops Sean Christopherson
2022-01-28 0:52 ` [PATCH 15/22] KVM: x86: Move get_cs_db_l_bits() helper to SVM Sean Christopherson
2022-01-28 0:52 ` [PATCH 16/22] KVM: SVM: Rename svm_flush_tlb() to svm_flush_tlb_current() Sean Christopherson
2022-01-28 0:52 ` [PATCH 17/22] KVM: SVM: Remove unused MAX_INST_SIZE #define Sean Christopherson
2022-01-28 0:52 ` [PATCH 18/22] KVM: SVM: Rename AVIC helpers to use "avic" prefix instead of "svm" Sean Christopherson
2022-01-28 0:52 ` [PATCH 19/22] KVM: x86: Use more verbose names for mem encrypt kvm_x86_ops hooks Sean Christopherson
2022-01-28 0:52 ` [PATCH 20/22] KVM: SVM: Rename SEV implemenations to conform to " Sean Christopherson
2022-01-28 0:52 ` [PATCH 21/22] KVM: SVM: Rename hook implementations to conform to kvm_x86_ops' names Sean Christopherson
2022-01-28 0:52 ` Sean Christopherson [this message]
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=20220128005208.4008533-23-seanjc@google.com \
--to=seanjc@google.com \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=like.xu.linux@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.