From nobody Wed Oct 8 08:19:52 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.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 7CF80272E7E; Tue, 1 Jul 2025 09:59:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751363954; cv=none; b=kCjxh9vWy1ufRonnpcuzpabt1FJkpRQ9ICvl8DHVpx0al982EvtV3HHSfKiSlrxWkR2C5Ymp/HEhNDPomXrUtsR2Ejl83TZqH36VGYjXHMiLip+Y9j71II8vILXDi3iGOAD7GLbLbV4OURJ2MWzYH9nT6d9PTK/GLnaf+oB0H5w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751363954; c=relaxed/simple; bh=PwAnS8GCFl9R0ZnXkmWVweujaDST7jWhau/vhrZXQZY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RYcY2IzKbFrASIxCDjkRKTJPOAhoQ33LnrguLRO0qaqcC88ZD5wAYG176YsTvKVZ/5kXBJ0lVWuW3u4HLp6vz/AF2OUHjpKhni0WKrgPPV/ZOPTkE33hbr4g8Nx1xw4j55UVdun/eARIc3luBmDjLvTTPg3nP/qeRRU9GYERJdg= 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=PpANrVFW; arc=none smtp.client-ip=192.198.163.12 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="PpANrVFW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1751363953; x=1782899953; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PwAnS8GCFl9R0ZnXkmWVweujaDST7jWhau/vhrZXQZY=; b=PpANrVFWnFQzS82pSI2u6KBOWervEQGW+XRgHh+uCVfiH+zXzgiTZ3lQ NM/WrGDaRSGov5R20VVecFm5uRpmBC61OtPGB9wezMH7QoUf7RvuvCvRr G24EDe0Uu/TF5ycb3kcQLBvXlQCc6Ezl7ie4TWoWgMFLZtVAJqE/jfF+U 8aWlOJPbRhnTi0iVRVxrjSKEVDpkhglIjhIXhbOMzmFyKcEmmxAz73hZc IxNCfxevjmoU7bi7j1aIRIb4E+DgHgKsOTv4QSJntfdkah8C7lcqnW/Ry PiNe/FvaK9FKcWbYLOnctjNDr+6AV5KTv01jrscmuxq9X0cPSsy2QqgP4 Q==; X-CSE-ConnectionGUID: ujCE2VTPQLeHs0IuVgZV/A== X-CSE-MsgGUID: rk6M+QOSSXewlvCnZougyA== X-IronPort-AV: E=McAfee;i="6800,10657,11480"; a="57428114" X-IronPort-AV: E=Sophos;i="6.16,279,1744095600"; d="scan'208";a="57428114" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jul 2025 02:59:12 -0700 X-CSE-ConnectionGUID: FEfNDtZ7Sau6zPbETLZ06Q== X-CSE-MsgGUID: wH3R9HGFQ0yeIauuf+vyYw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,279,1744095600"; d="scan'208";a="190896431" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa001.jf.intel.com with ESMTP; 01 Jul 2025 02:59:00 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id C5534862; Tue, 01 Jul 2025 12:58:50 +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: [PATCHv8 12/17] x86/traps: Communicate a LASS violation in #GP message Date: Tue, 1 Jul 2025 12:58:41 +0300 Message-ID: <20250701095849.2360685-13-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250701095849.2360685-1-kirill.shutemov@linux.intel.com> References: <20250701095849.2360685-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 Provide a more helpful message on #GP when a kernel side LASS violation is detected. A NULL pointer dereference is reported if a LASS violation occurs due to accessing the first page frame. Signed-off-by: Alexander Shishkin Signed-off-by: Kirill A. Shutemov --- arch/x86/kernel/traps.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index 40e34bb66d7c..5206eb0ab01a 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c @@ -636,7 +636,16 @@ DEFINE_IDTENTRY(exc_bounds) enum kernel_gp_hint { GP_NO_HINT, GP_NON_CANONICAL, - GP_CANONICAL + GP_CANONICAL, + GP_LASS_VIOLATION, + GP_NULL_POINTER, +}; + +static const char * const kernel_gp_hint_help[] =3D { + [GP_NON_CANONICAL] =3D "probably for non-canonical address", + [GP_CANONICAL] =3D "maybe for address", + [GP_LASS_VIOLATION] =3D "LASS prevented access to address", + [GP_NULL_POINTER] =3D "kernel NULL pointer dereference", }; =20 /* @@ -672,6 +681,12 @@ static enum kernel_gp_hint get_kernel_gp_address(struc= t pt_regs *regs, if (*addr < ~__VIRTUAL_MASK && *addr + insn.opnd_bytes - 1 > __VIRTUAL_MASK) return GP_NON_CANONICAL; + else if (*addr < ~__VIRTUAL_MASK && + cpu_feature_enabled(X86_FEATURE_LASS)) { + if (*addr < PAGE_SIZE) + return GP_NULL_POINTER; + return GP_LASS_VIOLATION; + } #endif =20 return GP_CANONICAL; @@ -833,11 +848,10 @@ DEFINE_IDTENTRY_ERRORCODE(exc_general_protection) else hint =3D get_kernel_gp_address(regs, &gp_addr); =20 - if (hint !=3D GP_NO_HINT) + if (hint !=3D GP_NO_HINT) { snprintf(desc, sizeof(desc), GPFSTR ", %s 0x%lx", - (hint =3D=3D GP_NON_CANONICAL) ? "probably for non-canonical address" - : "maybe for address", - gp_addr); + kernel_gp_hint_help[hint], gp_addr); + } =20 /* * KASAN is interested only in the non-canonical case, clear it --=20 2.47.2