From nobody Tue Oct 7 21:38:32 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (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 DDC8228A719; Mon, 7 Jul 2025 08:03:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751875416; cv=none; b=WV1wg4+bsHMxA3UFuVq5qfiS9qKHb3sHy5lD55QXOuvDvPqfV6MShH/AWpq5eOUTVJleaWrdcmJrLCGcDq46k2hVTlS3rJytTrGVSVh8QPWRL6a2lf+xgNGy4C42A+qXgAWzy8t2F74Lzge1gdzju7FHZnWD4Tk+CwaVQnWj4tQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751875416; c=relaxed/simple; bh=G+eP9Bw73xI4j+67SYkgeX9LiSQjfbtHwX1bukiOpM0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ifcBZfuQiklDKEwEcXcLeSHaJoWcrqJz1wry85CwPm+sBcSL48IxVOdzhn3LKF9RWsJaFgIC80ljkz0GA31OHlP7tqYExoo2+vq4UfHMAvXTFNTXHOc9YF0Y8fUkdB9sSzMpwumIn2Z8YZiJRA94p4Prs6VQs9gMdHo0fAV91d8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.helo=mgamail.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=eMHGlhxc; arc=none smtp.client-ip=198.175.65.20 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.helo=mgamail.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="eMHGlhxc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1751875415; x=1783411415; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=G+eP9Bw73xI4j+67SYkgeX9LiSQjfbtHwX1bukiOpM0=; b=eMHGlhxcAwWWwxvPsqrDXCR9/yK+W7ZXAjBPFtl5grrW1qLJWBm7MqWl YuY2xl3X+khKmqfm+Vx34y/fGQbMX4co7KQzNfKlhYLb7U9sqlW9vi2nz NMkr8vUpkCGhH4QZRalJ3ZmCt3P9zv3ZqrLs5hfR8cvI1bXukA3Zxq/hi cg9JBHNMfh90LtkYytWXhNyuoBlV4VM1fRyQOpsagMwUIgS++yLMEx2f0 E0rF3EhsZs4jHIgWcLse8Wrn8Hxw3AEH+LIVlneOTWDl81MrnPdYZxnl2 w16481lX9ADIrfdmpbaM7Pvc7c4zOrh9cZKgWEulp07AGf9yZbMb/kfZy Q==; X-CSE-ConnectionGUID: KzEC1U1aTZOOu572vadoqA== X-CSE-MsgGUID: gGCwKlDiRiuiKJgrIsm9bg== X-IronPort-AV: E=McAfee;i="6800,10657,11486"; a="53807253" X-IronPort-AV: E=Sophos;i="6.16,293,1744095600"; d="scan'208";a="53807253" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jul 2025 01:03:33 -0700 X-CSE-ConnectionGUID: l5LBmWXXRBig4FBVoq1GFg== X-CSE-MsgGUID: PXuB/gMDQn6i5/7M8condQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,293,1744095600"; d="scan'208";a="160804330" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa005.jf.intel.com with ESMTP; 07 Jul 2025 01:03:23 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id D1BE1458; Mon, 07 Jul 2025 11:03:17 +0300 (EEST) From: "Kirill A. Shutemov" 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 , Alexey Kardashevskiy , Alexander Shishkin Cc: Jonathan Corbet , Sohil Mehta , Ingo Molnar , Pawan Gupta , Daniel Sneddon , Kai Huang , Sandipan Das , Breno Leitao , Rick Edgecombe , 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, linux-mm@kvack.org, "Kirill A. Shutemov" Subject: [PATCHv9 05/16] efi: Disable LASS around set_virtual_address_map() EFI call Date: Mon, 7 Jul 2025 11:03:05 +0300 Message-ID: <20250707080317.3791624-6-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250707080317.3791624-1-kirill.shutemov@linux.intel.com> References: <20250707080317.3791624-1-kirill.shutemov@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alexander Shishkin Of all the EFI runtime services, set_virtual_address_map() is the only one that is called at its lower mapping, which LASS prohibits regardless of EFLAGS.AC setting. The only way to allow this to happen is to disable LASS in the CR4 register. Disable LASS around this low address EFI call. Signed-off-by: Alexander Shishkin Signed-off-by: Kirill A. Shutemov Reviewed-by: Sohil Mehta --- arch/x86/platform/efi/efi.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c index 463b784499a8..5b23c0daedef 100644 --- a/arch/x86/platform/efi/efi.c +++ b/arch/x86/platform/efi/efi.c @@ -787,6 +787,7 @@ static void __init __efi_enter_virtual_mode(void) int count =3D 0, pg_shift =3D 0; void *new_memmap =3D NULL; efi_status_t status; + unsigned long lass; unsigned long pa; =20 if (efi_alloc_page_tables()) { @@ -825,11 +826,25 @@ static void __init __efi_enter_virtual_mode(void) =20 efi_sync_low_kernel_mappings(); =20 + /* + * set_virtual_address_map() is the only service located at lower + * addresses, so LASS has to be disabled around it. + * + * Note that flipping RFLAGS.AC is not sufficient for this, as it only + * permits data accesses and not instruction fetch. The entire LASS + * needs to be disabled. + */ + lass =3D cr4_read_shadow() & X86_CR4_LASS; + cr4_clear_bits(lass); + status =3D efi_set_virtual_address_map(efi.memmap.desc_size * count, efi.memmap.desc_size, efi.memmap.desc_version, (efi_memory_desc_t *)pa, efi_systab_phys); + + cr4_set_bits(lass); + if (status !=3D EFI_SUCCESS) { pr_err("Unable to switch EFI into virtual mode (status=3D%lx)!\n", status); --=20 2.47.2