[RFC,12/34] x86/cpu/intel: Actually use "address configuration" infrastructure for MKTME
Message ID | 20240222183942.601EE2E5@davehans-spike.ostc.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-77166-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp280963dyb; Thu, 22 Feb 2024 15:31:46 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWqj7VjG/N5LOQSG5oQAJNPlw1uE2w7zgu5Fvxq3eGBTOtSUkIFN5ce3n0CExUuluvsJYgZZPH2vMiG9E3Vex2ih+/zVA== X-Google-Smtp-Source: AGHT+IHHvCm5XLQjzZeT2oUptSxmvDu+rUCd9BLljLEtXBX0GLL5Qc2sOc9gF9hz5LIuzrrdMBhM X-Received: by 2002:a17:907:1704:b0:a3f:3ed5:d6cf with SMTP id le4-20020a170907170400b00a3f3ed5d6cfmr150582ejc.70.1708644706606; Thu, 22 Feb 2024 15:31:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708644706; cv=pass; d=google.com; s=arc-20160816; b=h7/6XZ++yR7cW433AYV5zuWu0TIeD+lPJoh2gQhbwt4T+CoJDVtezqODkOKqQslBEk OfjbS4R7ln1OLc7xtv3FIJp54q6P0bn6E2VU4RJ+XKDA8lilH/ElUJnn3wlzjPFc6hAQ V+rcYc0UTnJmMsbj7gzImfghK5RJb9QE779Eqk0To+4imzcPU98EqKhK2C1fLhT20QsW J9cV1IbtoR6ZsUkhF5Z5DHLCvGKyBIZT0hIuGzF4XYwC+g6LfWGXoyXKsnpaXHN94nx4 U2AZlRX+m+YChclwAPKWbYHl5QzIJB3TCdOBE9k5mUZnUc5wUHUeQ3a6MaGRJztSdV4m bESQ== 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=Omfco2XE1bingxHSv1DlDZNE+xYyk4VOqXBCKicVeL0=; fh=HUgOPOMLUPcroonsK10/uEWpbBCP57e0QFUoVmMwghQ=; b=PMCCCn8kkdbC8V1+zMIO0rGnOdgk2m3NSmtTgvxjpqpo4b194HZf6N4McfxQIdeSTQ SsxD1j7qf9zbvkC39tjGCUwLgq1n404m8FjOXDbHSlGMPSDYDvBHF1gMRPP+0gMkiqbc 7v5ZMsJqD984PzhjtBegt2xPhC6jmis5NzaCozOalJ+38gnRWbVm5q2qWyk+TFgeyMos ecR8PXuSmVPTpOoVhPUmkZs7b6BXYpEn011NKBSEDXfzwL2aoYCq5LfISUS59P/P4Mym b70KkZVW0EoN9WQf/k5jZA2bva2tOH3bsd8g9vH/if6KElbCAdfcCBr5vLAVeoXwARr6 QTjQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HAqOVzGt; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-77166-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77166-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id s20-20020a170906061400b00a3e4575e46csi4818122ejb.509.2024.02.22.15.31.46 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 15:31:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-77166-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HAqOVzGt; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-77166-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77166-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 149CD1F28E76 for <ouuuleilei@gmail.com>; Thu, 22 Feb 2024 18:46:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 162E8137936; Thu, 22 Feb 2024 18:39:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="HAqOVzGt" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (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 3794A73F3C for <linux-kernel@vger.kernel.org>; Thu, 22 Feb 2024 18:39:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708627185; cv=none; b=lnQ3ZPBnYR2RpXLBNATqzD+4pNxObM2soATyInsBCyojF8YloI4l+K0SeFBgK8rReqJdEHf8wkFqITwsV0rXNSj1+kihnc3WXCBSFJl9+VN5GhugQSSY5Z3KhmQeilovy0l/46GpoDL6Bo0/xjrU7pkSXv1WW8wtxrsdZzpvBGU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708627185; c=relaxed/simple; bh=NH8Lr4ZEp+LyLCUOWjofEDWwYXC0tbCz8QJ2z7udv3U=; h=Subject:To:Cc:From:Date:References:In-Reply-To:Message-Id; b=tcMTAyF8soO31/ZJpyO6pNQRxLz8LOXACn04cb3BNLqZ52eXPiB1xN1zD5YCZqZHVMeiUf03l4sYAgI8khHn+DLTKMUaYvJ+BN16NmsT3p7LmxVpoao9YpJYMAhRupOa/M5LWbblVllL7CLVeMBtVc4kOSJjNHbcFO9TdVDRV40= 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=HAqOVzGt; arc=none smtp.client-ip=198.175.65.16 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=1708627184; x=1740163184; h=subject:to:cc:from:date:references:in-reply-to: message-id; bh=NH8Lr4ZEp+LyLCUOWjofEDWwYXC0tbCz8QJ2z7udv3U=; b=HAqOVzGt0q7bY+FM0ixHEfzeUWWvDh075m1sFdIf+Ay4ZOgRIaQJQqez 6SY/fovWJToKhYYeAlmOe6fWiQyajQoXw2zox0e4c+L5IptgYcKvqlzEZ 3kNRSSznld9cznk9MryrTIPNFcgkajDoV4svxBhZUzyBMm9EZ74LyYP0G x2Xv2WuyN7XFHFAybviadUS1oNZMaE18SlJbZjcTIeY8JLQsKpK4h+AY6 HNJLoYnuOO7pFIKPUZEOlzMzXtzntTx5goEc2x1Ueh/e9Y34G0f3+rhDk gWhLOYSroPrTj02O/UwY+aAA0w+ZykL6nPrsJC0BkRnnK7Z7uN895/HB3 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10992"; a="3031777" X-IronPort-AV: E=Sophos;i="6.06,179,1705392000"; d="scan'208";a="3031777" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Feb 2024 10:39:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,179,1705392000"; d="scan'208";a="5975494" Received: from davehans-spike.ostc.intel.com (HELO localhost.localdomain) ([10.165.164.11]) by orviesa008.jf.intel.com with ESMTP; 22 Feb 2024 10:39:43 -0800 Subject: [RFC][PATCH 12/34] x86/cpu/intel: Actually use "address configuration" infrastructure for MKTME 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 <dave.hansen@linux.intel.com> From: Dave Hansen <dave.hansen@linux.intel.com> Date: Thu, 22 Feb 2024 10:39:42 -0800 References: <20240222183926.517AFCD2@davehans-spike.ostc.intel.com> In-Reply-To: <20240222183926.517AFCD2@davehans-spike.ostc.intel.com> Message-Id: <20240222183942.601EE2E5@davehans-spike.ostc.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791643831982529623 X-GMAIL-MSGID: 1791643831982529623 |
Series |
x86: Rework system-wide configuration masquerading as per-cpu data
|
|
Commit Message
Dave Hansen
Feb. 22, 2024, 6:39 p.m. UTC
From: Dave Hansen <dave.hansen@linux.intel.com> Now that the TME detection is only called once at boot, stop twiddling 'boot_cpu_data' directly and move over to 'bsp_addr_config'. Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com> --- b/arch/x86/kernel/cpu/intel.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
Comments
On Thu, Feb 22, 2024 at 10:39:42AM -0800, Dave Hansen wrote: > > From: Dave Hansen <dave.hansen@linux.intel.com> > > Now that the TME detection is only called once at boot, stop twiddling > 'boot_cpu_data' directly and move over to 'bsp_addr_config'. > > Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com> > --- > > b/arch/x86/kernel/cpu/intel.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff -puN arch/x86/kernel/cpu/intel.c~intel-addr-reduce arch/x86/kernel/cpu/intel.c > --- a/arch/x86/kernel/cpu/intel.c~intel-addr-reduce 2024-02-22 10:08:54.296682462 -0800 > +++ b/arch/x86/kernel/cpu/intel.c 2024-02-22 10:08:54.296682462 -0800 > @@ -401,11 +401,8 @@ detect_keyid_bits: > mktme_status = MKTME_ENABLED; > } > > - /* > - * KeyID bits effectively lower the number of physical address > - * bits. Update cpuinfo_x86::x86_phys_bits accordingly. > - */ > - c->x86_phys_bits -= keyid_bits; > + /* KeyID bits effectively lower the number of physical address bits */ > + bsp_addr_config.phys_addr_reduction_bits = keyid_bits; Do we expect reduction_bits to stack? Like can multiple features steal physical bits? Make use "+= keyid_bits" here?
On 2/23/24 03:41, Kirill A. Shutemov wrote: >> - /* >> - * KeyID bits effectively lower the number of physical address >> - * bits. Update cpuinfo_x86::x86_phys_bits accordingly. >> - */ >> - c->x86_phys_bits -= keyid_bits; >> + /* KeyID bits effectively lower the number of physical address bits */ >> + bsp_addr_config.phys_addr_reduction_bits = keyid_bits; > Do we expect reduction_bits to stack? Like can multiple features steal > physical bits? Make use "+= keyid_bits" here? Good question. IMNHO, the idea that different "users" of these fields can be oblivious to each other is the reason that this has gotten so bad. I thought about interfering or stacking a bit when I was putting this together. It's one of the reasons I chose to add the specific 'phys_addr_reduction_bits' field _instead_ of continuing to just munge 'phys_addr_bits'. I want 'bsp_addr_config' to represent the *inputs* that eventually end up in x86_config, and have the inputs distilled down to the output in one (or very few) places. There are thankfully very few users of this: Intel and AMD memory encryption and one Intel CPU erratum for very old CPUs. So they can't stack in practice. If we ever need something to stack, I'd prefer that we add two fields, maybe: bsp_addr_config.enc_reduction_bits and bsp_addr_config.maxphyaddr_erratum_override or something, then have any collision be resolved when 'bsp_addr_config' is consulted, in *ONE* central pace in the code.
diff -puN arch/x86/kernel/cpu/intel.c~intel-addr-reduce arch/x86/kernel/cpu/intel.c --- a/arch/x86/kernel/cpu/intel.c~intel-addr-reduce 2024-02-22 10:08:54.296682462 -0800 +++ b/arch/x86/kernel/cpu/intel.c 2024-02-22 10:08:54.296682462 -0800 @@ -401,11 +401,8 @@ detect_keyid_bits: mktme_status = MKTME_ENABLED; } - /* - * KeyID bits effectively lower the number of physical address - * bits. Update cpuinfo_x86::x86_phys_bits accordingly. - */ - c->x86_phys_bits -= keyid_bits; + /* KeyID bits effectively lower the number of physical address bits */ + bsp_addr_config.phys_addr_reduction_bits = keyid_bits; } static void bsp_init_intel(struct cpuinfo_x86 *c)