From patchwork Tue Dec 13 06:09:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 32644 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2657747wrr; Mon, 12 Dec 2022 22:11:42 -0800 (PST) X-Google-Smtp-Source: AA0mqf4JDYEj+YZrtNQGX3tmD5cehdBKRxDrlHILH9zaNRoLAymTMvQNRuDY/MNNuSkXKHcK6PRA X-Received: by 2002:a17:906:7116:b0:7c1:8450:f963 with SMTP id x22-20020a170906711600b007c18450f963mr3914977ejj.34.1670911902397; Mon, 12 Dec 2022 22:11:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670911902; cv=none; d=google.com; s=arc-20160816; b=N153/CSS/O9l7WF+M3tDkJzljBBqy7l7O/U158lObZZ2JyO8U+QL/9OGj/E+xF28v8 r365jBTiHl3tFLTniJycAikWBprkJoLZwOwMwbM39mryvnZf5TKK7ZDHZEKgDpvRS58l LZVKqXzZs/jyKVfB99K0N1d8cC3ACBWADuiUqsLR+drrwk85q5YJxPsiwwpLBsOEzjOH bSvQ0KzGfSg8UVZ8H6AJ85O1IRNQGOyKQX/ARlYOquYv6H0aW+atojAsxYjmEGc+JGJj cLEo+apZkpxBGacW60sQpAxE/B0aV8WCGQns9dws/4dGVDi5A4VEaR/5YHedKxSsSBNB MOuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:reply-to:dkim-signature; bh=NFEhFRkg0+nIHx94jx/VqF2L4sTiUmledWciOk7WPsw=; b=Dwlv+38A4ccV1uItj1OcYeuU18ncOoiYi+WkqhXkcmRtI3AkTrRNJiaEIlz6Wc/t/a V0wsSUDwffnN6Y+sjF5t2vdpvKNjbYCT2IKIxL5xpoxQuzJQeKKS/S0bc9gcqmKo/pDy RenocjuF7dXmOVe6ZsuC8kBzBvbLuSeCueR5wB1WbMYU7+q7F0Ju2DV6K0Se/tuxn/8Y o73ASMCwUFbFW9fQ08KnCAxN7kiSKY4mR3H/wUF4t2hrB2cJLSflJVx61yHP2bGdYHlK QS34Jp1VHMyGEbwjLLEvZ6Eb01J3Xhlb57AHrqfysDH6DzUX97GqLoQt9NUHjyZXbcnE 5bZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Mb6tzs3Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sh37-20020a1709076ea500b0078d2f0bf546si917270ejc.186.2022.12.12.22.11.19; Mon, 12 Dec 2022 22:11:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Mb6tzs3Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234444AbiLMGJk (ORCPT + 99 others); Tue, 13 Dec 2022 01:09:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234391AbiLMGJY (ORCPT ); Tue, 13 Dec 2022 01:09:24 -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 9EC781A809 for ; Mon, 12 Dec 2022 22:09:23 -0800 (PST) Received: by mail-pf1-x44a.google.com with SMTP id cp23-20020a056a00349700b005775c52dbceso1406303pfb.21 for ; Mon, 12 Dec 2022 22:09:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=NFEhFRkg0+nIHx94jx/VqF2L4sTiUmledWciOk7WPsw=; b=Mb6tzs3YFjNk5QMuKsNyQaWTpQK6Q7lsJPdTl4vbogpOKDC+ntZV7Jpct4rB9qejgS +TtDI14OD1/tbbyL0L1wge29Emn1TKCNDyUVIVW/9MyHaXI0nXK8IvBdIC6yg8guyoAF gfuWOj8X/Vo1tvZWFwPCHpGbpQmSokz4ohTqy8O5ywgy8xNUQdq25HZyfOn06xVPbeHz f1jN5vSQgRJo2tLg2dmUbtNrbiKUpHc6IEDkC93EvSlNUWgEFgWzh466hT2saqDJ4VPo 6z92FRVBWysyeOs5/s4MlzrzvuBOUfUzSekVTf7PEWy4nB84hbdH6GhBOxMWrJyxaqJ0 D0sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=NFEhFRkg0+nIHx94jx/VqF2L4sTiUmledWciOk7WPsw=; b=OMdqhkjHrmc7VDOj4Rfj1Tyx1Z2pDX6f02PGC2NqgwtneMlyjHIgvUJ0QIC4dOgRVN 1P6WnAlCZlRr+zvNgdGz30/M74iQow8I7OMRDNvtz9MKjfTuhoswx7YM4jSqAcrMDWFB efF2nKkLwrCeZ7ot24HV/2SB2nw8jcrkQWOlZEBqxBsOPnASt+knCRRSDIFLVxcsf/Kl faT87OtPnuIeLUuy8SSRsslP+FKZmdznafTU/iHCiKmpCXIkeCZHeuBUjJnGbZFNBjv6 ojXX7BHsOvltZf6Eu/dVjrbzCE6iEc7U5jvJpVV25IxSf2lWUmzPlUr/N/llZghQ41Yp T8sw== X-Gm-Message-State: ANoB5plsP/e8HyOPdWrw6xyT/dUbLDhrmMEf3SZycRQZ27d3mphz2Jrr 3msOjD5YFAR3S99FhynPYWUh3pBSjeM= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:90b:2d90:b0:219:7904:6de with SMTP id sj16-20020a17090b2d9000b00219790406demr166821pjb.136.1670911763239; Mon, 12 Dec 2022 22:09:23 -0800 (PST) Reply-To: Sean Christopherson Date: Tue, 13 Dec 2022 06:09:09 +0000 In-Reply-To: <20221213060912.654668-1-seanjc@google.com> Mime-Version: 1.0 References: <20221213060912.654668-1-seanjc@google.com> X-Mailer: git-send-email 2.39.0.rc1.256.g54fd8350bd-goog Message-ID: <20221213060912.654668-5-seanjc@google.com> Subject: [PATCH 4/7] KVM: VMX: Always inline to_vmx() and to_kvm_vmx() From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Peter Zijlstra , Andy Lutomirski , Thomas Gleixner X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752078118774688145?= X-GMAIL-MSGID: =?utf-8?q?1752078118774688145?= Tag to_vmx() and to_kvm_vmx() __always_inline as they both just reflect the passed in pointer (the embedded struct is the first field in the container), and drop the @vmx param from vmx_vcpu_enter_exit(), which likely existed purely to make noinstr validation happy. Amusingly, when the compiler decides to not inline the helpers, e.g. for KASAN builds, to_vmx() and to_kvm_vmx() may end up pointing at the same symbol, which generates very confusing objtool warnings. E.g. the use of to_vmx() in a future patch led to objtool complaining about to_kvm_vmx(), and only once all use of to_kvm_vmx() was commented out did to_vmx() pop up in the obj tool report. vmlinux.o: warning: objtool: vmx_vcpu_enter_exit+0x160: call to to_kvm_vmx() leaves .noinstr.text section Signed-off-by: Sean Christopherson --- arch/x86/kvm/vmx/vmx.c | 5 +++-- arch/x86/kvm/vmx/vmx.h | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index fe5615fd8295..e2c96f204b82 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -7096,9 +7096,10 @@ static fastpath_t vmx_exit_handlers_fastpath(struct kvm_vcpu *vcpu) } static noinstr void vmx_vcpu_enter_exit(struct kvm_vcpu *vcpu, - struct vcpu_vmx *vmx, unsigned long flags) { + struct vcpu_vmx *vmx = to_vmx(vcpu); + guest_state_enter_irqoff(); /* L1D Flush includes CPU buffer clear to mitigate MDS */ @@ -7216,7 +7217,7 @@ static fastpath_t vmx_vcpu_run(struct kvm_vcpu *vcpu) kvm_wait_lapic_expire(vcpu); /* The actual VMENTER/EXIT is in the .noinstr.text section. */ - vmx_vcpu_enter_exit(vcpu, vmx, __vmx_vcpu_run_flags(vmx)); + vmx_vcpu_enter_exit(vcpu, __vmx_vcpu_run_flags(vmx)); /* All fields are clean at this point */ if (static_branch_unlikely(&enable_evmcs)) { diff --git a/arch/x86/kvm/vmx/vmx.h b/arch/x86/kvm/vmx/vmx.h index bb720a2f11ab..2acdc54bc34b 100644 --- a/arch/x86/kvm/vmx/vmx.h +++ b/arch/x86/kvm/vmx/vmx.h @@ -640,12 +640,12 @@ BUILD_CONTROLS_SHADOW(tertiary_exec, TERTIARY_VM_EXEC_CONTROL, 64) (1 << VCPU_EXREG_EXIT_INFO_1) | \ (1 << VCPU_EXREG_EXIT_INFO_2)) -static inline struct kvm_vmx *to_kvm_vmx(struct kvm *kvm) +static __always_inline struct kvm_vmx *to_kvm_vmx(struct kvm *kvm) { return container_of(kvm, struct kvm_vmx, kvm); } -static inline struct vcpu_vmx *to_vmx(struct kvm_vcpu *vcpu) +static __always_inline struct vcpu_vmx *to_vmx(struct kvm_vcpu *vcpu) { return container_of(vcpu, struct vcpu_vmx, vcpu); }