Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp650422rwi; Wed, 2 Nov 2022 16:44:30 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6u+XeM/4KsyFtiCwiaUWNIxeDaH5ZY/QBCgh7XgY4ahp+T2DEvuqOxbRcSaULF+VdxyAP1 X-Received: by 2002:a17:907:74a:b0:77e:9455:b4e3 with SMTP id xc10-20020a170907074a00b0077e9455b4e3mr26680591ejb.471.1667432670073; Wed, 02 Nov 2022 16:44:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667432670; cv=none; d=google.com; s=arc-20160816; b=pfiOTxJK131zliRfp3PbUkUaWjYIMPDJVU7/yr9ipGdeyTkE0KDqiwY8WyN1X6Kpa8 YehELgAj6vZpr9XlU2vp5yYo7S13xq3Om6oIzRXNA9HXzetRAGA9GP5SGKj/9NdVHDUP 2Q6uJKJvZbRyr6ScX12LqgzxJTq0LW8sgIQ5OuBMmjoCQde/TAMtbpj3zd9GbsINCgnk Yu4eCTFFVSOf0bxhBBSNbU/XguldF8Ohb5idtJSYQiklFOJu6GV94lQa8W9pdqrGTFhn p7TgMLKUm6DgIEFDyjtsZANUjZ7zUkQzbIg2O/WvPTs+CRNBXQoEwtEZLQ9sWgfT0aWB 7xkw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dt17-20020a170907729100b007a96e504c7esi17486048ejc.753.2022.11.02.16.44.05; Wed, 02 Nov 2022 16:44:30 -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 + 97 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 ); 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 ; Wed, 2 Nov 2022 16:20:16 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-370624ca2e8so674917b3.16 for ; 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 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 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 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, Isaku Yamahata , Fabiano Rosas , Michael Ellerman , Chao Gao , Thomas Gleixner , Yuan Yao 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: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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] = { \ -- 2.38.1.431.g37b22c650d-goog