From patchwork Thu Feb 22 18:39:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Hansen X-Patchwork-Id: 205022 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp172384dyb; Thu, 22 Feb 2024 11:50:35 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUXPD+0uRYwbMSfxLft8EVGCWkxSne+oymt+GfrDYAIrocfuS5KTKR7wT3iK2ycTI5unndz/qsf1lM8vADBqGtuEOs5nw== X-Google-Smtp-Source: AGHT+IH4nzJ/2jv6SQYezn48vitFbNsMDJSXo6AT0N1lagEQTINrQ9FuI4Rz/ls+/hPEy8SoSqxJ X-Received: by 2002:a17:902:654c:b0:1dc:1c81:1b19 with SMTP id d12-20020a170902654c00b001dc1c811b19mr7308497pln.3.1708631435789; Thu, 22 Feb 2024 11:50:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708631435; cv=pass; d=google.com; s=arc-20160816; b=xiNkm24Yhonl2zXOG1Ff/IawVK2D5SqX6/p+3hI5S2EB6YEcnryCD1SDKNnQJSgHim PfCxifwB/ohrpQpTHSgrZO9E6OVVbKc7qFkqmkHoSaYtLFwc6VVpGVDT6UW56nWxiTvy pw7G3l250nFbCLBV6Nz/E9ACONz+eFJz7kWtAVzCo4gSANcqs1kNUBDmEHIrZ2wdCQws jX4QQt368eHIrh3vrnZoTu78jFHm8g1mM8Qx1VM6AexdSqMDJfCQred1u2zULrx79/0U zcUIw513HAQHw/y2tIYyXo6+YIagGDybJSy2mGK7L102pAeQ7uwrB4lL2/I4Wx0Jb2NC 5O8A== 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=obDj8eqK/ZYdMdzQOof2KYJRL+yChq1JoyHapq3K/N0=; fh=HUgOPOMLUPcroonsK10/uEWpbBCP57e0QFUoVmMwghQ=; b=mx9cMXky3FAnsVQtYQJPjyXZcb0QaetFFN2MlJJYPe7aY0erv9ddFAu9gvxKB923MU 0r86GMyDK+VWDjEveaxAFjFDxfZEHWMOVRVZNARqtISnTM19luTzcosu6ItPxxNKjJVF H+sGbKzqIGou/MWIKrnpC8sGNkX2P3wmn9uOSxhBgl6/673QCdjDo6aha82f/POoXUha L4lU7j1HKSMwmLLo++tlFsH9QD519l6ZnS2ZHEjqBloeLy2Bl3B+KlyxJBQNKK9BJ5Ia CnJ+F0tdkAV4S9p8ZydY2U8Z1obg/SXjoPJ5k0wqxhcBmTiCvLuKio9hOBCI1ZslR59T 4nmQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TK4MxH1A; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-77164-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77164-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id b9-20020a170902d50900b001db7d1afd64si10992016plg.342.2024.02.22.11.50.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 11:50:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-77164-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TK4MxH1A; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-77164-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77164-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id A63142881A3 for ; Thu, 22 Feb 2024 18:45:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0A24412D205; Thu, 22 Feb 2024 18:39:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="TK4MxH1A" 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 7F66373F00 for ; Thu, 22 Feb 2024 18:39:40 +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=1708627182; cv=none; b=Hn7MzfpHvTmPpWOdcabnRACtTpoXMWAtYhdIn1h+WmKGGRJyVeMozIGLDuyvQEXyZSnz6ozg7P7fSn7iU+xjzB2t7wI65bNMt5u/x8mXa+YHi1cXLW+SdTfZPdUd9sI/LVzlf8DPgGAx03HizRail7cmHgpcwktnNajs3TF7pSk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708627182; c=relaxed/simple; bh=QA4nL+IB5LTiCN1WiRhJJReXahalUQ3SRSOkHWOGUt8=; h=Subject:To:Cc:From:Date:References:In-Reply-To:Message-Id; b=Dcp1cUC5P4IARULEctqMd1bJVXFug561eo/5XuFBjw3eRgiaHdxEqql785mym/fZq4DQTVfSUZKwNoZmtteM9sh4mNLFZEEsK3lI0NZQWKRvJAVigGHEim+KRMhItepwHUqyHosY9j2AJwZkG59zAplJ0Ty3q3F/U+ScOwXGY74= 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=TK4MxH1A; 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=1708627181; x=1740163181; h=subject:to:cc:from:date:references:in-reply-to: message-id; bh=QA4nL+IB5LTiCN1WiRhJJReXahalUQ3SRSOkHWOGUt8=; b=TK4MxH1ACISlPqEmR1W6iiTwv/3nrkrtpcK3fiNCXXm/khZ3+SXn2Egz FdUl4jhieZv1V7FiyjSgUjxu7Xz0bWp//AlhZTeH0tnVhV/pLoPCpZlVo 5IS3XMzPR2VfyCQ9qalSMlxFmQNDz7q5T6G8Xq0MGY11K1qvjOqONzzIy NciDktEfrGVQeWHSrVbAAdBPveG/uxMQ+tQT+SE58wCVqNuAN11FNiOcI ikklbMILa6+DFrefswLiRO6S2Kq4xxRSI/nC+IVdPQKvHprL/A5Cl20J9 IJdvi0+VhlH+Aopo9gOnbrCrv1RX0vaBAx6ZLgeto2jPr/eRFdicMKy6m g==; X-IronPort-AV: E=McAfee;i="6600,9927,10992"; a="3031759" X-IronPort-AV: E=Sophos;i="6.06,179,1705392000"; d="scan'208";a="3031759" 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:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,179,1705392000"; d="scan'208";a="5975474" 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:41 -0800 Subject: [RFC][PATCH 10/34] x86/cpu/amd: Use new "address configuration" infrastructure 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:39:40 -0800 References: <20240222183926.517AFCD2@davehans-spike.ostc.intel.com> In-Reply-To: <20240222183926.517AFCD2@davehans-spike.ostc.intel.com> Message-Id: <20240222183940.4F44A1FF@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: 1791629916222223341 X-GMAIL-MSGID: 1791629916222223341 From: Dave Hansen The AMD memory encryption code is currently one of the 'boot_cpu_data' field twiddlers. This has led to all kinds of interesting ordering bugs at boot. Move it away from random fiddling and over to 'bsp_addr_config'. Signed-off-by: Dave Hansen --- b/arch/x86/kernel/cpu/amd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff -puN arch/x86/kernel/cpu/amd.c~amd-phys_addr_reduction_bits arch/x86/kernel/cpu/amd.c --- a/arch/x86/kernel/cpu/amd.c~amd-phys_addr_reduction_bits 2024-02-22 10:08:53.340644930 -0800 +++ b/arch/x86/kernel/cpu/amd.c 2024-02-22 10:08:53.344645087 -0800 @@ -622,7 +622,8 @@ static void early_detect_mem_encrypt(str * will be a value above 32-bits this is still done for * CONFIG_X86_32 so that accurate values are reported. */ - c->x86_phys_bits -= (cpuid_ebx(0x8000001f) >> 6) & 0x3f; + bsp_addr_config.phys_addr_reduction_bits = + (cpuid_ebx(0x8000001f) >> 6) & 0x3f; if (IS_ENABLED(CONFIG_X86_32)) goto clear_all;