Message ID | 20231110235528.1561679-5-seanjc@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b129:0:b0:403:3b70:6f57 with SMTP id q9csp1456093vqs; Fri, 10 Nov 2023 15:56:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IElkQt7eOpaSYQj6/wxNK3Q25geAS0be1MqJjwkUqPv3uznHdLe2X6y0JJQZFMi4yKTTvKo X-Received: by 2002:a17:902:d511:b0:1cc:431f:55e6 with SMTP id b17-20020a170902d51100b001cc431f55e6mr896696plg.63.1699660607255; Fri, 10 Nov 2023 15:56:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699660607; cv=none; d=google.com; s=arc-20160816; b=ZXgZ4K53UqbACXJ0+ns3fzuO9YSirUrN/7T+iB6f/nrgqO7pYZD6TUnK/6LKkKfMb3 jErnuZSiicT6q2SPAHHcB+OEUyO0yDuvNEXl5xQCMyWgG0Mx8xIojPfaYxuTl+CWWZo6 Ib1LFX6JE1B9DoOLaHEj7I3OZ0kgyPbcg7ZxozDGeRyvqdBPbACezlDg/JCYz589rXCx 29qeCA57cezvYeyPPQ5nHe+SeKFhF2h2p3YnJmpEX481yzJjoN9roWIxrhm3SMfOAG6n mO3GdEMU7u4/UE2VZ7/Z4d06wNDjTnYAsqp6GnzhbO7f9mN+pXuA/4PtBT2rOSXN7EJC XiYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:reply-to:dkim-signature; bh=oLHGbgMEnF7UGu+6KnCI0TJhWQAK6x2mt0wz6s7ykc4=; fh=5gy8eLL9j0mBq5w7XH+Mzaa/H0RFuTaOFYvX0+V/1sM=; b=yTbP5o49gVMWGdtfj2YMsYiFnrWEg5AvazSslK6tvfuMc5bRXtK8dGORbb7ps39RdC yBQIjc5ykPe39QUgi9zHBIU8yhQII6G5p/UoR67zTIZHT35WcKxHILBNDIY6S099I7VY hs3q2fDGes9yALEwe4Dy5W/5ZCsf3Oun+yxbDuAYFnrilN8Gjik84qqqZ1xIk+gi2FMp 5gdOwTg5RGn8gQYGG7BAf9xq6KuzuCPLQ9knsLorFGA4vW4X8qiINYOCHyq7uVOWn7nR J/Yy5j0Hqb3FnDlHU4K0VjD2nYhfgf+/O5hIWstWtbV01fHmFExF2O6FZF9Y9JAhRNpJ AueQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=dAzZU6Cd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id o18-20020a170902d4d200b001c7249f5e40si475583plg.469.2023.11.10.15.56.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Nov 2023 15:56:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=dAzZU6Cd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 7025E81CF7D0; Fri, 10 Nov 2023 15:56:36 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344968AbjKJXzv (ORCPT <rfc822;heyuhang3455@gmail.com> + 29 others); Fri, 10 Nov 2023 18:55:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230100AbjKJXzo (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 10 Nov 2023 18:55:44 -0500 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2B3B4212 for <linux-kernel@vger.kernel.org>; Fri, 10 Nov 2023 15:55:41 -0800 (PST) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-5ae5b12227fso36794137b3.0 for <linux-kernel@vger.kernel.org>; Fri, 10 Nov 2023 15:55:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1699660541; x=1700265341; 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=oLHGbgMEnF7UGu+6KnCI0TJhWQAK6x2mt0wz6s7ykc4=; b=dAzZU6CdykaoHdvYARoV6neDZVvw7hVI4xpMyWN7gM9IWzVKxO3zkFNR6kFkTQfyvq uk566WTmbyYGz1Ljxvqph6xCL+KLLH/6Pc5/OKOUonEk1sLodD1LwU2uYSTQ5Flm6Pax 1bNebUib4UWKL6dqJSWIeUrkdmNToszAAbcGvmeOe7qwkRPgrMbXMeaAlRnsdlJDkJhL Klql/IVqWc3zUmXd1nYq1Mup4Yqi3CpqSofs379JcCLQPC+jGGvksi4SHbDJAVLErZ7u IeGMavAkJFGf9LtblTyFq5U4B5p+98N736XPDXISA0xIt1XnNF3xF31IqotaPcFuxpqf IMQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699660541; x=1700265341; 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=oLHGbgMEnF7UGu+6KnCI0TJhWQAK6x2mt0wz6s7ykc4=; b=SiSVP4FREm1dA/knY5Cu7Xoxzyh02+rVIm8J2oYGINUBnmLtrPXVXKUBujv/e6wQK2 KyVAydbmGHMbH3RpWCny3w1ESzPp0h7gmQNoOyC67ccxqrIMg/aoasBGLlOON8y9T/jj +piVesziSldt1aURwlsfCynrczfyyvLFu1RLjpiowu/7DBkECgOIhJFOjthNcG2+USPC DipeaB8JrjKf6tH71fzH5gGwSn9OoDInnJB5HD81zE5uL/M3mbq/v9sEdtNAh9GW94T4 mLEe5fl0vHEtB9hOw4j3dLknNHe3FZ5c/l+OG0J6nPA7/MPIVNslyIH4+2GQaDMMUCca svBQ== X-Gm-Message-State: AOJu0YxfTTulNO1RwhNS07H4Yt6Fk1vKOwK5ahslrTxfoHY6yyyYyrLR QcgHhrMwnKVjlQBVhcFGdEo2AxMlTnw= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a81:a18b:0:b0:5be:94a6:d84b with SMTP id y133-20020a81a18b000000b005be94a6d84bmr23544ywg.5.1699660540914; Fri, 10 Nov 2023 15:55:40 -0800 (PST) Reply-To: Sean Christopherson <seanjc@google.com> Date: Fri, 10 Nov 2023 15:55:23 -0800 In-Reply-To: <20231110235528.1561679-1-seanjc@google.com> Mime-Version: 1.0 References: <20231110235528.1561679-1-seanjc@google.com> X-Mailer: git-send-email 2.42.0.869.gea05f2083d-goog Message-ID: <20231110235528.1561679-5-seanjc@google.com> Subject: [PATCH 4/9] KVM: x86: Avoid double CPUID lookup when updating MWAIT at runtime From: Sean Christopherson <seanjc@google.com> To: Sean Christopherson <seanjc@google.com>, Paolo Bonzini <pbonzini@redhat.com> Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Maxim Levitsky <mlevitsk@redhat.com> Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Fri, 10 Nov 2023 15:56:36 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782223321139050694 X-GMAIL-MSGID: 1782223321139050694 |
Series |
KVM: x86: Replace governed features with guest cpu_caps
|
|
Commit Message
Sean Christopherson
Nov. 10, 2023, 11:55 p.m. UTC
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.
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
arch/x86/kvm/cpuid.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
Comments
On Fri, 2023-11-10 at 15:55 -0800, Sean Christopherson wrote: > 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. > > Signed-off-by: Sean Christopherson <seanjc@google.com> > --- > 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 5cf3d697ecb3..6777780be6ae 100644 > --- a/arch/x86/kvm/cpuid.c > +++ b/arch/x86/kvm/cpuid.c > @@ -276,6 +276,11 @@ static void __kvm_update_cpuid_runtime(struct kvm_vcpu *vcpu, struct kvm_cpuid_e > > 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 = cpuid_entry2_find(entries, nent, 7, 0); > @@ -296,14 +301,6 @@ static void __kvm_update_cpuid_runtime(struct kvm_vcpu *vcpu, struct kvm_cpuid_e > if (kvm_hlt_in_guest(vcpu->kvm) && best && > (best->eax & (1 << KVM_FEATURE_PV_UNHALT))) > best->eax &= ~(1 << KVM_FEATURE_PV_UNHALT); > - > - if (!kvm_check_has_quirk(vcpu->kvm, KVM_X86_QUIRK_MISC_ENABLE_NO_MWAIT)) { > - best = cpuid_entry2_find(entries, nent, 0x1, KVM_CPUID_INDEX_NOT_SIGNIFICANT); > - if (best) > - cpuid_entry_change(best, X86_FEATURE_MWAIT, > - vcpu->arch.ia32_misc_enable_msr & > - MSR_IA32_MISC_ENABLE_MWAIT); > - } > } > > void kvm_update_cpuid_runtime(struct kvm_vcpu *vcpu) Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> Best regards, Maxim Levitsky
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index 5cf3d697ecb3..6777780be6ae 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -276,6 +276,11 @@ static void __kvm_update_cpuid_runtime(struct kvm_vcpu *vcpu, struct kvm_cpuid_e 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 = cpuid_entry2_find(entries, nent, 7, 0); @@ -296,14 +301,6 @@ static void __kvm_update_cpuid_runtime(struct kvm_vcpu *vcpu, struct kvm_cpuid_e if (kvm_hlt_in_guest(vcpu->kvm) && best && (best->eax & (1 << KVM_FEATURE_PV_UNHALT))) best->eax &= ~(1 << KVM_FEATURE_PV_UNHALT); - - if (!kvm_check_has_quirk(vcpu->kvm, KVM_X86_QUIRK_MISC_ENABLE_NO_MWAIT)) { - best = cpuid_entry2_find(entries, nent, 0x1, KVM_CPUID_INDEX_NOT_SIGNIFICANT); - if (best) - cpuid_entry_change(best, X86_FEATURE_MWAIT, - vcpu->arch.ia32_misc_enable_msr & - MSR_IA32_MISC_ENABLE_MWAIT); - } } void kvm_update_cpuid_runtime(struct kvm_vcpu *vcpu)