From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C7CFA33032B for ; Tue, 24 Feb 2026 20:07:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771963677; cv=none; b=mdLbqcg6zw8AlGuCeCSJsQl77BzpnhlQcqlPPtu4M9arnT32Mij/I762SZg34+TkT2YHgm94MelnuvqL+BUCO5GNuLk0RgKjVQK9Z/9ol6Hg49mssGTi5+gKzLVzc178e1RvvQHoSSoJx/NqE0SQ5DzaIFM6qRcqBnGT6b0+ZG0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771963677; c=relaxed/simple; bh=eyBj2yvKsJFGK2cTkEC3YuaenexRWRXOc8sgvR01INg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=AONteG1Ak4VFVQEUerA/ifhS9bE7h98T8fhnslWTIdPUkfE3ZHTJ2W8ohy2s2kfxxz4IT8hlV9Sv3O7xjfUDDb2IYKW3mfe9rV9kHTssyOBDWu6kNJwkCqWAeC6MlcGZaBDn1fcJFggCqNBVWqq/9fvN+qcT1hqVphhGQ9mlanY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B3315497; Tue, 24 Feb 2026 12:07:48 -0800 (PST) Received: from arm.com (arrakis.cambridge.arm.com [10.1.197.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2966C3F59E; Tue, 24 Feb 2026 12:07:54 -0800 (PST) Date: Tue, 24 Feb 2026 20:07:51 +0000 From: Catalin Marinas To: Nirmoy Das Cc: Will Deacon , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH] arm64: signal: preserve si_addr for addresses in the VA hole Message-ID: References: <20260224135503.3329100-1-nirmoyd@nvidia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260224135503.3329100-1-nirmoyd@nvidia.com> On Tue, Feb 24, 2026 at 05:55:03AM -0800, Nirmoy Das wrote: > When userspace accesses an address in the "hole" between user and kernel > virtual address space, the kernel delivers SIGSEGV with si_addr set to > the faulting address. However, untagged_addr() uses sign_extend64() to > canonicalize the address which corrupts hole addresses making debugging > difficult as userspace cannot see the actual faulting value. > > Fix this by only stripping the TBI top-byte for addresses that fall > within the valid user range (below TASK_SIZE) after masking. For hole > addresses, preserve the full original address including any tag bits. >From an architecture perspective, TTBRx selection is done based on bit 55. If TBI is enabled for one of the TTBRx ranges, bits 63:56 of the address are ignored for the translation. Since TBI is always on for the user, it makes sense to always ignore these bits. You just need to be aware that the byte is sign-extended from bit 55. How does it help with debugging if you know the top byte since it's ignored by the hardware anyway. > diff --git a/arch/arm64/include/asm/signal.h b/arch/arm64/include/asm/signal.h > index ef449f5f4ba8..ca7ff6e5cd2f 100644 > --- a/arch/arm64/include/asm/signal.h > +++ b/arch/arm64/include/asm/signal.h > @@ -3,6 +3,7 @@ > #define __ARM64_ASM_SIGNAL_H > > #include > +#include > #include > #include > > @@ -10,6 +11,8 @@ static inline void __user *arch_untagged_si_addr(void __user *addr, > unsigned long sig, > unsigned long si_code) > { > + unsigned long masked; > + > /* > * For historical reasons, all bits of the fault address are exposed as > * address bits for watchpoint exceptions. New architectures should > @@ -18,7 +21,16 @@ static inline void __user *arch_untagged_si_addr(void __user *addr, > if (sig == SIGTRAP && si_code == TRAP_BRKPT) > return addr; > > - return untagged_addr(addr); > + /* > + * Strip tag bits only for valid user addresses. For addresses > + * in the VA hole, preserve the original value so userspace can > + * see the actual faulting address for debugging. > + */ > + masked = (unsigned long)addr & ((1UL << 56) - 1); > + if (masked >= TASK_SIZE) > + return addr; This doesn't make much sense architecturally. In the worst case, I'd keep the top byte only if bit 55 is set (not in relation to TASK_SIZE). But even in this case, I don't see what problem it solves. That top bit doesn't give you any useful information and, with MTE on, TBI1 is also on. -- Catalin