From nobody Tue Jun 30 01:42:29 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0AC6DC433F5 for ; Fri, 28 Jan 2022 00:53:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344856AbiA1AxZ (ORCPT ); Thu, 27 Jan 2022 19:53:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344746AbiA1AxQ (ORCPT ); Thu, 27 Jan 2022 19:53:16 -0500 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31DC2C061714 for ; Thu, 27 Jan 2022 16:53:16 -0800 (PST) Received: by mail-pl1-x64a.google.com with SMTP id p7-20020a1709026b8700b0014a8d8fbf6fso2275266plk.23 for ; Thu, 27 Jan 2022 16:53:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=DiMuq2Bil4+pHQEcZ/O668QC6BBPA3hB3Y9QWnY+qA4=; b=cwog0v0MWjJXvH7HzpkNIMx19BpXimiXFYSwqSWPvTgF7KcYoLDfP9famQQsVAw1pK 7jrURWWD9scbGodLmwR6XEA90MUBFC4+58qFLfdkBW0CWLf6e1h2k3PsyGrB6kdJaip6 CXv27tMDqn9bvNv6FnI6sgMVcK+6y4Pr0q13x+7EdvaQV8qtVZ9E1u2MVuIx748qS2nR oXao7AQK2X+nfTn9Js4d+6tV+3uOrsYH4k2MwwyVsI38irMQ3rqYT7Bm6tuWwYPBlTvd yS+b6/PrCIgXV5AZhNPg5SQ5HUIhdZQ91kq16ibQ+bP09We9l2OHZ0GPbgBLhwocgzDv /DfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=DiMuq2Bil4+pHQEcZ/O668QC6BBPA3hB3Y9QWnY+qA4=; b=sEn2IE7WM9S2t8BFswn2BS5GX7ctuy8PFLkwUw/6JuU2yJRCriQ4g0ToOWoq5DUmF9 djHEOuW3iTUcqwXrg7HM1LMvXEmvdEb/U72h3TGJ02zIGj4iVA/0oPvahKVBRNXlpqb+ o+m5cyzhZbzG1uFp46NrjPuTJkNVs3TJ/XFC9eZkdnNXklWCzdYIcEhyg8PbiN/vtHx3 li/LKRtrO/yUy/DNFYQozKFfr2MyvrBOT0ZvbZ07SZd0hNE0llubXAkmb5UEwgbSslZf +em7KPGYBLhY884d0dda1dZrdM/fFCrABbiWdWh8xWtb4qYSP81OkEhXJpVZZrJbqV+L cnkQ== X-Gm-Message-State: AOAM533IXHbj7pHmwHEwu712hh07MCtuC7P+N+JBEj4z67SXMoRuDePv 7yjDWzT3RHB3UM4Uidmi7RzlwprLc00= X-Google-Smtp-Source: ABdhPJzPYJHaWhZ33ihP4QCmQQPFItRzz3C8yWoefe+67z0NWQRDJ5/bLXQ9LOemoceygPB6gbDKujku70I= X-Received: from seanjc.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e5]) (user=seanjc job=sendgmr) by 2002:aa7:888b:: with SMTP id z11mr88139pfe.76.1643331195691; Thu, 27 Jan 2022 16:53:15 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 28 Jan 2022 00:51:47 +0000 In-Reply-To: <20220128005208.4008533-1-seanjc@google.com> Message-Id: <20220128005208.4008533-2-seanjc@google.com> Mime-Version: 1.0 References: <20220128005208.4008533-1-seanjc@google.com> X-Mailer: git-send-email 2.35.0.rc0.227.g00780c9af4-goog Subject: [PATCH 01/22] KVM: x86: Drop unnecessary and confusing KVM_X86_OP_NULL macro From: Sean Christopherson To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Like Xu Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Drop KVM_X86_OP_NULL, which is superfluous and confusing. The macro is just a "pass-through" to KVM_X86_OP; it was added with the intent of actually using it in the future, but that obviously never happened. The name is confusing because its intended use was to provide a way for vendor implementations to specify a NULL pointer, and even if it were used, wouldn't necessarily be synonymous with declaring a kvm_x86_op as DEFINE_STATIC_CALL_NULL. Lastly, actually using KVM_X86_OP_NULL as intended isn't a maintanable approach, e.g. bleeds vendor details into common x86 code, and would either be prone to bit rot or would require modifying common x86 code when modifying a vendor implementation. No functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/include/asm/kvm-x86-ops.h | 76 ++++++++++++++---------------- arch/x86/include/asm/kvm_host.h | 2 - arch/x86/kvm/x86.c | 1 - 3 files changed, 35 insertions(+), 44 deletions(-) diff --git a/arch/x86/include/asm/kvm-x86-ops.h b/arch/x86/include/asm/kvm-= x86-ops.h index 631d5040b31e..e07151b2d1f6 100644 --- a/arch/x86/include/asm/kvm-x86-ops.h +++ b/arch/x86/include/asm/kvm-x86-ops.h @@ -1,25 +1,20 @@ /* SPDX-License-Identifier: GPL-2.0 */ -#if !defined(KVM_X86_OP) || !defined(KVM_X86_OP_NULL) +#ifndef KVM_X86_OP BUILD_BUG_ON(1) #endif =20 /* - * KVM_X86_OP() and KVM_X86_OP_NULL() are used to help generate - * "static_call()"s. They are also intended for use when defining - * the vmx/svm kvm_x86_ops. KVM_X86_OP() can be used for those - * functions that follow the [svm|vmx]_func_name convention. - * KVM_X86_OP_NULL() can leave a NULL definition for the - * case where there is no definition or a function name that - * doesn't match the typical naming convention is supplied. + * Invoke KVM_X86_OP() on all functions in struct kvm_x86_ops, e.g. to gen= erate + * static_call declarations, definitions and updates. */ -KVM_X86_OP_NULL(hardware_enable) -KVM_X86_OP_NULL(hardware_disable) -KVM_X86_OP_NULL(hardware_unsetup) -KVM_X86_OP_NULL(cpu_has_accelerated_tpr) +KVM_X86_OP(hardware_enable) +KVM_X86_OP(hardware_disable) +KVM_X86_OP(hardware_unsetup) +KVM_X86_OP(cpu_has_accelerated_tpr) KVM_X86_OP(has_emulated_msr) KVM_X86_OP(vcpu_after_set_cpuid) KVM_X86_OP(vm_init) -KVM_X86_OP_NULL(vm_destroy) +KVM_X86_OP(vm_destroy) KVM_X86_OP(vcpu_create) KVM_X86_OP(vcpu_free) KVM_X86_OP(vcpu_reset) @@ -33,9 +28,9 @@ KVM_X86_OP(get_segment_base) KVM_X86_OP(get_segment) KVM_X86_OP(get_cpl) KVM_X86_OP(set_segment) -KVM_X86_OP_NULL(get_cs_db_l_bits) +KVM_X86_OP(get_cs_db_l_bits) KVM_X86_OP(set_cr0) -KVM_X86_OP_NULL(post_set_cr3) +KVM_X86_OP(post_set_cr3) KVM_X86_OP(is_valid_cr4) KVM_X86_OP(set_cr4) KVM_X86_OP(set_efer) @@ -51,15 +46,15 @@ KVM_X86_OP(set_rflags) KVM_X86_OP(get_if_flag) KVM_X86_OP(tlb_flush_all) KVM_X86_OP(tlb_flush_current) -KVM_X86_OP_NULL(tlb_remote_flush) -KVM_X86_OP_NULL(tlb_remote_flush_with_range) +KVM_X86_OP(tlb_remote_flush) +KVM_X86_OP(tlb_remote_flush_with_range) KVM_X86_OP(tlb_flush_gva) KVM_X86_OP(tlb_flush_guest) KVM_X86_OP(vcpu_pre_run) KVM_X86_OP(run) -KVM_X86_OP_NULL(handle_exit) -KVM_X86_OP_NULL(skip_emulated_instruction) -KVM_X86_OP_NULL(update_emulated_instruction) +KVM_X86_OP(handle_exit) +KVM_X86_OP(skip_emulated_instruction) +KVM_X86_OP(update_emulated_instruction) KVM_X86_OP(set_interrupt_shadow) KVM_X86_OP(get_interrupt_shadow) KVM_X86_OP(patch_hypercall) @@ -78,17 +73,17 @@ 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_NULL(guest_apic_has_interrupt) +KVM_X86_OP(guest_apic_has_interrupt) KVM_X86_OP(load_eoi_exitmap) KVM_X86_OP(set_virtual_apic_mode) -KVM_X86_OP_NULL(set_apic_access_page_addr) +KVM_X86_OP(set_apic_access_page_addr) KVM_X86_OP(deliver_posted_interrupt) -KVM_X86_OP_NULL(sync_pir_to_irr) +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) KVM_X86_OP(load_mmu_pgd) -KVM_X86_OP_NULL(has_wbinvd_exit) +KVM_X86_OP(has_wbinvd_exit) KVM_X86_OP(get_l2_tsc_offset) KVM_X86_OP(get_l2_tsc_multiplier) KVM_X86_OP(write_tsc_offset) @@ -96,32 +91,31 @@ KVM_X86_OP(write_tsc_multiplier) KVM_X86_OP(get_exit_info) KVM_X86_OP(check_intercept) KVM_X86_OP(handle_exit_irqoff) -KVM_X86_OP_NULL(request_immediate_exit) +KVM_X86_OP(request_immediate_exit) KVM_X86_OP(sched_in) -KVM_X86_OP_NULL(update_cpu_dirty_logging) -KVM_X86_OP_NULL(vcpu_blocking) -KVM_X86_OP_NULL(vcpu_unblocking) -KVM_X86_OP_NULL(update_pi_irte) -KVM_X86_OP_NULL(start_assignment) -KVM_X86_OP_NULL(apicv_post_state_restore) -KVM_X86_OP_NULL(dy_apicv_has_pending_interrupt) -KVM_X86_OP_NULL(set_hv_timer) -KVM_X86_OP_NULL(cancel_hv_timer) +KVM_X86_OP(update_cpu_dirty_logging) +KVM_X86_OP(vcpu_blocking) +KVM_X86_OP(vcpu_unblocking) +KVM_X86_OP(update_pi_irte) +KVM_X86_OP(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) KVM_X86_OP(smi_allowed) KVM_X86_OP(enter_smm) KVM_X86_OP(leave_smm) KVM_X86_OP(enable_smi_window) -KVM_X86_OP_NULL(mem_enc_op) -KVM_X86_OP_NULL(mem_enc_reg_region) -KVM_X86_OP_NULL(mem_enc_unreg_region) +KVM_X86_OP(mem_enc_op) +KVM_X86_OP(mem_enc_reg_region) +KVM_X86_OP(mem_enc_unreg_region) KVM_X86_OP(get_msr_feature) KVM_X86_OP(can_emulate_instruction) KVM_X86_OP(apic_init_signal_blocked) -KVM_X86_OP_NULL(enable_direct_tlbflush) -KVM_X86_OP_NULL(migrate_timers) +KVM_X86_OP(enable_direct_tlbflush) +KVM_X86_OP(migrate_timers) KVM_X86_OP(msr_filter_changed) -KVM_X86_OP_NULL(complete_emulated_msr) +KVM_X86_OP(complete_emulated_msr) =20 #undef KVM_X86_OP -#undef KVM_X86_OP_NULL diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_hos= t.h index b2c3721b1c98..756806d2e801 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1538,14 +1538,12 @@ extern struct kvm_x86_ops kvm_x86_ops; =20 #define KVM_X86_OP(func) \ DECLARE_STATIC_CALL(kvm_x86_##func, *(((struct kvm_x86_ops *)0)->func)); -#define KVM_X86_OP_NULL KVM_X86_OP #include =20 static inline void kvm_ops_static_call_update(void) { #define KVM_X86_OP(func) \ static_call_update(kvm_x86_##func, kvm_x86_ops.func); -#define KVM_X86_OP_NULL KVM_X86_OP #include } =20 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 8033eca6f3a1..ebab514ec82a 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -129,7 +129,6 @@ EXPORT_SYMBOL_GPL(kvm_x86_ops); #define KVM_X86_OP(func) \ DEFINE_STATIC_CALL_NULL(kvm_x86_##func, \ *(((struct kvm_x86_ops *)0)->func)); -#define KVM_X86_OP_NULL KVM_X86_OP #include EXPORT_STATIC_CALL_GPL(kvm_x86_get_cs_db_l_bits); EXPORT_STATIC_CALL_GPL(kvm_x86_cache_reg); --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Tue Jun 30 01:42:29 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC72DC433EF for ; Fri, 28 Jan 2022 00:53:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344912AbiA1Axf (ORCPT ); Thu, 27 Jan 2022 19:53:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344781AbiA1AxR (ORCPT ); Thu, 27 Jan 2022 19:53:17 -0500 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2CEAC06173B for ; Thu, 27 Jan 2022 16:53:17 -0800 (PST) Received: by mail-pl1-x649.google.com with SMTP id q2-20020a170902f78200b0014b56300928so2286961pln.16 for ; Thu, 27 Jan 2022 16:53:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=D+8yLffBpcYXir7zQquCWfilc7hYk5NU754z8ZuVcI0=; b=l3oaC8bDMB6GHFPur3mfb80FvDtAg5hI8iGf6j0sAfZglYBFBVC7EoNNskV/Jn5sDp EJUUu0V1iztO/kgKkH8wrtkK2jk1Lqg3XydHWdvcwLPSF0ELu3fgnAeH6ws+cWx0yMVj grepJ49o05cY2m+gLEfP/jIMVUDJuVKAp2u52oFjQ3Mb4Yq95qOItBbmJUe4imwTxIwO APZ1g42kQ9LfMatasvoSNCtOL+/xxaC9iVwvYNjp47+8fKQkfPM1Kl31hp29KXIs5hK/ 8UZuGVHVKR8cJP0Lk7rtaENvE2SDQ+HPZhk/ZBuVJsgjzO8+SRbIOgEqujDE1R2lOCh1 l1lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=D+8yLffBpcYXir7zQquCWfilc7hYk5NU754z8ZuVcI0=; b=YAk69SAvB81sOVfo+J1jByNLhBDVUaTN4hWgDhbwxRQso1bLuaU+tV2fpqi/N4kd5B LbPfRW9z5bSNcJELNQq3JwQC7FvuPata7fUj1R3QgikP+6qGacGOHXHO8qSes5T2Wg4p /A9gsUjzGZoEmsub0L0sfPoVYBe9ehs02W3OFtUBPgzpcSDIZCjJtDH3p4BjVJ//iyl0 Wrv+toQxZMEdZP9s5KDgqWiVnlympa4b4gJc68EQAPf/ff//SssRePWcF/TuCzAxAlwi iw8kx/POGtMYuh96U8tt1h86wiWHpR+qAiLod/gtPPHNpJLPKmTNRMWSgcnejTBsDLFw RQbA== X-Gm-Message-State: AOAM5302+BQFBPFRq4iAr5ymIEnPs+bdnShzrBXTmO23/f28rmOBmD1H 0mSM4EIfmGlRofkyqsyK03crAAbwx6I= X-Google-Smtp-Source: ABdhPJyPSYP7ieApS5vO+h7AYs12hkvF5vXsGKsjR1ZHetBHp7KGslfufN4eM93AcKJiDKQ1RWiSOrKTZuI= X-Received: from seanjc.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e5]) (user=seanjc job=sendgmr) by 2002:a17:90b:4d82:: with SMTP id oj2mr1878448pjb.1.1643331197011; Thu, 27 Jan 2022 16:53:17 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 28 Jan 2022 00:51:48 +0000 In-Reply-To: <20220128005208.4008533-1-seanjc@google.com> Message-Id: <20220128005208.4008533-3-seanjc@google.com> Mime-Version: 1.0 References: <20220128005208.4008533-1-seanjc@google.com> X-Mailer: git-send-email 2.35.0.rc0.227.g00780c9af4-goog Subject: [PATCH 02/22] KVM: x86: Move delivery of non-APICv interrupt into vendor code From: Sean Christopherson To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Like Xu Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Handle non-APICv interrupt delivery in vendor code, even though it means VMX and SVM will temporarily have duplicate code. SVM's AVIC has a race condition that requires KVM to fall back to legacy interrupt injection _after_ the interrupt has been logged in the vIRR, i.e. to fix the race, SVM will need to open code the full flow anyways[*]. Refactor the code so that the SVM bug without introducing other issues, e.g. SVM would return "success" and thus invoke trace_kvm_apicv_accept_irq() even when delivery through the AVIC failed, and to opportunistically prepare for using KVM_X86_OP to fill each vendor's kvm_x86_ops struct, which will rely on the vendor function matching the kvm_x86_op pointer name. No functional change intended. [*] https://lore.kernel.org/all/20211213104634.199141-4-mlevitsk@redhat.com Signed-off-by: Sean Christopherson --- arch/x86/include/asm/kvm-x86-ops.h | 2 +- arch/x86/include/asm/kvm_host.h | 3 ++- arch/x86/kvm/lapic.c | 10 ++-------- arch/x86/kvm/svm/svm.c | 17 ++++++++++++++++- arch/x86/kvm/vmx/vmx.c | 17 ++++++++++++++++- 5 files changed, 37 insertions(+), 12 deletions(-) diff --git a/arch/x86/include/asm/kvm-x86-ops.h b/arch/x86/include/asm/kvm-= x86-ops.h index e07151b2d1f6..fd134c436029 100644 --- a/arch/x86/include/asm/kvm-x86-ops.h +++ b/arch/x86/include/asm/kvm-x86-ops.h @@ -77,7 +77,7 @@ 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_posted_interrupt) +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) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_hos= t.h index 756806d2e801..c895e94ffb80 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1409,7 +1409,8 @@ struct kvm_x86_ops { void (*load_eoi_exitmap)(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap); void (*set_virtual_apic_mode)(struct kvm_vcpu *vcpu); void (*set_apic_access_page_addr)(struct kvm_vcpu *vcpu); - int (*deliver_posted_interrupt)(struct kvm_vcpu *vcpu, int vector); + void (*deliver_interrupt)(struct kvm_lapic *apic, int delivery_mode, + int trig_mode, int vector); int (*sync_pir_to_irr)(struct kvm_vcpu *vcpu); int (*set_tss_addr)(struct kvm *kvm, unsigned int addr); int (*set_identity_map_addr)(struct kvm *kvm, u64 ident_addr); diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index 4662469240bc..d7e6fde82d25 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -1096,14 +1096,8 @@ static int __apic_accept_irq(struct kvm_lapic *apic,= int delivery_mode, apic->regs + APIC_TMR); } =20 - if (static_call(kvm_x86_deliver_posted_interrupt)(vcpu, vector)) { - kvm_lapic_set_irr(vector, apic); - kvm_make_request(KVM_REQ_EVENT, vcpu); - kvm_vcpu_kick(vcpu); - } else { - trace_kvm_apicv_accept_irq(vcpu->vcpu_id, delivery_mode, - trig_mode, vector); - } + static_call(kvm_x86_deliver_interrupt)(apic, delivery_mode, + trig_mode, vector); break; =20 case APIC_DM_REMRD: diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index d73bff4f9e86..75d277067141 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -3293,6 +3293,21 @@ static void svm_set_irq(struct kvm_vcpu *vcpu) SVM_EVTINJ_VALID | SVM_EVTINJ_TYPE_INTR; } =20 +static void svm_deliver_interrupt(struct kvm_lapic *apic, int delivery_mod= e, + int trig_mode, int vector) +{ + struct kvm_vcpu *vcpu =3D apic->vcpu; + + if (svm_deliver_avic_intr(vcpu, vector)) { + kvm_lapic_set_irr(vector, apic); + kvm_make_request(KVM_REQ_EVENT, vcpu); + kvm_vcpu_kick(vcpu); + } else { + trace_kvm_apicv_accept_irq(vcpu->vcpu_id, delivery_mode, + trig_mode, vector); + } +} + static void svm_update_cr8_intercept(struct kvm_vcpu *vcpu, int tpr, int i= rr) { struct vcpu_svm *svm =3D to_svm(vcpu); @@ -4547,7 +4562,7 @@ static struct kvm_x86_ops svm_x86_ops __initdata =3D { .pmu_ops =3D &amd_pmu_ops, .nested_ops =3D &svm_nested_ops, =20 - .deliver_posted_interrupt =3D svm_deliver_avic_intr, + .deliver_interrupt =3D svm_deliver_interrupt, .dy_apicv_has_pending_interrupt =3D svm_dy_apicv_has_pending_interrupt, .update_pi_irte =3D svm_update_pi_irte, .setup_mce =3D svm_setup_mce, diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 92e30bfdf785..97d6edbd25a0 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -4041,6 +4041,21 @@ static int vmx_deliver_posted_interrupt(struct kvm_v= cpu *vcpu, int vector) return 0; } =20 +static void vmx_deliver_interrupt(struct kvm_lapic *apic, int delivery_mod= e, + int trig_mode, int vector) +{ + struct kvm_vcpu *vcpu =3D apic->vcpu; + + if (vmx_deliver_posted_interrupt(vcpu, vector)) { + kvm_lapic_set_irr(vector, apic); + kvm_make_request(KVM_REQ_EVENT, vcpu); + kvm_vcpu_kick(vcpu); + } else { + trace_kvm_apicv_accept_irq(vcpu->vcpu_id, delivery_mode, + trig_mode, vector); + } +} + /* * Set up the vmcs's constant host-state fields, i.e., host-state fields t= hat * will not change in the lifetime of the guest. @@ -7766,7 +7781,7 @@ static struct kvm_x86_ops vmx_x86_ops __initdata =3D { .hwapic_isr_update =3D vmx_hwapic_isr_update, .guest_apic_has_interrupt =3D vmx_guest_apic_has_interrupt, .sync_pir_to_irr =3D vmx_sync_pir_to_irr, - .deliver_posted_interrupt =3D vmx_deliver_posted_interrupt, + .deliver_interrupt =3D vmx_deliver_interrupt, .dy_apicv_has_pending_interrupt =3D pi_has_pending_interrupt, =20 .set_tss_addr =3D vmx_set_tss_addr, --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Tue Jun 30 01:42:29 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0239DC433FE for ; Fri, 28 Jan 2022 00:53:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344923AbiA1Axg (ORCPT ); Thu, 27 Jan 2022 19:53:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344799AbiA1AxT (ORCPT ); Thu, 27 Jan 2022 19:53:19 -0500 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82E21C061749 for ; Thu, 27 Jan 2022 16:53:19 -0800 (PST) Received: by mail-pl1-x649.google.com with SMTP id y3-20020a170902ed4300b0014c958855acso405642plb.20 for ; Thu, 27 Jan 2022 16:53:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=cCud0Kpa8l1l/qGHOZiBm/VeUVJQYIj1xOVhvfcHUZI=; b=brk94DiVtQRsClZuWo0yKIokEP8lGH82FvMbhpJN5DDit+fDkuCuHBxY0LXx3iI6c5 uIrMmLrii1RBnJaG8EXivkA+zs066u35Iosg+1OvBoBhLV4e/jcVnAymnzp0ChNMFSmK kYkPV5isii7QV1UaEi8qYCnf8gWg4KYcGgh0KHqC3kMpvA9DfZWgR1ojDXyO0B1ZNTru TaXk6vWZojatURdTmdj5JhX5gNXC8lVMjI0gdhlS97jqAZahfYKqUTFQbY2i0gesZ1fT HqZ8nq/nxoRcdfH0nTG/bLpc+8s6Kho33aVCCWWYYi0hNYZBY0apVKvdPFF0kDYYm3kF r8dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=cCud0Kpa8l1l/qGHOZiBm/VeUVJQYIj1xOVhvfcHUZI=; b=qU87mEqwgu/krLIbGPdSPnYOjpoaLf23jck5rLJNTF0u3k2BQOJWCmG6h//SrZ9lgM L3UK37LDBQ9moZssu+6B14k2NhXZeSsnHs4+ZbmRJTHhqy4TDKPtYlkJ3lt1HO2NTB/j NAB1IzRgm9mupg9rpEBh5saq1rT4EwxkoPMVLyDzLOLUPvlGpVY4MdRKZXj2o4O/3YOF sSpLhaKckdpH7q1DJjyoL6HQz7Rq0G41bLwikffvgmP+8Y8myTybJyDw/CS7SpfcXpQ2 a9VTyCwCdxFsX//m/WPbVl9hRmNV0QKFdZsyhFHDwtuJLcrBEXLp4L/4z49+Rg+/Rew8 qZCQ== X-Gm-Message-State: AOAM533TK6hxZMJZszZiL5zoiw+pdP942a+5TAA1/TuPaC6YMbjhogn9 WN+mwLwwWIylqHfGSYFnZwAeTBr23P0= X-Google-Smtp-Source: ABdhPJxjDKhytSS1r+DHo41J3pSmCsXa6mfHle7bKxcfeM9uEkj0aoDjmtUMBhT9j+AfC/Vl1q0dJTlVfag= X-Received: from seanjc.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e5]) (user=seanjc job=sendgmr) by 2002:a17:902:ce84:: with SMTP id f4mr5575274plg.140.1643331198890; Thu, 27 Jan 2022 16:53:18 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 28 Jan 2022 00:51:49 +0000 In-Reply-To: <20220128005208.4008533-1-seanjc@google.com> Message-Id: <20220128005208.4008533-4-seanjc@google.com> Mime-Version: 1.0 References: <20220128005208.4008533-1-seanjc@google.com> X-Mailer: git-send-email 2.35.0.rc0.227.g00780c9af4-goog Subject: [PATCH 03/22] KVM: x86: Drop export for .tlb_flush_current() static_call key From: Sean Christopherson To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Like Xu Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Remove the export of kvm_x86_tlb_flush_current() as there are no longer any users outside of common x86 code. Signed-off-by: Sean Christopherson --- arch/x86/kvm/x86.c | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index ebab514ec82a..a2821c46dfa4 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -132,7 +132,6 @@ EXPORT_SYMBOL_GPL(kvm_x86_ops); #include EXPORT_STATIC_CALL_GPL(kvm_x86_get_cs_db_l_bits); EXPORT_STATIC_CALL_GPL(kvm_x86_cache_reg); -EXPORT_STATIC_CALL_GPL(kvm_x86_tlb_flush_current); =20 static bool __read_mostly ignore_msrs =3D 0; module_param(ignore_msrs, bool, S_IRUGO | S_IWUSR); --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Tue Jun 30 01:42:29 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C5C3C433EF for ; Fri, 28 Jan 2022 00:53:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344833AbiA1Axl (ORCPT ); Thu, 27 Jan 2022 19:53:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344822AbiA1AxV (ORCPT ); Thu, 27 Jan 2022 19:53:21 -0500 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AE92C06174E for ; Thu, 27 Jan 2022 16:53:21 -0800 (PST) Received: by mail-pj1-x104a.google.com with SMTP id n9-20020a17090a73c900b001b5cafefa27so2873449pjk.2 for ; Thu, 27 Jan 2022 16:53:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=KSdQd/HH6zg6Fen+iY/KfeFerxFepmAT3RGzM3Nml5A=; b=j1dFYBtKm8srVaFX4HS++T1WlxV27Kar2Gfkea24AUYnvMFXsdoO/3v6JhqQZg+HP5 XqbM2kbaV4+b4FLFAXss+MeCCuXsH4gL5YZ7Sjkux8da+CvRXscmNA1g0AYegOZ7beGn cwGG5D9reBxSoELyzgCgwZFaf4bJl5iHrBS45Bh+7J1l9Nieueycb5qy1Y2pmOT4HsO9 HkhQswdeQWabbSzX6Ak1ysgLK4F3y4RaZL1c0zTIE92XJ9fyWm8x58kDRKtAbdayz/px SWalyoMRQxn74tcbhKkjcr5adkVdKQS42CsH7FwLu97ErcekCWwlQMnuLiBBYqNx/60i aCtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=KSdQd/HH6zg6Fen+iY/KfeFerxFepmAT3RGzM3Nml5A=; b=zTgRu+GPp1zz47nVdVwm+NHhrAjPEvm6PcivXKZVFwpjJRI00fr1vjA2hnw+cl+Erg I7rsX0bdEDREf0yst7xg7EncMgukh3r9/tYjP2t7hwBuHicV1YpLw2cr8RTNmrBVVGKI 0bgyh2+bSv+zrOkUZ/O8KhlbysUfVc8b6+wB0WuPif+p0dt06XnqKzdDX788+tVJcPD4 8A9QZ7xjvswNU6xWxm2gE7PMh8vDOMoG/RtUa5qUJcZW/merVo+Cbg3I2UfdqIbZCMBe CXa151yVC2I+lfO9oiJTHFK43gRrJcQ64BK68dHi2w8NiESzP99L2T2iAZN3ZsFhwHff OkRw== X-Gm-Message-State: AOAM531SRmax3wrGistIohVNkoYruA0WmfVJa4Fmv/eJIS2VhDwe47jB U+e9eyU21ruGIx4eBS8yHcz8bEVgqZo= X-Google-Smtp-Source: ABdhPJyIpiKDjPqYuHV7zw86jsDrJ8JfHnUBFjC64kM/2NIlptvuJpbvVTVZsfl2LJhU9ioMUC3GycgSmGM= X-Received: from seanjc.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e5]) (user=seanjc job=sendgmr) by 2002:a17:90a:e2ca:: with SMTP id fr10mr7015733pjb.51.1643331200616; Thu, 27 Jan 2022 16:53:20 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 28 Jan 2022 00:51:50 +0000 In-Reply-To: <20220128005208.4008533-1-seanjc@google.com> Message-Id: <20220128005208.4008533-5-seanjc@google.com> Mime-Version: 1.0 References: <20220128005208.4008533-1-seanjc@google.com> X-Mailer: git-send-email 2.35.0.rc0.227.g00780c9af4-goog Subject: [PATCH 04/22] KVM: x86: Rename kvm_x86_ops pointers to align w/ preferred vendor names From: Sean Christopherson To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Like Xu Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Rename a variety of kvm_x86_op function pointers so that preferred name for vendor implementations follows the pattern _, e.g. rename .run() to .vcpu_run() to match {svm,vmx}_vcpu_run(). This will allow vendor implementations to be wired up via the KVM_X86_OP macro. In many cases, VMX and SVM "disagree" on the preferred name, though in reality it's VMX and x86 that disagree as SVM blindly prepended _svm to the kvm_x86_ops name. Justification for using the VMX nomenclature: - set_{irq,nmi} =3D> inject_{irq,nmi} because the helper is injecting an event that has already been "set" in e.g. the vIRR. SVM's relevant VMCB field is even named event_inj, and KVM's stat is irq_injections. - prepare_guest_switch =3D> prepare_switch_to_guest because the former is ambiguous, e.g. it could mean switching between multiple guests, switching from the guest to host, etc... - update_pi_irte =3D> pi_update_irte to allow for matching match the rest of VMX's posted interrupt naming scheme, which is vmx_pi_(). - start_assignment =3D> pi_start_assignment to again follow VMX's posted interrupt naming scheme, and to provide context for what bit of code might care about an otherwise undescribed "assignment". The "tlb_flush" =3D> "flush_tlb" creates an inconsistency with respect to Hyper-V's "tlb_remote_flush" hooks, but Hyper-V really is the one that's wrong. x86, VMX, and SVM all use flush_tlb, and even common KVM is on a variant of the bandwagon with "kvm_flush_remote_tlbs", e.g. a more appropriate name for the Hyper-V hooks would be flush_remote_tlbs. Leave that change for another time as the Hyper-V hooks always start as NULL, i.e. the name doesn't matter for using kvm-x86-ops.h, and changing all names requires an astounding amount of churn. VMX and SVM function names are intentionally left as is to minimize the diff. Both VMX and SVM will need to rename even more functions in order to fully utilize KVM_X86_OPS, i.e. an additional patch for each is inevitable. No functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/include/asm/kvm-x86-ops.h | 20 +++++++++---------- arch/x86/include/asm/kvm_host.h | 20 +++++++++---------- arch/x86/kvm/mmu/mmu.c | 6 +++--- arch/x86/kvm/svm/svm.c | 18 ++++++++--------- arch/x86/kvm/vmx/vmx.c | 20 +++++++++---------- arch/x86/kvm/x86.c | 31 ++++++++++++++---------------- 6 files changed, 56 insertions(+), 59 deletions(-) diff --git a/arch/x86/include/asm/kvm-x86-ops.h b/arch/x86/include/asm/kvm-= x86-ops.h index fd134c436029..a87632641a13 100644 --- a/arch/x86/include/asm/kvm-x86-ops.h +++ b/arch/x86/include/asm/kvm-x86-ops.h @@ -18,7 +18,7 @@ KVM_X86_OP(vm_destroy) KVM_X86_OP(vcpu_create) KVM_X86_OP(vcpu_free) KVM_X86_OP(vcpu_reset) -KVM_X86_OP(prepare_guest_switch) +KVM_X86_OP(prepare_switch_to_guest) KVM_X86_OP(vcpu_load) KVM_X86_OP(vcpu_put) KVM_X86_OP(update_exception_bitmap) @@ -44,22 +44,22 @@ KVM_X86_OP(cache_reg) KVM_X86_OP(get_rflags) KVM_X86_OP(set_rflags) KVM_X86_OP(get_if_flag) -KVM_X86_OP(tlb_flush_all) -KVM_X86_OP(tlb_flush_current) +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(tlb_flush_gva) -KVM_X86_OP(tlb_flush_guest) +KVM_X86_OP(flush_tlb_gva) +KVM_X86_OP(flush_tlb_guest) KVM_X86_OP(vcpu_pre_run) -KVM_X86_OP(run) +KVM_X86_OP(vcpu_run) KVM_X86_OP(handle_exit) KVM_X86_OP(skip_emulated_instruction) KVM_X86_OP(update_emulated_instruction) KVM_X86_OP(set_interrupt_shadow) KVM_X86_OP(get_interrupt_shadow) KVM_X86_OP(patch_hypercall) -KVM_X86_OP(set_irq) -KVM_X86_OP(set_nmi) +KVM_X86_OP(inject_irq) +KVM_X86_OP(inject_nmi) KVM_X86_OP(queue_exception) KVM_X86_OP(cancel_injection) KVM_X86_OP(interrupt_allowed) @@ -96,8 +96,8 @@ 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(update_pi_irte) -KVM_X86_OP(start_assignment) +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) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_hos= t.h index c895e94ffb80..91c0e4957bd0 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1330,7 +1330,7 @@ struct kvm_x86_ops { void (*vcpu_free)(struct kvm_vcpu *vcpu); void (*vcpu_reset)(struct kvm_vcpu *vcpu, bool init_event); =20 - void (*prepare_guest_switch)(struct kvm_vcpu *vcpu); + void (*prepare_switch_to_guest)(struct kvm_vcpu *vcpu); void (*vcpu_load)(struct kvm_vcpu *vcpu, int cpu); void (*vcpu_put)(struct kvm_vcpu *vcpu); =20 @@ -1360,8 +1360,8 @@ struct kvm_x86_ops { void (*set_rflags)(struct kvm_vcpu *vcpu, unsigned long rflags); bool (*get_if_flag)(struct kvm_vcpu *vcpu); =20 - void (*tlb_flush_all)(struct kvm_vcpu *vcpu); - void (*tlb_flush_current)(struct kvm_vcpu *vcpu); + void (*flush_tlb_all)(struct kvm_vcpu *vcpu); + void (*flush_tlb_current)(struct kvm_vcpu *vcpu); int (*tlb_remote_flush)(struct kvm *kvm); int (*tlb_remote_flush_with_range)(struct kvm *kvm, struct kvm_tlb_range *range); @@ -1372,16 +1372,16 @@ struct kvm_x86_ops { * Can potentially get non-canonical addresses through INVLPGs, which * the implementation may choose to ignore if appropriate. */ - void (*tlb_flush_gva)(struct kvm_vcpu *vcpu, gva_t addr); + void (*flush_tlb_gva)(struct kvm_vcpu *vcpu, gva_t addr); =20 /* * Flush any TLB entries created by the guest. Like tlb_flush_gva(), * does not need to flush GPA->HPA mappings. */ - void (*tlb_flush_guest)(struct kvm_vcpu *vcpu); + void (*flush_tlb_guest)(struct kvm_vcpu *vcpu); =20 int (*vcpu_pre_run)(struct kvm_vcpu *vcpu); - enum exit_fastpath_completion (*run)(struct kvm_vcpu *vcpu); + enum exit_fastpath_completion (*vcpu_run)(struct kvm_vcpu *vcpu); int (*handle_exit)(struct kvm_vcpu *vcpu, enum exit_fastpath_completion exit_fastpath); int (*skip_emulated_instruction)(struct kvm_vcpu *vcpu); @@ -1390,8 +1390,8 @@ struct kvm_x86_ops { u32 (*get_interrupt_shadow)(struct kvm_vcpu *vcpu); void (*patch_hypercall)(struct kvm_vcpu *vcpu, unsigned char *hypercall_addr); - void (*set_irq)(struct kvm_vcpu *vcpu); - void (*set_nmi)(struct kvm_vcpu *vcpu); + void (*inject_irq)(struct kvm_vcpu *vcpu); + void (*inject_nmi)(struct kvm_vcpu *vcpu); void (*queue_exception)(struct kvm_vcpu *vcpu); void (*cancel_injection)(struct kvm_vcpu *vcpu); int (*interrupt_allowed)(struct kvm_vcpu *vcpu, bool for_injection); @@ -1458,9 +1458,9 @@ struct kvm_x86_ops { void (*vcpu_blocking)(struct kvm_vcpu *vcpu); void (*vcpu_unblocking)(struct kvm_vcpu *vcpu); =20 - int (*update_pi_irte)(struct kvm *kvm, unsigned int host_irq, + int (*pi_update_irte)(struct kvm *kvm, unsigned int host_irq, uint32_t guest_irq, bool set); - void (*start_assignment)(struct kvm *kvm); + void (*pi_start_assignment)(struct kvm *kvm); void (*apicv_post_state_restore)(struct kvm_vcpu *vcpu); bool (*dy_apicv_has_pending_interrupt)(struct kvm_vcpu *vcpu); =20 diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index b29fc88b51b4..9f1b4711d5ea 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -5097,7 +5097,7 @@ int kvm_mmu_load(struct kvm_vcpu *vcpu) kvm_mmu_sync_roots(vcpu); =20 kvm_mmu_load_pgd(vcpu); - static_call(kvm_x86_tlb_flush_current)(vcpu); + static_call(kvm_x86_flush_tlb_current)(vcpu); out: return r; } @@ -5357,7 +5357,7 @@ void kvm_mmu_invalidate_gva(struct kvm_vcpu *vcpu, st= ruct kvm_mmu *mmu, if (is_noncanonical_address(gva, vcpu)) return; =20 - static_call(kvm_x86_tlb_flush_gva)(vcpu, gva); + static_call(kvm_x86_flush_tlb_gva)(vcpu, gva); } =20 if (!mmu->invlpg) @@ -5413,7 +5413,7 @@ void kvm_mmu_invpcid_gva(struct kvm_vcpu *vcpu, gva_t= gva, unsigned long pcid) } =20 if (tlb_flush) - static_call(kvm_x86_tlb_flush_gva)(vcpu, gva); + static_call(kvm_x86_flush_tlb_gva)(vcpu, gva); =20 ++vcpu->stat.invlpg; =20 diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 75d277067141..991d3e628c60 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -4472,7 +4472,7 @@ static struct kvm_x86_ops svm_x86_ops __initdata =3D { .vm_init =3D svm_vm_init, .vm_destroy =3D svm_vm_destroy, =20 - .prepare_guest_switch =3D svm_prepare_guest_switch, + .prepare_switch_to_guest =3D svm_prepare_guest_switch, .vcpu_load =3D svm_vcpu_load, .vcpu_put =3D svm_vcpu_put, .vcpu_blocking =3D avic_vcpu_blocking, @@ -4503,21 +4503,21 @@ static struct kvm_x86_ops svm_x86_ops __initdata = =3D { .set_rflags =3D svm_set_rflags, .get_if_flag =3D svm_get_if_flag, =20 - .tlb_flush_all =3D svm_flush_tlb, - .tlb_flush_current =3D svm_flush_tlb, - .tlb_flush_gva =3D svm_flush_tlb_gva, - .tlb_flush_guest =3D svm_flush_tlb, + .flush_tlb_all =3D svm_flush_tlb, + .flush_tlb_current =3D svm_flush_tlb, + .flush_tlb_gva =3D svm_flush_tlb_gva, + .flush_tlb_guest =3D svm_flush_tlb, =20 .vcpu_pre_run =3D svm_vcpu_pre_run, - .run =3D svm_vcpu_run, + .vcpu_run =3D svm_vcpu_run, .handle_exit =3D handle_exit, .skip_emulated_instruction =3D skip_emulated_instruction, .update_emulated_instruction =3D NULL, .set_interrupt_shadow =3D svm_set_interrupt_shadow, .get_interrupt_shadow =3D svm_get_interrupt_shadow, .patch_hypercall =3D svm_patch_hypercall, - .set_irq =3D svm_set_irq, - .set_nmi =3D svm_inject_nmi, + .inject_irq =3D svm_set_irq, + .inject_nmi =3D svm_inject_nmi, .queue_exception =3D svm_queue_exception, .cancel_injection =3D svm_cancel_injection, .interrupt_allowed =3D svm_interrupt_allowed, @@ -4564,7 +4564,7 @@ static struct kvm_x86_ops svm_x86_ops __initdata =3D { =20 .deliver_interrupt =3D svm_deliver_interrupt, .dy_apicv_has_pending_interrupt =3D svm_dy_apicv_has_pending_interrupt, - .update_pi_irte =3D svm_update_pi_irte, + .pi_update_irte =3D svm_update_pi_irte, .setup_mce =3D svm_setup_mce, =20 .smi_allowed =3D svm_smi_allowed, diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 97d6edbd25a0..1d2d850b124b 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -7719,7 +7719,7 @@ static struct kvm_x86_ops vmx_x86_ops __initdata =3D { .vcpu_free =3D vmx_free_vcpu, .vcpu_reset =3D vmx_vcpu_reset, =20 - .prepare_guest_switch =3D vmx_prepare_switch_to_guest, + .prepare_switch_to_guest =3D vmx_prepare_switch_to_guest, .vcpu_load =3D vmx_vcpu_load, .vcpu_put =3D vmx_vcpu_put, =20 @@ -7747,21 +7747,21 @@ static struct kvm_x86_ops vmx_x86_ops __initdata = =3D { .set_rflags =3D vmx_set_rflags, .get_if_flag =3D vmx_get_if_flag, =20 - .tlb_flush_all =3D vmx_flush_tlb_all, - .tlb_flush_current =3D vmx_flush_tlb_current, - .tlb_flush_gva =3D vmx_flush_tlb_gva, - .tlb_flush_guest =3D vmx_flush_tlb_guest, + .flush_tlb_all =3D vmx_flush_tlb_all, + .flush_tlb_current =3D vmx_flush_tlb_current, + .flush_tlb_gva =3D vmx_flush_tlb_gva, + .flush_tlb_guest =3D vmx_flush_tlb_guest, =20 .vcpu_pre_run =3D vmx_vcpu_pre_run, - .run =3D vmx_vcpu_run, + .vcpu_run =3D vmx_vcpu_run, .handle_exit =3D vmx_handle_exit, .skip_emulated_instruction =3D vmx_skip_emulated_instruction, .update_emulated_instruction =3D vmx_update_emulated_instruction, .set_interrupt_shadow =3D vmx_set_interrupt_shadow, .get_interrupt_shadow =3D vmx_get_interrupt_shadow, .patch_hypercall =3D vmx_patch_hypercall, - .set_irq =3D vmx_inject_irq, - .set_nmi =3D vmx_inject_nmi, + .inject_irq =3D vmx_inject_irq, + .inject_nmi =3D vmx_inject_nmi, .queue_exception =3D vmx_queue_exception, .cancel_injection =3D vmx_cancel_injection, .interrupt_allowed =3D vmx_interrupt_allowed, @@ -7814,8 +7814,8 @@ static struct kvm_x86_ops vmx_x86_ops __initdata =3D { .pmu_ops =3D &intel_pmu_ops, .nested_ops =3D &vmx_nested_ops, =20 - .update_pi_irte =3D pi_update_irte, - .start_assignment =3D vmx_pi_start_assignment, + .pi_update_irte =3D pi_update_irte, + .pi_start_assignment =3D vmx_pi_start_assignment, =20 #ifdef CONFIG_X86_64 .set_hv_timer =3D vmx_set_hv_timer, diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index a2821c46dfa4..cc14f79c446c 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -3264,7 +3264,7 @@ static void kvmclock_reset(struct kvm_vcpu *vcpu) static void kvm_vcpu_flush_tlb_all(struct kvm_vcpu *vcpu) { ++vcpu->stat.tlb_flush; - static_call(kvm_x86_tlb_flush_all)(vcpu); + static_call(kvm_x86_flush_tlb_all)(vcpu); } =20 static void kvm_vcpu_flush_tlb_guest(struct kvm_vcpu *vcpu) @@ -3282,14 +3282,14 @@ static void kvm_vcpu_flush_tlb_guest(struct kvm_vcp= u *vcpu) kvm_mmu_sync_prev_roots(vcpu); } =20 - static_call(kvm_x86_tlb_flush_guest)(vcpu); + static_call(kvm_x86_flush_tlb_guest)(vcpu); } =20 =20 static inline void kvm_vcpu_flush_tlb_current(struct kvm_vcpu *vcpu) { ++vcpu->stat.tlb_flush; - static_call(kvm_x86_tlb_flush_current)(vcpu); + static_call(kvm_x86_flush_tlb_current)(vcpu); } =20 /* @@ -9283,10 +9283,10 @@ static int inject_pending_event(struct kvm_vcpu *vc= pu, bool *req_immediate_exit) */ else if (!vcpu->arch.exception.pending) { if (vcpu->arch.nmi_injected) { - static_call(kvm_x86_set_nmi)(vcpu); + static_call(kvm_x86_inject_nmi)(vcpu); can_inject =3D false; } else if (vcpu->arch.interrupt.injected) { - static_call(kvm_x86_set_irq)(vcpu); + static_call(kvm_x86_inject_irq)(vcpu); can_inject =3D false; } } @@ -9366,7 +9366,7 @@ static int inject_pending_event(struct kvm_vcpu *vcpu= , bool *req_immediate_exit) if (r) { --vcpu->arch.nmi_pending; vcpu->arch.nmi_injected =3D true; - static_call(kvm_x86_set_nmi)(vcpu); + static_call(kvm_x86_inject_nmi)(vcpu); can_inject =3D false; WARN_ON(static_call(kvm_x86_nmi_allowed)(vcpu, true) < 0); } @@ -9380,7 +9380,7 @@ static int inject_pending_event(struct kvm_vcpu *vcpu= , bool *req_immediate_exit) goto out; if (r) { kvm_queue_interrupt(vcpu, kvm_cpu_get_interrupt(vcpu), false); - static_call(kvm_x86_set_irq)(vcpu); + static_call(kvm_x86_inject_irq)(vcpu); WARN_ON(static_call(kvm_x86_interrupt_allowed)(vcpu, true) < 0); } if (kvm_cpu_has_injectable_intr(vcpu)) @@ -10005,7 +10005,7 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) =20 preempt_disable(); =20 - static_call(kvm_x86_prepare_guest_switch)(vcpu); + static_call(kvm_x86_prepare_switch_to_guest)(vcpu); =20 /* * Disable IRQs before setting IN_GUEST_MODE. Posted interrupt @@ -10082,7 +10082,7 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) */ WARN_ON_ONCE(kvm_apicv_activated(vcpu->kvm) !=3D kvm_vcpu_apicv_active(v= cpu)); =20 - exit_fastpath =3D static_call(kvm_x86_run)(vcpu); + exit_fastpath =3D static_call(kvm_x86_vcpu_run)(vcpu); if (likely(exit_fastpath !=3D EXIT_FASTPATH_REENTER_GUEST)) break; =20 @@ -10385,10 +10385,7 @@ static int complete_emulated_mmio(struct kvm_vcpu = *vcpu) /* Swap (qemu) user FPU context for the guest FPU context. */ static void kvm_load_guest_fpu(struct kvm_vcpu *vcpu) { - /* - * Exclude PKRU from restore as restored separately in - * kvm_x86_ops.run(). - */ + /* Exclude PKRU, it's restored separately immediately after VM-Exit. */ fpu_swap_kvm_fpstate(&vcpu->arch.guest_fpu, true); trace_kvm_fpu(1); } @@ -12396,7 +12393,7 @@ bool kvm_arch_can_dequeue_async_page_present(struct= kvm_vcpu *vcpu) void kvm_arch_start_assignment(struct kvm *kvm) { if (atomic_inc_return(&kvm->arch.assigned_device_count) =3D=3D 1) - static_call_cond(kvm_x86_start_assignment)(kvm); + static_call_cond(kvm_x86_pi_start_assignment)(kvm); } EXPORT_SYMBOL_GPL(kvm_arch_start_assignment); =20 @@ -12444,7 +12441,7 @@ int kvm_arch_irq_bypass_add_producer(struct irq_byp= ass_consumer *cons, =20 irqfd->producer =3D prod; kvm_arch_start_assignment(irqfd->kvm); - ret =3D static_call(kvm_x86_update_pi_irte)(irqfd->kvm, + ret =3D static_call(kvm_x86_pi_update_irte)(irqfd->kvm, prod->irq, irqfd->gsi, 1); =20 if (ret) @@ -12469,7 +12466,7 @@ void kvm_arch_irq_bypass_del_producer(struct irq_by= pass_consumer *cons, * when the irq is masked/disabled or the consumer side (KVM * int this case doesn't want to receive the interrupts. */ - ret =3D static_call(kvm_x86_update_pi_irte)(irqfd->kvm, prod->irq, irqfd-= >gsi, 0); + ret =3D static_call(kvm_x86_pi_update_irte)(irqfd->kvm, prod->irq, irqfd-= >gsi, 0); if (ret) printk(KERN_INFO "irq bypass consumer (token %p) unregistration" " fails: %d\n", irqfd->consumer.token, ret); @@ -12480,7 +12477,7 @@ void kvm_arch_irq_bypass_del_producer(struct irq_by= pass_consumer *cons, int kvm_arch_update_irqfd_routing(struct kvm *kvm, unsigned int host_irq, uint32_t guest_irq, bool set) { - return static_call(kvm_x86_update_pi_irte)(kvm, host_irq, guest_irq, set); + return static_call(kvm_x86_pi_update_irte)(kvm, host_irq, guest_irq, set); } =20 bool kvm_arch_irqfd_route_changed(struct kvm_kernel_irq_routing_entry *old, --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Tue Jun 30 01:42:29 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA385C433F5 for ; Fri, 28 Jan 2022 00:53:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344989AbiA1Axo (ORCPT ); Thu, 27 Jan 2022 19:53:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344855AbiA1AxZ (ORCPT ); Thu, 27 Jan 2022 19:53:25 -0500 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D10B3C061753 for ; Thu, 27 Jan 2022 16:53:22 -0800 (PST) Received: by mail-pj1-x104a.google.com with SMTP id k2-20020a17090a658200b001b399622095so2851337pjj.9 for ; Thu, 27 Jan 2022 16:53:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=MoHy27U3pXaXkL0u2KKkeb8SzX8P4k1qrRDTcgsWetA=; b=EqdpBATfjlVVuZojDLCyulKP1ekFA1dhoWS7qfqhKAGctc9u66Eg5171vUXlLUm4HE Var11+u7SKElmw93R/hlCwCDqc5vzefmNzGbr+80RNF2yoQHlPK5XtH1/SdviM1XTGGN YM0jpR5nfIzr0XDBbxEeEZmo4uR2eJamLqLu0bvSk1XDwjjUe3I6Oe0C+KfKNOpQ2PxN K+iDLhjNYwFuoPqbE3jgVAkupGcCSDIXpiWhxfSBEpu3auyEkAYi1VpGBRIZkNcrRnuY FsM/Y8jP1wTIx+DFNYDCKCR2eV4ZDwpk34awoNG/cMJ+J0HBWhwzfYThc7GezvbpOqSq zbQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=MoHy27U3pXaXkL0u2KKkeb8SzX8P4k1qrRDTcgsWetA=; b=2kfmZJVOpVzAp62sj/DS2fcZoBQk9UQP1W2gBs9xk/jNx3ZhdG0lrvPwcv5ibz9ygB 0bKezUErEhse+q823sslN4DYK1ug36DVbO7TCIxhrAnSZOYx82hbNMDWNdhi/1fgonNj EY7vC1Nr4vbOh9tN154P7OfQFnq1VVR/YnxZXcOnFaI19PgS/sPIiccIBZNIC/sBzqJV Is1AhA3tx7NXi2m2DYkJI+2LJinMBpiW2GAsgcpCQFcHEktFkzbxRqkTPIsk14mLG+/9 Y8YN24kxsvZBbs0ns/olWsCDLVkNBkbPbdqMxcgYgWHr/NnzDYjzjlSPn90ozRkkkOWL untQ== X-Gm-Message-State: AOAM5312aUSwmUjtrjc+4veMtoJcnamAEjQf7eGsBLoV1siiitjOxVnM iVwTX+FMkp6RsMcdLnilIMbxt1zddzo= X-Google-Smtp-Source: ABdhPJz5GveShZKKXurJYvOum+YlxCN026eERDfD3Ui6hAISaoh3rOcsEo7zG5HDWxojIvpU/MEppShInwI= X-Received: from seanjc.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e5]) (user=seanjc job=sendgmr) by 2002:a17:90a:17c4:: with SMTP id q62mr16834393pja.145.1643331202367; Thu, 27 Jan 2022 16:53:22 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 28 Jan 2022 00:51:51 +0000 In-Reply-To: <20220128005208.4008533-1-seanjc@google.com> Message-Id: <20220128005208.4008533-6-seanjc@google.com> Mime-Version: 1.0 References: <20220128005208.4008533-1-seanjc@google.com> X-Mailer: git-send-email 2.35.0.rc0.227.g00780c9af4-goog Subject: [PATCH 05/22] KVM: x86: Use static_call() for .vcpu_deliver_sipi_vector() From: Sean Christopherson To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Like Xu Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Define and use a static_call() for kvm_x86_ops.vcpu_deliver_sipi_vector(), mostly so that the op is defined in kvm-x86-ops.h. This will allow using KVM_X86_OP in vendor code to wire up the implementation. Any performance gains eeked out by using static_call() is a happy bonus and not the primary motiviation. Signed-off-by: Sean Christopherson --- arch/x86/include/asm/kvm-x86-ops.h | 1 + arch/x86/kvm/lapic.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/kvm-x86-ops.h b/arch/x86/include/asm/kvm-= x86-ops.h index a87632641a13..eb93aa439d61 100644 --- a/arch/x86/include/asm/kvm-x86-ops.h +++ b/arch/x86/include/asm/kvm-x86-ops.h @@ -117,5 +117,6 @@ 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) =20 #undef KVM_X86_OP diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index d7e6fde82d25..dc4bc9eea81c 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -2928,7 +2928,7 @@ int kvm_apic_accept_events(struct kvm_vcpu *vcpu) /* evaluate pending_events before reading the vector */ smp_rmb(); sipi_vector =3D apic->sipi_vector; - kvm_x86_ops.vcpu_deliver_sipi_vector(vcpu, sipi_vector); + static_call(kvm_x86_vcpu_deliver_sipi_vector)(vcpu, sipi_vector); vcpu->arch.mp_state =3D KVM_MP_STATE_RUNNABLE; } } --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Tue Jun 30 01:42:29 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE0E1C433F5 for ; Fri, 28 Jan 2022 00:53:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345018AbiA1Axs (ORCPT ); Thu, 27 Jan 2022 19:53:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344884AbiA1Ax3 (ORCPT ); Thu, 27 Jan 2022 19:53:29 -0500 Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F2D7C061759 for ; Thu, 27 Jan 2022 16:53:24 -0800 (PST) Received: by mail-pf1-x44a.google.com with SMTP id g21-20020a056a0023d500b004cc3a6556c5so1972178pfc.22 for ; Thu, 27 Jan 2022 16:53:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=0eMfYCih7vaFuBJ8EMuOAoXTDwMjKd4f4Kk7vbGbBek=; b=UobE1XhGxotFV1a2F+P38rwwjwaCv2Et8zUI3jzIa4+8hMEkEMYcuvA8iIkX+fKLKn ysUsmJ2VFXBxBM23y8Z4UQMUV+lu1ouJQsw/m+N+KyzNl4oYOmL73lqiCSnpWInTuM2b qfiESD8hcmbVZUDKJ+tB8B9u117ixbWeRI0x6Nu5aLlY/Hwisl4ESULKgQUwAgGnseBC 5vk7+V6Ha0MUdElrnKzkA2qHjlygi7maBN9CWaYnkpLF3fy7knVX77qVZtENq7wEViy2 XACyQi4yu++tl4zrQfO3HULgHey1FeJEE72ZEWb2+odXP4JeP4K5r6i87Z+Hr+zElTA+ zg2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=0eMfYCih7vaFuBJ8EMuOAoXTDwMjKd4f4Kk7vbGbBek=; b=yNebNpLCfP/GtJZBAcGQ7NdDR4qrdOrI2erpuFunRCz/AKs84OyVzVKD6vKEJI3Jgy lo0U1Rlh8182CgeJDiutMtcHxOBThQyiZync81MzbrFcIeggaH2tJYvWgtVYq0RVw7He MfvYugBkRw5ZdLDJo/rtKti2t+bVKbZqHHGt0Tu71rpYBRjjrcsMfX8bbULwU7JL0kJX YEh0Ee7EHmqMQlNbeY702aPO1pCQkKCUUDy1brgUeGCO+CmvAqwJ9iVCKQ5cqee6lLv/ pZ4umkOk437AY04dkonNrRPjMp/a77CYDMn6Paz/wjVOizdrAl7vvZo0ycn1Dgb+KnIi fqww== X-Gm-Message-State: AOAM532aqKnQhj5vhY2UUjxLWQp969CEvGGYi6FRLy5TfhO+xZwmkwit 8ftSTOOQRAzvSoNlFsBZAQACEYgVrC0= X-Google-Smtp-Source: ABdhPJz7pZs1Ceyo+NRWY7GpWcoS2ruelsiAb+55NOdScJRBCbqI54L2vUBn/KJ2p/BlO2vgm9Mt4MU6OuM= X-Received: from seanjc.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e5]) (user=seanjc job=sendgmr) by 2002:a17:902:dac4:: with SMTP id q4mr6635369plx.22.1643331203897; Thu, 27 Jan 2022 16:53:23 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 28 Jan 2022 00:51:52 +0000 In-Reply-To: <20220128005208.4008533-1-seanjc@google.com> Message-Id: <20220128005208.4008533-7-seanjc@google.com> Mime-Version: 1.0 References: <20220128005208.4008533-1-seanjc@google.com> X-Mailer: git-send-email 2.35.0.rc0.227.g00780c9af4-goog Subject: [PATCH 06/22] KVM: VMX: Call vmx_get_cpl() directly in handle_dr() From: Sean Christopherson To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Like Xu Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use vmx_get_cpl() instead of bouncing through kvm_x86_ops.get_cpl() when performing a CPL check on MOV DR accesses. This avoids a RETPOLINE (when enabled), and more importantly removes a vendor reference to kvm_x86_ops and helps pave the way for unexporting kvm_x86_ops. Signed-off-by: Sean Christopherson --- arch/x86/kvm/vmx/vmx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 1d2d850b124b..de66786396bd 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -5184,7 +5184,7 @@ static int handle_dr(struct kvm_vcpu *vcpu) if (!kvm_require_dr(vcpu, dr)) return 1; =20 - if (kvm_x86_ops.get_cpl(vcpu) > 0) + if (vmx_get_cpl(vcpu) > 0) goto out; =20 dr7 =3D vmcs_readl(GUEST_DR7); --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Tue Jun 30 01:42:29 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9E59C433FE for ; Fri, 28 Jan 2022 00:53:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345025AbiA1Axw (ORCPT ); Thu, 27 Jan 2022 19:53:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344806AbiA1Axj (ORCPT ); Thu, 27 Jan 2022 19:53:39 -0500 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1476CC06175D for ; Thu, 27 Jan 2022 16:53:26 -0800 (PST) Received: by mail-pl1-x649.google.com with SMTP id k7-20020a170902ba8700b0014c7e2870d4so2242130pls.21 for ; Thu, 27 Jan 2022 16:53:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=2j8iaEuz/tIBAA+GjS6JoDFbk1lAQCK3PPm1k48P+4I=; b=KVG8nNQ2+1dkTL7ilZT+29OjKphirmaq4NpKKPehEmteGNFicoJYOBq29I2w/xr/Jc 9UbTOOCLG4KTUB/3N1j4my19D7mP5FI6R+mBy24DFK/8RmzIdfDoro785nmzMWUPwCet fSgVLWCMxCSowuxI3Uyws0D4mBNIUGmgHVSFGFnohvYZCsQw38q9Bb1fJgSR/4fb67c/ JmuVAf/Hcft984rBeKzO9z9qcE2HrSP+PKqh2TBiUPz3xHhtHwYKWkeYAvKXtphqeaTH t13kFtEmFdwGimVQNlqBC1PQVbuBdSmxgYIGtRIgoGjpTCVhsWDTzEzEy9FOj7xZja2z tACg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=2j8iaEuz/tIBAA+GjS6JoDFbk1lAQCK3PPm1k48P+4I=; b=faFeyRV5M0nbiwC5Y6ot1joFSd/hGolv17ROnKVxbj6i0xUBiPCjCJJl7KO9aDfCAd CwW+9nGLy2aYBc402Aef7HR23tNM4Hk6bjA7vK8U7by0ytfxHOdxiZ3p18ebW8G7dn33 WHHYtLFLYkwdYo61vw5KrggG/qL8fJfpQh+S+d/346XvRyVUPQkYo8CWGHORd50DMJui QsTx3iwHSC49NzT6RMU46PsBLd5gnTpbsd7ZbajwuFO2RFfpMJR4be6bqf/Xo+rPJdAS 9axrn1KW4lYQsTTBnskHvP7hxrBPc0CzFWG6PFDFmTaggMiqqUbHFp9I//Tcj+cyvXB8 t2aw== X-Gm-Message-State: AOAM5315LdNrNBt2OoxDYH3zs7ZYAmOEt3+j80vbcayKBs2/Lyv4oAS1 slkrqpkEnnWYwNYSRJS6190q/eCS8T8= X-Google-Smtp-Source: ABdhPJxEBzacSqFLF93miUHudGeoua8Whi1PUfT85tGo4RFFXXAaVXJGHBB0mgwvLwUa1HKa82wdKXGahlY= X-Received: from seanjc.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e5]) (user=seanjc job=sendgmr) by 2002:a17:90b:4a47:: with SMTP id lb7mr17068491pjb.58.1643331205595; Thu, 27 Jan 2022 16:53:25 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 28 Jan 2022 00:51:53 +0000 In-Reply-To: <20220128005208.4008533-1-seanjc@google.com> Message-Id: <20220128005208.4008533-8-seanjc@google.com> Mime-Version: 1.0 References: <20220128005208.4008533-1-seanjc@google.com> X-Mailer: git-send-email 2.35.0.rc0.227.g00780c9af4-goog Subject: [PATCH 07/22] KVM: xen: Use static_call() for invoking kvm_x86_ops hooks From: Sean Christopherson To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Like Xu Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use static_call() for invoking kvm_x86_ops function that already have a defined static call, mostly as a step toward having _all_ calls to kvm_x86_ops route through a static_call() in order to simplify auditing, e.g. via grep, that all functions have an entry in kvm-x86-ops.h, but also because there's no reason not to use a static_call(). Signed-off-by: Sean Christopherson --- arch/x86/kvm/xen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/xen.c b/arch/x86/kvm/xen.c index bad57535fad0..419bae180930 100644 --- a/arch/x86/kvm/xen.c +++ b/arch/x86/kvm/xen.c @@ -695,7 +695,7 @@ int kvm_xen_write_hypercall_page(struct kvm_vcpu *vcpu,= u64 data) instructions[0] =3D 0xb8; =20 /* vmcall / vmmcall */ - kvm_x86_ops.patch_hypercall(vcpu, instructions + 5); + static_call(kvm_x86_patch_hypercall)(vcpu, instructions + 5); =20 /* ret */ instructions[8] =3D 0xc3; @@ -830,7 +830,7 @@ int kvm_xen_hypercall(struct kvm_vcpu *vcpu) vcpu->run->exit_reason =3D KVM_EXIT_XEN; vcpu->run->xen.type =3D KVM_EXIT_XEN_HCALL; vcpu->run->xen.u.hcall.longmode =3D longmode; - vcpu->run->xen.u.hcall.cpl =3D kvm_x86_ops.get_cpl(vcpu); + vcpu->run->xen.u.hcall.cpl =3D static_call(kvm_x86_get_cpl)(vcpu); vcpu->run->xen.u.hcall.input =3D input; vcpu->run->xen.u.hcall.params[0] =3D params[0]; vcpu->run->xen.u.hcall.params[1] =3D params[1]; --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Tue Jun 30 01:42:29 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1300C433F5 for ; Fri, 28 Jan 2022 00:53:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345089AbiA1Axz (ORCPT ); Thu, 27 Jan 2022 19:53:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344779AbiA1Axl (ORCPT ); Thu, 27 Jan 2022 19:53:41 -0500 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA828C06175F for ; Thu, 27 Jan 2022 16:53:27 -0800 (PST) Received: by mail-pg1-x549.google.com with SMTP id u133-20020a63798b000000b0034c0630b044so2395973pgc.3 for ; Thu, 27 Jan 2022 16:53:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=ldoMrug6/7uSyZ7OKlLwWruZUYkJwaLAkyiaTEJ0iUU=; b=mUdnvkN7tH+7otOj0dkAhqTLAcfZ+KC1Q/CJ4/Avi+YlF4wdsJJyLvhzaSt1vl44fv r3P/ljme71mSY7D2gj2RHTNnEA54nq4544MbHpQdwTpkN/y9zN+NL6c3v0YxMw61Mefj VruGb62kl1ebUw9XdjmqbhtKyv2+hJHjpsFh68HNSnAI3fK5uBgzHBgS65Pb8wdRTqE+ Q8ePRBp6PwKUh/mkOgcaYUEe9KrRqsw9ehWXekCrmD7q+lV3beXIHncX9JWr3qxtcoFj BaHxeuuvJIBNA539Isbnk70Am7vMq6O42GlO7zZp2EMYXlwN0rtBq/4WoqROZ+X8zFGp lUew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=ldoMrug6/7uSyZ7OKlLwWruZUYkJwaLAkyiaTEJ0iUU=; b=XCjwSTH1BK+HS8NCIz65vhfqBDDnaqWvptrHXzCN6pXxf6J1Oo0/Gc5fj6lPQJcElZ VXceaHijzdnE73z3eXvf/7gX0PZeNi9Nu8K3/yZRtmsMjLDMaYFY4EEmcAgMY0aRZgke fupuKiFzMJZAFkF5iuymqsJ3UCyMGlhcUJBcEdea09UZ/L4yYKe/+3BjlMFm0ZZlkKwz za5Xt6kWGZ+HH5Qdduf06t794tR0708x5OsSsPTRs6JmkoWrurKTTJGMMrmvC5DZMYuA VKLF2te/rIDcgKYEtzP6FkNcaYmSYbHW7yTmraXpOPZxKzzis+yvAKsE/LpTTGZZN93j Jx5g== X-Gm-Message-State: AOAM531uOabCaIxxEaoY40wrrxuGhbuDapokOos1WlHNrL7kYzEWJRdv Bdq7x02u07wCb9BwW10G2N1nDTVLrjs= X-Google-Smtp-Source: ABdhPJxoxaXfQrJ86rto1Je3b2wzdDzQzfiKG9ukjweOcaysI3tbhWDZNMQmALj1SPWHx85HrEiaOdhcyMo= X-Received: from seanjc.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e5]) (user=seanjc job=sendgmr) by 2002:a05:6a00:1256:: with SMTP id u22mr5882686pfi.82.1643331207256; Thu, 27 Jan 2022 16:53:27 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 28 Jan 2022 00:51:54 +0000 In-Reply-To: <20220128005208.4008533-1-seanjc@google.com> Message-Id: <20220128005208.4008533-9-seanjc@google.com> Mime-Version: 1.0 References: <20220128005208.4008533-1-seanjc@google.com> X-Mailer: git-send-email 2.35.0.rc0.227.g00780c9af4-goog Subject: [PATCH 08/22] KVM: nVMX: Refactor PMU refresh to avoid referencing kvm_x86_ops.pmu_ops From: Sean Christopherson To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Like Xu Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Refactor the nested VMX PMU refresh helper to pass it a flag stating whether or not the vCPU has PERF_GLOBAL_CTRL instead of having the nVMX helper query the information by bouncing through kvm_x86_ops.pmu_ops. This will allow a future patch to use static_call() for the PMU ops without having to export any static call definitions from common x86, and it is also a step toward unexported kvm_x86_ops. Alternatively, nVMX could call kvm_pmu_is_valid_msr() to indirectly use kvm_x86_ops.pmu_ops, but that would incur an extra layer of indirection and would require exporting kvm_pmu_is_valid_msr(). Opportunistically rename the helper to keep line lengths somewhat reasonable, and to better capture its high-level role. No functional change intended. Cc: Like Xu Signed-off-by: Sean Christopherson --- arch/x86/kvm/vmx/nested.c | 5 +++-- arch/x86/kvm/vmx/nested.h | 3 ++- arch/x86/kvm/vmx/pmu_intel.c | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c index 2777cea05cc0..fdae31db640c 100644 --- a/arch/x86/kvm/vmx/nested.c +++ b/arch/x86/kvm/vmx/nested.c @@ -4796,7 +4796,8 @@ int get_vmx_mem_address(struct kvm_vcpu *vcpu, unsign= ed long exit_qualification, return 0; } =20 -void nested_vmx_pmu_entry_exit_ctls_update(struct kvm_vcpu *vcpu) +void nested_vmx_pmu_refresh(struct kvm_vcpu *vcpu, + bool vcpu_has_perf_global_ctrl) { struct vcpu_vmx *vmx; =20 @@ -4804,7 +4805,7 @@ void nested_vmx_pmu_entry_exit_ctls_update(struct kvm= _vcpu *vcpu) return; =20 vmx =3D to_vmx(vcpu); - if (kvm_x86_ops.pmu_ops->is_valid_msr(vcpu, MSR_CORE_PERF_GLOBAL_CTRL)) { + if (vcpu_has_perf_global_ctrl) { vmx->nested.msrs.entry_ctls_high |=3D VM_ENTRY_LOAD_IA32_PERF_GLOBAL_CTRL; vmx->nested.msrs.exit_ctls_high |=3D diff --git a/arch/x86/kvm/vmx/nested.h b/arch/x86/kvm/vmx/nested.h index b69a80f43b37..c92cea0b8ccc 100644 --- a/arch/x86/kvm/vmx/nested.h +++ b/arch/x86/kvm/vmx/nested.h @@ -32,7 +32,8 @@ int vmx_set_vmx_msr(struct kvm_vcpu *vcpu, u32 msr_index,= u64 data); int vmx_get_vmx_msr(struct nested_vmx_msrs *msrs, u32 msr_index, u64 *pdat= a); int get_vmx_mem_address(struct kvm_vcpu *vcpu, unsigned long exit_qualific= ation, u32 vmx_instruction_info, bool wr, int len, gva_t *ret); -void nested_vmx_pmu_entry_exit_ctls_update(struct kvm_vcpu *vcpu); +void nested_vmx_pmu_refresh(struct kvm_vcpu *vcpu, + bool vcpu_has_perf_global_ctrl); void nested_mark_vmcs12_pages_dirty(struct kvm_vcpu *vcpu); bool nested_vmx_check_io_bitmaps(struct kvm_vcpu *vcpu, unsigned int port, int size); diff --git a/arch/x86/kvm/vmx/pmu_intel.c b/arch/x86/kvm/vmx/pmu_intel.c index 466d18fc0c5d..03fab48b149c 100644 --- a/arch/x86/kvm/vmx/pmu_intel.c +++ b/arch/x86/kvm/vmx/pmu_intel.c @@ -541,7 +541,8 @@ static void intel_pmu_refresh(struct kvm_vcpu *vcpu) bitmap_set(pmu->all_valid_pmc_idx, INTEL_PMC_MAX_GENERIC, pmu->nr_arch_fixed_counters); =20 - nested_vmx_pmu_entry_exit_ctls_update(vcpu); + nested_vmx_pmu_refresh(vcpu, + intel_is_valid_msr(vcpu, MSR_CORE_PERF_GLOBAL_CTRL)); =20 if (intel_pmu_lbr_is_compatible(vcpu)) x86_perf_get_lbr(&lbr_desc->records); --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Tue Jun 30 01:42:29 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8EFA4C433FE for ; Fri, 28 Jan 2022 00:53:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345120AbiA1Ax6 (ORCPT ); Thu, 27 Jan 2022 19:53:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344844AbiA1Axl (ORCPT ); Thu, 27 Jan 2022 19:53:41 -0500 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 619D3C061749 for ; Thu, 27 Jan 2022 16:53:29 -0800 (PST) Received: by mail-pg1-x54a.google.com with SMTP id r3-20020a634403000000b0034dea886e0aso2353901pga.21 for ; Thu, 27 Jan 2022 16:53:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=XZfdfe5GuGm3RtP1jRjs71xAECkK02JG77i8V+SPhgY=; b=fLi9UoMtBQY+5NnVWk1/LbWEFc66cLYpS/U8lPFBMQRbsdgHjVaZzWNIBDbl0JqBff dDy1n+xJfvOz8vbj+6KuGvmkF+U6wwIdry9D/40FPi+N5koa3hMqqLR5jemkMeTGw0jo IDyYteQCPYKpRlAES9YFLxHDF+FFvKSyjqV2GVbxwg4689veOdLJXhDkWFszDQTNBhcH XrX5U4lMV/B8sQGc3NRta4aJCohFPbKEM6bkdmMeALfPI74m/r9Q6TprrkARCF1zWIsM Y1YKtLA/dMZElji6XTOthHX4qGFEt/kVcVstJJ50mH56BgEnhYe2cSTiUsWGj1Rs9lRG UnRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=XZfdfe5GuGm3RtP1jRjs71xAECkK02JG77i8V+SPhgY=; b=26RDCySZaUZcbOxVOOCcvP6wAOSuZAHKu5Ls7Kdm+ZfvPXVY8vh42AJTrtG20Kp4ly K4uF5BTufmLcWTpx4Gh8X9RywCilylDc1tujqdcurprfdI/+iewswT/Ty78LDBfpLSBN KE/3ejCvL3aVMLLZK69UZiiXXzL1WT7GRKEnQ4/klAi44wHMRjeQfvaUvCTAK+WopS+r inmE5WfK2hp3OzZkpkoDt6j8ldG9DTOmklmSqbv1NFijr+yLgngg5HPmNMvktdOVcpEa eRLZloAZ4Nzsz6mOSckS1lwB2fkJf9BdDqExZMI1BN2N8yFhqy8SZcKzIdwddIFJzchh IJ5g== X-Gm-Message-State: AOAM532kg07OfY+5SEagqX0nntIyXzMMfFG9hUpuCqPNAymUr2wUEbAJ XbTDUv6o0LAUIAkWmFoy/QLC19CZYQc= X-Google-Smtp-Source: ABdhPJxsZetChpy8Z4l8tP/qGFSveiiGe0+jG2DjXVNvHspUVM9gdS0zRinWI1bET9voX2MWzyCWWquS6v0= X-Received: from seanjc.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e5]) (user=seanjc job=sendgmr) by 2002:a17:90b:4ad2:: with SMTP id mh18mr16905329pjb.51.1643331208942; Thu, 27 Jan 2022 16:53:28 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 28 Jan 2022 00:51:55 +0000 In-Reply-To: <20220128005208.4008533-1-seanjc@google.com> Message-Id: <20220128005208.4008533-10-seanjc@google.com> Mime-Version: 1.0 References: <20220128005208.4008533-1-seanjc@google.com> X-Mailer: git-send-email 2.35.0.rc0.227.g00780c9af4-goog Subject: [PATCH 09/22] KVM: x86: Uninline and export hv_track_root_tdp() From: Sean Christopherson To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Like Xu Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Uninline and export Hyper-V's hv_track_root_tdp(), which is (somewhat indirectly) the last remaining reference to kvm_x86_ops from vendor modules, i.e. will allow unexporting kvm_x86_ops. Reloading the TDP PGD isn't the fastest of paths, hv_track_root_tdp() isn't exactly tiny, and disallowing vendor code from accessing kvm_x86_ops provides nice-to-have encapsulation of common x86 code (and of Hyper-V code for that matter). No functional change intended. Signed-off-by: Sean Christopherson Reviewed-by: Vitaly Kuznetsov --- arch/x86/kvm/kvm_onhyperv.c | 14 ++++++++++++++ arch/x86/kvm/kvm_onhyperv.h | 14 +------------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/arch/x86/kvm/kvm_onhyperv.c b/arch/x86/kvm/kvm_onhyperv.c index b469f45e3fe4..ee4f696a0782 100644 --- a/arch/x86/kvm/kvm_onhyperv.c +++ b/arch/x86/kvm/kvm_onhyperv.c @@ -92,3 +92,17 @@ int hv_remote_flush_tlb(struct kvm *kvm) return hv_remote_flush_tlb_with_range(kvm, NULL); } EXPORT_SYMBOL_GPL(hv_remote_flush_tlb); + +void hv_track_root_tdp(struct kvm_vcpu *vcpu, hpa_t root_tdp) +{ + struct kvm_arch *kvm_arch =3D &vcpu->kvm->arch; + + if (kvm_x86_ops.tlb_remote_flush =3D=3D hv_remote_flush_tlb) { + spin_lock(&kvm_arch->hv_root_tdp_lock); + vcpu->arch.hv_root_tdp =3D root_tdp; + if (root_tdp !=3D kvm_arch->hv_root_tdp) + kvm_arch->hv_root_tdp =3D INVALID_PAGE; + spin_unlock(&kvm_arch->hv_root_tdp_lock); + } +} +EXPORT_SYMBOL_GPL(hv_track_root_tdp); diff --git a/arch/x86/kvm/kvm_onhyperv.h b/arch/x86/kvm/kvm_onhyperv.h index 1c67abf2eba9..287e98ef9df3 100644 --- a/arch/x86/kvm/kvm_onhyperv.h +++ b/arch/x86/kvm/kvm_onhyperv.h @@ -10,19 +10,7 @@ int hv_remote_flush_tlb_with_range(struct kvm *kvm, struct kvm_tlb_range *range); int hv_remote_flush_tlb(struct kvm *kvm); - -static inline void hv_track_root_tdp(struct kvm_vcpu *vcpu, hpa_t root_tdp) -{ - struct kvm_arch *kvm_arch =3D &vcpu->kvm->arch; - - if (kvm_x86_ops.tlb_remote_flush =3D=3D hv_remote_flush_tlb) { - spin_lock(&kvm_arch->hv_root_tdp_lock); - vcpu->arch.hv_root_tdp =3D root_tdp; - if (root_tdp !=3D kvm_arch->hv_root_tdp) - kvm_arch->hv_root_tdp =3D INVALID_PAGE; - spin_unlock(&kvm_arch->hv_root_tdp_lock); - } -} +void hv_track_root_tdp(struct kvm_vcpu *vcpu, hpa_t root_tdp); #else /* !CONFIG_HYPERV */ static inline void hv_track_root_tdp(struct kvm_vcpu *vcpu, hpa_t root_tdp) { --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Tue Jun 30 01:42:29 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4346C433F5 for ; Fri, 28 Jan 2022 00:54:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344932AbiA1AyA (ORCPT ); Thu, 27 Jan 2022 19:54:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344859AbiA1Axl (ORCPT ); Thu, 27 Jan 2022 19:53:41 -0500 Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 015CDC061768 for ; Thu, 27 Jan 2022 16:53:31 -0800 (PST) Received: by mail-pf1-x44a.google.com with SMTP id i6-20020a626d06000000b004c0abfd53b3so2464208pfc.12 for ; Thu, 27 Jan 2022 16:53:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=ADtLnC7rC8gu4V3bqeDUD4mAscpBUdWqwAs1PraRCkw=; b=psBjtOn9J3Eh3Pc/Ropdvm/BqO87KA3r+8yOwYWROS23VFm73VLstZCUXjP/dFRh8F 8ERZZ2QL+QUFnFMuuObpzcU/ekomsr9qzaElPaq7dW1KmvYjIZXrUfWwNCdAXjDCX63/ IoNOJAow/rQCZHMeFBP0P6WR/WxLXjmR5hseiFjx2utGWmQ0yapCh5sC/utnNUIXywgU ychZGErvItyZZZPpHjs90XKvs5DZCcbWSxxek9qogRhY+n0mMX+NHoDr7ycekmCEpUqs sZFzHI2nvqdF6SK58p0wdaqv9vm+gbdog+pBj77Hufu+UOZp/21JYkK1+poMKoah3Ipe dltw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=ADtLnC7rC8gu4V3bqeDUD4mAscpBUdWqwAs1PraRCkw=; b=gAvOf0w/exHkT0Gn1rdEkrL9CarjoawQ6gavZfe5lax+8i1yp8LLmt6EqbortoA8k0 7axz5HLKWW9mmcwfuvAaAqX8GmwfeyuWsfG7zyvowUzgTDXPS6SqJwuY4RY9+UBxKsv3 Nk+CcZirJiYZO2otgpFNQ+uNYYbaY+BR6wHM5SN48ntEKnmtGJgagrxk0UbCT0DkFIKe hvpvLu7ohyoaHQWiFRkk4u7lHvJnrIOY6MpNAosox3ndcFMvGlkupWryI93Hq3zEbTWE BOov+8sLhTP+lEnDy1/AdHGI1BUecEpLuDlpCdf8jPr763e8rdb77v6Hz+jN8AixLwW7 vh3g== X-Gm-Message-State: AOAM530PUtcJ/sV/frUV8IgDX8gyKeyKAR1beSQLAnuZ8rE2wuURfjSE qwIr5HUjQcNTgaIbgGeiCKTdtAIeIXg= X-Google-Smtp-Source: ABdhPJxLkLHu14NSMGZzCeuyo/Vu0/MjIaw4sO4tBzYj/s5KmDF1uOoQ4pjBoMP+0a4xo9D/1ErkClxjx1w= X-Received: from seanjc.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e5]) (user=seanjc job=sendgmr) by 2002:a17:903:22d1:: with SMTP id y17mr5969171plg.107.1643331210493; Thu, 27 Jan 2022 16:53:30 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 28 Jan 2022 00:51:56 +0000 In-Reply-To: <20220128005208.4008533-1-seanjc@google.com> Message-Id: <20220128005208.4008533-11-seanjc@google.com> Mime-Version: 1.0 References: <20220128005208.4008533-1-seanjc@google.com> X-Mailer: git-send-email 2.35.0.rc0.227.g00780c9af4-goog Subject: [PATCH 10/22] KVM: x86: Unexport kvm_x86_ops From: Sean Christopherson To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Like Xu Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Drop the export of kvm_x86_ops now it is no longer referenced by SVM or VMX. Disallowing access to kvm_x86_ops is very desirable as it prevents vendor code from incorrectly modifying hooks after they have been set by kvm_arch_hardware_setup(), and more importantly after each function's associated static_call key has been updated. No functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/kvm/x86.c | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index cc14f79c446c..a8ea1b212267 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -124,7 +124,6 @@ static int __set_sregs2(struct kvm_vcpu *vcpu, struct k= vm_sregs2 *sregs2); static void __get_sregs2(struct kvm_vcpu *vcpu, struct kvm_sregs2 *sregs2); =20 struct kvm_x86_ops kvm_x86_ops __read_mostly; -EXPORT_SYMBOL_GPL(kvm_x86_ops); =20 #define KVM_X86_OP(func) \ DEFINE_STATIC_CALL_NULL(kvm_x86_##func, \ --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Tue Jun 30 01:42:29 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 07FE1C433F5 for ; Fri, 28 Jan 2022 00:54:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345181AbiA1AyD (ORCPT ); Thu, 27 Jan 2022 19:54:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344876AbiA1Axm (ORCPT ); Thu, 27 Jan 2022 19:53:42 -0500 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [IPv6:2607:f8b0:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2212C06176A for ; Thu, 27 Jan 2022 16:53:32 -0800 (PST) Received: by mail-pf1-x449.google.com with SMTP id a12-20020a056a001d0c00b004cc283b2e30so2371515pfx.2 for ; Thu, 27 Jan 2022 16:53:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=x674bgr4MZ+skXJdAJ4IMcJE6zqdTys8wAdZyd8Nm7s=; b=MPEcECl11PxoOnqqo0qf9ICGM2jqXYqMVBnuE2gK1BlYeWxvV+QXMZKJVQv6bePA4E WLIsWupIl59bhG5lkmRT4sOaI47B4Xr13k2qB8PBfYYl3lTm8+JhKI0W4/riv7LUNMm/ gdnFQHMhnKgZy5eUBeIMUq3UJhrZznIMrhXvbWT1w9ei1x+4E2bX04p+IyzYwlskDNan nXZ/MTAW2uPGqnlcHUe8o7D/OeeLkJq11vMS/nBpxLPHcj34aElLU4AvQ22dVwgMQq0z wz0/fW2jEpjQSTFJoRtipNgvoX/oKFqZox6NKO58CjIUbuf0qlOUYXEnkfktPamqehCB RO3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=x674bgr4MZ+skXJdAJ4IMcJE6zqdTys8wAdZyd8Nm7s=; b=2xhVvjgWQ683vm9IMREKdEgTgOUsB8o8OS+5dX4aDbuD73aFp5Alx0Vfc+l8/fLbJ3 pc7dAe+OLw8bQ+AKSfee+ksFEeg04ECwhFFBoUxfHihP+bKpsOzgnZq2Jujf0HlmQZsK rKfl03gIgZ2gC0Rk+axqh5/wNQxe99IPKyG72RsLJdiI30IlMBDk014TZQR6YEuP6bCz 8GhZbZAxmZKzFUaOGnpM6xFPtHyFqo5f+sT3scnZKvv/bGIZdzJ7sPmB8WCEIu+8VbM+ SUFHxFOO0l1YyJFsA8ykpm9euKrCcnXiRDF2XIpSMLRf2dR3k78WmJYFRs7hZiL1N4d7 lX0A== X-Gm-Message-State: AOAM533nSJ3mdMaqt0AhweTOJ6b6HGXRCmHJ8AfQ+BYTbZrnc1v884WI Kt+l8RTU9y7u4Rokbojr6Ft0U77el7I= X-Google-Smtp-Source: ABdhPJxptEsAjn9h/p8f0/AdKS7H6bYnE+p9asF58tkLi5VDCWmzUezpj1P96i2zYP4oN03onEMjY9Kwo3k= X-Received: from seanjc.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e5]) (user=seanjc job=sendgmr) by 2002:a17:90a:9c5:: with SMTP id 63mr16817690pjo.144.1643331212060; Thu, 27 Jan 2022 16:53:32 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 28 Jan 2022 00:51:57 +0000 In-Reply-To: <20220128005208.4008533-1-seanjc@google.com> Message-Id: <20220128005208.4008533-12-seanjc@google.com> Mime-Version: 1.0 References: <20220128005208.4008533-1-seanjc@google.com> X-Mailer: git-send-email 2.35.0.rc0.227.g00780c9af4-goog Subject: [PATCH 11/22] KVM: x86: Use static_call() for copy/move encryption context ioctls() From: Sean Christopherson To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Like Xu Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Define and use static_call()s for .vm_{copy,move}_enc_context_from(), mostly so that the op is defined in kvm-x86-ops.h. This will allow using KVM_X86_OP in vendor code to wire up the implementation. Any performance gains eeked out by using static_call() is a happy bonus and not the primary motiviation. Opportunistically refactor the code to reduce indentation and keep line lengths reasonable, and to be consistent when wrapping versus running a bit over the 80 char soft limit. Signed-off-by: Sean Christopherson --- arch/x86/include/asm/kvm-x86-ops.h | 2 ++ arch/x86/kvm/x86.c | 17 ++++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/arch/x86/include/asm/kvm-x86-ops.h b/arch/x86/include/asm/kvm-= x86-ops.h index eb93aa439d61..4ee046e60c34 100644 --- a/arch/x86/include/asm/kvm-x86-ops.h +++ b/arch/x86/include/asm/kvm-x86-ops.h @@ -110,6 +110,8 @@ 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) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index a8ea1b212267..580a2adaec7c 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -5958,15 +5958,18 @@ int kvm_vm_ioctl_enable_cap(struct kvm *kvm, #endif case KVM_CAP_VM_COPY_ENC_CONTEXT_FROM: r =3D -EINVAL; - if (kvm_x86_ops.vm_copy_enc_context_from) - r =3D kvm_x86_ops.vm_copy_enc_context_from(kvm, cap->args[0]); - return r; + if (!kvm_x86_ops.vm_copy_enc_context_from) + break; + + r =3D static_call(kvm_x86_vm_copy_enc_context_from)(kvm, cap->args[0]); + break; case KVM_CAP_VM_MOVE_ENC_CONTEXT_FROM: r =3D -EINVAL; - if (kvm_x86_ops.vm_move_enc_context_from) - r =3D kvm_x86_ops.vm_move_enc_context_from( - kvm, cap->args[0]); - return r; + if (!kvm_x86_ops.vm_move_enc_context_from) + break; + + r =3D static_call(kvm_x86_vm_move_enc_context_from)(kvm, cap->args[0]); + break; case KVM_CAP_EXIT_HYPERCALL: if (cap->args[0] & ~KVM_EXIT_HYPERCALL_VALID_MASK) { r =3D -EINVAL; --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Tue Jun 30 01:42:29 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE82FC4332F for ; Fri, 28 Jan 2022 00:54:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345243AbiA1AyJ (ORCPT ); Thu, 27 Jan 2022 19:54:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344973AbiA1Axm (ORCPT ); Thu, 27 Jan 2022 19:53:42 -0500 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62CE8C061770 for ; Thu, 27 Jan 2022 16:53:34 -0800 (PST) Received: by mail-pj1-x104a.google.com with SMTP id f60-20020a17090a704200b001b51d88e887so3623585pjk.1 for ; Thu, 27 Jan 2022 16:53:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=JgW9MKcGIQjIHi99tqvfeFUZw8kv5Qh9J0/QV1SIB0I=; b=Xf8M2HCj214PlyvAKWtn6cw2QMhNw1MZulRM3NvGFSnbF+QTRwKel/uYGe9qidQvw8 81Aa/76ztI3Ij8WUX4EG9SDYS3wat+bBFhzt04IlgfoQnRoKbRhidgTKELm6donSmr2y pir9YKUOaEs3EFqFIAVxSYo+oj1NC1+HoLAINJBNVYV8mqFrtm+2y0UTusAgPk5w90ZC E9CvqEaQYDh0cgLT3ONUoN1Pj6wXWM4m6prk/x7avtv1T2H8sDbIzjfPDuZ54UI7sb0M aeUXNg+e8bBci7ZmJz2UFlti91xRXyIwoVHtN2IEKcmpCqzV+mVD6RbWyQELhlXtFod+ 1k8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=JgW9MKcGIQjIHi99tqvfeFUZw8kv5Qh9J0/QV1SIB0I=; b=7GPuenAX3Ov82QJ8jnj0asc7pYcf3/GRGWXRK+P5Y8XgQ86PgEvsLe63BtfVwsuSFn nfkridHs4sS1o/ZfhZshbR8LpLoJXDVkj4sECxqbseN3Kpbm874slcMWqp4C0rmkhTQA FvxOwzPx+FtTIcRDlISthoY7QDxIIUFDqPL4UrkD6+dhVneMY9rMGrNA/EdG1mR11How +YRBxMRnaP51T+9YBDPIC6kXScLn+u0JOCpJEk8JiVUh9ww5hs/99NtFACRN6QUP9uUo BECwlf6Cv63bVYNMjiGisEegU1CNGvukinEJ09WZcmoGJL44nHjLRcqkkgR6ITToJnIK yQKQ== X-Gm-Message-State: AOAM533PZLhzYdkkKJ3T6sPM3S6pI3/NahxqzYbeyIzFBjegHwF+zS/p 43v4irD8O1zRXh7tnw3WnX00bwTC+3c= X-Google-Smtp-Source: ABdhPJznlzPCYb9PPVlSs01EBkBxvfgOIlYdAeaD8HA+E5wkfz4Alwy9eGFxzc7Q5mWuEGglBvOR3t1r1dc= X-Received: from seanjc.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e5]) (user=seanjc job=sendgmr) by 2002:a05:6a00:1a50:: with SMTP id h16mr3291030pfv.74.1643331213878; Thu, 27 Jan 2022 16:53:33 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 28 Jan 2022 00:51:58 +0000 In-Reply-To: <20220128005208.4008533-1-seanjc@google.com> Message-Id: <20220128005208.4008533-13-seanjc@google.com> Mime-Version: 1.0 References: <20220128005208.4008533-1-seanjc@google.com> X-Mailer: git-send-email 2.35.0.rc0.227.g00780c9af4-goog Subject: [PATCH 12/22] KVM: x86: Allow different macros for APICv, CVM, and Hyper-V kvm_x86_ops From: Sean Christopherson To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Like Xu Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- 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 =20 /* - * Invoke KVM_X86_OP() on all functions in struct kvm_x86_ops, e.g. to gen= erate - * 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) =20 +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 --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Tue Jun 30 01:42:29 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5FCC1C433EF for ; Fri, 28 Jan 2022 00:54:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345002AbiA1AyL (ORCPT ); Thu, 27 Jan 2022 19:54:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344926AbiA1Axu (ORCPT ); Thu, 27 Jan 2022 19:53:50 -0500 Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECBD0C061778 for ; Thu, 27 Jan 2022 16:53:35 -0800 (PST) Received: by mail-pf1-x44a.google.com with SMTP id u80-20020a627953000000b004c82105f20dso2470616pfc.11 for ; Thu, 27 Jan 2022 16:53:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=61ZTgbq8+LvvTurQO/m+o8EgN1H5z8zbSRJ+o6lgAxg=; b=lgUPWVx6n2ZzmYGReVtlBLHVhwO7qWarF5fWR7/aAE8wzBHyTLVqxgK/NsopFA5t5d 7o7jAjC+sDm0SBslGzOi2VjhvuVPv6op9hff2iHDCDxRO2V6MdPXYT9Iy7+J2u5CzS9W rbn0LXjpQnVpCZx/4xyoxaUKKHPSO9q8YyNv1R4pXgbeeopQTPoVTN3PHNVYZJBHqGyd olQj9MKfvh6Z76Yw2zjs2UJ8bk8EtRdyi7l6ZtXfIRl8FPFuoOpuHy1df0R3PpiJD3BY 4dR7SqOx/MVDTFTGG2WtiOq4qVrbxMEPV/igSdG3CgEBHF+NPZ9NsE7mJ1W9W7C1KOFS Ci6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=61ZTgbq8+LvvTurQO/m+o8EgN1H5z8zbSRJ+o6lgAxg=; b=4G5MlEtmYdD2NnpHoeopj60ioeT2gRvPzn3iTkknNhm8SO3vDw66rNYoY5Th6VG906 8z1zzdBO5uY14hL4bBpgGmRWn3snc51jM1++Spa5If6BUgZvNNA/XZuOFjKaifN/Yo8T pRhpNeSb4AGZcg/zpe2TZtwawtgb0V/sqlDeVWigX9FOeGHbIOC8NK3YCjSSZRXqS00h UlqaDo35CNOs0SfDY1XP5BvDTHOmq2YlfvX410ipaLNv0qOtn8w09/FYC7vM3hkxoJzX NQFoKdeHpW8ofZVuwGPJA2w8FAeYmA0m+2rLS2DkPHZeENAYy7rg57jvhzBlu/FcFLLl hgjA== X-Gm-Message-State: AOAM533rh8pB+qV7BxHZIuuYQ3N5PcJ8ftm6kwAqotPfrM2YnPkxRM2Y pFMGLQ08SivS+JNTGv22CvRUkB/TkNs= X-Google-Smtp-Source: ABdhPJwliaWPKPh4iu4vXjLBu+BdyUwfcUpwuzg17xE83xBOpd/dI7Wfo4fv1pLYSlMAWLnkIZWrVc+oOtc= X-Received: from seanjc.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e5]) (user=seanjc job=sendgmr) by 2002:a17:902:b58c:: with SMTP id a12mr5675354pls.91.1643331215434; Thu, 27 Jan 2022 16:53:35 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 28 Jan 2022 00:51:59 +0000 In-Reply-To: <20220128005208.4008533-1-seanjc@google.com> Message-Id: <20220128005208.4008533-14-seanjc@google.com> Mime-Version: 1.0 References: <20220128005208.4008533-1-seanjc@google.com> X-Mailer: git-send-email 2.35.0.rc0.227.g00780c9af4-goog Subject: [PATCH 13/22] KVM: VMX: Rename VMX functions to conform to kvm_x86_ops names From: Sean Christopherson To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Like Xu Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Massage VMX's implementation names for kvm_x86_ops to maximize use of kvm-x86-ops.h. Leave cpu_has_vmx_wbinvd_exit() as-is to preserve the cpu_has_vmx_*() pattern used for querying VMCS capabilities. Keep pi_has_pending_interrupt() as vmx_dy_apicv_has_pending_interrupt() does a poor job of describing exactly what is being checked in VMX land. No functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/kvm/vmx/posted_intr.c | 6 +++--- arch/x86/kvm/vmx/posted_intr.h | 4 ++-- arch/x86/kvm/vmx/vmx.c | 26 +++++++++++++------------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/arch/x86/kvm/vmx/posted_intr.c b/arch/x86/kvm/vmx/posted_intr.c index aa1fe9085d77..3834bb30ce54 100644 --- a/arch/x86/kvm/vmx/posted_intr.c +++ b/arch/x86/kvm/vmx/posted_intr.c @@ -244,7 +244,7 @@ void vmx_pi_start_assignment(struct kvm *kvm) } =20 /* - * pi_update_irte - set IRTE for Posted-Interrupts + * vmx_pi_update_irte - set IRTE for Posted-Interrupts * * @kvm: kvm * @host_irq: host irq of the interrupt @@ -252,8 +252,8 @@ void vmx_pi_start_assignment(struct kvm *kvm) * @set: set or unset PI * returns 0 on success, < 0 on failure */ -int pi_update_irte(struct kvm *kvm, unsigned int host_irq, uint32_t guest_= irq, - bool set) +int vmx_pi_update_irte(struct kvm *kvm, unsigned int host_irq, + uint32_t guest_irq, bool set) { struct kvm_kernel_irq_routing_entry *e; struct kvm_irq_routing_table *irq_rt; diff --git a/arch/x86/kvm/vmx/posted_intr.h b/arch/x86/kvm/vmx/posted_intr.h index eb14e76b84ef..9a45d5c9f116 100644 --- a/arch/x86/kvm/vmx/posted_intr.h +++ b/arch/x86/kvm/vmx/posted_intr.h @@ -97,8 +97,8 @@ void vmx_vcpu_pi_put(struct kvm_vcpu *vcpu); void pi_wakeup_handler(void); void __init pi_init_cpu(int cpu); bool pi_has_pending_interrupt(struct kvm_vcpu *vcpu); -int pi_update_irte(struct kvm *kvm, unsigned int host_irq, uint32_t guest_= irq, - bool set); +int vmx_pi_update_irte(struct kvm *kvm, unsigned int host_irq, + uint32_t guest_irq, bool set); void vmx_pi_start_assignment(struct kvm *kvm); =20 #endif /* __KVM_X86_VMX_POSTED_INTR_H */ diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index de66786396bd..2138f7439a19 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -541,7 +541,7 @@ static inline bool cpu_need_virtualize_apic_accesses(st= ruct kvm_vcpu *vcpu) return flexpriority_enabled && lapic_in_kernel(vcpu); } =20 -static inline bool report_flexpriority(void) +static inline bool vmx_cpu_has_accelerated_tpr(void) { return flexpriority_enabled; } @@ -2341,7 +2341,7 @@ static int kvm_cpu_vmxon(u64 vmxon_pointer) return -EFAULT; } =20 -static int hardware_enable(void) +static int vmx_hardware_enable(void) { int cpu =3D raw_smp_processor_id(); u64 phys_addr =3D __pa(per_cpu(vmxarea, cpu)); @@ -2382,7 +2382,7 @@ static void vmclear_local_loaded_vmcss(void) __loaded_vmcs_clear(v); } =20 -static void hardware_disable(void) +static void vmx_hardware_disable(void) { vmclear_local_loaded_vmcss(); =20 @@ -6967,7 +6967,7 @@ static fastpath_t vmx_vcpu_run(struct kvm_vcpu *vcpu) return vmx_exit_handlers_fastpath(vcpu); } =20 -static void vmx_free_vcpu(struct kvm_vcpu *vcpu) +static void vmx_vcpu_free(struct kvm_vcpu *vcpu) { struct vcpu_vmx *vmx =3D to_vmx(vcpu); =20 @@ -6978,7 +6978,7 @@ static void vmx_free_vcpu(struct kvm_vcpu *vcpu) free_loaded_vmcs(vmx->loaded_vmcs); } =20 -static int vmx_create_vcpu(struct kvm_vcpu *vcpu) +static int vmx_vcpu_create(struct kvm_vcpu *vcpu) { struct vmx_uret_msr *tsx_ctrl; struct vcpu_vmx *vmx; @@ -7682,7 +7682,7 @@ static void vmx_migrate_timers(struct kvm_vcpu *vcpu) } } =20 -static void hardware_unsetup(void) +static void vmx_hardware_unsetup(void) { kvm_set_posted_intr_wakeup_handler(NULL); =20 @@ -7705,18 +7705,18 @@ static bool vmx_check_apicv_inhibit_reasons(ulong b= it) static struct kvm_x86_ops vmx_x86_ops __initdata =3D { .name =3D "kvm_intel", =20 - .hardware_unsetup =3D hardware_unsetup, + .hardware_unsetup =3D vmx_hardware_unsetup, =20 - .hardware_enable =3D hardware_enable, - .hardware_disable =3D hardware_disable, - .cpu_has_accelerated_tpr =3D report_flexpriority, + .hardware_enable =3D vmx_hardware_enable, + .hardware_disable =3D vmx_hardware_disable, + .cpu_has_accelerated_tpr =3D vmx_cpu_has_accelerated_tpr, .has_emulated_msr =3D vmx_has_emulated_msr, =20 .vm_size =3D sizeof(struct kvm_vmx), .vm_init =3D vmx_vm_init, =20 - .vcpu_create =3D vmx_create_vcpu, - .vcpu_free =3D vmx_free_vcpu, + .vcpu_create =3D vmx_vcpu_create, + .vcpu_free =3D vmx_vcpu_free, .vcpu_reset =3D vmx_vcpu_reset, =20 .prepare_switch_to_guest =3D vmx_prepare_switch_to_guest, @@ -7814,7 +7814,7 @@ static struct kvm_x86_ops vmx_x86_ops __initdata =3D { .pmu_ops =3D &intel_pmu_ops, .nested_ops =3D &vmx_nested_ops, =20 - .pi_update_irte =3D pi_update_irte, + .pi_update_irte =3D vmx_pi_update_irte, .pi_start_assignment =3D vmx_pi_start_assignment, =20 #ifdef CONFIG_X86_64 --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Tue Jun 30 01:42:29 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B27E0C433EF for ; Fri, 28 Jan 2022 00:54:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345070AbiA1AyQ (ORCPT ); Thu, 27 Jan 2022 19:54:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345033AbiA1Axw (ORCPT ); Thu, 27 Jan 2022 19:53:52 -0500 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94857C06177C for ; Thu, 27 Jan 2022 16:53:37 -0800 (PST) Received: by mail-pj1-x104a.google.com with SMTP id y14-20020a17090ad70e00b001b4fc2943b3so5210178pju.8 for ; Thu, 27 Jan 2022 16:53:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=C7P7Lo+MHz+aDeG8aypZh7++gwohNrhZtfXpoo4GhRc=; b=rxSvNbj1FPQawP+4EDxY3c4o9aokF7v2F1cuEwoZQI6ZwxmGhMNnKNUl3AKSik1LoT 68Yx/T3rAHD8goqU8NgEiDyVIA2pk2MWrs7zwkvhD8PODG16pidsfl4PdJQHsIRKCHjf gY4yc7HNHj+09o18BT1SI0QpYHmK58R0tE4WsaLCBGKBdzbuosUbTsFBoJ/oNpyTlxUB tBCYCHBF1mvPqO+CODrqHax6AuqGW1nVDjzaM/cNx5EkNZYRN8RCg/Z5Bu00VhvG754M /PyzRHpCItV3Ff2G+zvd8fuxcuADJ29DvH07hharTXi2iTb5WZFbZCoiZ5QRsiMrsCkn SkSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=C7P7Lo+MHz+aDeG8aypZh7++gwohNrhZtfXpoo4GhRc=; b=H3TrpqB6ZsRvRBYnp50MV+w9kV0uZUhxPmNvEdmda1zKSECoUa0uz47RaB8oOmlNZJ llr4X6ADWLGQg0Tp0GZXo/NCyQ8va68qy/XhYhltlQrnl6VdEJUFFQg4c6kvBpiAxGLT VNrylDkVqZShTYoQSaOIFsPRl7+bhLfyEogQDXqidu9/x9YuhjSkNLSY/R1an8u2qTQw YLoGtrcO9+z7XLRO5bKvNYe1mMk6CKaRbkpTPrJYYcJmHcK79FP98NN8uG19sTikm5Vw 7zTvE1u0zlFg9/++9sS3ECc2Z9dVFvbSBMV5stDrHvKqtJXLS+HGysTKUUxYQCdr+1jS loiA== X-Gm-Message-State: AOAM531Pl6d1mEULgyChRcArh3adlsYASjkjryB4rkT33MBAI6wni+VX LPznA3c7Ovu+8mUr/JPT5nuCE7GNMEA= X-Google-Smtp-Source: ABdhPJwOGArX1csvPGQcF2VcKjeSM8bSH+X5XS5zlS9c//QcVjM14dW1/bvwcrq84RCXuYqYNjiguoij8Jw= X-Received: from seanjc.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e5]) (user=seanjc job=sendgmr) by 2002:a05:6a00:10d2:: with SMTP id d18mr5562615pfu.2.1643331217063; Thu, 27 Jan 2022 16:53:37 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 28 Jan 2022 00:52:00 +0000 In-Reply-To: <20220128005208.4008533-1-seanjc@google.com> Message-Id: <20220128005208.4008533-15-seanjc@google.com> Mime-Version: 1.0 References: <20220128005208.4008533-1-seanjc@google.com> X-Mailer: git-send-email 2.35.0.rc0.227.g00780c9af4-goog Subject: [PATCH 14/22] KVM: VMX: Use kvm-x86-ops.h to fill vmx_x86_ops From: Sean Christopherson To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Like Xu Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Fill vmx_x86_ops by including kvm-x86-ops.h and defining the appropriate macros. Use the default for KVM_X86_APICV_OP as VMX doesn't have a single prefix for all APICv ops, and the majority of APICv ops that do conform to the kvm_x86_ops names do so with the standard vmx_ prefix. Document the handful of exceptions where vmx_x86_ops deviates from the "default". No functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/kvm/vmx/vmx.c | 149 +++++++---------------------------------- 1 file changed, 25 insertions(+), 124 deletions(-) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 2138f7439a19..f22d02fe4df3 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -7702,141 +7702,42 @@ static bool vmx_check_apicv_inhibit_reasons(ulong = bit) return supported & BIT(bit); } =20 +/* Not currently implemented for VMX. */ +#define vmx_vm_destroy NULL +#define vmx_vcpu_blocking NULL +#define vmx_vcpu_unblocking NULL + +/* Redirects to common KVM helpers (hooks provided for SEV-ES). */ +#define vmx_complete_emulated_msr kvm_complete_insn_gp +#define vmx_vcpu_deliver_sipi_vector kvm_vcpu_deliver_sipi_vector + +/* Redirects to preserve VMX's preferred nomenclature. */ +#define vmx_has_wbinvd_exit cpu_has_vmx_wbinvd_exit +#define vmx_dy_apicv_has_pending_interrupt pi_has_pending_interrupt + +/* VMX preemption timer support is 64-bit only as it uses 64-bit division.= */ +#ifndef CONFIG_X86_64 +#define vmx_set_hv_timer NULL +#define vmx_cancel_hv_timer NULL +#endif + static struct kvm_x86_ops vmx_x86_ops __initdata =3D { .name =3D "kvm_intel", - - .hardware_unsetup =3D vmx_hardware_unsetup, - - .hardware_enable =3D vmx_hardware_enable, - .hardware_disable =3D vmx_hardware_disable, - .cpu_has_accelerated_tpr =3D vmx_cpu_has_accelerated_tpr, - .has_emulated_msr =3D vmx_has_emulated_msr, - .vm_size =3D sizeof(struct kvm_vmx), - .vm_init =3D vmx_vm_init, - - .vcpu_create =3D vmx_vcpu_create, - .vcpu_free =3D vmx_vcpu_free, - .vcpu_reset =3D vmx_vcpu_reset, - - .prepare_switch_to_guest =3D vmx_prepare_switch_to_guest, - .vcpu_load =3D vmx_vcpu_load, - .vcpu_put =3D vmx_vcpu_put, - - .update_exception_bitmap =3D vmx_update_exception_bitmap, - .get_msr_feature =3D vmx_get_msr_feature, - .get_msr =3D vmx_get_msr, - .set_msr =3D vmx_set_msr, - .get_segment_base =3D vmx_get_segment_base, - .get_segment =3D vmx_get_segment, - .set_segment =3D vmx_set_segment, - .get_cpl =3D vmx_get_cpl, - .get_cs_db_l_bits =3D vmx_get_cs_db_l_bits, - .set_cr0 =3D vmx_set_cr0, - .is_valid_cr4 =3D vmx_is_valid_cr4, - .set_cr4 =3D vmx_set_cr4, - .set_efer =3D vmx_set_efer, - .get_idt =3D vmx_get_idt, - .set_idt =3D vmx_set_idt, - .get_gdt =3D vmx_get_gdt, - .set_gdt =3D vmx_set_gdt, - .set_dr7 =3D vmx_set_dr7, - .sync_dirty_debug_regs =3D vmx_sync_dirty_debug_regs, - .cache_reg =3D vmx_cache_reg, - .get_rflags =3D vmx_get_rflags, - .set_rflags =3D vmx_set_rflags, - .get_if_flag =3D vmx_get_if_flag, - - .flush_tlb_all =3D vmx_flush_tlb_all, - .flush_tlb_current =3D vmx_flush_tlb_current, - .flush_tlb_gva =3D vmx_flush_tlb_gva, - .flush_tlb_guest =3D vmx_flush_tlb_guest, - - .vcpu_pre_run =3D vmx_vcpu_pre_run, - .vcpu_run =3D vmx_vcpu_run, - .handle_exit =3D vmx_handle_exit, - .skip_emulated_instruction =3D vmx_skip_emulated_instruction, - .update_emulated_instruction =3D vmx_update_emulated_instruction, - .set_interrupt_shadow =3D vmx_set_interrupt_shadow, - .get_interrupt_shadow =3D vmx_get_interrupt_shadow, - .patch_hypercall =3D vmx_patch_hypercall, - .inject_irq =3D vmx_inject_irq, - .inject_nmi =3D vmx_inject_nmi, - .queue_exception =3D vmx_queue_exception, - .cancel_injection =3D vmx_cancel_injection, - .interrupt_allowed =3D vmx_interrupt_allowed, - .nmi_allowed =3D vmx_nmi_allowed, - .get_nmi_mask =3D vmx_get_nmi_mask, - .set_nmi_mask =3D vmx_set_nmi_mask, - .enable_nmi_window =3D vmx_enable_nmi_window, - .enable_irq_window =3D vmx_enable_irq_window, - .update_cr8_intercept =3D vmx_update_cr8_intercept, - .set_virtual_apic_mode =3D vmx_set_virtual_apic_mode, - .set_apic_access_page_addr =3D vmx_set_apic_access_page_addr, - .refresh_apicv_exec_ctrl =3D vmx_refresh_apicv_exec_ctrl, - .load_eoi_exitmap =3D vmx_load_eoi_exitmap, - .apicv_post_state_restore =3D vmx_apicv_post_state_restore, - .check_apicv_inhibit_reasons =3D vmx_check_apicv_inhibit_reasons, - .hwapic_irr_update =3D vmx_hwapic_irr_update, - .hwapic_isr_update =3D vmx_hwapic_isr_update, - .guest_apic_has_interrupt =3D vmx_guest_apic_has_interrupt, - .sync_pir_to_irr =3D vmx_sync_pir_to_irr, - .deliver_interrupt =3D vmx_deliver_interrupt, - .dy_apicv_has_pending_interrupt =3D pi_has_pending_interrupt, - - .set_tss_addr =3D vmx_set_tss_addr, - .set_identity_map_addr =3D vmx_set_identity_map_addr, - .get_mt_mask =3D vmx_get_mt_mask, - - .get_exit_info =3D vmx_get_exit_info, - - .vcpu_after_set_cpuid =3D vmx_vcpu_after_set_cpuid, - - .has_wbinvd_exit =3D cpu_has_vmx_wbinvd_exit, - - .get_l2_tsc_offset =3D vmx_get_l2_tsc_offset, - .get_l2_tsc_multiplier =3D vmx_get_l2_tsc_multiplier, - .write_tsc_offset =3D vmx_write_tsc_offset, - .write_tsc_multiplier =3D vmx_write_tsc_multiplier, - - .load_mmu_pgd =3D vmx_load_mmu_pgd, - - .check_intercept =3D vmx_check_intercept, - .handle_exit_irqoff =3D vmx_handle_exit_irqoff, - - .request_immediate_exit =3D vmx_request_immediate_exit, - - .sched_in =3D vmx_sched_in, - .cpu_dirty_log_size =3D PML_ENTITY_NUM, - .update_cpu_dirty_logging =3D vmx_update_cpu_dirty_logging, =20 .pmu_ops =3D &intel_pmu_ops, .nested_ops =3D &vmx_nested_ops, =20 - .pi_update_irte =3D vmx_pi_update_irte, - .pi_start_assignment =3D vmx_pi_start_assignment, +#define KVM_X86_OP(func) .func =3D vmx_##func, =20 -#ifdef CONFIG_X86_64 - .set_hv_timer =3D vmx_set_hv_timer, - .cancel_hv_timer =3D vmx_cancel_hv_timer, -#endif +/* VMX doesn't yet support confidential VMs. */ +#define KVM_X86_CVM_OP(func) .func =3D NULL, =20 - .setup_mce =3D vmx_setup_mce, +/* Hyper-V hooks are filled at runtime. */ +#define KVM_X86_HYPERV_OP(func) .func =3D NULL, =20 - .smi_allowed =3D vmx_smi_allowed, - .enter_smm =3D vmx_enter_smm, - .leave_smm =3D vmx_leave_smm, - .enable_smi_window =3D vmx_enable_smi_window, - - .can_emulate_instruction =3D vmx_can_emulate_instruction, - .apic_init_signal_blocked =3D vmx_apic_init_signal_blocked, - .migrate_timers =3D vmx_migrate_timers, - - .msr_filter_changed =3D vmx_msr_filter_changed, - .complete_emulated_msr =3D kvm_complete_insn_gp, - - .vcpu_deliver_sipi_vector =3D kvm_vcpu_deliver_sipi_vector, +#include }; =20 static __init void vmx_setup_user_return_msrs(void) --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Tue Jun 30 01:42:29 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 565BDC43217 for ; Fri, 28 Jan 2022 00:54:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345118AbiA1AyW (ORCPT ); Thu, 27 Jan 2022 19:54:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345036AbiA1Axx (ORCPT ); Thu, 27 Jan 2022 19:53:53 -0500 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA0CBC06174A for ; Thu, 27 Jan 2022 16:53:39 -0800 (PST) Received: by mail-pj1-x104a.google.com with SMTP id n9-20020a17090a73c900b001b5cafefa27so2873888pjk.2 for ; Thu, 27 Jan 2022 16:53:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=+fgTTm9nrHmeG0FgLza5Karyosr5i7v7pBMlh0d99R0=; b=AoJD+O+f5LrotQSvynZoaLZnhwDrHUhmG34xGE9mx2riuWL0zeVdquhHAbb11THRtX YlfjZ2s/xnB9RkHsgYaFz8PtvQ+orER04OVMExOvNdtR0sehxd78A+SQZMmKLJnsFCqn gtbCHrRxq7wjzgcGVOd5qcUruluJe0hLJyOTaK0jpnnx44vxJJFr0VAnMDnjTK65TBrE oRDwD/kI8Dmwrb1P53XMwuX9woWNkWtn2/7B/gHVJ215/oNHuvHFFcKt4wjsR8JooldJ oTVg+bPMm8PO6vb3/wjqZbM0J84L5fdfGJhX6pFcKEUR41Wq5JWUNipfrBNBEZKHy5no FlHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=+fgTTm9nrHmeG0FgLza5Karyosr5i7v7pBMlh0d99R0=; b=pvhC3Qaw/TC3+dYW63FVJxtxwp/jhdHBe2FvTISi9NMVGGHZ/rDOXWr2EJNY+zU/ur VoR/K3RcfrInVDcJCI9IaQ1R2cpjV5GtCEXyk+pUNYGGUGOtDct2XoK71vE1+hCUUFme ov1xaBvQSuqNjyo+rBq3uCDYITqu7uhTB8zsAD5Aq8YlL3/+SZpsyQLZZILvNa9IWmft +RiwCqS4KwB18N31gMGR+vfXuvECepTj47YmStRocPAfwck8i+cP2Ne3sefVgb9agXJ3 lPib3I+d1GwZcuzD+cNHcfVKdltvQO9RsM1WuAReNS2lpkKZZlcFuF21iHVDt1tOco9l Do0Q== X-Gm-Message-State: AOAM531f/Q8+c2sQO0vbLjiUJE5qFvzEoeiVGNkaFr9GcLlOCllowfDj PD+51vwxnW1zAxSqu8GhSegFzyFuvQs= X-Google-Smtp-Source: ABdhPJwmTuCahChEBGU7SHh+TlMJfQzORp/I86NBNcOH5v+eoVWBfWkcAwKpe0cOPshnM8Po5sPoUGg2V5Q= X-Received: from seanjc.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e5]) (user=seanjc job=sendgmr) by 2002:a17:90b:4c8e:: with SMTP id my14mr1878284pjb.0.1643331218725; Thu, 27 Jan 2022 16:53:38 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 28 Jan 2022 00:52:01 +0000 In-Reply-To: <20220128005208.4008533-1-seanjc@google.com> Message-Id: <20220128005208.4008533-16-seanjc@google.com> Mime-Version: 1.0 References: <20220128005208.4008533-1-seanjc@google.com> X-Mailer: git-send-email 2.35.0.rc0.227.g00780c9af4-goog Subject: [PATCH 15/22] KVM: x86: Move get_cs_db_l_bits() helper to SVM From: Sean Christopherson To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Like Xu Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Move kvm_get_cs_db_l_bits() to SVM and rename it appropriately so that its svm_x86_ops entry can be filled via kvm-x86-ops, and to eliminate a superfluous export from KVM x86. No functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/include/asm/kvm_host.h | 1 - arch/x86/kvm/svm/svm.c | 11 ++++++++++- arch/x86/kvm/x86.c | 10 ---------- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_hos= t.h index 91c0e4957bd0..f97d155810ac 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1717,7 +1717,6 @@ int kvm_set_dr(struct kvm_vcpu *vcpu, int dr, unsigne= d long val); void kvm_get_dr(struct kvm_vcpu *vcpu, int dr, unsigned long *val); unsigned long kvm_get_cr8(struct kvm_vcpu *vcpu); void kvm_lmsw(struct kvm_vcpu *vcpu, unsigned long msw); -void kvm_get_cs_db_l_bits(struct kvm_vcpu *vcpu, int *db, int *l); int kvm_emulate_xsetbv(struct kvm_vcpu *vcpu); =20 int kvm_get_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr); diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 991d3e628c60..fda09a6ea3ba 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -1531,6 +1531,15 @@ static int svm_get_cpl(struct kvm_vcpu *vcpu) return save->cpl; } =20 +static void svm_get_cs_db_l_bits(struct kvm_vcpu *vcpu, int *db, int *l) +{ + struct kvm_segment cs; + + svm_get_segment(vcpu, &cs, VCPU_SREG_CS); + *db =3D cs.db; + *l =3D cs.l; +} + static void svm_get_idt(struct kvm_vcpu *vcpu, struct desc_ptr *dt) { struct vcpu_svm *svm =3D to_svm(vcpu); @@ -4486,7 +4495,7 @@ static struct kvm_x86_ops svm_x86_ops __initdata =3D { .get_segment =3D svm_get_segment, .set_segment =3D svm_set_segment, .get_cpl =3D svm_get_cpl, - .get_cs_db_l_bits =3D kvm_get_cs_db_l_bits, + .get_cs_db_l_bits =3D svm_get_cs_db_l_bits, .set_cr0 =3D svm_set_cr0, .post_set_cr3 =3D svm_post_set_cr3, .is_valid_cr4 =3D svm_is_valid_cr4, diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 580a2adaec7c..b151db419590 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -10570,16 +10570,6 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *= vcpu, struct kvm_regs *regs) return 0; } =20 -void kvm_get_cs_db_l_bits(struct kvm_vcpu *vcpu, int *db, int *l) -{ - struct kvm_segment cs; - - kvm_get_segment(vcpu, &cs, VCPU_SREG_CS); - *db =3D cs.db; - *l =3D cs.l; -} -EXPORT_SYMBOL_GPL(kvm_get_cs_db_l_bits); - static void __get_sregs_common(struct kvm_vcpu *vcpu, struct kvm_sregs *sr= egs) { struct desc_ptr dt; --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Tue Jun 30 01:42:29 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F3EB8C433F5 for ; Fri, 28 Jan 2022 00:54:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344975AbiA1AyV (ORCPT ); Thu, 27 Jan 2022 19:54:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345042AbiA1Axx (ORCPT ); Thu, 27 Jan 2022 19:53:53 -0500 Received: from mail-pj1-x1049.google.com (mail-pj1-x1049.google.com [IPv6:2607:f8b0:4864:20::1049]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AAB2C06174E for ; Thu, 27 Jan 2022 16:53:41 -0800 (PST) Received: by mail-pj1-x1049.google.com with SMTP id v8-20020a17090a778800b001b2e6d08cd1so2855198pjk.8 for ; Thu, 27 Jan 2022 16:53:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=1vh1VvZNhhnSubMCarnsOOQ5sYO+DptkQEoJu+SV9JY=; b=Kr+fuAc5ZPitCBM3g3XiW8CsMou2XI88siFZXSY12stQOkRkSiv37ClwtffG0QeePP +WpTTNt4HAzZ6sFLTbyEln7C+a6mMQKabtVoarqk48EDEWwWikx8Xu62FmczNgyYQTj4 VZGQJHnWadtfHRj+elbAze5Npy0Mb4a2gVH4RVtk4VPYyL6q3eDRlKVasu6DImWGxBwa bHIRl+Knx3XkHvey+nWhLbAjCrcOu3iTm/Ludl8fmxU5VrjqCjnzTPfgFdk+4xZS1vsu 876zdw4Xw1ooQKps6dgf5iU+8Nhr0zAcPFyBnWmU8+rxdg4SnFlrTkiwOfz/JVahoKbY EYkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=1vh1VvZNhhnSubMCarnsOOQ5sYO+DptkQEoJu+SV9JY=; b=44nBAraj4pvAfKCMTLF6A+gkplwwo+xlL1QvJhejD2Je/2qImSwsD8+ZN5MrBI8dxi B2QDKFWOqgPrSsk9nA/sohBtQ4wdzZXKJchpPPrBQVDgDUdU/2uQLugeUfvNUs3LhlIM pDA0Vf7o2i4OBYIjfuvr+Fse4wo5xPTNAxaxt2j4geg1Z0JOd9mhB+UMv4jiaqYVVBWO xuSnSy1l6vF4JNCuiKVpfaxENIeyLSeJIuZNRNfVqmrWP/2xUcHJWBlkNI9z5OVoB1MQ GOpp3wtkFna5rL9mhPdtfjQNz6cmAmcsZT3idwFDHIEDbubw+onQzknfkN66dALAcX9L LlbA== X-Gm-Message-State: AOAM530Mwjc2lFfPdWTye63lrzo1wsRb/zAuR9wNfkSCCE5Xhw4fCE3G bmjUru0gTDt5rTPfD4nLN50OYNDDxWU= X-Google-Smtp-Source: ABdhPJwTMAcCNpEASRZ8M0zDEAr02qtTm+qXF8X/FzAwXCV1T4TqMnuylsdUjEg3UkvfWRQpF1ZoxxFTso4= X-Received: from seanjc.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e5]) (user=seanjc job=sendgmr) by 2002:a17:902:d48e:: with SMTP id c14mr5713568plg.79.1643331220698; Thu, 27 Jan 2022 16:53:40 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 28 Jan 2022 00:52:02 +0000 In-Reply-To: <20220128005208.4008533-1-seanjc@google.com> Message-Id: <20220128005208.4008533-17-seanjc@google.com> Mime-Version: 1.0 References: <20220128005208.4008533-1-seanjc@google.com> X-Mailer: git-send-email 2.35.0.rc0.227.g00780c9af4-goog Subject: [PATCH 16/22] KVM: SVM: Rename svm_flush_tlb() to svm_flush_tlb_current() From: Sean Christopherson To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Like Xu Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Rename svm_flush_tlb() to svm_flush_tlb_current() so that at least one of the flushing operations in svm_x86_ops can be filled via kvm-x86-ops.h, and to document the scope of the flush (specifically that it doesn't flush "all"). Opportunistically make svm_tlb_flush_current(), was svm_flush_tlb(), static. No functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/kvm/svm/svm.c | 12 +++++++----- arch/x86/kvm/svm/svm.h | 1 - 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index fda09a6ea3ba..5382710ba106 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -265,6 +265,8 @@ u32 svm_msrpm_offset(u32 msr) =20 #define MAX_INST_SIZE 15 =20 +static void svm_flush_tlb_current(struct kvm_vcpu *vcpu); + static int get_npt_level(void) { #ifdef CONFIG_X86_64 @@ -1654,7 +1656,7 @@ void svm_set_cr4(struct kvm_vcpu *vcpu, unsigned long= cr4) unsigned long old_cr4 =3D vcpu->arch.cr4; =20 if (npt_enabled && ((old_cr4 ^ cr4) & X86_CR4_PGE)) - svm_flush_tlb(vcpu); + svm_flush_tlb_current(vcpu); =20 vcpu->arch.cr4 =3D cr4; if (!npt_enabled) @@ -3489,7 +3491,7 @@ static int svm_set_identity_map_addr(struct kvm *kvm,= u64 ident_addr) return 0; } =20 -void svm_flush_tlb(struct kvm_vcpu *vcpu) +static void svm_flush_tlb_current(struct kvm_vcpu *vcpu) { struct vcpu_svm *svm =3D to_svm(vcpu); =20 @@ -4512,10 +4514,10 @@ static struct kvm_x86_ops svm_x86_ops __initdata = =3D { .set_rflags =3D svm_set_rflags, .get_if_flag =3D svm_get_if_flag, =20 - .flush_tlb_all =3D svm_flush_tlb, - .flush_tlb_current =3D svm_flush_tlb, + .flush_tlb_all =3D svm_flush_tlb_current, + .flush_tlb_current =3D svm_flush_tlb_current, .flush_tlb_gva =3D svm_flush_tlb_gva, - .flush_tlb_guest =3D svm_flush_tlb, + .flush_tlb_guest =3D svm_flush_tlb_current, =20 .vcpu_pre_run =3D svm_vcpu_pre_run, .vcpu_run =3D svm_vcpu_run, diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h index baa5435f1bde..16ad5fa128f4 100644 --- a/arch/x86/kvm/svm/svm.h +++ b/arch/x86/kvm/svm/svm.h @@ -480,7 +480,6 @@ void svm_vcpu_free_msrpm(u32 *msrpm); int svm_set_efer(struct kvm_vcpu *vcpu, u64 efer); void svm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0); void svm_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4); -void svm_flush_tlb(struct kvm_vcpu *vcpu); void disable_nmi_singlestep(struct vcpu_svm *svm); bool svm_smi_blocked(struct kvm_vcpu *vcpu); bool svm_nmi_blocked(struct kvm_vcpu *vcpu); --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Tue Jun 30 01:42:29 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5565DC433EF for ; Fri, 28 Jan 2022 00:54:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345342AbiA1AyT (ORCPT ); Thu, 27 Jan 2022 19:54:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345051AbiA1Axy (ORCPT ); Thu, 27 Jan 2022 19:53:54 -0500 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DB31C061758 for ; Thu, 27 Jan 2022 16:53:42 -0800 (PST) Received: by mail-pj1-x104a.google.com with SMTP id x1-20020a17090ab00100b001b380b8ed35so2853111pjq.7 for ; Thu, 27 Jan 2022 16:53:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=noH9rc43NtcZZk3qKXNAM68WagyoFBJqh2/OYWzzfPU=; b=tPUaKMnIg2K86mUTwaL+noJBuc8zQTKSlcBDAq7cGRCmkzbgoMWo3lKRW9jH9Vw0hG mSQ53Y5dDDhFoXXDcfoKceDkHi6UnTY5xv9fRtaEE4Dt10tTl4Ne5kTUUnTWyiYp8Ido VfD3s07xyStDdnjUvEV3lzb67QSHfEA/xqmozOiDsK01KULTy9x6fbZ521r8Dp42ZQ1S qIdMITmRSPk8vsUhPS4LYeJEl8+Op3kQtH13HhifHQO/QbMUqvTD82vlJ5OMBslY2pxY kTea3f0utvsdMi0aCg6aIuN/jf8/Q9vmW6sTrVXefu9TSu2JR3RfdrjwSGH5BMTru9Ca qkPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=noH9rc43NtcZZk3qKXNAM68WagyoFBJqh2/OYWzzfPU=; b=D3yz4ndOiweZtak6/z7jNKySjn8Wod/afdhJtMI+itrKlhQMsahDlut8lFNmgLXflz V/7feKABpDsMjo+TVhXlIkbIaU1ZqAOhEnt6By/RNfYlk7YT1yNVNb/62zpPtwLWk0CF 7io6ewG0Ov+zlCrRIRBrnQaN3vLPiVH80AYVHYzrRGeGQnY3ZJvlknvuTU2r2CPLpofj 5CS7bRKdYgiaXyXWEGu4ySVj+bCnVQCOP4f0Fa9LG3kUI/YR+5lV5/GSvedORaqI7N4w DM9q0qJQXfug7D7UltQHCmMRhv3/jGnXpW5F9TZZeyvNm47LT/1Y2RWiS2ktJZYZSg48 o/lQ== X-Gm-Message-State: AOAM530YHtMjR4R4yI3WPXfo9lduTbKxygecQqaNdV05xC3gZDX5cmFY 6Z+blbFARCRj0jcw03DrwikYCC9R9jA= X-Google-Smtp-Source: ABdhPJyr6LlxPKDUE8fsLXXo5l1/1ZdCXWljHyCpawtXxfcExphqhBvD2MToVMzZUnc1PH+jzCcY8eh7qoc= X-Received: from seanjc.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e5]) (user=seanjc job=sendgmr) by 2002:a05:6a00:15d6:: with SMTP id o22mr5788714pfu.35.1643331222083; Thu, 27 Jan 2022 16:53:42 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 28 Jan 2022 00:52:03 +0000 In-Reply-To: <20220128005208.4008533-1-seanjc@google.com> Message-Id: <20220128005208.4008533-18-seanjc@google.com> Mime-Version: 1.0 References: <20220128005208.4008533-1-seanjc@google.com> X-Mailer: git-send-email 2.35.0.rc0.227.g00780c9af4-goog Subject: [PATCH 17/22] KVM: SVM: Remove unused MAX_INST_SIZE #define From: Sean Christopherson To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Like Xu Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Remove SVM's MAX_INST_SIZE, which has long since been obsoleted by the common MAX_INSN_SIZE. Note, the latter's "insn" is also the generally preferred abbreviation of instruction. No functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/kvm/svm/svm.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 5382710ba106..87e136b81991 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -263,8 +263,6 @@ u32 svm_msrpm_offset(u32 msr) return MSR_INVALID; } =20 -#define MAX_INST_SIZE 15 - static void svm_flush_tlb_current(struct kvm_vcpu *vcpu); =20 static int get_npt_level(void) --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Tue Jun 30 01:42:29 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69F0DC433EF for ; Fri, 28 Jan 2022 00:54:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345431AbiA1Ay1 (ORCPT ); Thu, 27 Jan 2022 19:54:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345065AbiA1Axy (ORCPT ); Thu, 27 Jan 2022 19:53:54 -0500 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3B22C0613E8 for ; Thu, 27 Jan 2022 16:53:44 -0800 (PST) Received: by mail-pj1-x104a.google.com with SMTP id v8-20020a17090a778800b001b2e6d08cd1so2855289pjk.8 for ; Thu, 27 Jan 2022 16:53:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=f3SP0dzXn4etNS8w8aGEW9D9Vtvc6iCjJjpem18829Y=; b=klQJTYmt+ACxt+Sl2MT+axJ9vVy3J3w50AAaF3tmE4qPW/7zSHvsyGdSy8gk14LRv/ cMxpK6A3hexImycHsUHqiDhITmP3nsoo3/8pAqPJvaAB1QeyPZbwRSUhJ7r0DzdGPOCZ 0CvLUnVrMN1qsmsui3HAyWjRigt/B2UH9q2KDW47vEUT5/Wpn/8DmWkfyvNVOGCxeTQf LV5f661Jshr3/QSFpbEHoyYrG80HU7ef5TLJxwYrlbgrCKwtvtIQYjP4gc8WegFUC53x XTVbztjeEMUhiQ64WvCH8bf8TRDAUKxZBsVmZ/DXo2fo0gz3naxX+7qprHDIGeSQYcH8 g67g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=f3SP0dzXn4etNS8w8aGEW9D9Vtvc6iCjJjpem18829Y=; b=30nVWq74S2ypSuk7gJrYKyETP5GKDz2VTqqtS7rlii1mgZRHzUi7c+DaD5AQRXLMu6 TjliIDzy3ZTpctTCt7V5hKOG4Oa+1n3Saw2x50aYl3VKuhi6f3oyAVFT6bY2uSdfBO3Z PsaFDYUTOFGc49HEFtoAKCeviXrqRdKT0uiN8qJLxQkwGZgtqxfIhcSISmg6GIDfLCJk T/cVm45aajI5pCr8zYmCjckwgybgpE9Cs9NQhXY/zJg2qHVbW/Ee48JuioqcWYOy+m1S aCUvIU7HzoOwO0g46A2qEGNRxA+Suy5MXg+SRiP5pQlq5v9/fvCxrwrh0Eag/7JDOMmG Ik6g== X-Gm-Message-State: AOAM532YV8jwDwQOwBb3wK2CC8LVqrKI6VxCqTasSPgL3jKPWShH8wRZ i5mFA5lDVKGyviZbTUKrtpwiVIPwgvE= X-Google-Smtp-Source: ABdhPJwWkWroXpTYgyRjxVwOtoYqCKnXhSbA5OZTbO1lYtm7RELm4x2fgTjAjq6WFJP0XbRaM3EVumBm7RE= X-Received: from seanjc.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e5]) (user=seanjc job=sendgmr) by 2002:a17:90b:4c8e:: with SMTP id my14mr1878319pjb.0.1643331223696; Thu, 27 Jan 2022 16:53:43 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 28 Jan 2022 00:52:04 +0000 In-Reply-To: <20220128005208.4008533-1-seanjc@google.com> Message-Id: <20220128005208.4008533-19-seanjc@google.com> Mime-Version: 1.0 References: <20220128005208.4008533-1-seanjc@google.com> X-Mailer: git-send-email 2.35.0.rc0.227.g00780c9af4-goog Subject: [PATCH 18/22] KVM: SVM: Rename AVIC helpers to use "avic" prefix instead of "svm" From: Sean Christopherson To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Like Xu Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use "avic" instead of "svm" for SVM's all of APICv hooks and make a few additional funciton name tweaks so that the AVIC functions conform to their associated kvm_x86_ops hooks. This will allow using kvm-x86-ops.h with a custom KVM_X86_APICV_OP() macro to fill all AVIC hooks in one fell swoop. No functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/kvm/svm/avic.c | 28 ++++++++++++++-------------- arch/x86/kvm/svm/svm.c | 18 +++++++++--------- arch/x86/kvm/svm/svm.h | 20 ++++++++++---------- 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/arch/x86/kvm/svm/avic.c b/arch/x86/kvm/svm/avic.c index 90364d02f22a..99f907ec5aa8 100644 --- a/arch/x86/kvm/svm/avic.c +++ b/arch/x86/kvm/svm/avic.c @@ -579,7 +579,7 @@ int avic_init_vcpu(struct vcpu_svm *svm) return ret; } =20 -void avic_post_state_restore(struct kvm_vcpu *vcpu) +void avic_apicv_post_state_restore(struct kvm_vcpu *vcpu) { if (avic_handle_apic_id_update(vcpu) !=3D 0) return; @@ -587,20 +587,20 @@ void avic_post_state_restore(struct kvm_vcpu *vcpu) avic_handle_ldr_update(vcpu); } =20 -void svm_set_virtual_apic_mode(struct kvm_vcpu *vcpu) +void avic_set_virtual_apic_mode(struct kvm_vcpu *vcpu) { return; } =20 -void svm_hwapic_irr_update(struct kvm_vcpu *vcpu, int max_irr) +void avic_hwapic_irr_update(struct kvm_vcpu *vcpu, int max_irr) { } =20 -void svm_hwapic_isr_update(struct kvm_vcpu *vcpu, int max_isr) +void avic_hwapic_isr_update(struct kvm_vcpu *vcpu, int max_isr) { } =20 -static int svm_set_pi_irte_mode(struct kvm_vcpu *vcpu, bool activate) +static int avic_set_pi_irte_mode(struct kvm_vcpu *vcpu, bool activate) { int ret =3D 0; unsigned long flags; @@ -632,7 +632,7 @@ static int svm_set_pi_irte_mode(struct kvm_vcpu *vcpu, = bool activate) return ret; } =20 -void svm_refresh_apicv_exec_ctrl(struct kvm_vcpu *vcpu) +void avic_refresh_apicv_exec_ctrl(struct kvm_vcpu *vcpu) { struct vcpu_svm *svm =3D to_svm(vcpu); struct vmcb *vmcb =3D svm->vmcb01.ptr; @@ -649,7 +649,7 @@ void svm_refresh_apicv_exec_ctrl(struct kvm_vcpu *vcpu) * we need to check and update the AVIC logical APIC ID table * accordingly before re-activating. */ - avic_post_state_restore(vcpu); + avic_apicv_post_state_restore(vcpu); vmcb->control.int_ctl |=3D AVIC_ENABLE_MASK; } else { vmcb->control.int_ctl &=3D ~AVIC_ENABLE_MASK; @@ -661,10 +661,10 @@ void svm_refresh_apicv_exec_ctrl(struct kvm_vcpu *vcp= u) else avic_vcpu_put(vcpu); =20 - svm_set_pi_irte_mode(vcpu, activated); + avic_set_pi_irte_mode(vcpu, activated); } =20 -void svm_load_eoi_exitmap(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap) +void avic_load_eoi_exitmap(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap) { return; } @@ -715,7 +715,7 @@ int svm_deliver_avic_intr(struct kvm_vcpu *vcpu, int ve= c) return 0; } =20 -bool svm_dy_apicv_has_pending_interrupt(struct kvm_vcpu *vcpu) +bool avic_dy_apicv_has_pending_interrupt(struct kvm_vcpu *vcpu) { return false; } @@ -817,7 +817,7 @@ get_pi_vcpu_info(struct kvm *kvm, struct kvm_kernel_irq= _routing_entry *e, } =20 /* - * svm_update_pi_irte - set IRTE for Posted-Interrupts + * avic_pi_update_irte - set IRTE for Posted-Interrupts * * @kvm: kvm * @host_irq: host irq of the interrupt @@ -825,8 +825,8 @@ get_pi_vcpu_info(struct kvm *kvm, struct kvm_kernel_irq= _routing_entry *e, * @set: set or unset PI * returns 0 on success, < 0 on failure */ -int svm_update_pi_irte(struct kvm *kvm, unsigned int host_irq, - uint32_t guest_irq, bool set) +int avic_pi_update_irte(struct kvm *kvm, unsigned int host_irq, + uint32_t guest_irq, bool set) { struct kvm_kernel_irq_routing_entry *e; struct kvm_irq_routing_table *irq_rt; @@ -926,7 +926,7 @@ int svm_update_pi_irte(struct kvm *kvm, unsigned int ho= st_irq, return ret; } =20 -bool svm_check_apicv_inhibit_reasons(ulong bit) +bool avic_check_apicv_inhibit_reasons(ulong bit) { ulong supported =3D BIT(APICV_INHIBIT_REASON_DISABLE) | BIT(APICV_INHIBIT_REASON_ABSENT) | diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 87e136b81991..a6ddc8b7c63b 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -4536,13 +4536,13 @@ static struct kvm_x86_ops svm_x86_ops __initdata = =3D { .enable_nmi_window =3D svm_enable_nmi_window, .enable_irq_window =3D svm_enable_irq_window, .update_cr8_intercept =3D svm_update_cr8_intercept, - .set_virtual_apic_mode =3D svm_set_virtual_apic_mode, - .refresh_apicv_exec_ctrl =3D svm_refresh_apicv_exec_ctrl, - .check_apicv_inhibit_reasons =3D svm_check_apicv_inhibit_reasons, - .load_eoi_exitmap =3D svm_load_eoi_exitmap, - .hwapic_irr_update =3D svm_hwapic_irr_update, - .hwapic_isr_update =3D svm_hwapic_isr_update, - .apicv_post_state_restore =3D avic_post_state_restore, + .set_virtual_apic_mode =3D avic_set_virtual_apic_mode, + .refresh_apicv_exec_ctrl =3D avic_refresh_apicv_exec_ctrl, + .check_apicv_inhibit_reasons =3D avic_check_apicv_inhibit_reasons, + .load_eoi_exitmap =3D avic_load_eoi_exitmap, + .hwapic_irr_update =3D avic_hwapic_irr_update, + .hwapic_isr_update =3D avic_hwapic_isr_update, + .apicv_post_state_restore =3D avic_apicv_post_state_restore, =20 .set_tss_addr =3D svm_set_tss_addr, .set_identity_map_addr =3D svm_set_identity_map_addr, @@ -4572,8 +4572,8 @@ static struct kvm_x86_ops svm_x86_ops __initdata =3D { .nested_ops =3D &svm_nested_ops, =20 .deliver_interrupt =3D svm_deliver_interrupt, - .dy_apicv_has_pending_interrupt =3D svm_dy_apicv_has_pending_interrupt, - .pi_update_irte =3D svm_update_pi_irte, + .dy_apicv_has_pending_interrupt =3D avic_dy_apicv_has_pending_interrupt, + .pi_update_irte =3D avic_pi_update_irte, .setup_mce =3D svm_setup_mce, =20 .smi_allowed =3D svm_smi_allowed, diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h index 16ad5fa128f4..096abbf01969 100644 --- a/arch/x86/kvm/svm/svm.h +++ b/arch/x86/kvm/svm/svm.h @@ -575,17 +575,17 @@ int avic_unaccelerated_access_interception(struct kvm= _vcpu *vcpu); int avic_init_vcpu(struct vcpu_svm *svm); void avic_vcpu_load(struct kvm_vcpu *vcpu, int cpu); void avic_vcpu_put(struct kvm_vcpu *vcpu); -void avic_post_state_restore(struct kvm_vcpu *vcpu); -void svm_set_virtual_apic_mode(struct kvm_vcpu *vcpu); -void svm_refresh_apicv_exec_ctrl(struct kvm_vcpu *vcpu); -bool svm_check_apicv_inhibit_reasons(ulong bit); -void svm_load_eoi_exitmap(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap); -void svm_hwapic_irr_update(struct kvm_vcpu *vcpu, int max_irr); -void svm_hwapic_isr_update(struct kvm_vcpu *vcpu, int max_isr); +void avic_apicv_post_state_restore(struct kvm_vcpu *vcpu); +void avic_set_virtual_apic_mode(struct kvm_vcpu *vcpu); +void avic_refresh_apicv_exec_ctrl(struct kvm_vcpu *vcpu); +bool avic_check_apicv_inhibit_reasons(ulong bit); +void avic_load_eoi_exitmap(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap); +void avic_hwapic_irr_update(struct kvm_vcpu *vcpu, int max_irr); +void avic_hwapic_isr_update(struct kvm_vcpu *vcpu, int max_isr); int svm_deliver_avic_intr(struct kvm_vcpu *vcpu, int vec); -bool svm_dy_apicv_has_pending_interrupt(struct kvm_vcpu *vcpu); -int svm_update_pi_irte(struct kvm *kvm, unsigned int host_irq, - uint32_t guest_irq, bool set); +bool avic_dy_apicv_has_pending_interrupt(struct kvm_vcpu *vcpu); +int avic_pi_update_irte(struct kvm *kvm, unsigned int host_irq, + uint32_t guest_irq, bool set); void avic_vcpu_blocking(struct kvm_vcpu *vcpu); void avic_vcpu_unblocking(struct kvm_vcpu *vcpu); =20 --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Tue Jun 30 01:42:29 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86543C433F5 for ; Fri, 28 Jan 2022 00:54:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345096AbiA1AyX (ORCPT ); Thu, 27 Jan 2022 19:54:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233707AbiA1Axy (ORCPT ); Thu, 27 Jan 2022 19:53:54 -0500 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08F8CC0613E9 for ; Thu, 27 Jan 2022 16:53:46 -0800 (PST) Received: by mail-pj1-x104a.google.com with SMTP id a4-20020a17090a70c400b001b21d9c8bc8so5216679pjm.7 for ; Thu, 27 Jan 2022 16:53:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=mGxZxg+g6ZaiMksJn+F0cEkCwSeLYT2PlHc8NO118xQ=; b=ezC+K2ZYCIk9me/dNtwvfb2XW3fnw1r9FEKqNmkCovZKeu9Y4XQZwUnyPgd8zaVWiY rqceTjEgJ1f9SbGM0rmPTX0ooK3yPBzwjmQf20/svRVrsfOGbIHd/xTszFesiOc5iETr S+dZT8Er+/CQHPDrTTqKoS64RWDIGobFJvXLSlzWJQFmGJP8tAJXxtPzp87Dg20beE71 eZFxZUagQvST3G8gahu4dP1EdWo1Td6ZQ4s8E/1ivMC++BDNu6wkB3ERaCVwXtjrQbqX 6gF82+BnRkDCfKFeKhYEsoqmFrpN74o680AUKI3wFxAaMTy99qVeSs8oMrf0/Vsw9CDc Ld7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=mGxZxg+g6ZaiMksJn+F0cEkCwSeLYT2PlHc8NO118xQ=; b=dOcmZdy1Gi6fzRni9Kr+EukaaIqO/r25ZjWSvcHRpI9jQfXwZhjH+98ax1d/gX8Vb4 OxFXMP+PQRt14aBUqYVKeNq/NFNfgetEhpYDYXeF4bKtHoTrw070OOpBwYUKLTECAEuy Q/cC0NhLGyQdJBTmmfGHExvJ20thI28P8rSmKpBKpkklCafJjeLKGaXarnl6jv9kVLVh 2HRA+xXWKXScw8N7My/kFte0l8j7VqzorXDCNyEKr6D9OuM9wH7SqpjZxoYY/WniZ8Zp 9sWG9UxFtM/3pGGSK2AvDhZ52qsMciqeB7IDK+28yQ53FPrb1f3bHqG3wrO7D4r7SeuS e2ig== X-Gm-Message-State: AOAM5327Cvgky8SFLM8qzk3my6kR0nWoqEsDatYYuz4YyxRkM14q6YAc hzdnPH5EoPfs78+/CjCfBxDNUBfCihI= X-Google-Smtp-Source: ABdhPJx37jAKEAyH5yJrrcF9yjUwqYBFYpjRCzYxoevRZNpimIGXPkTMRDvWujLO9d1nIcU/qycuTykCIOM= X-Received: from seanjc.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e5]) (user=seanjc job=sendgmr) by 2002:a17:902:bd0a:: with SMTP id p10mr6216610pls.159.1643331225540; Thu, 27 Jan 2022 16:53:45 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 28 Jan 2022 00:52:05 +0000 In-Reply-To: <20220128005208.4008533-1-seanjc@google.com> Message-Id: <20220128005208.4008533-20-seanjc@google.com> Mime-Version: 1.0 References: <20220128005208.4008533-1-seanjc@google.com> X-Mailer: git-send-email 2.35.0.rc0.227.g00780c9af4-goog Subject: [PATCH 19/22] KVM: x86: Use more verbose names for mem encrypt kvm_x86_ops hooks From: Sean Christopherson To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Like Xu Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use slightly more verbose names for the so called "memory encrypt", a.k.a. "mem enc", kvm_x86_ops hooks to bridge the gap between the current super short kvm_x86_ops names and SVM's more verbose, but non-conforming names. This is a step toward using kvm-x86-ops.h with KVM_X86_CVM_OP() to fill svm_x86_ops. Opportunistically rename mem_enc_op() to mem_enc_ioctl() to better reflect its true nature, as it really is a full fledged ioctl() of its own. Ideally, the hook would be named confidential_vm_ioctl() or so, as the ioctl() is a gateway to more than just memory encryption, and because its underlying purpose to support Confidential VMs, which can be provided without memory encryption, e.g. if the TCB of the guest includes the host kernel but not host userspace, or by isolation in hardware without encrypting memory. But, diverging from KVM_MEMORY_ENCRYPT_OP even further is undeseriable, and short of creating alises for all related ioctl()s, which introduces a different flavor of divergence, KVM is stuck with the nomenclature. Defer renaming SVM's functions to a future commit as there are additional changes needed to make SVM fully conforming and to match reality (looking at you, svm_vm_copy_asid_from()). No functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/include/asm/kvm-x86-ops.h | 6 +++--- arch/x86/include/asm/kvm_host.h | 6 +++--- arch/x86/kvm/svm/sev.c | 2 +- arch/x86/kvm/svm/svm.c | 6 +++--- arch/x86/kvm/svm/svm.h | 2 +- arch/x86/kvm/x86.c | 18 ++++++++++++------ 6 files changed, 23 insertions(+), 17 deletions(-) diff --git a/arch/x86/include/asm/kvm-x86-ops.h b/arch/x86/include/asm/kvm-= x86-ops.h index cb3af3a55317..efc4d5da45ad 100644 --- a/arch/x86/include/asm/kvm-x86-ops.h +++ b/arch/x86/include/asm/kvm-x86-ops.h @@ -133,9 +133,9 @@ KVM_X86_HYPERV_OP(tlb_remote_flush) KVM_X86_HYPERV_OP(tlb_remote_flush_with_range) KVM_X86_HYPERV_OP(enable_direct_tlbflush) =20 -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(mem_enc_ioctl) +KVM_X86_CVM_OP(mem_enc_register_region) +KVM_X86_CVM_OP(mem_enc_unregister_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) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_hos= t.h index f97d155810ac..6228c12fc6c3 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1475,9 +1475,9 @@ struct kvm_x86_ops { int (*leave_smm)(struct kvm_vcpu *vcpu, const char *smstate); void (*enable_smi_window)(struct kvm_vcpu *vcpu); =20 - int (*mem_enc_op)(struct kvm *kvm, void __user *argp); - int (*mem_enc_reg_region)(struct kvm *kvm, struct kvm_enc_region *argp); - int (*mem_enc_unreg_region)(struct kvm *kvm, struct kvm_enc_region *argp); + int (*mem_enc_ioctl)(struct kvm *kvm, void __user *argp); + int (*mem_enc_register_region)(struct kvm *kvm, struct kvm_enc_region *ar= gp); + int (*mem_enc_unregister_region)(struct kvm *kvm, struct kvm_enc_region *= argp); int (*vm_copy_enc_context_from)(struct kvm *kvm, unsigned int source_fd); int (*vm_move_enc_context_from)(struct kvm *kvm, unsigned int source_fd); =20 diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index b82eeef89a3e..7f346ddcae0a 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -1761,7 +1761,7 @@ int svm_vm_migrate_from(struct kvm *kvm, unsigned int= source_fd) return ret; } =20 -int svm_mem_enc_op(struct kvm *kvm, void __user *argp) +int svm_mem_enc_ioctl(struct kvm *kvm, void __user *argp) { struct kvm_sev_cmd sev_cmd; int r; diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index a6ddc8b7c63b..4b9041e931a8 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -4581,9 +4581,9 @@ static struct kvm_x86_ops svm_x86_ops __initdata =3D { .leave_smm =3D svm_leave_smm, .enable_smi_window =3D svm_enable_smi_window, =20 - .mem_enc_op =3D svm_mem_enc_op, - .mem_enc_reg_region =3D svm_register_enc_region, - .mem_enc_unreg_region =3D svm_unregister_enc_region, + .mem_enc_ioctl =3D svm_mem_enc_ioctl, + .mem_enc_register_region =3D svm_register_enc_region, + .mem_enc_unregister_region =3D svm_unregister_enc_region, =20 .vm_copy_enc_context_from =3D svm_vm_copy_asid_from, .vm_move_enc_context_from =3D svm_vm_migrate_from, diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h index 096abbf01969..7cf81e029f9c 100644 --- a/arch/x86/kvm/svm/svm.h +++ b/arch/x86/kvm/svm/svm.h @@ -598,7 +598,7 @@ void avic_vcpu_unblocking(struct kvm_vcpu *vcpu); extern unsigned int max_sev_asid; =20 void sev_vm_destroy(struct kvm *kvm); -int svm_mem_enc_op(struct kvm *kvm, void __user *argp); +int svm_mem_enc_ioctl(struct kvm *kvm, void __user *argp); int svm_register_enc_region(struct kvm *kvm, struct kvm_enc_region *range); int svm_unregister_enc_region(struct kvm *kvm, diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index b151db419590..01f68b3da5ee 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -6444,8 +6444,10 @@ long kvm_arch_vm_ioctl(struct file *filp, break; case KVM_MEMORY_ENCRYPT_OP: { r =3D -ENOTTY; - if (kvm_x86_ops.mem_enc_op) - r =3D static_call(kvm_x86_mem_enc_op)(kvm, argp); + if (!kvm_x86_ops.mem_enc_ioctl) + goto out; + + r =3D static_call(kvm_x86_mem_enc_ioctl)(kvm, argp); break; } case KVM_MEMORY_ENCRYPT_REG_REGION: { @@ -6456,8 +6458,10 @@ long kvm_arch_vm_ioctl(struct file *filp, goto out; =20 r =3D -ENOTTY; - if (kvm_x86_ops.mem_enc_reg_region) - r =3D static_call(kvm_x86_mem_enc_reg_region)(kvm, ®ion); + if (!kvm_x86_ops.mem_enc_register_region) + goto out; + + r =3D static_call(kvm_x86_mem_enc_register_region)(kvm, ®ion); break; } case KVM_MEMORY_ENCRYPT_UNREG_REGION: { @@ -6468,8 +6472,10 @@ long kvm_arch_vm_ioctl(struct file *filp, goto out; =20 r =3D -ENOTTY; - if (kvm_x86_ops.mem_enc_unreg_region) - r =3D static_call(kvm_x86_mem_enc_unreg_region)(kvm, ®ion); + if (!kvm_x86_ops.mem_enc_unregister_region) + goto out; + + r =3D static_call(kvm_x86_mem_enc_unregister_region)(kvm, ®ion); break; } case KVM_HYPERV_EVENTFD: { --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Tue Jun 30 01:42:29 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0425C433F5 for ; Fri, 28 Jan 2022 00:54:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345137AbiA1Aya (ORCPT ); Thu, 27 Jan 2022 19:54:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344823AbiA1Axy (ORCPT ); Thu, 27 Jan 2022 19:53:54 -0500 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAB3AC0613EE for ; Thu, 27 Jan 2022 16:53:47 -0800 (PST) Received: by mail-pl1-x64a.google.com with SMTP id q2-20020a170902f78200b0014b56300928so2287587pln.16 for ; Thu, 27 Jan 2022 16:53:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=IKra2yE5BUeML4Gu42Nb19pN2PZRnep0CqEh3hnPyCQ=; b=LS+zwtEG7jphpNmJTFioDe3rVdx52JF+7cYcEhl8MFTXS8rdNDCDJ+BQCRz46pVvRp WK/hypcY5HIeFZF0LdTgixQNf0ffr0Le3Ik2OVDvC2kG/3D6zNVpqVtUXuled5y9jWhC ecQsoX/O4/sIYxilV9Woz+aqdcoeo8f2wPZYXWnt5o3VxLcqmIyzvakIx1BjAwxl3Qvl WqBSyL9eIuUkNhifeKyBNsajAA310/NecdUXtkSQMlHvoq1jzNXtGzf9cSebsB2enoEK SGHFkrrAtGt+u4ztwnDewZdsaephD/Jhou5rrYEzkyn7tGI7cAVYwCNnje39fPZkEidO wptg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=IKra2yE5BUeML4Gu42Nb19pN2PZRnep0CqEh3hnPyCQ=; b=nTihLJSRkzuK+uU7e/yDat84YSN04xMBJIXTW5t2pwuHSHak/j2TwKTI+7266BCBnz fGOiRvN5ZJlGOT3bv2Ht5YPOodWlc3TU4SgOVSNDfOBJ9gXW3Eey6KLEuxOLHPOs8/Qz VMOTNrOfUMPTr1swpGVhPjSQGEPtHR9d5dD4kcdVqKhtD/O3uwcvW4Ck4AhJC7cb32I8 FDiZKZMMBASrljgc8gDcxc64VFUcNYA6JyDRqnZbCAeX38TyZXtBxVnhJvNrdh6owR2o CSgEOjlYmHuY3hscw6rgnHasumIWGr3WLqvA1Xs8O8/HxZ0EpVeRcXREHNyvBErF5xgi L2IQ== X-Gm-Message-State: AOAM531GmAv4PD4snTkG+xWU2O4CRVdnXTYADfpCTlAJ7VYhSGkiJWeR tuYPrDltE5TEYCoR9mu+/7yfwAqAGXU= X-Google-Smtp-Source: ABdhPJxNhbEs851OGykz4C3A1h6jM1Ik83dhmCFQEm2x2LtdiGSbJXPIkAD9JRHU4RZIEFg3eJQsGklBQAg= X-Received: from seanjc.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e5]) (user=seanjc job=sendgmr) by 2002:aa7:94a9:: with SMTP id a9mr5452769pfl.78.1643331227310; Thu, 27 Jan 2022 16:53:47 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 28 Jan 2022 00:52:06 +0000 In-Reply-To: <20220128005208.4008533-1-seanjc@google.com> Message-Id: <20220128005208.4008533-21-seanjc@google.com> Mime-Version: 1.0 References: <20220128005208.4008533-1-seanjc@google.com> X-Mailer: git-send-email 2.35.0.rc0.227.g00780c9af4-goog Subject: [PATCH 20/22] KVM: SVM: Rename SEV implemenations to conform to kvm_x86_ops hooks From: Sean Christopherson To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Like Xu Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Rename svm_vm_copy_asid_from() and svm_vm_migrate_from() to conform to the names used by kvm_x86_ops, and opportunistically use "sev" instead of "svm" to more precisely identify the role of the hooks. svm_vm_copy_asid_from() in particular was poorly named as the function does much more than simply copy the ASID. No functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/kvm/svm/sev.c | 14 +++++++------- arch/x86/kvm/svm/svm.c | 14 +++++++------- arch/x86/kvm/svm/svm.h | 14 +++++++------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index 7f346ddcae0a..4662e5fd7559 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -1681,7 +1681,7 @@ static int sev_es_migrate_from(struct kvm *dst, struc= t kvm *src) return 0; } =20 -int svm_vm_migrate_from(struct kvm *kvm, unsigned int source_fd) +int sev_vm_move_enc_context_from(struct kvm *kvm, unsigned int source_fd) { struct kvm_sev_info *dst_sev =3D &to_kvm_svm(kvm)->sev_info; struct kvm_sev_info *src_sev, *cg_cleanup_sev; @@ -1761,7 +1761,7 @@ int svm_vm_migrate_from(struct kvm *kvm, unsigned int= source_fd) return ret; } =20 -int svm_mem_enc_ioctl(struct kvm *kvm, void __user *argp) +int sev_mem_enc_ioctl(struct kvm *kvm, void __user *argp) { struct kvm_sev_cmd sev_cmd; int r; @@ -1858,8 +1858,8 @@ int svm_mem_enc_ioctl(struct kvm *kvm, void __user *a= rgp) return r; } =20 -int svm_register_enc_region(struct kvm *kvm, - struct kvm_enc_region *range) +int sev_mem_enc_register_region(struct kvm *kvm, + struct kvm_enc_region *range) { struct kvm_sev_info *sev =3D &to_kvm_svm(kvm)->sev_info; struct enc_region *region; @@ -1932,8 +1932,8 @@ static void __unregister_enc_region_locked(struct kvm= *kvm, kfree(region); } =20 -int svm_unregister_enc_region(struct kvm *kvm, - struct kvm_enc_region *range) +int sev_mem_enc_unregister_region(struct kvm *kvm, + struct kvm_enc_region *range) { struct enc_region *region; int ret; @@ -1972,7 +1972,7 @@ int svm_unregister_enc_region(struct kvm *kvm, return ret; } =20 -int svm_vm_copy_asid_from(struct kvm *kvm, unsigned int source_fd) +int sev_vm_copy_enc_context_from(struct kvm *kvm, unsigned int source_fd) { struct file *source_kvm_file; struct kvm *source_kvm; diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 4b9041e931a8..a075c6458a27 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -1574,7 +1574,7 @@ static void svm_set_gdt(struct kvm_vcpu *vcpu, struct= desc_ptr *dt) vmcb_mark_dirty(svm->vmcb, VMCB_DT); } =20 -static void svm_post_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3) +static void sev_post_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3) { struct vcpu_svm *svm =3D to_svm(vcpu); =20 @@ -4497,7 +4497,7 @@ static struct kvm_x86_ops svm_x86_ops __initdata =3D { .get_cpl =3D svm_get_cpl, .get_cs_db_l_bits =3D svm_get_cs_db_l_bits, .set_cr0 =3D svm_set_cr0, - .post_set_cr3 =3D svm_post_set_cr3, + .post_set_cr3 =3D sev_post_set_cr3, .is_valid_cr4 =3D svm_is_valid_cr4, .set_cr4 =3D svm_set_cr4, .set_efer =3D svm_set_efer, @@ -4581,12 +4581,12 @@ static struct kvm_x86_ops svm_x86_ops __initdata = =3D { .leave_smm =3D svm_leave_smm, .enable_smi_window =3D svm_enable_smi_window, =20 - .mem_enc_ioctl =3D svm_mem_enc_ioctl, - .mem_enc_register_region =3D svm_register_enc_region, - .mem_enc_unregister_region =3D svm_unregister_enc_region, + .mem_enc_ioctl =3D sev_mem_enc_ioctl, + .mem_enc_register_region =3D sev_mem_enc_register_region, + .mem_enc_unregister_region =3D sev_mem_enc_unregister_region, =20 - .vm_copy_enc_context_from =3D svm_vm_copy_asid_from, - .vm_move_enc_context_from =3D svm_vm_migrate_from, + .vm_copy_enc_context_from =3D sev_vm_copy_enc_context_from, + .vm_move_enc_context_from =3D sev_vm_move_enc_context_from, =20 .can_emulate_instruction =3D svm_can_emulate_instruction, =20 diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h index 7cf81e029f9c..67c17509c4c0 100644 --- a/arch/x86/kvm/svm/svm.h +++ b/arch/x86/kvm/svm/svm.h @@ -598,13 +598,13 @@ void avic_vcpu_unblocking(struct kvm_vcpu *vcpu); extern unsigned int max_sev_asid; =20 void sev_vm_destroy(struct kvm *kvm); -int svm_mem_enc_ioctl(struct kvm *kvm, void __user *argp); -int svm_register_enc_region(struct kvm *kvm, - struct kvm_enc_region *range); -int svm_unregister_enc_region(struct kvm *kvm, - struct kvm_enc_region *range); -int svm_vm_copy_asid_from(struct kvm *kvm, unsigned int source_fd); -int svm_vm_migrate_from(struct kvm *kvm, unsigned int source_fd); +int sev_mem_enc_ioctl(struct kvm *kvm, void __user *argp); +int sev_mem_enc_register_region(struct kvm *kvm, + struct kvm_enc_region *range); +int sev_mem_enc_unregister_region(struct kvm *kvm, + struct kvm_enc_region *range); +int sev_vm_copy_enc_context_from(struct kvm *kvm, unsigned int source_fd); +int sev_vm_move_enc_context_from(struct kvm *kvm, unsigned int source_fd); void pre_sev_run(struct vcpu_svm *svm, int cpu); void __init sev_set_cpu_caps(void); void __init sev_hardware_setup(void); --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Tue Jun 30 01:42:29 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE8ABC433EF for ; Fri, 28 Jan 2022 00:54:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345478AbiA1Ayd (ORCPT ); Thu, 27 Jan 2022 19:54:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344848AbiA1Axy (ORCPT ); Thu, 27 Jan 2022 19:53:54 -0500 Received: from mail-pj1-x1049.google.com (mail-pj1-x1049.google.com [IPv6:2607:f8b0:4864:20::1049]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CAE0C0613F4 for ; Thu, 27 Jan 2022 16:53:49 -0800 (PST) Received: by mail-pj1-x1049.google.com with SMTP id l1-20020a17090aec0100b001b508cd63f6so2689398pjy.9 for ; Thu, 27 Jan 2022 16:53:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=TE3DAQCjfF5bgZh0A92f+DGaQa5/4c2uMoQr42NNpYc=; b=ATljjYZvZYn32Np3QtiPH5TMWbe0bLoM+3PtuoC8d4BTCbRLK+69hch+U8NxzQY7Ye 6UukonUBCmUBsHFEuA0j4/6SsG/s1bN6IsV07pCxYyZ971BzgrsLQEkkHfbxbr/OdtvR oAiL8iOGxK4qxu6Z4v7qvZoBGzxvzq2ERqs72iEKZm6o+aYZc05Vxx+4uO8XjQ8krvUb DcATEhWvD+eeCIhabGiC4yx5AMAxzQ37ws/got7lxNH7DlL6oPLFWqo38OGpZC6/KOev QJr04ASzimCABDdsiVNwjINY0BwQJ/lpiFN2Evh7ZhEaVP0hVrp7BsjS44iHe74WxrPR Tx+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=TE3DAQCjfF5bgZh0A92f+DGaQa5/4c2uMoQr42NNpYc=; b=6/czbkcfWZV71bYwfKEK9FmxQBG00j1xPFP1jkW3ZTlp2E1uYZrp9DfAkdn6sT37wt iRYCtVowknWgHZW4sIDNaS861tmX0/eg6xqk2Wxf/5qK3Hw8lHwW5NfXP1EqbYVk5wPF k7VXrawRshF7sU1dadPovx0PwhhewelNvwE6uY+Yu0grUTYgVX55oW4l530dIHWD1uok af8APRu+K45Tv6wHM4GNfMoOQu4hmQK1We5NrxcxJC4kRiMsignr3dTO4EIfEpg3Ko8X 83XIxjnZV4e+tJmEqej6e9fU5biT8CLIEJCmKOfjO/9h4XJPwAxScdLW+tCNB9qOLgqz 8GlQ== X-Gm-Message-State: AOAM530ulclftiw4r9ywA4rv2myu/jZ0L2YoYATHSVUdgG3owYqvftdZ rAzugXQ8cih33qWOpdw1HLRMcC18MPk= X-Google-Smtp-Source: ABdhPJzxJLKJXxL8dGBPM2EBhuloc0p9kUAzPbJW+osbLeZcyeLmeW6furTp4Fo8QEdbeezv2nHK/gl91TM= X-Received: from seanjc.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e5]) (user=seanjc job=sendgmr) by 2002:a62:7c42:: with SMTP id x63mr5442452pfc.31.1643331228888; Thu, 27 Jan 2022 16:53:48 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 28 Jan 2022 00:52:07 +0000 In-Reply-To: <20220128005208.4008533-1-seanjc@google.com> Message-Id: <20220128005208.4008533-22-seanjc@google.com> Mime-Version: 1.0 References: <20220128005208.4008533-1-seanjc@google.com> X-Mailer: git-send-email 2.35.0.rc0.227.g00780c9af4-goog Subject: [PATCH 21/22] KVM: SVM: Rename hook implementations to conform to kvm_x86_ops' names From: Sean Christopherson To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Like Xu Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Massage SVM's implementation names that still diverge from kvm_x86_ops to allow for wiring up all SVM-defined functions via kvm-x86-ops.h. No functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/kvm/svm/sev.c | 4 ++-- arch/x86/kvm/svm/svm.c | 40 ++++++++++++++++++++-------------------- arch/x86/kvm/svm/svm.h | 6 +++--- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index 4662e5fd7559..f4d88292f337 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -2173,7 +2173,7 @@ void __init sev_hardware_setup(void) #endif } =20 -void sev_hardware_teardown(void) +void sev_hardware_unsetup(void) { if (!sev_enabled) return; @@ -2907,7 +2907,7 @@ void sev_es_vcpu_reset(struct vcpu_svm *svm) sev_enc_bit)); } =20 -void sev_es_prepare_guest_switch(struct vmcb_save_area *hostsa) +void sev_es_prepare_switch_to_guest(struct vmcb_save_area *hostsa) { /* * As an SEV-ES guest, hardware will restore the host state on VMEXIT, diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index a075c6458a27..7f70f456a5a5 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -353,7 +353,7 @@ static void svm_set_interrupt_shadow(struct kvm_vcpu *v= cpu, int mask) =20 } =20 -static int skip_emulated_instruction(struct kvm_vcpu *vcpu) +static int svm_skip_emulated_instruction(struct kvm_vcpu *vcpu) { struct vcpu_svm *svm =3D to_svm(vcpu); =20 @@ -401,7 +401,7 @@ static void svm_queue_exception(struct kvm_vcpu *vcpu) * raises a fault that is not intercepted. Still better than * failing in all cases. */ - (void)skip_emulated_instruction(vcpu); + (void)svm_skip_emulated_instruction(vcpu); rip =3D kvm_rip_read(vcpu); svm->int3_rip =3D rip + svm->vmcb->save.cs.base; svm->int3_injected =3D rip - old_rip; @@ -873,11 +873,11 @@ static void shrink_ple_window(struct kvm_vcpu *vcpu) } } =20 -static void svm_hardware_teardown(void) +static void svm_hardware_unsetup(void) { int cpu; =20 - sev_hardware_teardown(); + sev_hardware_unsetup(); =20 for_each_possible_cpu(cpu) svm_cpu_uninit(cpu); @@ -1175,7 +1175,7 @@ void svm_switch_vmcb(struct vcpu_svm *svm, struct kvm= _vmcb_info *target_vmcb) svm->vmcb =3D target_vmcb->ptr; } =20 -static int svm_create_vcpu(struct kvm_vcpu *vcpu) +static int svm_vcpu_create(struct kvm_vcpu *vcpu) { struct vcpu_svm *svm; struct page *vmcb01_page; @@ -1246,7 +1246,7 @@ static void svm_clear_current_vmcb(struct vmcb *vmcb) cmpxchg(&per_cpu(svm_data, i)->current_vmcb, vmcb, NULL); } =20 -static void svm_free_vcpu(struct kvm_vcpu *vcpu) +static void svm_vcpu_free(struct kvm_vcpu *vcpu) { struct vcpu_svm *svm =3D to_svm(vcpu); =20 @@ -1265,7 +1265,7 @@ static void svm_free_vcpu(struct kvm_vcpu *vcpu) __free_pages(virt_to_page(svm->msrpm), get_order(MSRPM_SIZE)); } =20 -static void svm_prepare_guest_switch(struct kvm_vcpu *vcpu) +static void svm_prepare_switch_to_guest(struct kvm_vcpu *vcpu) { struct vcpu_svm *svm =3D to_svm(vcpu); struct svm_cpu_data *sd =3D per_cpu(svm_data, vcpu->cpu); @@ -1285,7 +1285,7 @@ static void svm_prepare_guest_switch(struct kvm_vcpu = *vcpu) struct vmcb_save_area *hostsa; hostsa =3D (struct vmcb_save_area *)(page_address(sd->save_area) + 0x400= ); =20 - sev_es_prepare_guest_switch(hostsa); + sev_es_prepare_switch_to_guest(hostsa); } =20 if (tsc_scaling) { @@ -2272,7 +2272,7 @@ static int task_switch_interception(struct kvm_vcpu *= vcpu) int_type =3D=3D SVM_EXITINTINFO_TYPE_SOFT || (int_type =3D=3D SVM_EXITINTINFO_TYPE_EXEPT && (int_vec =3D=3D OF_VECTOR || int_vec =3D=3D BP_VECTOR))) { - if (!skip_emulated_instruction(vcpu)) + if (!svm_skip_emulated_instruction(vcpu)) return 0; } =20 @@ -3192,7 +3192,7 @@ static void svm_get_exit_info(struct kvm_vcpu *vcpu, = u32 *reason, *error_code =3D 0; } =20 -static int handle_exit(struct kvm_vcpu *vcpu, fastpath_t exit_fastpath) +static int svm_handle_exit(struct kvm_vcpu *vcpu, fastpath_t exit_fastpath) { struct vcpu_svm *svm =3D to_svm(vcpu); struct kvm_run *kvm_run =3D vcpu->run; @@ -3289,7 +3289,7 @@ static void svm_inject_nmi(struct kvm_vcpu *vcpu) ++vcpu->stat.nmi_injections; } =20 -static void svm_set_irq(struct kvm_vcpu *vcpu) +static void svm_inject_irq(struct kvm_vcpu *vcpu) { struct vcpu_svm *svm =3D to_svm(vcpu); =20 @@ -4199,7 +4199,7 @@ static int svm_enter_smm(struct kvm_vcpu *vcpu, char = *smstate) * by 0x400 (matches the offset of 'struct vmcb_save_area' * within 'struct vmcb'). Note: HSAVE area may also be used by * L1 hypervisor to save additional host context (e.g. KVM does - * that, see svm_prepare_guest_switch()) which must be + * that, see svm_prepare_switch_to_guest()) which must be * preserved. */ if (kvm_vcpu_map(vcpu, gpa_to_gfn(svm->nested.hsave_msr), @@ -4467,21 +4467,21 @@ static int svm_vm_init(struct kvm *kvm) static struct kvm_x86_ops svm_x86_ops __initdata =3D { .name =3D "kvm_amd", =20 - .hardware_unsetup =3D svm_hardware_teardown, + .hardware_unsetup =3D svm_hardware_unsetup, .hardware_enable =3D svm_hardware_enable, .hardware_disable =3D svm_hardware_disable, .cpu_has_accelerated_tpr =3D svm_cpu_has_accelerated_tpr, .has_emulated_msr =3D svm_has_emulated_msr, =20 - .vcpu_create =3D svm_create_vcpu, - .vcpu_free =3D svm_free_vcpu, + .vcpu_create =3D svm_vcpu_create, + .vcpu_free =3D svm_vcpu_free, .vcpu_reset =3D svm_vcpu_reset, =20 .vm_size =3D sizeof(struct kvm_svm), .vm_init =3D svm_vm_init, .vm_destroy =3D svm_vm_destroy, =20 - .prepare_switch_to_guest =3D svm_prepare_guest_switch, + .prepare_switch_to_guest =3D svm_prepare_switch_to_guest, .vcpu_load =3D svm_vcpu_load, .vcpu_put =3D svm_vcpu_put, .vcpu_blocking =3D avic_vcpu_blocking, @@ -4519,13 +4519,13 @@ static struct kvm_x86_ops svm_x86_ops __initdata = =3D { =20 .vcpu_pre_run =3D svm_vcpu_pre_run, .vcpu_run =3D svm_vcpu_run, - .handle_exit =3D handle_exit, - .skip_emulated_instruction =3D skip_emulated_instruction, + .handle_exit =3D svm_handle_exit, + .skip_emulated_instruction =3D svm_skip_emulated_instruction, .update_emulated_instruction =3D NULL, .set_interrupt_shadow =3D svm_set_interrupt_shadow, .get_interrupt_shadow =3D svm_get_interrupt_shadow, .patch_hypercall =3D svm_patch_hypercall, - .inject_irq =3D svm_set_irq, + .inject_irq =3D svm_inject_irq, .inject_nmi =3D svm_inject_nmi, .queue_exception =3D svm_queue_exception, .cancel_injection =3D svm_cancel_injection, @@ -4830,7 +4830,7 @@ static __init int svm_hardware_setup(void) return 0; =20 err: - svm_hardware_teardown(); + svm_hardware_unsetup(); return r; } =20 diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h index 67c17509c4c0..852b12aee03d 100644 --- a/arch/x86/kvm/svm/svm.h +++ b/arch/x86/kvm/svm/svm.h @@ -321,7 +321,7 @@ static __always_inline struct vcpu_svm *to_svm(struct k= vm_vcpu *vcpu) =20 /* * Only the PDPTRs are loaded on demand into the shadow MMU. All other - * fields are synchronized in handle_exit, because accessing the VMCB is c= heap. + * fields are synchronized on VM-Exit, because accessing the VMCB is cheap. * * CR3 might be out of date in the VMCB but it is not marked dirty; instea= d, * KVM_REQ_LOAD_MMU_PGD is always requested when the cached vcpu->arch.cr3 @@ -608,7 +608,7 @@ int sev_vm_move_enc_context_from(struct kvm *kvm, unsig= ned int source_fd); void pre_sev_run(struct vcpu_svm *svm, int cpu); void __init sev_set_cpu_caps(void); void __init sev_hardware_setup(void); -void sev_hardware_teardown(void); +void sev_hardware_unsetup(void); int sev_cpu_init(struct svm_cpu_data *sd); void sev_free_vcpu(struct kvm_vcpu *vcpu); int sev_handle_vmgexit(struct kvm_vcpu *vcpu); @@ -616,7 +616,7 @@ int sev_es_string_io(struct vcpu_svm *svm, int size, un= signed int port, int in); void sev_es_init_vmcb(struct vcpu_svm *svm); void sev_es_vcpu_reset(struct vcpu_svm *svm); void sev_vcpu_deliver_sipi_vector(struct kvm_vcpu *vcpu, u8 vector); -void sev_es_prepare_guest_switch(struct vmcb_save_area *hostsa); +void sev_es_prepare_switch_to_guest(struct vmcb_save_area *hostsa); void sev_es_unmap_ghcb(struct vcpu_svm *svm); =20 /* vmenter.S */ --=20 2.35.0.rc0.227.g00780c9af4-goog From nobody Tue Jun 30 01:42:29 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50815C433EF for ; Fri, 28 Jan 2022 00:54:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345520AbiA1Ayl (ORCPT ); Thu, 27 Jan 2022 19:54:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345081AbiA1Axz (ORCPT ); Thu, 27 Jan 2022 19:53:55 -0500 Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E7D0C06175B for ; Thu, 27 Jan 2022 16:53:51 -0800 (PST) Received: by mail-pf1-x44a.google.com with SMTP id d9-20020a62f809000000b004bb5ffee9b3so2462700pfh.15 for ; Thu, 27 Jan 2022 16:53:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=cvygIoGiSQi3oTt0w5ZXf8sI2CTAC6vrqi+OOTHPRDE=; b=FVi96naPKGiz/aF8Eh+slKp5cJeQJ6po/1hq26mKVP/XUrxRfayPckK10ADhIvj3hI i6+e5NIccsNi5PDn0+PxRt/33GHxddNO0Ne34QQopnoj+FDYcH65XRq7iGHIPEyvA2/9 iP3EZF0F13nryrttQEIQmptEdrFzblKIulKPzwhnxjnkIkqhEoom40mHGIVAXCG7LY7L Prn8DXm3yKx5BQl7bBagSIkmAmX3q2PX/9+GyeOJec2+HzI5iJRp220XcVWN6tp4pMdo +xjl65qgtOzI5iooEsKb0MpGDXnsfF9ZaGON1CIvLpJUyXGs2J8qZ83smaU5PEydAgbx NrqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=cvygIoGiSQi3oTt0w5ZXf8sI2CTAC6vrqi+OOTHPRDE=; b=Tkuzv8WvpJRXGnq6Zur8gQbgqtiHjc8ABwlbUz6gMA1ezrX6WkE7F3gtztCtlpuxZ0 OUYBJ8f05qrFZkkhsZ2osroD60kErAyVwwNZW1rawEVy+gXcThOVwYYP6Mfw+dJU70AP SPJ769us0rPnKTsm2GkrHyHS63ol+c3DmZZTbw7DGoMJbznPUB2OgxU6ChEwDeiWodSJ oumJYmz/03aaGeyINQ8Q6mZ/nTPMG9vL0qpZRhMik9UfhFWuk4gchhFVrmlNlD8prC3p EM5jzi1Cw50pz2wfClTkr/w5QcB87KkbqTEm76GI7Xr1RiwhII9uIYAQQZb2C9x0CV0K aW+A== X-Gm-Message-State: AOAM531GnKqODpZMNqaWKNBeuChylMpiy5CaRAliKKqi16reOTXaSSB5 zsVzBs8PLoQ2lobJ6WSSgRUjocTLqD8= X-Google-Smtp-Source: ABdhPJyb8tZJAL5p8BS/mQylHLPkXgqhV/ICfjkoJuopLsQFkNASSP9NS2yeeF9/K0Wc++PRvjolQ9+5vtQ= X-Received: from seanjc.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e5]) (user=seanjc job=sendgmr) by 2002:a17:902:9a4b:: with SMTP id x11mr5995083plv.56.1643331230528; Thu, 27 Jan 2022 16:53:50 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 28 Jan 2022 00:52:08 +0000 In-Reply-To: <20220128005208.4008533-1-seanjc@google.com> Message-Id: <20220128005208.4008533-23-seanjc@google.com> Mime-Version: 1.0 References: <20220128005208.4008533-1-seanjc@google.com> X-Mailer: git-send-email 2.35.0.rc0.227.g00780c9af4-goog Subject: [PATCH 22/22] KVM: SVM: Use kvm-x86-ops.h to fill svm_x86_ops From: Sean Christopherson To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Like Xu Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- 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; } =20 +/* + * SVM unconditionally flushes between nested transition and so doesn't pr= ovide + * 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 =3D { .name =3D "kvm_amd", - - .hardware_unsetup =3D svm_hardware_unsetup, - .hardware_enable =3D svm_hardware_enable, - .hardware_disable =3D svm_hardware_disable, - .cpu_has_accelerated_tpr =3D svm_cpu_has_accelerated_tpr, - .has_emulated_msr =3D svm_has_emulated_msr, - - .vcpu_create =3D svm_vcpu_create, - .vcpu_free =3D svm_vcpu_free, - .vcpu_reset =3D svm_vcpu_reset, - .vm_size =3D sizeof(struct kvm_svm), - .vm_init =3D svm_vm_init, - .vm_destroy =3D svm_vm_destroy, - - .prepare_switch_to_guest =3D svm_prepare_switch_to_guest, - .vcpu_load =3D svm_vcpu_load, - .vcpu_put =3D svm_vcpu_put, - .vcpu_blocking =3D avic_vcpu_blocking, - .vcpu_unblocking =3D avic_vcpu_unblocking, - - .update_exception_bitmap =3D svm_update_exception_bitmap, - .get_msr_feature =3D svm_get_msr_feature, - .get_msr =3D svm_get_msr, - .set_msr =3D svm_set_msr, - .get_segment_base =3D svm_get_segment_base, - .get_segment =3D svm_get_segment, - .set_segment =3D svm_set_segment, - .get_cpl =3D svm_get_cpl, - .get_cs_db_l_bits =3D svm_get_cs_db_l_bits, - .set_cr0 =3D svm_set_cr0, - .post_set_cr3 =3D sev_post_set_cr3, - .is_valid_cr4 =3D svm_is_valid_cr4, - .set_cr4 =3D svm_set_cr4, - .set_efer =3D svm_set_efer, - .get_idt =3D svm_get_idt, - .set_idt =3D svm_set_idt, - .get_gdt =3D svm_get_gdt, - .set_gdt =3D svm_set_gdt, - .set_dr7 =3D svm_set_dr7, - .sync_dirty_debug_regs =3D svm_sync_dirty_debug_regs, - .cache_reg =3D svm_cache_reg, - .get_rflags =3D svm_get_rflags, - .set_rflags =3D svm_set_rflags, - .get_if_flag =3D svm_get_if_flag, - - .flush_tlb_all =3D svm_flush_tlb_current, - .flush_tlb_current =3D svm_flush_tlb_current, - .flush_tlb_gva =3D svm_flush_tlb_gva, - .flush_tlb_guest =3D svm_flush_tlb_current, - - .vcpu_pre_run =3D svm_vcpu_pre_run, - .vcpu_run =3D svm_vcpu_run, - .handle_exit =3D svm_handle_exit, - .skip_emulated_instruction =3D svm_skip_emulated_instruction, - .update_emulated_instruction =3D NULL, - .set_interrupt_shadow =3D svm_set_interrupt_shadow, - .get_interrupt_shadow =3D svm_get_interrupt_shadow, - .patch_hypercall =3D svm_patch_hypercall, - .inject_irq =3D svm_inject_irq, - .inject_nmi =3D svm_inject_nmi, - .queue_exception =3D svm_queue_exception, - .cancel_injection =3D svm_cancel_injection, - .interrupt_allowed =3D svm_interrupt_allowed, - .nmi_allowed =3D svm_nmi_allowed, - .get_nmi_mask =3D svm_get_nmi_mask, - .set_nmi_mask =3D svm_set_nmi_mask, - .enable_nmi_window =3D svm_enable_nmi_window, - .enable_irq_window =3D svm_enable_irq_window, - .update_cr8_intercept =3D svm_update_cr8_intercept, - .set_virtual_apic_mode =3D avic_set_virtual_apic_mode, - .refresh_apicv_exec_ctrl =3D avic_refresh_apicv_exec_ctrl, - .check_apicv_inhibit_reasons =3D avic_check_apicv_inhibit_reasons, - .load_eoi_exitmap =3D avic_load_eoi_exitmap, - .hwapic_irr_update =3D avic_hwapic_irr_update, - .hwapic_isr_update =3D avic_hwapic_isr_update, - .apicv_post_state_restore =3D avic_apicv_post_state_restore, - - .set_tss_addr =3D svm_set_tss_addr, - .set_identity_map_addr =3D svm_set_identity_map_addr, - .get_mt_mask =3D svm_get_mt_mask, - - .get_exit_info =3D svm_get_exit_info, - - .vcpu_after_set_cpuid =3D svm_vcpu_after_set_cpuid, - - .has_wbinvd_exit =3D svm_has_wbinvd_exit, - - .get_l2_tsc_offset =3D svm_get_l2_tsc_offset, - .get_l2_tsc_multiplier =3D svm_get_l2_tsc_multiplier, - .write_tsc_offset =3D svm_write_tsc_offset, - .write_tsc_multiplier =3D svm_write_tsc_multiplier, - - .load_mmu_pgd =3D svm_load_mmu_pgd, - - .check_intercept =3D svm_check_intercept, - .handle_exit_irqoff =3D svm_handle_exit_irqoff, - - .request_immediate_exit =3D __kvm_request_immediate_exit, - - .sched_in =3D svm_sched_in, =20 .pmu_ops =3D &amd_pmu_ops, .nested_ops =3D &svm_nested_ops, =20 - .deliver_interrupt =3D svm_deliver_interrupt, - .dy_apicv_has_pending_interrupt =3D avic_dy_apicv_has_pending_interrupt, - .pi_update_irte =3D avic_pi_update_irte, - .setup_mce =3D svm_setup_mce, +#define KVM_X86_OP(func) .func =3D svm_##func, +#define KVM_X86_APICV_OP(func) .func =3D avic_##func, +#define KVM_X86_CVM_OP(func) .func =3D sev_##func, =20 - .smi_allowed =3D svm_smi_allowed, - .enter_smm =3D svm_enter_smm, - .leave_smm =3D svm_leave_smm, - .enable_smi_window =3D svm_enable_smi_window, - - .mem_enc_ioctl =3D sev_mem_enc_ioctl, - .mem_enc_register_region =3D sev_mem_enc_register_region, - .mem_enc_unregister_region =3D sev_mem_enc_unregister_region, - - .vm_copy_enc_context_from =3D sev_vm_copy_enc_context_from, - .vm_move_enc_context_from =3D sev_vm_move_enc_context_from, - - .can_emulate_instruction =3D svm_can_emulate_instruction, - - .apic_init_signal_blocked =3D svm_apic_init_signal_blocked, - - .msr_filter_changed =3D svm_msr_filter_changed, - .complete_emulated_msr =3D svm_complete_emulated_msr, - - .vcpu_deliver_sipi_vector =3D svm_vcpu_deliver_sipi_vector, +/* Hyper-V hooks are filled at runtime. */ +#define KVM_X86_HYPERV_OP(func) .func =3D NULL, +#include }; =20 /* --=20 2.35.0.rc0.227.g00780c9af4-goog