From nobody Tue Dec 2 02:43:00 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 9D3DF2DBF4B; Tue, 18 Nov 2025 18:34:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763490895; cv=none; b=e+XajmXV/Kjs9g1z9RgKiW1lzaimQeVUwTx2Yt35UBd6YjocNMqaHh2G6Ha149CeCPu7vmeMzNjvRTh3aP3TzntBnOYB4xZh3+6c/n6JV9fi1vTn4iGkYbH171iOIPQHmFMVd40df4ynMPldJGnhBmDMBwtZOmF2+Z/AiDD0OMs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763490895; c=relaxed/simple; bh=8d3y0tuH+JUD4QfSiQiDm9n5LoaQCNgr1flLLNl4hIs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EVU8bBEXrE1dPKKR3wEOHFJx7uF9agxAwMUXlCZume2UGvQmcJleHKraWiKAkWuxUeYjB/d6PK8CD7hAfoq0u4WYFluexbFWMvMShYKFo5grqXgd3JJz9RyfLWWqJgTG9aRcH5Zvch7q2tMK25lTgqxGxSMaoZz2O1OLY+ZZwf0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=QoyV7cRw; arc=none smtp.client-ip=198.175.65.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="QoyV7cRw" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1763490894; x=1795026894; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8d3y0tuH+JUD4QfSiQiDm9n5LoaQCNgr1flLLNl4hIs=; b=QoyV7cRwB73rjVeuTHZY6oIo0hju5HsfcMug/VbLnBaiojmNzm257V68 z2URUzseIVx3A4FozrTHb2c1DAnFBH9SwQjp8mElGRvURA0dJ8Dp/RiYb tK6GZuMu8HOB7U7KZ5Ewt1sSKzm/E6RaVIptxNqVOM4zpHdxpRJ9UfF7q OuEke+/fRJlH5o54slptsCJ3qubrV3GEOCVynC10CylaKjmuQGoh4223J ALlbbIdLuv2QOPdcqgQqo5Fj86cW4fPwpdGzGuEdMMqIHApVt/fZ2k4zf UvOWr4CXpsKnD0SA9tObSlj7388E7zAHEf/cY7i99JAIWA0NZRge6MlEu w==; X-CSE-ConnectionGUID: IZ272lcBQ72aqHVxGjnXsQ== X-CSE-MsgGUID: 7I7DHdf6QFy6SVYQaQjDpw== X-IronPort-AV: E=McAfee;i="6800,10657,11617"; a="76979883" X-IronPort-AV: E=Sophos;i="6.19,314,1754982000"; d="scan'208";a="76979883" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Nov 2025 10:31:56 -0800 X-CSE-ConnectionGUID: PRQHp1SLT8+yYXwzNhEANg== X-CSE-MsgGUID: wG00PbBiQtq7a5pnFZwRcg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,314,1754982000"; d="scan'208";a="190088946" Received: from sohilmeh.sc.intel.com ([172.25.103.65]) by orviesa006.jf.intel.com with ESMTP; 18 Nov 2025 10:31:55 -0800 From: Sohil Mehta To: x86@kernel.org, Dave Hansen , Thomas Gleixner , Ingo Molnar , Borislav Petkov Cc: Jonathan Corbet , "H . Peter Anvin" , Andy Lutomirski , Josh Poimboeuf , Peter Zijlstra , Ard Biesheuvel , "Kirill A . Shutemov" , Sohil Mehta , Xin Li , David Woodhouse , Sean Christopherson , Rick Edgecombe , Vegard Nossum , Andrew Cooper , Randy Dunlap , Geert Uytterhoeven , Kees Cook , Tony Luck , Alexander Shishkin , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org Subject: [PATCH v13 5/8] x86/kexec: Disable LASS during relocate kernel Date: Tue, 18 Nov 2025 10:29:07 -0800 Message-ID: <20251118182911.2983253-6-sohil.mehta@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251118182911.2983253-1-sohil.mehta@intel.com> References: <20251118182911.2983253-1-sohil.mehta@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" The relocate kernel mechanism uses an identity mapping to copy the new kernel, which leads to a LASS violation when executing from a low address. LASS must be disabled after the original CR4 value is saved because kexec paths that preserve context need to restore CR4.LASS. But, disabling it along with CET during identity_mapped() is too late. So, disable LASS immediately after saving CR4, along with PGE, and before jumping to the identity-mapped page. Signed-off-by: Sohil Mehta Reviewed-by: Dave Hansen --- v12: - Pick up review tag. v11: - Improve commit message. --- arch/x86/kernel/relocate_kernel_64.S | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocat= e_kernel_64.S index 11e20bb13aca..4ffba68dc57b 100644 --- a/arch/x86/kernel/relocate_kernel_64.S +++ b/arch/x86/kernel/relocate_kernel_64.S @@ -95,9 +95,12 @@ SYM_CODE_START_NOALIGN(relocate_kernel) /* Leave CR4 in %r13 to enable the right paging mode later. */ movq %cr4, %r13 =20 - /* Disable global pages immediately to ensure this mapping is RWX */ + /* + * Disable global pages immediately to ensure this mapping is RWX. + * Disable LASS before jumping to the identity mapped page. + */ movq %r13, %r12 - andq $~(X86_CR4_PGE), %r12 + andq $~(X86_CR4_PGE | X86_CR4_LASS), %r12 movq %r12, %cr4 =20 /* Save %rsp and CRs. */ --=20 2.43.0