From patchwork Thu Feb 22 18:40:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Hansen X-Patchwork-Id: 205011 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp167969dyb; Thu, 22 Feb 2024 11:40:39 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU4Rv7TflS62ec4ORLQ4Un3JdvvI+E98wSzGOncW4xj25VLPeVBz+tTbRez9Oy/dWAHI8JZQVNfoD9prZNPvoVNKryjHQ== X-Google-Smtp-Source: AGHT+IGIYve8Io+XHpp0wlbaSTlVCiOGjAKekXzL9rpZ2cQusyqy+FVa1ndh/0Lfg2zY5YJ+sYGQ X-Received: by 2002:a05:620a:9d2:b0:787:6b73:b53c with SMTP id y18-20020a05620a09d200b007876b73b53cmr1248qky.65.1708630838977; Thu, 22 Feb 2024 11:40:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708630838; cv=pass; d=google.com; s=arc-20160816; b=pZjFeo/FkEWx1rwxIbQZza3AJSXyECzFRaqlAmSQYHQmHyLHJ8eoGV5b/cCTtNFtpB xMiD1Zinj9LSLbsS+9vTcPs12GfoYGsujer+t+Zrw7oH3OH0x1gJL4CGmdemxjItCslV EPsRASSNdI4eIHrTPGdAbuAq0DybTmBjjOitbQBvH7UjtBjOghgJRy4eOKs7P7WGrij9 IXGveqGE5oJLTSSwt9T3vGwK2jZ7orid6OxIUiWxNN7gBnvJdoDtM2lxLJhquPdqoZ6M YWWWgkxg1W6Z+P3pgeJSFWq7qExqbrX5in3aSVrax0n+QsW1Zam8b1XB6ABxxIyKFxlK xUCg== 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77188-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id dv12-20020a05620a1b8c00b00787a7db98cbsi1243950qkb.537.2024.02.22.11.40.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 11:40:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-77188-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77188-ouuuleilei=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 E49051C26340 for ; Thu, 22 Feb 2024 18:51:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 79DD414038D; Thu, 22 Feb 2024 18:40:26 +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: X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791629290409760014 X-GMAIL-MSGID: 1791629290409760014 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;