Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp1106996lqo; Fri, 17 May 2024 10:49:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW+Twjd7K4XIvHMTW24uAX9KPzzKN+70TOOyonlWrqKvhTXFODCLBjd1r4BCFQBatmSdASuzdxmQEdDduVfwJWhPcSyg+arhcV5j1I+Xw== X-Google-Smtp-Source: AGHT+IF9ZaooW0hgT27YBzz/kAcnd22507R1DfSBnNPKhi3CSO4yETSxvsaE+eUtAVRU5zZSeOif X-Received: by 2002:a17:902:650e:b0:1e9:a0ce:f618 with SMTP id d9443c01a7336-1ef442ba9c5mr220268115ad.69.1715968177670; Fri, 17 May 2024 10:49:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715968177; cv=pass; d=google.com; s=arc-20160816; b=VOORGwQKs2z67pe7iYZ1NI4YyWed4NBfGnz+lTLhp2zzuLS+iP5lCxJEcqlUYXmk5c RMwiXh6+30IRe3Rvcto0YZweg43k6sEcCUY2E6cNWDp4yEwHlnJ8ceLv2s192nPrKyx5 A8iqM5Q60H+5bNG04ezy9UQQK7ZAGsEvW7s3mlgQzhySRcOMC5I//Ii+E4n6VXQCsHeN 57eAdOsV4VJuKHJgznI3N7VACjIL/MWP6LPPI0LWTustKNMtVUlVTy2Wm3PLRGJCuFDB VZX0EgQ4+6eAH5WAB4iEqQVWh4yVzB+iVIRyP28y/6BFmNrSPcdSmn7VU1cbH5Psm8UZ Qtng== 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=2pz7YgP7vcZ5afCmvotaPNlE5OZ8SYZNDln97glxEfU=; fh=21CiXBNy2IrdT0R894KEsjrhbEPyVZcjvRbVPy0JIkU=; b=ZgtRuT66wHvyx8g3+iM7yG0KXSW02QwhGzwxfHmWHyVSyOrAcrEi16xieegYnUhSwG ilr+5avPs+mOPvkVIysvoXi5LY/XPfprQ0LiIfugLuyvDHxQfZ3WoGOr6vKuFePA7ZmF u0x+xS1pDwexMDOwww8QQPIKvfNH2/lYkEP7AOuvrZnDkxLx7hku0AU1pch/WU64ZUbn 9opq6LQF/IYdpIxTKk/zoX33CcpUzv8oOH7amsdXPYf4+BbKHjNJA51eTL8/mTZB4o8s E7W96xc1pirnzbykfiP4F9R6BZVMZXyszKdraV09fdGO9A3HlS9U5lrfXWQ5TPn+1CQb 3zlw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=O0eCM8KV; 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-182450-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182450-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d9443c01a7336-1ef0c153833si184363465ad.473.2024.05.17.10.49.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 May 2024 10:49:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-182450-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=O0eCM8KV; 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-182450-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182450-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 8882BB235A8 for ; Fri, 17 May 2024 17:45:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8D0AE145325; Fri, 17 May 2024 17:40:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="O0eCM8KV" Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (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 53ADC1448D9 for ; Fri, 17 May 2024 17:40:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715967617; cv=none; b=qbitH/uEfdC2OBHP7IVrNJvoUsU/YdVZhQpbmbs/yYPuvmg0JdvdJBj0H60uVS9GL9CJ5AW+RautoGs19Q4ZmTnHW259kcanGKZb0yjotSiZk5jWp229gb5jyhPaj2xMSN8gNjwbroU/wU05zoarVb1JRiqF7lzP/CQVvOk5aqo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715967617; c=relaxed/simple; bh=CrAZspNK1WyzfzQdMro0gv3zS+R+XJvPdMTGMRibFVA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=WmXcdufUHrY093YGwonNeMoxd6I0V87nNSCXnrV5rx7V4JO7YISRaugL/PeKqG86JNlCLPmwAIdw3LSYqggtNzeSLpzmxBqWolJN9PWi2lquGYl620L94xH7dv4s7hsrDT/cOhOU3QklREfIub+ILd2NoxI3a1lDMZn862i2fsA= 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=O0eCM8KV; arc=none smtp.client-ip=209.85.128.201 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-yw1-f201.google.com with SMTP id 00721157ae682-61c9e36888bso163284517b3.2 for ; Fri, 17 May 2024 10:40:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715967615; x=1716572415; 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=2pz7YgP7vcZ5afCmvotaPNlE5OZ8SYZNDln97glxEfU=; b=O0eCM8KVwR3XBMbZ+yXJRvoE+4DcA7e41fl+qXz9Ga4Nk/xt9/QMvfb7snA4EAt5x+ iAsCjb2dPeRrjUSWzt1Qs0X2UILR+P2kJq884wCchfQ3bx1p3CGljeko+RZjleInuTHD /guLBKNFlWzaGoEvB2uRjP3/LoDXAevN4ZCJfdZ8OYKve13BEnbkoYluK471elk5EryH HYwVJk9SfGDobxdUNH6myUdB3DnWTpG0pf239oM60eiPX93SxkqJLc4Q/KfILg80tCv2 CJPbQ9l1aF4Hvlhdfc5yIiEtl9edExeIZPu/gbTc27RRtlYI7Z3yXjpgezIGSCqCl9g5 ocew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715967615; x=1716572415; 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=2pz7YgP7vcZ5afCmvotaPNlE5OZ8SYZNDln97glxEfU=; b=kaRUwtkgwfxLRHsDPt6m3eF7hNDoEkgcQfak+QQlb119OWeYRrrZquS1PIgEz46hpl i7aszLK7Vm3pAPkgq6lkJe6pT/83Nj7kDyc1GMoB36YIpqW+JiacVxYO5ocalD2YmqxB KhyZu/knE9NzD1XCk6+74D3thtfSYfIdaQHhUvc1pVn00t8wtD/agqre+4beQjT73LUm 7jgV/I4Chwe77IdXC+xPTDpe67nxTg0WvlZb2LToIIOLCuy3nH6Cpix9KvEi8+hhBH3O /lhh7XxoTh5g+efnVBE3fr91eeYZM/tUOGwCYX1By9Ecb6n/hLBuj7LW4+rAKepSf/YQ J72A== X-Forwarded-Encrypted: i=1; AJvYcCUbAXj5Br9izBDi94NIyMMKkRMzmc8Ozf0cn2h9W1eWoSJKYMMf41C2A6/M8TXYi5AfWfvHpiEkx16nR40JVxkL/lKxGZKuvV3FpmSJ X-Gm-Message-State: AOJu0Yx+AnRrZhHh1id49AFA/bSJQQlQfZFFazNPD1IZd/wrZ60WXlky SPdXYYcRdDgK+PeQk5sVV1ikEMBPvoOwbGczeTJiS0VjSLbGtK9HRdDjq3chnkVeTY9XpZ/uCmx fzQ== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a81:6d97:0:b0:627:3c45:4a90 with SMTP id 00721157ae682-6273c454b1emr16064777b3.4.1715967615528; Fri, 17 May 2024 10:40:15 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 17 May 2024 10:38:54 -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-18-seanjc@google.com> Subject: [PATCH v2 17/49] KVM: x86: Do reverse CPUID sanity checks in __feature_leaf() 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" Do the compile-time sanity checks on reverse_cpuid in __feature_leaf() so that higher level APIs don't need to "manually" perform the sanity checks. No functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/kvm/cpuid.h | 3 --- arch/x86/kvm/reverse_cpuid.h | 6 ++++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/arch/x86/kvm/cpuid.h b/arch/x86/kvm/cpuid.h index 7eb3d7318fc4..d68b7d879820 100644 --- a/arch/x86/kvm/cpuid.h +++ b/arch/x86/kvm/cpuid.h @@ -198,7 +198,6 @@ static __always_inline void kvm_cpu_cap_clear(unsigned int x86_feature) { unsigned int x86_leaf = __feature_leaf(x86_feature); - reverse_cpuid_check(x86_leaf); kvm_cpu_caps[x86_leaf] &= ~__feature_bit(x86_feature); } @@ -206,7 +205,6 @@ static __always_inline void kvm_cpu_cap_set(unsigned int x86_feature) { unsigned int x86_leaf = __feature_leaf(x86_feature); - reverse_cpuid_check(x86_leaf); kvm_cpu_caps[x86_leaf] |= __feature_bit(x86_feature); } @@ -214,7 +212,6 @@ static __always_inline u32 kvm_cpu_cap_get(unsigned int x86_feature) { unsigned int x86_leaf = __feature_leaf(x86_feature); - reverse_cpuid_check(x86_leaf); return kvm_cpu_caps[x86_leaf] & __feature_bit(x86_feature); } diff --git a/arch/x86/kvm/reverse_cpuid.h b/arch/x86/kvm/reverse_cpuid.h index 2f4e155080ba..245f71c16272 100644 --- a/arch/x86/kvm/reverse_cpuid.h +++ b/arch/x86/kvm/reverse_cpuid.h @@ -136,7 +136,10 @@ static __always_inline u32 __feature_translate(int x86_feature) static __always_inline u32 __feature_leaf(int x86_feature) { - return __feature_translate(x86_feature) / 32; + u32 x86_leaf = __feature_translate(x86_feature) / 32; + + reverse_cpuid_check(x86_leaf); + return x86_leaf; } /* @@ -159,7 +162,6 @@ static __always_inline struct cpuid_reg x86_feature_cpuid(unsigned int x86_featu { unsigned int x86_leaf = __feature_leaf(x86_feature); - reverse_cpuid_check(x86_leaf); return reverse_cpuid[x86_leaf]; } -- 2.45.0.215.g3402c0e53f-goog