From patchwork Wed Nov 30 23:09:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13060789 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D7C64C4321E for ; Thu, 1 Dec 2022 00:02:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID :References:Mime-Version:In-Reply-To:Date:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=d5eGuM3xLZ+/YSDR26bTcwilLwkMFIUnPFmUN4b84dg=; b=Fzz9cJlteIdtoY k6eFbAz7M54d77LD1XDqA8aG2UScdmyC9njnfxHBI/ESetMs1FjC2Acvciw6Zmnj+Zib/4SzdTtR0 92qzxUhsw/FMTh8w8y8KGVfj6Ba1PI/P0dhe84YDokNY8dpyfLBVXgCMEqY6oo0DXU3VlFImZ0ZOk FOtrrSfUuYwjka1SSk4zaEC2fGf0vVmkWQC2CLkw6pkxVAVsODxb9Fg4HZ03hSmkVErbr4AdW9yHs Uo9+j4zQeAPAiB6YnFzpSmRXrBXxrA7+dvuTe08Y/NzwBEMOZn0ycw48eBp4FSrd24umDogDJMvjw q3xna8+e3sxgklRIOjqA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p0X1z-003Sdi-FV; Thu, 01 Dec 2022 00:02:23 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p0WbY-003Gqn-4h for linux-riscv@bombadil.infradead.org; Wed, 30 Nov 2022 23:35:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:Cc:To:From:Subject: Message-ID:References:Mime-Version:In-Reply-To:Date:Reply-To:Sender: Content-Transfer-Encoding:Content-ID:Content-Description; bh=sHcyHjJ8KuW26EmyMG2GCKXDxJlY2ojJURA0kcfw/9k=; b=jQMFTroo0BRvq5HanPLewLoBzV Dg7hP9zu1KVg382JuuP4tRh4kXvw97kJw9RgicZRegYrgsqm2YHeV1P5vRPXtUpTKbkCAFeE4Tmy3 DbWd/CB3pzNFWnrZItUYYsWbZWYkVxSJX8HPW4pCNgFHXKpQEVZ44hnMHvpLjUoqRkZfoLRK7obBE 8QRkwCR72CZyfcEGH8Zc4W1P8/7mgjiyAPMzZL2E2b+pz+o2nn17+QBnVbZZ0Uo9FVTHdXkDrhWpe RMKZ4vBtzFIlT/2IvzHSXRUNvP+Vz8/sPD7ISh77PBXO7s6Na36QZQS6l4h8c8gKN4cbdfKCGzzlC Tz2vszPQ==; Received: from mail-pf1-x449.google.com ([2607:f8b0:4864:20::449]) by casper.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p0WE2-00FPmW-L0 for linux-riscv@lists.infradead.org; Wed, 30 Nov 2022 23:10:49 +0000 Received: by mail-pf1-x449.google.com with SMTP id v23-20020aa78097000000b005748c087db1so208995pff.2 for ; Wed, 30 Nov 2022 15:10:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; 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=sHcyHjJ8KuW26EmyMG2GCKXDxJlY2ojJURA0kcfw/9k=; b=VFFqhuPme1m1eQU16n2iG/J4RAGy2zrHzndrwcDa2UqPCuhmGJAJUoqWiUJ0hBawNj h+1PCcwEa7TWtGKSi7eE+1ph58rOUBv3xDHOkx/n95w6cUeiQfhXEh79gM7EIyUtnO0y ioN8O+FtRJeTVR0iP2uSqqMMZ5ce7bBX8TmoSKstA2185sSr20JSkv0QaUPbyNWz1HPN V+igGOZxxi1EiiIK8zOP02RlczC9ypmTY7mqbv223oTCKi8YwUrElYdikisBH1Zh971w Fr2k5IgU2gcv415RYRumMziSQSo+TFWu1mQkGuJbocDRmVfBg+o1I6JFksOzDsAHNWBN gCrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=sHcyHjJ8KuW26EmyMG2GCKXDxJlY2ojJURA0kcfw/9k=; b=MVfJwat1eRs9/zH5efrL0jYmc1lYhUD6PBkug+IpU26pKOG/pvh3WBqrW0Gd8/fnje +EbUHvFcxMqYrNHhFKoSFfhFUJ1i1AQs2btjckY7Z2ajOlomriKIwuSu3a2Se+hpEYbN Qyo7aGN242MsksgrqcoyhyugMjbMm5PYXS4cHrBtBaJ91RrF7N34yJvh6VVHOxsOiFJv J9Qj+/c001u4CQv/BYiwaMLVWcTllQOhDQG/W9XanlViAXiT6W1EVNvQL3DaahUZPOW6 mgSFxUQ0L4ZFxrv20p6LvAuT02S9S+79HIrEH0Ms9qQtGWDqZDZdkr8jrfdo/V8CjOXf UnyQ== X-Gm-Message-State: ANoB5pk1cS8D2YAL7CQURHkunbKB2willgpnwgEOnJb8KCWBdIjm6zsn Oa/v+lBS8FMQ6rV0wpgo8y0adFdrrYA= X-Google-Smtp-Source: AA0mqf6iPCX6KyjCp3cF1IRt5Mv13lZJWlEm0jsHehxUqphsE1Cogz37ZNgUSTWxB9XNJiT56sIeMfxkVVA= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a65:63d8:0:b0:477:172b:c350 with SMTP id n24-20020a6563d8000000b00477172bc350mr40707643pgv.313.1669849838234; Wed, 30 Nov 2022 15:10:38 -0800 (PST) Date: Wed, 30 Nov 2022 23:09:19 +0000 In-Reply-To: <20221130230934.1014142-1-seanjc@google.com> Mime-Version: 1.0 References: <20221130230934.1014142-1-seanjc@google.com> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog Message-ID: <20221130230934.1014142-36-seanjc@google.com> Subject: [PATCH v2 35/50] KVM: VMX: Use current CPU's info to perform "disabled by BIOS?" checks From: Sean Christopherson To: Paolo Bonzini , Marc Zyngier , Huacai Chen , Aleksandar Markovic , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Matthew Rosato , Eric Farman , Sean Christopherson , Vitaly Kuznetsov , David Woodhouse , Paul Durrant Cc: James Morse , Alexandru Elisei , Suzuki K Poulose , Oliver Upton , Atish Patra , David Hildenbrand , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, Yuan Yao , Cornelia Huck , Isaku Yamahata , " =?utf-8?q?Philippe_Mathieu-Da?= =?utf-8?q?ud=C3=A9?= " , Fabiano Rosas , Michael Ellerman , Kai Huang , Chao Gao , Thomas Gleixner X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221130_231046_728511_63343EFE X-CRM114-Status: GOOD ( 11.91 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Sean Christopherson Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Use this_cpu_has() instead of boot_cpu_has() to perform the effective "disabled by BIOS?" checks for VMX. This will allow consolidating code between vmx_disabled_by_bios() and vmx_check_processor_compat(). Checking the boot CPU isn't a strict requirement as any divergence in VMX enabling between the boot CPU and other CPUs will result in KVM refusing to load thanks to the aforementioned vmx_check_processor_compat(). Furthermore, using the boot CPU was an unintentional change introduced by commit a4d0b2fdbcf7 ("KVM: VMX: Use VMX feature flag to query BIOS enabling"). Prior to using the feature flags, KVM checked the raw MSR value from the current CPU. Reported-by: Kai Huang Signed-off-by: Sean Christopherson Reviewed-by: Kai Huang --- arch/x86/kvm/vmx/vmx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index e859d2b7daa4..3f7d9f88b314 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -2492,8 +2492,8 @@ static __init int cpu_has_kvm_support(void) static __init int vmx_disabled_by_bios(void) { - return !boot_cpu_has(X86_FEATURE_MSR_IA32_FEAT_CTL) || - !boot_cpu_has(X86_FEATURE_VMX); + return !this_cpu_has(X86_FEATURE_MSR_IA32_FEAT_CTL) || + !this_cpu_has(X86_FEATURE_VMX); } static int kvm_cpu_vmxon(u64 vmxon_pointer)