Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3111905rwb; Wed, 30 Nov 2022 15:44:26 -0800 (PST) X-Google-Smtp-Source: AA0mqf4YYEXgjfrUkJgCKOk4X9k9Y7dzNZ4z8oGVZBvU5/lrYGelia4HPSeLaqciwzH64gCsvj93 X-Received: by 2002:a17:90a:bd7:b0:213:30b2:4e4e with SMTP id x23-20020a17090a0bd700b0021330b24e4emr75737125pjd.193.1669851866649; Wed, 30 Nov 2022 15:44:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669851866; cv=none; d=google.com; s=arc-20160816; b=k8TQwO/klfoet10fx1qNePabGlFDMmjyDPi+55eVYHjeVOnBuUeEzpq9cWDFiQLPRs 9DHRXa2yIVBmJNhLR0qdyJZF0mIxnIuZjYpiH/vlN4hFj1LwsD7tPDI4Jnigp+0w/Gky zUjOGWvGHOc+JSOKtvxHc6IWMmMSndWI2Z5YGt1ylzmR0pJ290WeTxwvm4NF139f/Wrv 1hsuefwBKP4+AvTXW/+q8akEJcSXK6NMjdj0zBZbkp0jduT5rKVRY63CkWlvyb0+2mc5 nv0uVU6Ils9qf6STbHtpSSgDdHqLGYD2/YV3tCrOGiPsqK1fAGS7Ss/U8OMewrxOitQL NFFQ== 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=syK6eF0z1YIhw5KnDfEJ/sqHR3QdYzGhfq3h/5i5Sas=; b=GOXL/TJ4/EQtGTGYEFmhuIdkevGOHjDLb9mJL1NxK7ySNAR0b3v8bZdgM3ZPED7akA vu0zvnEOqRI0t/BJ9dlP4GSq6cV7iIL8n/wJRZSG+UTgZvO2DOg+gYQB9J9OwSx4RkBQ LNwEYG+XjWswYxzloBrNvOBJcTtOAlHLaoKxveqtiPw6gx4emJwKjfjXS10QleTwFozo v8LM3X6ijqHuEr1ZU80kNUTzfRcTNRenTUjJ3wnM6bNgENWzajmDg3FsOhyFq2dof6St HwPvbFygqtt9DuCrsNfSDleAY6oPLkRsqGznohRcUtaYa2GMN3pCK4YbzpZmdzC9/rgk tOVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=GVS6tfQs; 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 z70-20020a633349000000b00476f8b57e45si2596757pgz.61.2022.11.30.15.44.15; Wed, 30 Nov 2022 15:44:26 -0800 (PST) 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=GVS6tfQs; 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 S230132AbiK3XOo (ORCPT + 83 others); Wed, 30 Nov 2022 18:14:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229994AbiK3XNg (ORCPT ); Wed, 30 Nov 2022 18:13:36 -0500 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96ED79F4A7 for ; Wed, 30 Nov 2022 15:10:51 -0800 (PST) Received: by mail-yb1-xb4a.google.com with SMTP id e185-20020a2569c2000000b006f28dd5da75so16201622ybc.19 for ; Wed, 30 Nov 2022 15:10:51 -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=syK6eF0z1YIhw5KnDfEJ/sqHR3QdYzGhfq3h/5i5Sas=; b=GVS6tfQs69HM9iPg5RyanavfgqTtstL/hP2NZwyz6ZiOn7sQ0OggFONinN3Xpq5A5O ROAGkLrScqRoWmoumJCapQkQLkR93EZiZmJgM/igbQR0yiEQhTM5NlbokX/zSqXnB7+r NTk4xoTIRJmdEYgV5XTVp3WbKa8QFND0VjYsfazhzfL9lIlQKqNHJYrNBIvwG1lwEaBo U+Ok61fL2GtL8yDcgFKd5TgqnT7w/4A4Fxq0CZ9SiNKAiH0owEiGaxOBRpIJfpm0capw Q57SZ4+/8uPzzEqCtGgs63hTCqUtPFogvCulI6jofLJAraG2Zyu8sPd3r85eKSZc1cYA LlTw== 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=syK6eF0z1YIhw5KnDfEJ/sqHR3QdYzGhfq3h/5i5Sas=; b=A/1Xdb49xYgBWIfmt/auZ3qTNBSpYTprUuMPf9pWhBpSBl9HJN1m6wv0SnpNVUM0qz 3wdue4zfQ/G5On+5KEWnLp2kwfltj0vtrIHbUDjf8PZKr8pDK4D8bN3DDuYz5BUPyDWz SFKeOIQMGI/9y6grw9mqKiAKgLbnyBcqEXOEck5qwmkQzbStTwzhVuAnPvQyEHVsweDg a2tN28WK85R3RK7CQIbtEPlNNBSb+q/VBL08NY/CqrcxoXR4SD/0VQshXzTb4+ziNIVQ hv9IXt15X/SEhZmD0ScQQqBw4sX2sgsM5JEccjdbw/8zTz4ICpNwGRiadAuMElFOjLoB fhYA== X-Gm-Message-State: ANoB5pkvnNMHrWw9RCpa6cfiU8tUops/qCjz+zCHEmPL1OdjNFDOShbZ ec6+fWTSdKIK6mVzQPkbiNZO0RotHkc= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:690c:e8b:b0:3c9:bdbf:444d with SMTP id cq11-20020a05690c0e8b00b003c9bdbf444dmr15670072ywb.56.1669849829390; Wed, 30 Nov 2022 15:10:29 -0800 (PST) Reply-To: Sean Christopherson Date: Wed, 30 Nov 2022 23:09:14 +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-31-seanjc@google.com> Subject: [PATCH v2 30/50] 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 , 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=20Mathieu-Daud=C3=A9?=" , Fabiano Rosas , Michael Ellerman , Kai Huang , Chao Gao , Thomas Gleixner 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 cd2ac9536c99..45162c1bcd8f 100644 --- a/arch/x86/kvm/vmx/capabilities.h +++ b/arch/x86/kvm/vmx/capabilities.h @@ -66,13 +66,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 76185a7a7ded..654d81f781da 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -488,8 +488,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.584.g0f3c55d4c2-goog