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 630A32BD58A for ; Wed, 24 Jun 2026 14:55:20 +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=1782312921; cv=none; b=FCU9S1C20uq0NVf3fGNlUkYIQ8gePdp1Zx4yTNbNkmobLsOCE7II4ZQHUDAZnTiSdAhehyglcGW45/SZOBR/4ke9Mgrai55jh9veoNn94LUWn42P2HZdiAoE2k26pv52wN/On1AeAr6TCQZO5Grcu1V1jXag94Hx+ykFntITtJw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782312921; c=relaxed/simple; bh=tEkCFO/7kjtDTSCATNl+pL/YVd1ciADIUOeJdcK0kik=; h=Message-ID:Date:MIME-Version:Subject:To:References:From:Cc: In-Reply-To:Content-Type; b=TDCNPumSU2uylo0Y9PjV8p2YdQ3Dd3EiIn6is8tTIE5OwKLsap71gwRewwepzYThaGbPk+Sadf2HGDXbiUxElin114PU+vlYWAtRxvL8+0EaK30C3+2K/p71tABrnTa+TgQIW9tGubjzrtWt6nF+D5TP6xuaNmyVcpaFA89F+hA= 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; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=Ar0n6+64; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="Ar0n6+64" 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 0610B2944; Wed, 24 Jun 2026 07:55:15 -0700 (PDT) Received: from [10.2.213.11] (e137867.arm.com [10.2.213.11]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E28433F62B; Wed, 24 Jun 2026 07:55:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1782312919; bh=tEkCFO/7kjtDTSCATNl+pL/YVd1ciADIUOeJdcK0kik=; h=Date:Subject:To:References:From:Cc:In-Reply-To:From; b=Ar0n6+64oRwrxWE3lp9TQ68Ez0mRiyFyHz9QPRPNY+Zy85YsKjXwzbds3QVzA9pBK d8QuTIacfO+/1tno4aM4Unz2j+NIS61dbJy0YxPFh/zqujby+KEqZ/o6QZ8KGpy0G8 pBL4er099nhu/NbNXZVLIZCZ6biGmhwafZmzcLL0= Message-ID: <7c6bbc36-b100-4ca1-a710-99b483b04d2d@arm.com> Date: Wed, 24 Jun 2026 15:55:14 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v15 09/11] arm64/ptrace: Skip syscall exit reporting for PTRACE_SYSEMU_SINGLESTEP To: Jinjie Ruan References: <20260511092103.1974980-1-ruanjinjie@huawei.com> <20260511092103.1974980-10-ruanjinjie@huawei.com> From: Ada Couprie Diaz Cc: Ada Couprie Diaz , catalin.marinas@arm.com, will@kernel.org, oleg@redhat.com, tglx@kernel.org, peterz@infradead.org, luto@kernel.org, kees@kernel.org, wad@chromium.org, mark.rutland@arm.com, yeoreum.yun@arm.com, linusw@kernel.org, kevin.brodsky@arm.com, ldv@strace.io, thuth@redhat.com, james.morse@arm.com, song@kernel.org, anshuman.khandual@arm.com, broonie@kernel.org, ryan.roberts@arm.com, pengcan@kylinos.cn, liqiang01@kylinos.cn, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Content-Language: en-US, en-GB, fr Organization: Arm Ltd. In-Reply-To: <20260511092103.1974980-10-ruanjinjie@huawei.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 11/05/2026 10:21, Jinjie Ruan wrote: > Align the syscall exit reporting logic with the generic entry > framework by skipping the exit stop when PTRACE_SYSEMU_SINGLESTEP is > in effect. > > [Rationale] > When a tracer uses PTRACE_SYSEMU_SINGLESTEP, both _TIF_SYSCALL_EMU > and _TIF_SINGLESTEP flags are set. Currently, arm64 reports a syscall > exit stop whenever _TIF_SINGLESTEP is set, regardless of the > emulation state. > > However, as per the generic entry implementation (see > include/linux/entry-common.h): > "If SYSCALL_EMU is set, then the only reason to report is when SINGLESTEP > is set (i.e. PTRACE_SYSEMU_SINGLESTEP). This syscall instruction has been > already reported in syscall_trace_enter()." > > Since PTRACE_SYSEMU intercepts and skips the actual syscall > execution, reporting a subsequent exit stop is redundant and > inconsistent with the expected behavior of emulated system calls. > > [Changes] > - Introduce report_single_step(): Add a helper to encapsulate the > logic for deciding whether to report a single-step stop at syscall > exit. It returns false if _TIF_SYSCALL_EMU is set, ensuring the > emulated syscall does not trigger a duplicate report. > > - Update syscall_exit_work(): Use the new helper to determine > the stepping state instead of directly checking _TIF_SINGLESTEP. > > [Impact] > - PTRACE_SINGLESTEP: Continues to report exit stops for actual > instructions. > > - PTRACE_SYSEMU: Continues to skip exit stops. > > - PTRACE_SYSEMU_SINGLESTEP: Now correctly skips the redundant exit > stop, aligning arm64 with the generic entry infrastructure. > > Cc: Mark Rutland > Cc: Will Deacon > Cc: Catalin Marinas > Reviewed-by: Linus Walleij > Reviewed-by: Yeoreum Yun > Signed-off-by: Jinjie Ruan > --- Reviewed-by: Ada Couprie Diaz