Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp1109477lqo; Fri, 17 May 2024 10:55:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXVu8ykZoLnMrlMSpw0ZyHAODcUt0cO++VEDg8BG1/B84RBafQa8BflOGVl1plxfPDvjwkJsTCLHf2hKI+mR/wGYa3QSdT0dhMZeGDRUA== X-Google-Smtp-Source: AGHT+IGJKT08dndXX5+92O/R/xvLpaPcQZckdUffxueUoKO/IwVByiMEOSVr49LlVqjC27j7T4Hh X-Received: by 2002:a05:6a00:844:b0:6f3:ef3d:60eb with SMTP id d2e1a72fcca58-6f4e03a3ac4mr27177745b3a.34.1715968514295; Fri, 17 May 2024 10:55:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715968514; cv=pass; d=google.com; s=arc-20160816; b=CeQfbPDW8O5ZWIGLLzIzltGw/CHQQCWsFnXN7O5MsVpDjafdUz64MCstDBCyTE8y+Z TzttQ5B2LPuvPAUmGOVZzk0tJtJsfUaDZeEJL7oRxV4j+mpdTzxmgUn4Z7MIbrMflqCM u43tAUyZ0Lcgv2IFT0JdF5GlwlNqdEGNtSytJTin30UA8Vpx7VRs4Bm9RF5HyBcUhDJ+ MnYEBADB/xgw+sQggIBNcx12UesKWc5VxnoI07adEhi2Srrkqd1vcs2kpakGcOY6hARk Ph7jOrHJ2jgQsl7T2hUxOKwmHQxblojX8tX6bpW3Qa6q6ul9qXuK8zjHe3Qc2KFBDasW CY3g== 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=l8oTz76tUDAvN6sZBnVH7v5zyJvjHU2O3KhRTzL+9sk=; fh=kjkB7EuvlLyk5ANxI4UDAcUyBxd998kIP5F7eSFP9l0=; b=BrrLYfMxYy5h4A4hihnrDMl1gu0Rmb4sxfrwi1KfbXE0UqRFY+gon/SF5SqGpr4mcW HwKA3q9kWhBfndgYbVk8W9YsU1o5Awi9ySi/wEvbgPBY7SaCDgeCXIMGU/POBK6PFCxl 6+O60+7dJ/NIhfIiQRkRP5Y0DChrzJjk1v1peu+qcZFJvkY7W3e+mfkiQ2dKKAkpDxjT bF0CmW3cKXtKgW+RmuEzzrEN8K9/k0iCbrRrazugJbgRafi9AJ6ztBfXEGltoEL7eLM2 VUO7diK/uNyOB7L14AKfibGrqrjZSwwhSEXokjLd7GB4szvgus1Jk2SaU2isEtnPf30N RD4w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Jy4L2vtD; 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-182474-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182474-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. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-64ed9fafbeasi4101124a12.481.2024.05.17.10.55.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 May 2024 10:55:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-182474-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Jy4L2vtD; 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-182474-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182474-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 D561A28696B for ; Fri, 17 May 2024 17:52:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3242D15885E; Fri, 17 May 2024 17:41:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Jy4L2vtD" Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.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 DA418158206 for ; Fri, 17 May 2024 17:41:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715967663; cv=none; b=UQp2XsDbovK9egByG7am1s/FlwdZTWQ+Q3SQ9gFi9Oa8inz3jbmcLRhUPqR+uX38mIKXEJZG+d+bbuFltZlHFGz7DmOaj6xP8hYne2lNyKDxQVXe+Lt6JhFmS5+GYbYfS643nZUvo8zOLBt0bvWDl2cSgETyivc1SdqvuUya2+Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715967663; c=relaxed/simple; bh=WvZ4N9oYkA1Skm+4BtaWiBtO1cB3REDFN1MpLKSQ2NE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=IE58US+WF87v8ZRCKfsA2habyOHdDTpRYSiFA4Tv8rNyhESWBsI7I5gBO0ffLZbpXvA/uP+Y1GmWOqA315erGkAUNaRZ3al7S72C/AMvSG3DHRFEYNnIay0mq/WUkCi2/UhZS2KCgX1GSKxQwVPe7iKZndfggyFw5JiJzLw+0zY= 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=Jy4L2vtD; arc=none smtp.client-ip=209.85.210.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-pf1-f202.google.com with SMTP id d2e1a72fcca58-6f46eb81892so8860129b3a.0 for ; Fri, 17 May 2024 10:41:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715967661; x=1716572461; 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=l8oTz76tUDAvN6sZBnVH7v5zyJvjHU2O3KhRTzL+9sk=; b=Jy4L2vtDy4wlRzgqURTlaHLGEjUQq8oA0rI/r9mXZ96q0+5/2hmeVOZkDmHyJ9W9bF OuYdlGcDiVu+nb1gfP+R+fk0YFtIc9z8XHI54kOhCRiiQUYnh2rooMlOWDRTV8YgHJIc Y43GY58I5gaBKr0/jMQNu6pi+09kgjvo5OH4SiLQVsfXZblfRBjqeZpeYSFxktzoRBmb yzYbeQKQOgFbh12i0T9CVQq7T83eVm+lZk/gLWTCn2Y1BowbAdGjVfR84aAqcOV1vzfi S2o5EGYUTMWmkhNQyA0Z2CSU2XIE7MG32jl7UhiWu9JtfpB4GpbdVkv34P0WJZzOJ6lL ZLpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715967661; x=1716572461; 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=l8oTz76tUDAvN6sZBnVH7v5zyJvjHU2O3KhRTzL+9sk=; b=kd2lJtRP+/FpOQKDkIx3S6r2QummxJbFi1thgnUlsOndWrUSa4jObMIuVA98dBccPx M7vumzhq+Bkn5E6KTXg2PkfvakOoOtVx2oYc3Ngl5TfAhW+WVt/tIlj06V72YppSiY49 YcljJQLaccVE+bPz8vG8qsWISjD3DX4WbltCAR3/b575tCzoKhB+Wt4TKh+1oGPGDAau 9qitVl4GH4qGqCRauavzotXfCFE6GMz+SynR2KH8CyA22bDr6NVL0mS1TKAKaE7LUxm/ qgD0BqTtoBxHnu6sHip7fZxjDJbUwYFzkb6DQhyV0AUWQXf3FO2zAFwHC1jkM3vDjLdf yZvQ== X-Forwarded-Encrypted: i=1; AJvYcCWquJXRzdl9hHru9TEf6GzeFzzAD9WGM5Co/uFY6AdVR6ZRoAHb3B+mnN/5j3eeGjqLBUm7P72DxxfEeqanTOgYfdbS4z5ZFbD3iVGo X-Gm-Message-State: AOJu0YxpX7PCxUOVs83tkNQxACdmqcdh3AfPbvdQTNARgYDeaaxfiLCF iMgVNGqH/CFZ3fKOyNkgjOo0hqUPPbvB3JF8Lb7P3oQbAu2eHPPiZIjDCPSnyfjdoR2ZiImbTEj ABA== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6a00:3a0f:b0:6ea:88cd:67e9 with SMTP id d2e1a72fcca58-6f4e0376006mr1143306b3a.4.1715967661243; Fri, 17 May 2024 10:41:01 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 17 May 2024 10:39:18 -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-42-seanjc@google.com> Subject: [PATCH v2 41/49] KVM: x86: Avoid double CPUID lookup when updating MWAIT at runtime 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 handling of X86_FEATURE_MWAIT during CPUID runtime updates to utilize the lookup done for other CPUID.0x1 features. No functional change intended. Reviewed-by: Maxim Levitsky Signed-off-by: Sean Christopherson --- arch/x86/kvm/cpuid.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index 8ada1cac8fcb..258c5fce87fc 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -343,6 +343,11 @@ void kvm_update_cpuid_runtime(struct kvm_vcpu *vcpu) cpuid_entry_change(best, X86_FEATURE_APIC, vcpu->arch.apic_base & MSR_IA32_APICBASE_ENABLE); + + if (!kvm_check_has_quirk(vcpu->kvm, KVM_X86_QUIRK_MISC_ENABLE_NO_MWAIT)) + cpuid_entry_change(best, X86_FEATURE_MWAIT, + vcpu->arch.ia32_misc_enable_msr & + MSR_IA32_MISC_ENABLE_MWAIT); } best = kvm_find_cpuid_entry_index(vcpu, 7, 0); @@ -358,14 +363,6 @@ void kvm_update_cpuid_runtime(struct kvm_vcpu *vcpu) if (best && (cpuid_entry_has(best, X86_FEATURE_XSAVES) || cpuid_entry_has(best, X86_FEATURE_XSAVEC))) best->ebx = xstate_required_size(vcpu->arch.xcr0, true); - - if (!kvm_check_has_quirk(vcpu->kvm, KVM_X86_QUIRK_MISC_ENABLE_NO_MWAIT)) { - best = kvm_find_cpuid_entry(vcpu, 0x1); - if (best) - cpuid_entry_change(best, X86_FEATURE_MWAIT, - vcpu->arch.ia32_misc_enable_msr & - MSR_IA32_MISC_ENABLE_MWAIT); - } } EXPORT_SYMBOL_GPL(kvm_update_cpuid_runtime); -- 2.45.0.215.g3402c0e53f-goog