Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp1111633lqo; Fri, 17 May 2024 11:00:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUUIAhzaAWm/HDZtPwB7uQKLJCPsRb4wlOsw1b06ZTMDGq33oD6SGkYn13VygukuNH4yjF+jaD6dUKRa8AhosDkKtrvw6nONxtkjEy1mA== X-Google-Smtp-Source: AGHT+IFX9H2aCP9WTgp7B2Rz0Z1sfSeN7Nhc1qukvm+ax207yHz0cWd7yXIDYz7nOSO8ajiXjXky X-Received: by 2002:a05:6a20:9498:b0:1a7:a3cb:7901 with SMTP id adf61e73a8af0-1afde1df659mr20266754637.61.1715968805004; Fri, 17 May 2024 11:00:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715968804; cv=pass; d=google.com; s=arc-20160816; b=xuESS/AGpo/CW3aqIBTh8sXAf6MPFcrX2HeUn8wJ5+zEt4Pm8S4Yf5azEfoifz2Ydp iJckMhVpah940ywWYj4sApFH1Q0h1oDQZQzLK48i7Fa1vKzJ113D5ZyWtWqNA7fr/hok LTp1RJbocjqwu2JDAnhbZUQzWyUMi7u7XBmkQOneXcPh0tFxJc8yKnjpU0DlG4FykaKn Eqo62DtQeYOKtSdlyc234sAschMAcGleo6IRuO4I3/URLltSFKKYNBOTZ3gYueVAWjNK NYQe+eo4oRhgjIJskDtcXPI+X+CcsiL6lOvPlbwveg6MysB7W8vIeRs9684eKb5es/XA IeTQ== 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=hnSx2cVkIAJFaLNy+y92FOfzJJRMl4049YLj6l59NXo=; fh=cOfnEXF9R6lsPgvrSZv2kJeK7Tfk57sGMDdQiW5fro0=; b=OmSqx795X1CMw49CeOPv3B8/Zr78dF2r0Obzqt3jbWxKx8UK98Sc5Ojx2CA+gFYBB5 k8hUc4765cqs5W+NgQpy3zxlJhIXVK82mc6pkD4q63N/LS8zZ4JcQf63FGbLZo7mv+4D ZQb/ERMuvCbo8jUUgsZLQyRPwK2e37mKLosSGHDUBP5EeHGNkPpOPgIAlxXZJM72gm8k h0wH7A3/6zgFlYxazSz6mrVKW3ldl2e8fsbtfhhzEpmB+m9pESk+5fMCssTcNbMvMyQe jFBl+uqUDpomJqdmCgN7yLxJOVUEbUHdiQdVLI52kPLK1Djjv2Qze0kCHGFFutqAhmCA 92vA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Vl8EV0QB; 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-182453-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182453-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-63413d72e88si17810909a12.855.2024.05.17.11.00.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 May 2024 11:00:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-182453-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Vl8EV0QB; 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-182453-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182453-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 84D9F2898F8 for ; Fri, 17 May 2024 17:46:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7586113E40C; Fri, 17 May 2024 17:40:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Vl8EV0QB" Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.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 D749614B956 for ; Fri, 17 May 2024 17:40:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715967624; cv=none; b=kmRH4Z/lc9z/mb0nmxrwUT61IEdCJtBXy0DtvqIg4gAijtTmxBEare7HGQjRwRlqvBxu/csjuV5fk2h4LIGOdMCwHyOHcVQhlWH+D1J3OZWq0b8mwTgQNdyai/iDpuUNsnE7sojWip28W2zT2LwrZyqYlpBi0YXOGYQmBnGj5Y4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715967624; c=relaxed/simple; bh=6hq41gtk1Pj0wLH+o0Np31/aebxJnq6BX/7eraPEjj8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=KffwdziQacdgJsHOJnt7tlbF7kM4etuTek+Sw7YedqoEF9eKLmZ8IsSFlBRfv/SVbyX+VDSxQd4IxWvcZeRBJye8SUYubLCQdcINeW3RWz/bmc0yz9D+Okr/a0ZfBL0K7Qp85qg+SRZVlwkmdYLN7UfFX234Zu1xENjqgOoWkt8= 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=Vl8EV0QB; arc=none smtp.client-ip=209.85.215.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-pg1-f202.google.com with SMTP id 41be03b00d2f7-5cfc2041cdfso7979080a12.2 for ; Fri, 17 May 2024 10:40:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715967622; x=1716572422; 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=hnSx2cVkIAJFaLNy+y92FOfzJJRMl4049YLj6l59NXo=; b=Vl8EV0QB4uZfyWUK7ov7oLtzRM+5g/PXgEoviro3QYlqIN5mgYEAEoQBwJ850DA/Y0 TPyq75xPMSe5InWQro/Z9n7DRQ48Zm6ew4k4+TKdAF+ovDXWrEz3SPTMoJcU/F41hU3G 5uZaZKHfiT/mJDfQZovTVUjwmB6R+RAvlul7pHgyOJ119WKfg6ulhaP7TIpG9xIR8J4J YDttTF1yc0kX49U6oz44bVVLGucjKLnzRCAo822qdy3xF+g/jlzKcKLzak1+/eQY3ip0 4htBmmXaAJ92tBWP7pRRiUDM/DttBMRpCZEXjkpFyCrpSGJ21RdgzR/szKHHL7onSu/N 1koA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715967622; x=1716572422; 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=hnSx2cVkIAJFaLNy+y92FOfzJJRMl4049YLj6l59NXo=; b=xILfd4dPwhX8B66kIUVlhbqnhhxqKrN+zHmaWxcxIbfdy8sZbxcjcaYd14Jo8nHhk3 A7IF6QwLRuNnJofWpdKOwMtOA3j8BGZqY5LDrHVuwMTe+6todTMsTDcMCXQMyOivkVZ6 3UTs+EBrxrVu3oyg3K03iHAekBkBxn+fcAmL3mlc+QV1TKGMXZGW6WBE2CuXN/Fe0LQ5 6ocrSWgBCjVj9vkjtLoiSRuLdve20F5n/LAEhvipyKDtYolnN4GF6sNerjfI5jceGJZu 7CYkBzjO5aDARYMM/EzkQLeCXKCHt+5gUCibxNZoY6ezqXf+/b1DVv+hQ/nVzyBkdG8V i2+g== X-Forwarded-Encrypted: i=1; AJvYcCUbt+mQ8JfNUslXXbm6XC627mXFrajke6RTh5JasYc9XwTmss4Xt0Px8Yl+5DSwdtj072Krb/6Sl5u1ChsebejljZB12K6N30nZsHCU X-Gm-Message-State: AOJu0YxTsMaRyHsmx6wq73WqexPW6X3/NOV/VFBBEOdY/44p37F+TCXZ knMF/uAdglyJqVwHMq8uNyXWaSba5e+sD3kTY91UW/VRZVVLqMkVGE4IyQequQkfIum+3D82fLK v1w== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a63:90c9:0:b0:659:237f:ed1a with SMTP id 41be03b00d2f7-659237fed5amr13907a12.7.1715967622162; Fri, 17 May 2024 10:40:22 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 17 May 2024 10:38:57 -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-21-seanjc@google.com> Subject: [PATCH v2 20/49] KVM: x86: Rename kvm_cpu_cap_mask() to kvm_cpu_cap_init() 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" Rename kvm_cpu_cap_mask() to kvm_cpu_cap_init() in anticipation of merging it with kvm_cpu_cap_init_kvm_defined(), and in anticipation of _setting_ bits in the helper (a future commit will play macro games to set emulated feature flags via kvm_cpu_cap_init()). No functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/kvm/cpuid.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index a802c09b50ab..5a4d6138c4f1 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -74,7 +74,7 @@ u32 xstate_required_size(u64 xstate_bv, bool compacted) * Raw Feature - For features that KVM supports based purely on raw host CPUID, * i.e. that KVM virtualizes even if the host kernel doesn't use the feature. * Simply force set the feature in KVM's capabilities, raw CPUID support will - * be factored in by kvm_cpu_cap_mask(). + * be factored in by __kvm_cpu_cap_mask(). */ #define RAW_F(name) \ ({ \ @@ -619,7 +619,7 @@ static __always_inline void __kvm_cpu_cap_mask(unsigned int leaf) static __always_inline void kvm_cpu_cap_init_kvm_defined(enum kvm_only_cpuid_leafs leaf, u32 mask) { - /* Use kvm_cpu_cap_mask for leafs that aren't KVM-only. */ + /* Use kvm_cpu_cap_init for leafs that aren't KVM-only. */ BUILD_BUG_ON(leaf < NCAPINTS); kvm_cpu_caps[leaf] = mask; @@ -627,7 +627,7 @@ void kvm_cpu_cap_init_kvm_defined(enum kvm_only_cpuid_leafs leaf, u32 mask) __kvm_cpu_cap_mask(leaf); } -static __always_inline void kvm_cpu_cap_mask(enum cpuid_leafs leaf, u32 mask) +static __always_inline void kvm_cpu_cap_init(enum cpuid_leafs leaf, u32 mask) { /* Use kvm_cpu_cap_init_kvm_defined for KVM-only leafs. */ BUILD_BUG_ON(leaf >= NCAPINTS); @@ -656,7 +656,7 @@ void kvm_set_cpu_caps(void) memcpy(&kvm_cpu_caps, &boot_cpu_data.x86_capability, sizeof(kvm_cpu_caps) - (NKVMCAPINTS * sizeof(*kvm_cpu_caps))); - kvm_cpu_cap_mask(CPUID_1_ECX, + kvm_cpu_cap_init(CPUID_1_ECX, /* * NOTE: MONITOR (and MWAIT) are emulated as NOP, but *not* * advertised to guests via CPUID! @@ -673,7 +673,7 @@ void kvm_set_cpu_caps(void) /* KVM emulates x2apic in software irrespective of host support. */ kvm_cpu_cap_set(X86_FEATURE_X2APIC); - kvm_cpu_cap_mask(CPUID_1_EDX, + kvm_cpu_cap_init(CPUID_1_EDX, F(FPU) | F(VME) | F(DE) | F(PSE) | F(TSC) | F(MSR) | F(PAE) | F(MCE) | F(CX8) | F(APIC) | 0 /* Reserved */ | F(SEP) | @@ -684,7 +684,7 @@ void kvm_set_cpu_caps(void) 0 /* HTT, TM, Reserved, PBE */ ); - kvm_cpu_cap_mask(CPUID_7_0_EBX, + kvm_cpu_cap_init(CPUID_7_0_EBX, F(FSGSBASE) | F(SGX) | F(BMI1) | F(HLE) | F(AVX2) | F(FDP_EXCPTN_ONLY) | F(SMEP) | F(BMI2) | F(ERMS) | F(INVPCID) | F(RTM) | F(ZERO_FCS_FDS) | 0 /*MPX*/ | F(AVX512F) | @@ -693,7 +693,7 @@ void kvm_set_cpu_caps(void) F(AVX512ER) | F(AVX512CD) | F(SHA_NI) | F(AVX512BW) | F(AVX512VL)); - kvm_cpu_cap_mask(CPUID_7_ECX, + kvm_cpu_cap_init(CPUID_7_ECX, F(AVX512VBMI) | RAW_F(LA57) | F(PKU) | 0 /*OSPKE*/ | F(RDPID) | F(AVX512_VPOPCNTDQ) | F(UMIP) | F(AVX512_VBMI2) | F(GFNI) | F(VAES) | F(VPCLMULQDQ) | F(AVX512_VNNI) | F(AVX512_BITALG) | @@ -708,7 +708,7 @@ void kvm_set_cpu_caps(void) if (!tdp_enabled || !boot_cpu_has(X86_FEATURE_OSPKE)) kvm_cpu_cap_clear(X86_FEATURE_PKU); - kvm_cpu_cap_mask(CPUID_7_EDX, + kvm_cpu_cap_init(CPUID_7_EDX, F(AVX512_4VNNIW) | F(AVX512_4FMAPS) | F(SPEC_CTRL) | F(SPEC_CTRL_SSBD) | F(ARCH_CAPABILITIES) | F(INTEL_STIBP) | F(MD_CLEAR) | F(AVX512_VP2INTERSECT) | F(FSRM) | @@ -727,7 +727,7 @@ void kvm_set_cpu_caps(void) if (boot_cpu_has(X86_FEATURE_AMD_SSBD)) kvm_cpu_cap_set(X86_FEATURE_SPEC_CTRL_SSBD); - kvm_cpu_cap_mask(CPUID_7_1_EAX, + kvm_cpu_cap_init(CPUID_7_1_EAX, F(AVX_VNNI) | F(AVX512_BF16) | F(CMPCCXADD) | F(FZRM) | F(FSRS) | F(FSRC) | F(AMX_FP16) | F(AVX_IFMA) | F(LAM) @@ -743,7 +743,7 @@ void kvm_set_cpu_caps(void) F(BHI_CTRL) | F(MCDT_NO) ); - kvm_cpu_cap_mask(CPUID_D_1_EAX, + kvm_cpu_cap_init(CPUID_D_1_EAX, F(XSAVEOPT) | F(XSAVEC) | F(XGETBV1) | F(XSAVES) | f_xfd ); @@ -751,7 +751,7 @@ void kvm_set_cpu_caps(void) SF(SGX1) | SF(SGX2) | SF(SGX_EDECCSSA) ); - kvm_cpu_cap_mask(CPUID_8000_0001_ECX, + kvm_cpu_cap_init(CPUID_8000_0001_ECX, F(LAHF_LM) | F(CMP_LEGACY) | 0 /*SVM*/ | 0 /* ExtApicSpace */ | F(CR8_LEGACY) | F(ABM) | F(SSE4A) | F(MISALIGNSSE) | F(3DNOWPREFETCH) | F(OSVW) | 0 /* IBS */ | F(XOP) | @@ -759,7 +759,7 @@ void kvm_set_cpu_caps(void) F(TOPOEXT) | 0 /* PERFCTR_CORE */ ); - kvm_cpu_cap_mask(CPUID_8000_0001_EDX, + kvm_cpu_cap_init(CPUID_8000_0001_EDX, F(FPU) | F(VME) | F(DE) | F(PSE) | F(TSC) | F(MSR) | F(PAE) | F(MCE) | F(CX8) | F(APIC) | 0 /* Reserved */ | F(SYSCALL) | @@ -777,7 +777,7 @@ void kvm_set_cpu_caps(void) SF(CONSTANT_TSC) ); - kvm_cpu_cap_mask(CPUID_8000_0008_EBX, + kvm_cpu_cap_init(CPUID_8000_0008_EBX, F(CLZERO) | F(XSAVEERPTR) | F(WBNOINVD) | F(AMD_IBPB) | F(AMD_IBRS) | F(AMD_SSBD) | F(VIRT_SSBD) | F(AMD_SSB_NO) | F(AMD_STIBP) | F(AMD_STIBP_ALWAYS_ON) | @@ -811,13 +811,13 @@ void kvm_set_cpu_caps(void) * Hide all SVM features by default, SVM will set the cap bits for * features it emulates and/or exposes for L1. */ - kvm_cpu_cap_mask(CPUID_8000_000A_EDX, 0); + kvm_cpu_cap_init(CPUID_8000_000A_EDX, 0); - kvm_cpu_cap_mask(CPUID_8000_001F_EAX, + kvm_cpu_cap_init(CPUID_8000_001F_EAX, 0 /* SME */ | 0 /* SEV */ | 0 /* VM_PAGE_FLUSH */ | 0 /* SEV_ES */ | F(SME_COHERENT)); - kvm_cpu_cap_mask(CPUID_8000_0021_EAX, + kvm_cpu_cap_init(CPUID_8000_0021_EAX, F(NO_NESTED_DATA_BP) | F(LFENCE_RDTSC) | 0 /* SmmPgCfgLock */ | F(NULL_SEL_CLR_BASE) | F(AUTOIBRS) | 0 /* PrefetchCtlMsr */ | F(WRMSR_XX_BASE_NS) @@ -837,7 +837,7 @@ void kvm_set_cpu_caps(void) * kernel. LFENCE_RDTSC was a Linux-defined synthetic feature long * before AMD joined the bandwagon, e.g. LFENCE is serializing on most * CPUs that support SSE2. On CPUs that don't support AMD's leaf, - * kvm_cpu_cap_mask() will unfortunately drop the flag due to ANDing + * kvm_cpu_cap_init() will unfortunately drop the flag due to ANDing * the mask with the raw host CPUID, and reporting support in AMD's * leaf can make it easier for userspace to detect the feature. */ @@ -847,7 +847,7 @@ void kvm_set_cpu_caps(void) kvm_cpu_cap_set(X86_FEATURE_NULL_SEL_CLR_BASE); kvm_cpu_cap_set(X86_FEATURE_NO_SMM_CTL_MSR); - kvm_cpu_cap_mask(CPUID_C000_0001_EDX, + kvm_cpu_cap_init(CPUID_C000_0001_EDX, F(XSTORE) | F(XSTORE_EN) | F(XCRYPT) | F(XCRYPT_EN) | F(ACE2) | F(ACE2_EN) | F(PHE) | F(PHE_EN) | F(PMM) | F(PMM_EN) -- 2.45.0.215.g3402c0e53f-goog