[28/44] KVM: VMX: Make VMCS configuration/capabilities structs read-only after init
Message ID | 20221102231911.3107438-29-seanjc@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp200979wru; Wed, 2 Nov 2022 16:25:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4knAyNu+gw0cnH12bwsCtKEeH6zoRILPEtk5F08TMzGEiswziyRimPdTNEdaMdKeOQS9Hv X-Received: by 2002:a17:90b:4d90:b0:213:687d:c0f0 with SMTP id oj16-20020a17090b4d9000b00213687dc0f0mr28571540pjb.212.1667431511733; Wed, 02 Nov 2022 16:25:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667431511; cv=none; d=google.com; s=arc-20160816; b=reATqtaPcTq00sssilRBrjIrb42ihKAUnVhO/8Uq8UdBB/G7LNS5Fj10t5lcPHTBoc NDbnFvQGLMHosdQKlp0YhK5MjAW6hICRgZXMW8qGSRUTNCiKXeooMqlBTC/QnNBrDinQ Aa1zpFR4VGf5Q7J1WISAGuK1xVgZYyaXgzBU+2df3l4wM8oCjXjQroI+3tCX8Nehy2df 3saF52lgQnNhcy6TUFLruyG3nEFiU/VTwxUkhrtktSB9NV6J1JJE5f5UIZUdfklIQyaS fldFI77MVfcXZ0darUH8P5eOBD1xhTBOQnJHSogAlN4bOi61L2YzobZtY2r6PmZMZuMF a0EQ== 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=mKnEtQX0QH/ggk+Ht36/d+63ROqx6WCYCltiz+Zzjv4=; b=LZTGLb7PcAaTO2RqqfwlJOTpFsmv1KDvqdiaw+n1AKXHv+uNaN+LnUYm60lnUDz0/m nx2NY3R0KF6b+TMdhN7ClDe35/9HDopNh1mJs/8/7j6uZeXa8+gxmFflIzVD6ruxCpiH 7SxWbWL3RBpIdP7cPmfqC5yg5Ayml1LXo6q0PzTxzv+gklEFPn4s+BbIFxXH2x2nNbMz juWaJgeohAT8tdZZXzdff3dXdu4Bt5KB02rptDP5960fprBnpODZIw1HxmV31YONfOce QqYa82gOyy0tVeGWawthBFUzb+xdPzjrHiBbAkg6MdumnJ52bXrw4slP8UxS0mN+iZ2s 0LJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="SdQ/LsY4"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 5-20020a631645000000b0046f33e14597si17432147pgw.106.2022.11.02.16.24.58; Wed, 02 Nov 2022 16:25:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="SdQ/LsY4"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231503AbiKBXYp (ORCPT <rfc822;yves.mi.zy@gmail.com> + 99 others); Wed, 2 Nov 2022 19:24:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231363AbiKBXX6 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 2 Nov 2022 19:23:58 -0400 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 68E64BC1E for <linux-kernel@vger.kernel.org>; Wed, 2 Nov 2022 16:20:16 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-370624ca2e8so674917b3.16 for <linux-kernel@vger.kernel.org>; Wed, 02 Nov 2022 16:20:16 -0700 (PDT) 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=mKnEtQX0QH/ggk+Ht36/d+63ROqx6WCYCltiz+Zzjv4=; b=SdQ/LsY4NGnVE1yE06OYtnoYVCRmFREHfZbDy+hy/qKLprusJ3oD9C3Z6OVRKqQrnE CInFERbmx9ZRnFYiATYzBK74mPS4+cAZJ+5ijRabgzbKKerJGVt8ZZlmJzt5Hj/aV0PA EGW/7VotUp9NojxVblVL/QpJZuKvGxyCajSBZEMqVRwQDUQw2wRSv4vj1QT6bcpnpc9t e4rP+2f3gLSJ/JJRtgPX3AbV2Tyauor4ctFIQiYJWU548K+/wXsudAS9Uik/E0jRBxNq qFZGa2xPRMU89uQ30BChflY3hdbUkhWTUyAN3U9JeOyLGBy95xzkfXnGKk726vF8pKbF n5DQ== 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=mKnEtQX0QH/ggk+Ht36/d+63ROqx6WCYCltiz+Zzjv4=; b=ox1DAO+f2rtggOVD9ImUATZhb4ha4OBnrBuC2zru51WPtcphr1mAJfTWfJ839X8NeJ i6Ya82JVM51IxR5yarfJqdy1VZUy5r2TA3K9pwdjKkyFomjY2aJWN7YbuN58Jff4U8k/ a+bAUEk+R/ooGiLJsrxr4rFFsapEW1aNnIrUGOsq2FlK32wNV438wK24ieiaTB9MXJ2i cqnqjfyPKS3OeSAu8CDu391iTm3mgIw+cuexRWcry2IWssMqsoBzXdtScPwRhu1fFqIK lHtwuTJ0R5Ta98f8mGyZEJgZOCGzjbm4H/qjC2viYd9SyxuTUitlh4T9CvLX59Rqebr1 6ppQ== X-Gm-Message-State: ACrzQf0JXst8hc7a7nnUYucULIQL78rIs7ltoXBzpEL0h7eLk8DApJ1g 15kVcnD/7bsfQqFQyoQDM2keVur1XNI= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a25:c615:0:b0:6c9:f71a:f95d with SMTP id k21-20020a25c615000000b006c9f71af95dmr26436245ybf.411.1667431202255; Wed, 02 Nov 2022 16:20:02 -0700 (PDT) Reply-To: Sean Christopherson <seanjc@google.com> Date: Wed, 2 Nov 2022 23:18:55 +0000 In-Reply-To: <20221102231911.3107438-1-seanjc@google.com> Mime-Version: 1.0 References: <20221102231911.3107438-1-seanjc@google.com> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog Message-ID: <20221102231911.3107438-29-seanjc@google.com> Subject: [PATCH 28/44] KVM: VMX: Make VMCS configuration/capabilities structs read-only after init From: Sean Christopherson <seanjc@google.com> To: Paolo Bonzini <pbonzini@redhat.com>, Marc Zyngier <maz@kernel.org>, Huacai Chen <chenhuacai@kernel.org>, Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>, Anup Patel <anup@brainfault.org>, Paul Walmsley <paul.walmsley@sifive.com>, Palmer Dabbelt <palmer@dabbelt.com>, Albert Ou <aou@eecs.berkeley.edu>, Christian Borntraeger <borntraeger@linux.ibm.com>, Janosch Frank <frankja@linux.ibm.com>, Claudio Imbrenda <imbrenda@linux.ibm.com>, Matthew Rosato <mjrosato@linux.ibm.com>, Eric Farman <farman@linux.ibm.com>, Sean Christopherson <seanjc@google.com>, Vitaly Kuznetsov <vkuznets@redhat.com> Cc: James Morse <james.morse@arm.com>, Alexandru Elisei <alexandru.elisei@arm.com>, Suzuki K Poulose <suzuki.poulose@arm.com>, Oliver Upton <oliver.upton@linux.dev>, Atish Patra <atishp@atishpatra.org>, David Hildenbrand <david@redhat.com>, 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, Isaku Yamahata <isaku.yamahata@intel.com>, Fabiano Rosas <farosas@linux.ibm.com>, Michael Ellerman <mpe@ellerman.id.au>, Chao Gao <chao.gao@intel.com>, Thomas Gleixner <tglx@linutronix.de>, Yuan Yao <yuan.yao@intel.com> Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,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 lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748428665075524957?= X-GMAIL-MSGID: =?utf-8?q?1748428665075524957?= |
Series |
KVM: Rework kvm_init() and hardware enabling
|
|
Commit Message
Sean Christopherson
Nov. 2, 2022, 11:18 p.m. UTC
Tag vmcs_config and vmx_capability structs as __init, the canonical
configuration is generated during hardware_setup() and must never be
modified after that point.
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
arch/x86/kvm/vmx/capabilities.h | 4 ++--
arch/x86/kvm/vmx/vmx.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kvm/vmx/capabilities.h b/arch/x86/kvm/vmx/capabilities.h index 87c4e46daf37..2aaa0fd53d08 100644 --- a/arch/x86/kvm/vmx/capabilities.h +++ b/arch/x86/kvm/vmx/capabilities.h @@ -68,13 +68,13 @@ struct vmcs_config { u64 misc; struct nested_vmx_msrs nested; }; -extern struct vmcs_config vmcs_config; +extern struct vmcs_config vmcs_config __ro_after_init; struct vmx_capability { u32 ept; u32 vpid; }; -extern struct vmx_capability vmx_capability; +extern struct vmx_capability vmx_capability __ro_after_init; static inline bool cpu_has_vmx_basic_inout(void) { diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 6adb60485839..81690fce0eb1 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -489,8 +489,8 @@ static DEFINE_PER_CPU(struct list_head, loaded_vmcss_on_cpu); static DECLARE_BITMAP(vmx_vpid_bitmap, VMX_NR_VPIDS); static DEFINE_SPINLOCK(vmx_vpid_lock); -struct vmcs_config vmcs_config; -struct vmx_capability vmx_capability; +struct vmcs_config vmcs_config __ro_after_init; +struct vmx_capability vmx_capability __ro_after_init; #define VMX_SEGMENT_FIELD(seg) \ [VCPU_SREG_##seg] = { \