Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp527405rdb; Thu, 22 Feb 2024 10:51:04 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVt+jnolKBKqRhz6tU9SIkVSecGVoO3tbpZpTgc4r4pX1upGTFoUb3XV1E1s1zyj/Vnl5f3oXXFBxDU0weKk4OvzjlTFF/TYzn8VqB0Iw== X-Google-Smtp-Source: AGHT+IF9hE7oUTc5K6C5bzBfQAWHx31Di3Gk6UOc3W8j6mqmtiR298IinuKHWeeUyMoOaf1P1glN X-Received: by 2002:a05:620a:4088:b0:787:a5ef:2513 with SMTP id f8-20020a05620a408800b00787a5ef2513mr1906153qko.22.1708627864249; Thu, 22 Feb 2024 10:51:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708627864; cv=pass; d=google.com; s=arc-20160816; b=uL7CYWcBIEolY9M2oDmMEDX6aWxCQWqXFFOxNOeO4bLxdFP4m1CIXeTH6mgt7La7Bd b8BkWw3TJCk/y1YLk1fsA8rpiC0/HfxgAPs+kCLfL/3fa18aWl6wCnXCrwZK7QeCo/I2 IsXaE154Qb90VG6KBvs3TDBn0Du3LmzXm/1OL/84FpscoM/IGUTc5qZKlOi8l9NAd0q8 5jnfQXpg1CL2Z9ZusJbRzVOITdbqp94PBuZiAKZDwOqv6H/fcZktPt8xzGlbbv3Vdvjg 0QOK6Z6arFKx4zVeET9Ux/mowobNeEpTtsPGKtkJtVWz1B8o1uxNOSU/+emZkuY+J4Qu 6TCA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:message-id :in-reply-to:references:date:from:cc:to:subject:dkim-signature; bh=mNh2djYRdJM+tniBegM28IZIeAmp29AH0SQY98zsjaE=; fh=HUgOPOMLUPcroonsK10/uEWpbBCP57e0QFUoVmMwghQ=; b=h8VNgd4Hkin63d7hGiTMJqmp/EVr1+kWmPGIBbxENSeETMOkj+Nz7z9ywDagvTv89P aR7Tco367DONVeHOymPcg0uG4muWKG+TH8ZkTowp1AiC++aFWu/1Ipjz32qX6xYoKRDd Vj/tYOdxgMqZIp8UDAZHAu+5akmTF2qrk/OX8DL9+Uh2LEjjJZzxkSszk5MIo1FfpmKu sS9bdYjPYWRYZOp36VLLgHw4tMh5t6V1aGFWu0FIpvQTAJSvjVzWG4N4DrDLsyEL82Kx y3QpibaJYu5H2hnFsERYFJR2W9ISd5/nDVS7Kp+YUCc+5BdhsFQpVmU3vHkZU7a2JCm0 aWtg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=PbJzUVpr; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-77188-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77188-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d7-20020a05620a158700b00787acc58aa8si315671qkk.644.2024.02.22.10.51.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 10:51:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-77188-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=PbJzUVpr; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-77188-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77188-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 1359D1C24A68 for ; Thu, 22 Feb 2024 18:50:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C999A140399; Thu, 22 Feb 2024 18:40:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="PbJzUVpr" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1B82314EFFF for ; Thu, 22 Feb 2024 18:40:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708627216; cv=none; b=S1r6khniYM1SOcyJbKsyQ/r8aJNIoXhG7UWr2IQX13alUPcl9KKKnFDj2SZMyJWl7JHhYnoJFQzObYkfNNFNghzdJdyhsodeNkA4VeokrvEKH/nB5+k40LB0MBUOOnqewRdH0AnTX4XeLmKxb1FKpDniR1Y5CFCzZ2YL+7GVj1U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708627216; c=relaxed/simple; bh=fXLqFFG0AjuZrNznR9RhW13fpkiv+9dzopyFF9ZKnd8=; h=Subject:To:Cc:From:Date:References:In-Reply-To:Message-Id; b=EFRdR6niaVWXJ41qfgFGnRZutbjvTZbpulnZQr28Kr5c7FdqjzichCOkeFGKY2EcKeg+j4/C1oIx6ig0DKGJYergS8KUmxggXmWgIxLbDe0VZn9iG1JVAjH/oYx0O1I1l5sriZ5Cum7TjZ8vxyRtEK/t0A/w4z2unMaa1g0vkrE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=PbJzUVpr; arc=none smtp.client-ip=192.198.163.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708627212; x=1740163212; h=subject:to:cc:from:date:references:in-reply-to: message-id; bh=fXLqFFG0AjuZrNznR9RhW13fpkiv+9dzopyFF9ZKnd8=; b=PbJzUVpr/JqnOoEKivrbAsqqXjDMAEMSsHe40XLy6eXIuaYAsTqMVOC8 YzSvumvh+ZuVm6pQLD9GboRJQbLdTtNHd40mMwZqli3LKE8cUIROO9wkc 4cBudFY/ayMa3xK669AOJsruGyfB2aXHV6cl0IMPxX9k20fzoXUxXsZcA UAAPoxkn76ZXF9iXZL9SwQNuVg56zEjFn8CLwzHnj6yHlmE/8LOIjpVxk xhm1vm33mFUQKoQ2bDGuxCOvg3KFVNh6E5pheDEaNYrVtj6z6hHlsZegY 5iRitYgCrB+e7nb7VN3+Usd3aHlN6FcVxcy7UC9nhyAQvlKcwsKv2eKRc g==; X-IronPort-AV: E=McAfee;i="6600,9927,10992"; a="13584610" X-IronPort-AV: E=Sophos;i="6.06,179,1705392000"; d="scan'208";a="13584610" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Feb 2024 10:40:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,179,1705392000"; d="scan'208";a="10265320" Received: from davehans-spike.ostc.intel.com (HELO localhost.localdomain) ([10.165.164.11]) by orviesa004.jf.intel.com with ESMTP; 22 Feb 2024 10:40:12 -0800 Subject: [RFC][PATCH 34/34] x86/cpu: Mark new boot CPU and config structures appropriately To: linux-kernel@vger.kernel.org Cc: kirill.shutemov@linux.intel.com,pbonzini@redhat.com,tglx@linutronix.de,x86@kernel.org,bp@alien8.de,Dave Hansen From: Dave Hansen Date: Thu, 22 Feb 2024 10:40:11 -0800 References: <20240222183926.517AFCD2@davehans-spike.ostc.intel.com> In-Reply-To: <20240222183926.517AFCD2@davehans-spike.ostc.intel.com> Message-Id: <20240222184011.9FCCBCBD@davehans-spike.ostc.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: From: Dave Hansen Just to recap the rules: 1. 'bsp_addr_config' is only used in early boot by the BSP. 2. 'x86_config' is only written once by the BSP and can be used read-only during normal system operation Mark 'bsp_addr_config' so it goes away after boot *and* non-init references to it can be detected and warned about. Mark 'x86_config' as __ro_after_init so it does not turn into the same mess that 'boot_cpu_data' is. Signed-off-by: Dave Hansen --- b/arch/x86/kernel/setup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff -puN arch/x86/kernel/setup.c~mark-new-structs arch/x86/kernel/setup.c --- a/arch/x86/kernel/setup.c~mark-new-structs 2024-02-22 10:09:05.173109438 -0800 +++ b/arch/x86/kernel/setup.c 2024-02-22 10:09:05.177109595 -0800 @@ -131,8 +131,8 @@ struct ist_info ist_info; struct cpuinfo_x86 boot_cpu_data __read_mostly; EXPORT_SYMBOL(boot_cpu_data); -struct x86_addr_config bsp_addr_config; -struct x86_sys_config x86_config __read_mostly; +struct x86_addr_config bsp_addr_config __initdata; +struct x86_sys_config x86_config __ro_after_init; #if !defined(CONFIG_X86_PAE) || defined(CONFIG_X86_64) __visible unsigned long mmu_cr4_features __ro_after_init; _