From patchwork Wed Jul 10 16:06:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Shishkin X-Patchwork-Id: 811913 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 1DFAE197A6A; Wed, 10 Jul 2024 16:09:53 +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=1720627795; cv=none; b=a3Wn+Oxdnmpmr1RYiri2+6h055CyUQ7hprX3+GBMNYbhyxhP9/yQXIbxY+jwr8crsJ01fD9GogvVIt4E47ChO5EVcafjrEmhJ/YyX1sNJ/NfTXqKT6mSRlkMQBspIRg2uBhLDaURlzHGk2T+ud+KWfvkEBsbF5vGu05VihC8QJk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720627795; c=relaxed/simple; bh=3ftzhE2HMy0sn2H91/T7W6LLqTlSAQgGntncMLyhsmw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LGZkXQonQ0E7+6C8Rj77JY6Nu5syQNe6RJUIQbGmI5YU4RXLMQX3nRFyGWtAtrEqN8+hd8QIH3VFHppOhOSm5SpMgsd/mQOpNQY3LYtyFXHM9gqTCS3f7ahyb1L5BTaiaooq8agRdMwQYOY/BHx7DZ1f2ljy9fei75g6ShjNwfA= 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=CKlmyhvN; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="CKlmyhvN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1720627794; x=1752163794; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3ftzhE2HMy0sn2H91/T7W6LLqTlSAQgGntncMLyhsmw=; b=CKlmyhvNcld8U0SQomSPXaqCOhXA5MbDTPpAh1FrLna2h9wuo0Oc+2aW SNi+JkxBQldnPD/jrCYwAwqex8em61Cc+NP4gEhuRZIS1sGGRSs3wyZOI ZVWytjEauKOHW6njw7nSWeDStC7EaNUNXltJmRjlzoVlB3dzW8OVk2eQy zbs4V2XioZvesNF/vD+9XwUXmo8NGltNvqGylYRpInIyJS4K27scrzz7C p7QyY5ntLIhJctVpi/X5/kJGsUcjHEG0E1isU/CKo3f0Z6/mAl2kMoYW6 xBQEh/s7FrxsO4pK2raSKzj56XrbX7FRGf7v7Dgn/+sXVGtqoRUMr5Zzd g==; X-CSE-ConnectionGUID: orBkQqbFQyO0E+N7dA04Tg== X-CSE-MsgGUID: ozxoi7aETneencODsdqnDA== X-IronPort-AV: E=McAfee;i="6700,10204,11129"; a="18103121" X-IronPort-AV: E=Sophos;i="6.09,198,1716274800"; d="scan'208";a="18103121" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jul 2024 09:09:53 -0700 X-CSE-ConnectionGUID: BpNCO9AUSH+lfP+mhxvjGg== X-CSE-MsgGUID: VsEZXrtKSJ2exKP4UUNK1A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,198,1716274800"; d="scan'208";a="53084891" Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by orviesa003.jf.intel.com with ESMTP; 10 Jul 2024 09:09:41 -0700 From: Alexander Shishkin To: Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Peter Zijlstra , Ard Biesheuvel , "Paul E. McKenney" , Josh Poimboeuf , Xiongwei Song , Xin Li , "Mike Rapoport (IBM)" , Brijesh Singh , Michael Roth , Tony Luck , "Kirill A. Shutemov" , Alexey Kardashevskiy Cc: Jonathan Corbet , Alexander Shishkin , Sohil Mehta , Ingo Molnar , Pawan Gupta , Daniel Sneddon , Kai Huang , Sandipan Das , Breno Leitao , Rick Edgecombe , Yian Chen , Alexei Starovoitov , Hou Tao , Juergen Gross , Vegard Nossum , Kees Cook , Eric Biggers , Jason Gunthorpe , "Masami Hiramatsu (Google)" , Andrew Morton , Luis Chamberlain , Yuntao Wang , Rasmus Villemoes , Christophe Leroy , Tejun Heo , Changbin Du , Huang Shijie , Geert Uytterhoeven , Namhyung Kim , Arnaldo Carvalho de Melo , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org Subject: [PATCH v4 07/16] x86/cpu: Defer CR pinning setup until after EFI initialization Date: Wed, 10 Jul 2024 19:06:43 +0300 Message-ID: <20240710160655.3402786-8-alexander.shishkin@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240710160655.3402786-1-alexander.shishkin@linux.intel.com> References: <20240710160655.3402786-1-alexander.shishkin@linux.intel.com> Precedence: bulk X-Mailing-List: linux-efi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In order to map the EFI runtime services, set_virtual_address_map needs to be called, which resides in the lower half of the address space. This means that LASS needs to be temporarily disabled around this call. This can only be done before the CR pinning is set up. Move CR pinning setup behind the EFI initialization. Signed-off-by: Alexander Shishkin Suggested-by: Kirill A. Shutemov --- arch/x86/kernel/cpu/common.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 8aa621dc7d30..c93c59a27dfa 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -1948,7 +1948,6 @@ static __init void identify_boot_cpu(void) enable_sep_cpu(); #endif cpu_detect_tlb(&boot_cpu_data); - setup_cr_pinning(); tsx_init(); tdx_init(); @@ -2367,10 +2366,16 @@ void __init arch_cpu_finalize_init(void) /* * This needs to follow the FPU initializtion, since EFI depends on it. + * It also needs to precede the CR pinning setup, because we need to be + * able to temporarily clear the CR4.LASS bit in order to execute the + * set_virtual_address_map call, which resides in lower addresses and + * would trip LASS if enabled. */ if (efi_enabled(EFI_RUNTIME_SERVICES)) efi_enter_virtual_mode(); + setup_cr_pinning(); + /* * Ensure that access to the per CPU representation has the initial * boot CPU configuration.