Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp1108865lqo; Fri, 17 May 2024 10:53:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWWw9wsins6bw8jQcvTEZnE0HL1UNWza3CNwm6nN2prGwMJJUYfZkV+DdWtOzE2iXhj1RSkVAhrRTb4D45zLWQH6NiHlJzsli2PEwS3Fg== X-Google-Smtp-Source: AGHT+IGo+sx15Dl30pA/9Djsoc1I+SldZGZ7pGYihrFVPD8tv0mLDCwUr1eNbaJTtKLgSVuWH9H2 X-Received: by 2002:a05:6808:7c3:b0:3c9:6594:8e31 with SMTP id 5614622812f47-3c997081ce7mr23014343b6e.35.1715968428018; Fri, 17 May 2024 10:53:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715968427; cv=pass; d=google.com; s=arc-20160816; b=y7k3GIajCk5FHYRIglGxPxAFcZP/zUnL4dl77RMvU5Ln5PGg38LdAlhDhDR69Wujpx Ab7Yz6HA9v3Pub/nsQ9Jd3y3xQDei0kdZja3ciJaoX/UN/5SEr6FKkHHbejJ/l3lkl3I +3Grg5pvrB2HTiktEMYFmLb/F3Shrl/RwCXO/ozF98Tf70ZiKGR6JNlCOdeZJznW8ASP BQVEk2/N2DPVONVGARmcZIYK1Iy+ZIZv8cYN63oFVhDsqHBk26wxOGt1UyVeCyJVrMlx syDwEtt9phh8MadAUMRMTpcv89A24mZ7CB3sJZkKJ+ezQ3Mecj0unAGly30OEI5PqLVb 8a4A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :reply-to:dkim-signature; bh=lWJTyML0btVQwtFr3Kj+PF9ZU7fFVwzZvNC575eeaaY=; fh=uEC3QJ0JIS6gD/BvwDSPhT/XgW6vqY4I3jI/NA5LaFE=; b=AvDzEQZemLenMxDHGWzClL4OCoW4GWysMsxYSJlDSEwtVrZ2k++pZGDk3pAA3a7WDA dxd92R9IOSktk2ksi/xU3VaNmzxLWM5vT+xdj7xaA114CB9fjXfOyzWUtBbFC5VCm877 WO+N/RZf/NlRHy32g3ysEBDOYU3cyFCtN6gfKUkdwjiHRQ9EY+5cnbAvwLD8Ra4zMJqP SNZuzzUh4OcK2SyGzVtrcT2PALNHcS34ZVtnbv6vxwTaiiwye7Bp1ucfidLiUozwOYZ3 ui8DQrvxsXMG4chWyua1hNF+rKGtcl1jaIU72UI0oIJudvtm6NHttK+MjvfaM67qJc4A qBpQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=l0VZBm7Q; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-182478-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182478-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-792bf277921si1593949885a.93.2024.05.17.10.53.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 May 2024 10:53:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-182478-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=l0VZBm7Q; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-182478-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182478-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id A7FBA1C225C5 for ; Fri, 17 May 2024 17:53:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E37C1158DD2; Fri, 17 May 2024 17:41:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="l0VZBm7Q" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ACF34158D7A for ; Fri, 17 May 2024 17:41:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715967671; cv=none; b=osAGi8SLBusWFG9Tm/vF+Q+xrJjBLOnaExFI7mPYiEl1SKUZ/ZpxQPO6bBA9V4ZYZ+EwazWoE8zZCG1DJiuhvLTAJC2SLidH0H2ua3Ooc4cvXOpTmrKfObTZbh4HuDuFZ2DFWmtCpqAgsQJS/0jOouUeZZPaUbyHqJrJi9UPr4g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715967671; c=relaxed/simple; bh=ln2oK/KM1gDoYeYR3eZfciWq5Jni2fklzotf5eA5PH0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=O1D+wD3vAM3vve/8kkFOGlqgC4tD2j5pdu1WsXTPc+PRE53UFHPCVfQ26IFdoimqq6felOfQiTsAj1F2HD0VIzMm06LI9LJHqnt6X+Ech7uS19IsrEjdQAaTIwzYWjlf5YJt/dTEHZgCnqIG/+qMrOm6ld2EC87fyVWqkaPZm7Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=l0VZBm7Q; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-de61a10141fso13424691276.1 for ; Fri, 17 May 2024 10:41:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715967669; x=1716572469; darn=vger.kernel.org; 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=lWJTyML0btVQwtFr3Kj+PF9ZU7fFVwzZvNC575eeaaY=; b=l0VZBm7Qa8qhk+V7SbE4WxiWD6ZJx6zcTHELTiN3ApWBtt80BnoXr7Y7pVonVh5clq zQatdburDI2XZU7bN431vdLwReIbkIkNkejT8mJQ1/qHQ/T4OGyXBhZsRyxyhiqLQvZJ Myf96Mxf+Wl3RQBRvQnIRVnhWDJM0K27ssmPTIHhwQGXBUQWglLIM4kAVr/NcnPFLenq +ASWR/k3W/TcZp12ytSC4EyNVr0aBpN42VzYSvte0H4209kaQUvkFCaZcboGLcf0yM6O PvI883LCyGuBaL25Uw3ecbwSAfA5TRJZgAJZSExomfy8cIxIxG/wMBxCwy74YECLoLNf Yb0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715967669; x=1716572469; 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=lWJTyML0btVQwtFr3Kj+PF9ZU7fFVwzZvNC575eeaaY=; b=axBDRW+2UPKCQ18Pn6oNJnqmk1wZIovX2oHMgp9C7eJmqRGKj0KFIim9a1lceLYrd7 Qesq71nT9GQ0LBrkgIv3bzuM90Ech2DVSiDwPx2yUCTbzS+m7B7KnHwlmb9lE9hiosw6 7okv7cOBDOgCVqLu8A6KeFPR9ENzoJel9BlNTe0itMKGLXMCzYeJN0z61QXWm0dpr4Lf n69irL5/CbEdw8mB82XA/VwoNV+3V+UoW74FyXLjcdiM7NK3X/qZ8TithWCfN8rokBs2 MMTz/0FlNzH7dQ7R1GV4gGUPqsMRF+ZsCY/VW+5HxH6fxRj0WUOVyqKRad6r5Z9QUJQz XreA== X-Forwarded-Encrypted: i=1; AJvYcCUCk0saPUgxZ2fEGqzIwc3du53lSMg/0L35Tnozjru4x3ILJ8irrPgmQJr/Xe16RAKhR4Coo1WxkjkH/0aAE0v77iyNZCi+T7XXU50O X-Gm-Message-State: AOJu0YzD8eQFdPQMZYtavrtMuCOA4KQDJVxdNk8m+H7OUIoS4IoKOzbX m+g6KutVq4iQ9YIY8e52+eEPNwqHXNNM9qEo+vCTyMOyQSgd/JdCn6Q/OGtqZh9XwaBpf6CsyFR ejQ== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:10c3:b0:dee:7c5c:e336 with SMTP id 3f1490d57ef6-dee7c5ce8a4mr1390438276.10.1715967668833; Fri, 17 May 2024 10:41:08 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 17 May 2024 10:39:22 -0700 In-Reply-To: <20240517173926.965351-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240517173926.965351-1-seanjc@google.com> X-Mailer: git-send-email 2.45.0.215.g3402c0e53f-goog Message-ID: <20240517173926.965351-46-seanjc@google.com> Subject: [PATCH v2 45/49] KVM: x86: Shuffle code to prepare for dropping guest_cpuid_has() From: Sean Christopherson To: Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Hou Wenlong , Kechen Lu , Oliver Upton , Maxim Levitsky , Binbin Wu , Yang Weijiang , Robert Hoo Content-Type: text/plain; charset="UTF-8" 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. Reviewed-by: Maxim Levitsky 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 60da304db4e4..7be56fa62342 100644 --- a/arch/x86/kvm/cpuid.h +++ b/arch/x86/kvm/cpuid.h @@ -168,21 +168,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; @@ -301,4 +286,19 @@ static inline bool kvm_vcpu_is_legal_cr3(struct kvm_vcpu *vcpu, unsigned long cr return kvm_vcpu_is_legal_gpa(vcpu, cr3); } +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 -- 2.45.0.215.g3402c0e53f-goog