Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp1773744rdb; Sun, 19 Nov 2023 09:35:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IHr1dzLA8tjAKwB20VxA6DcC7gD3NLnt2y6Q8FOFEIBe6jk/gHIW/QSKg2/CY/5dUV5IDiA X-Received: by 2002:a17:902:db03:b0:1cc:4fbe:9278 with SMTP id m3-20020a170902db0300b001cc4fbe9278mr4674426plx.50.1700415355832; Sun, 19 Nov 2023 09:35:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700415355; cv=none; d=google.com; s=arc-20160816; b=Nvc3V7/AZXxhnmQ5EK/Sa47iyzOLyeUdcBuO5axinDCQ3X75xk7Ix3W1fSyhhlYXqw abiNfpQ7ite18z980PR4byrmFqQ8Pkbhl0LO0wHHpov2rU3hjBw8J/cJPvYgflBZWiEQ DSo9D+ZImpkNw6ZiP2RtGkdbAG1bpP5KuQAVY3Kx3zUWFd0Kki7p8bTEUQ8UutiRSXIB rSgQHYqWVs6fsCJmc5kuj3LyWpOThneeg5/QD/Owi+UP6xgXyFx/G9UNt0i1uv3YRR+E hmWwOkBWiRmu7TsVRLdoVz5SMHRZ2ZHv12GDpanKz63F97URVTO1W3Z18QgHKt0MJfUc +NJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=3okOyMxyER+1UcLcyJrkl/ivMZnxpI75V+9VEqz4llI=; fh=a/B0iV5LWklS7QUR0cRnqbJdAtXzyhd2Xbve3+VFDMU=; b=f8mTTomrs90DJl9g9pQz/9aLdjwWJC9YRgr8l4W56Qq2+wSNif26Fs2RWFXNB3N/DL ZMX5Q9F+PJJupuQkeHm9hNgCcB8Y11DB69K3hzfOYpwDzgJpujvqBjA3htPivHX2QEi8 MoSW1vzWv3lZlLXPsUIS4sqaCVv7jONgEEpQil5tH1hawt6ph17xh1aGQTI1+vVmB22Y sxPQgNYRFdqIpZjCdffb9tCI21kaJ8w8NdUp4DVYDkrLGu3XU23UWvcGdkW0pGqtz6FZ SdwEEIE+9sUoO1K3saAY3qqrUUG0GloAOwiBYb9i7TYaz4723wv2DCx4R70i6D0KsM1B EpTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="FmW/OTdl"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id jj14-20020a170903048e00b001c60783985esi6244325plb.93.2023.11.19.09.35.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Nov 2023 09:35:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="FmW/OTdl"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 4CD9180AC5B0; Sun, 19 Nov 2023 09:35:53 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231559AbjKSRfx (ORCPT + 99 others); Sun, 19 Nov 2023 12:35:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231551AbjKSRfv (ORCPT ); Sun, 19 Nov 2023 12:35:51 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97F78115 for ; Sun, 19 Nov 2023 09:35:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700415346; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3okOyMxyER+1UcLcyJrkl/ivMZnxpI75V+9VEqz4llI=; b=FmW/OTdlQ8qdwwBH6ruR01LLmVBOdZnFoXTF1Q3IbrB8JrLkoToyaTZ1anjweEEm+Ks7Hn PVqKz41Ynt4MjXdtPPhSzh+t8kKBSn2nOCS02b8JYGTEpgNYi7aaUWRftD6y2pKokRqeLm Pg06j+b0KDPmNYHZb0vXwfGLkpoAhHY= Received: from mail-lj1-f199.google.com (mail-lj1-f199.google.com [209.85.208.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-529-fq6mEnELMf6-_go1-EaEkQ-1; Sun, 19 Nov 2023 12:35:44 -0500 X-MC-Unique: fq6mEnELMf6-_go1-EaEkQ-1 Received: by mail-lj1-f199.google.com with SMTP id 38308e7fff4ca-2c53ea92642so32001721fa.2 for ; Sun, 19 Nov 2023 09:35:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700415343; x=1701020143; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=3okOyMxyER+1UcLcyJrkl/ivMZnxpI75V+9VEqz4llI=; b=SYW4Gbe3DgPcSpMIK8tnzObZG5+8ZVTzdL11Nzbm0oChb+60RDGhKx/+BEQ9AtDIs7 2L/WfmLRHB9eSmce+WUZKsv1tUdsC2M/wvNMwH2P/IiEGZ8DMWynVYAjVhXvYFQn0keN J2lZ791NEOKpNUXJFaH5gXCLdCkmUiHQBS0hhcPAffFrRVytbQe8Bg+Jt0ygjFW/Y4r/ mHBUfr8hm89uUjEGRAnUd4dYSkEaGXQjyem/WwXcZR2zZFpHL+NAt1ML21GTNBHvQXXR Fy75s9332IxcjXg0xurI0Vm5ZuyobXS9Df3TMS8qj7TafLtoJKSNWmkpu1lkdwjYerNh GapQ== X-Gm-Message-State: AOJu0YyKhLXDeeIk54zC36DOcfaV+re89f4XSwoIwWvv+1FdrQsmtjPN vlWTS3ECDJ86zLYFFd54YHTWEK44lR0QeD6hew9g7eMpvd+pK6k2wykNxCbK/NNm96vVgdGZJ1W dTvrsl320Pni3UdTmp9Xv4Kax X-Received: by 2002:a2e:9b18:0:b0:2c8:7192:800 with SMTP id u24-20020a2e9b18000000b002c871920800mr3134540lji.51.1700415343491; Sun, 19 Nov 2023 09:35:43 -0800 (PST) X-Received: by 2002:a2e:9b18:0:b0:2c8:7192:800 with SMTP id u24-20020a2e9b18000000b002c871920800mr3134533lji.51.1700415343158; Sun, 19 Nov 2023 09:35:43 -0800 (PST) Received: from starship ([77.137.131.4]) by smtp.gmail.com with ESMTPSA id c20-20020a7bc854000000b0040a43d458c9sm14662541wml.25.2023.11.19.09.35.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Nov 2023 09:35:42 -0800 (PST) Message-ID: <325fd3126a72c926b9d8d0ee060f90ce6d8a582e.camel@redhat.com> Subject: Re: [PATCH 7/9] KVM: x86: Shuffle code to prepare for dropping guest_cpuid_has() From: Maxim Levitsky To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Date: Sun, 19 Nov 2023 19:35:40 +0200 In-Reply-To: <20231110235528.1561679-8-seanjc@google.com> References: <20231110235528.1561679-1-seanjc@google.com> <20231110235528.1561679-8-seanjc@google.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sun, 19 Nov 2023 09:35:53 -0800 (PST) On Fri, 2023-11-10 at 15:55 -0800, Sean Christopherson wrote: > Move the implementations of guest_has_{spec_ctrl,pred_cmd}_msr() down > below guest_cpu_cap_has() so that their use of guest_cpuid_has() can be > replaced with calls to guest_cpu_cap_has(). > > No functional change intended. > > Signed-off-by: Sean Christopherson > --- > arch/x86/kvm/cpuid.h | 30 +++++++++++++++--------------- > 1 file changed, 15 insertions(+), 15 deletions(-) > > diff --git a/arch/x86/kvm/cpuid.h b/arch/x86/kvm/cpuid.h > index 1707ef10b269..bebf94a69630 100644 > --- a/arch/x86/kvm/cpuid.h > +++ b/arch/x86/kvm/cpuid.h > @@ -163,21 +163,6 @@ static inline int guest_cpuid_stepping(struct kvm_vcpu *vcpu) > return x86_stepping(best->eax); > } > > -static inline bool guest_has_spec_ctrl_msr(struct kvm_vcpu *vcpu) > -{ > - return (guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL) || > - guest_cpuid_has(vcpu, X86_FEATURE_AMD_STIBP) || > - guest_cpuid_has(vcpu, X86_FEATURE_AMD_IBRS) || > - guest_cpuid_has(vcpu, X86_FEATURE_AMD_SSBD)); > -} > - > -static inline bool guest_has_pred_cmd_msr(struct kvm_vcpu *vcpu) > -{ > - return (guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL) || > - guest_cpuid_has(vcpu, X86_FEATURE_AMD_IBPB) || > - guest_cpuid_has(vcpu, X86_FEATURE_SBPB)); > -} > - > static inline bool supports_cpuid_fault(struct kvm_vcpu *vcpu) > { > return vcpu->arch.msr_platform_info & MSR_PLATFORM_INFO_CPUID_FAULT; > @@ -298,4 +283,19 @@ static __always_inline bool guest_cpu_cap_has(struct kvm_vcpu *vcpu, > return vcpu->arch.cpu_caps[x86_leaf] & __feature_bit(x86_feature); > } > > +static inline bool guest_has_spec_ctrl_msr(struct kvm_vcpu *vcpu) > +{ > + return (guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL) || > + guest_cpuid_has(vcpu, X86_FEATURE_AMD_STIBP) || > + guest_cpuid_has(vcpu, X86_FEATURE_AMD_IBRS) || > + guest_cpuid_has(vcpu, X86_FEATURE_AMD_SSBD)); > +} > + > +static inline bool guest_has_pred_cmd_msr(struct kvm_vcpu *vcpu) > +{ > + return (guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL) || > + guest_cpuid_has(vcpu, X86_FEATURE_AMD_IBPB) || > + guest_cpuid_has(vcpu, X86_FEATURE_SBPB)); > +} > + > #endif Reviewed-by: Maxim Levitsky Best regards, Maxim Levitsky