From patchwork Wed Jul 10 16:06:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Shishkin X-Patchwork-Id: 811909 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 A7998197A65; Wed, 10 Jul 2024 16:11:38 +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=1720627900; cv=none; b=Od9ES/HzFkTRSARXzh+pD+y3jxEWP7Ba0JnvMOdAJlZnUqNuD1OuRtjIlkzialZGVEhS1UVyOeyzgcAzxUNE7IRTKFAfoFLYdnKCXR+5fid6/a7iu3H6QqcBL7oXM5zPc7rzTx2pQwaVhiz8IK3HzFWa2FQ8PDlsQrvUU/x7+eE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720627900; c=relaxed/simple; bh=1qops/D1whUCaCuumg8tNYUF7OTw7VyV1BOkXLwJENI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uzJ0u3SUQQ8qLVGIYE90R3qQVKcaaRyxU2BoSRbRBxGj2Doj4KFdhAuh5mXLIe0g97VsMRCRVFW3uk00zOy8U5LR2app9yesRWnWic8+FknngIXyfiqLMYpR30VBGHo/naM3T6YRwzs3WI8SFL1KDPaebOlNqRsjp8Ly3aSN5jE= 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=Wo8e8oz7; 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="Wo8e8oz7" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1720627898; x=1752163898; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1qops/D1whUCaCuumg8tNYUF7OTw7VyV1BOkXLwJENI=; b=Wo8e8oz7k9wgGu+w4eJndlIhBrJtDmU1JUukYMFUqyc5SVGSxDP5TLSt zi6yeMjcSDzvh1fXK6JS069/UsUmtRfhCro8Am+OSDOb5NV/+fWo9vOgJ AIAixal7nbyU194SuOaO9uXjoaa5vvwTt+iRcmcFbJyf6xWUjkGtQM04h C8H/9wNrbFJJW+uTMYxkba24PWfyBWVXGQ/UBU72cRdvIVnV31weWOBwy zCIZwRusO7MxKKILiP8Jo29UbxuzeqOQ+ZYd+4dwAR7f2AzKaEfDljge/ M6Ni+4Ctxs12hqVd9Mp0hVnGBuZGVZdvMytuehQG1/Wjm/sRqxxP96t7q g==; X-CSE-ConnectionGUID: fPLia0WDR1+Xg/yUMv9i6Q== X-CSE-MsgGUID: HNa+h+lwQJuUuqyE8WWk/g== X-IronPort-AV: E=McAfee;i="6700,10204,11129"; a="18103545" X-IronPort-AV: E=Sophos;i="6.09,198,1716274800"; d="scan'208";a="18103545" 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:11:38 -0700 X-CSE-ConnectionGUID: IkWVpXxJSQmmH8rmIw53kA== X-CSE-MsgGUID: uMxjKUZ/Tmqh02uFLlNeVg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,198,1716274800"; d="scan'208";a="53085712" 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:11:26 -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 15/16] efi: Disable LASS around set_virtual_address_map call Date: Wed, 10 Jul 2024 19:06:51 +0300 Message-ID: <20240710160655.3402786-16-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 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 --- arch/x86/platform/efi/efi.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c index f090ec972d7b..6e5c2bb4f4df 100644 --- a/arch/x86/platform/efi/efi.c +++ b/arch/x86/platform/efi/efi.c @@ -848,11 +848,24 @@ static void __init __efi_enter_virtual_mode(void) efi_sync_low_kernel_mappings(); + /* + * set_virtual_address_map is the only service located at lower + * addresses, so we have to temporarily disable LASS around it. + * Note that clearing EFLAGS.AC is not enough for this, the whole + * LASS needs to be disabled. + */ + if (cpu_feature_enabled(X86_FEATURE_LASS)) + cr4_clear_bits(X86_CR4_LASS); + status = 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); + + if (cpu_feature_enabled(X86_FEATURE_LASS)) + cr4_set_bits(X86_CR4_LASS); + if (status != EFI_SUCCESS) { pr_err("Unable to switch EFI into virtual mode (status=%lx)!\n", status);