lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 28 Jan 2022 00:51:58 +0000
From:   Sean Christopherson <seanjc@...gle.com>
To:     Paolo Bonzini <pbonzini@...hat.com>
Cc:     Sean Christopherson <seanjc@...gle.com>,
        Vitaly Kuznetsov <vkuznets@...hat.com>,
        Wanpeng Li <wanpengli@...cent.com>,
        Jim Mattson <jmattson@...gle.com>,
        Joerg Roedel <joro@...tes.org>, kvm@...r.kernel.org,
        linux-kernel@...r.kernel.org, Like Xu <like.xu.linux@...il.com>
Subject: [PATCH 12/22] KVM: x86: Allow different macros for APICv, CVM, and
 Hyper-V kvm_x86_ops

Introduce optional macros for defining APICv, Confidental VM (a.k.a. so
called memory encryption), and Hyper-V kvm_x86_ops.  Specialized macros
will allow vendor code to easily apply a single pattern when wiring up
implementations, e.g. SVM using "sev" for Confidential VMs and AVIC for
APICv, and VMX currently doesn't support any Condifential VM hooks.

Bundling also adds a small amount of self-documentation to the various
hooks in kvm-x86-ops.h.

Signed-off-by: Sean Christopherson <seanjc@...gle.com>
---
 arch/x86/include/asm/kvm-x86-ops.h | 74 +++++++++++++++++++-----------
 1 file changed, 48 insertions(+), 26 deletions(-)

diff --git a/arch/x86/include/asm/kvm-x86-ops.h b/arch/x86/include/asm/kvm-x86-ops.h
index 4ee046e60c34..cb3af3a55317 100644
--- a/arch/x86/include/asm/kvm-x86-ops.h
+++ b/arch/x86/include/asm/kvm-x86-ops.h
@@ -4,8 +4,24 @@ BUILD_BUG_ON(1)
 #endif
 
 /*
- * Invoke KVM_X86_OP() on all functions in struct kvm_x86_ops, e.g. to generate
- * static_call declarations, definitions and updates.
+ * APICv, Hyper-V, and Confidential VM macros are optional, redirect to the
+ * standard ops macro if the caller didn't define a type-specific variant.
+ */
+#ifndef KVM_X86_APICV_OP
+#define KVM_X86_APICV_OP KVM_X86_OP
+#endif
+
+#ifndef KVM_X86_HYPERV_OP
+#define KVM_X86_HYPERV_OP KVM_X86_OP
+#endif
+
+#ifndef KVM_X86_CVM_OP
+#define KVM_X86_CVM_OP KVM_X86_OP
+#endif
+
+/*
+ * Invoke the appropriate macro on all functions in struct kvm_x86_ops, e.g. to
+ * generate static_call declarations, definitions and updates.
  */
 KVM_X86_OP(hardware_enable)
 KVM_X86_OP(hardware_disable)
@@ -30,7 +46,6 @@ KVM_X86_OP(get_cpl)
 KVM_X86_OP(set_segment)
 KVM_X86_OP(get_cs_db_l_bits)
 KVM_X86_OP(set_cr0)
-KVM_X86_OP(post_set_cr3)
 KVM_X86_OP(is_valid_cr4)
 KVM_X86_OP(set_cr4)
 KVM_X86_OP(set_efer)
@@ -46,8 +61,6 @@ KVM_X86_OP(set_rflags)
 KVM_X86_OP(get_if_flag)
 KVM_X86_OP(flush_tlb_all)
 KVM_X86_OP(flush_tlb_current)
-KVM_X86_OP(tlb_remote_flush)
-KVM_X86_OP(tlb_remote_flush_with_range)
 KVM_X86_OP(flush_tlb_gva)
 KVM_X86_OP(flush_tlb_guest)
 KVM_X86_OP(vcpu_pre_run)
@@ -69,16 +82,7 @@ KVM_X86_OP(set_nmi_mask)
 KVM_X86_OP(enable_nmi_window)
 KVM_X86_OP(enable_irq_window)
 KVM_X86_OP(update_cr8_intercept)
-KVM_X86_OP(check_apicv_inhibit_reasons)
-KVM_X86_OP(refresh_apicv_exec_ctrl)
-KVM_X86_OP(hwapic_irr_update)
-KVM_X86_OP(hwapic_isr_update)
-KVM_X86_OP(guest_apic_has_interrupt)
-KVM_X86_OP(load_eoi_exitmap)
-KVM_X86_OP(set_virtual_apic_mode)
-KVM_X86_OP(set_apic_access_page_addr)
 KVM_X86_OP(deliver_interrupt)
-KVM_X86_OP(sync_pir_to_irr)
 KVM_X86_OP(set_tss_addr)
 KVM_X86_OP(set_identity_map_addr)
 KVM_X86_OP(get_mt_mask)
@@ -94,12 +98,6 @@ KVM_X86_OP(handle_exit_irqoff)
 KVM_X86_OP(request_immediate_exit)
 KVM_X86_OP(sched_in)
 KVM_X86_OP(update_cpu_dirty_logging)
-KVM_X86_OP(vcpu_blocking)
-KVM_X86_OP(vcpu_unblocking)
-KVM_X86_OP(pi_update_irte)
-KVM_X86_OP(pi_start_assignment)
-KVM_X86_OP(apicv_post_state_restore)
-KVM_X86_OP(dy_apicv_has_pending_interrupt)
 KVM_X86_OP(set_hv_timer)
 KVM_X86_OP(cancel_hv_timer)
 KVM_X86_OP(setup_mce)
@@ -107,18 +105,42 @@ KVM_X86_OP(smi_allowed)
 KVM_X86_OP(enter_smm)
 KVM_X86_OP(leave_smm)
 KVM_X86_OP(enable_smi_window)
-KVM_X86_OP(mem_enc_op)
-KVM_X86_OP(mem_enc_reg_region)
-KVM_X86_OP(mem_enc_unreg_region)
-KVM_X86_OP(vm_copy_enc_context_from)
-KVM_X86_OP(vm_move_enc_context_from)
 KVM_X86_OP(get_msr_feature)
 KVM_X86_OP(can_emulate_instruction)
 KVM_X86_OP(apic_init_signal_blocked)
-KVM_X86_OP(enable_direct_tlbflush)
 KVM_X86_OP(migrate_timers)
 KVM_X86_OP(msr_filter_changed)
 KVM_X86_OP(complete_emulated_msr)
 KVM_X86_OP(vcpu_deliver_sipi_vector)
 
+KVM_X86_APICV_OP(check_apicv_inhibit_reasons)
+KVM_X86_APICV_OP(refresh_apicv_exec_ctrl)
+KVM_X86_APICV_OP(load_eoi_exitmap)
+KVM_X86_APICV_OP(set_virtual_apic_mode)
+KVM_X86_APICV_OP(set_apic_access_page_addr)
+KVM_X86_APICV_OP(sync_pir_to_irr)
+KVM_X86_APICV_OP(hwapic_irr_update)
+KVM_X86_APICV_OP(hwapic_isr_update)
+KVM_X86_APICV_OP(guest_apic_has_interrupt)
+KVM_X86_APICV_OP(vcpu_blocking)
+KVM_X86_APICV_OP(vcpu_unblocking)
+KVM_X86_APICV_OP(pi_update_irte)
+KVM_X86_APICV_OP(pi_start_assignment)
+KVM_X86_APICV_OP(apicv_post_state_restore)
+KVM_X86_APICV_OP(dy_apicv_has_pending_interrupt)
+
+KVM_X86_HYPERV_OP(tlb_remote_flush)
+KVM_X86_HYPERV_OP(tlb_remote_flush_with_range)
+KVM_X86_HYPERV_OP(enable_direct_tlbflush)
+
+KVM_X86_CVM_OP(mem_enc_op)
+KVM_X86_CVM_OP(mem_enc_reg_region)
+KVM_X86_CVM_OP(mem_enc_unreg_region)
+KVM_X86_CVM_OP(vm_copy_enc_context_from)
+KVM_X86_CVM_OP(vm_move_enc_context_from)
+KVM_X86_CVM_OP(post_set_cr3)
+
+#undef KVM_X86_APICV_OP
+#undef KVM_X86_HYPERV_OP
+#undef KVM_X86_CVM_OP
 #undef KVM_X86_OP
-- 
2.35.0.rc0.227.g00780c9af4-goog

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ