Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp5713324pxb; Tue, 16 Feb 2021 05:57:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJyzRdX5a7tXJ9LRvWbKErA2UGcCU5wGRmqntGes5YhcysNesBxD3MsLWEr8XRwWtnCSloEU X-Received: by 2002:a19:6411:: with SMTP id y17mr11706455lfb.562.1613483846578; Tue, 16 Feb 2021 05:57:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613483846; cv=none; d=google.com; s=arc-20160816; b=xJ7aNBF05KeysslzR+u1IoO5TVBLjUtpwdPEkfwOMKaX/4qFxbJS0ueCptzQeZEwcj 7nr5/eNnUWyN/sc07tUhCtyEMuK+gNr44Co8xtU5UU5UVNvJ19rVohseREevjdib17s0 I+wV/6jjZOf9ddMMj4bLXYnbNDolcG+SHuGoT5UWbrnUbXmkivPMSukoUe7pgBr6ntix xqE70yoJ1Vf8rbKuiPrFG1d3KAu/znRmkSvlcPksu0wuaGN2eJr+Vki8HpjSG2UTriwD aOE4ZQ6E46lUNsOLOfbOt6kOft+0CNAZw4f8fOOA/yeqLq0+jeCbnKPtwUm9aEnCdMpg E8AQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date; bh=m/QtgS71oSVwu/rwlB88CQ2Hf8kqcIl9/liO7JHU36c=; b=If8x97AHiTKpaLSrHxQVwUYtpYGgDTOM6saAyCcD5iCb/xiU/icbbl5PT11KYdUPBA Uz9/csPpl8+fUNLirPVAV6+hAkwMeAiHxzy0NwPHOsY9ZFroCS4qsWmey/e2gqr3i7CK 0ZVkjrq4f1nZQecdk06ue4K4Z/p1S312o+qbXIj2eUCMaI0AlHqenHzgjqj1fOPo/1vi fjslBTPR1dyFoWOah99ppYK/0xzENZGrJDggcQKc14s+4d/NxcMry4CeeSXv5gI5BtAx GVI66JQH7fWrdEKZeERMCi3IPMreX4qU7XzD7yfjnZNQQvLjQd3ofod5WwamAdg08Ci4 iG2w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k2si13295326ejr.529.2021.02.16.05.57.03; Tue, 16 Feb 2021 05:57:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229993AbhBPN4Y (ORCPT + 99 others); Tue, 16 Feb 2021 08:56:24 -0500 Received: from angie.orcam.me.uk ([157.25.102.26]:34238 "EHLO angie.orcam.me.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229713AbhBPN4U (ORCPT ); Tue, 16 Feb 2021 08:56:20 -0500 Received: by angie.orcam.me.uk (Postfix, from userid 500) id 799E292009D; Tue, 16 Feb 2021 14:55:36 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id 7266592009C; Tue, 16 Feb 2021 14:55:36 +0100 (CET) Date: Tue, 16 Feb 2021 14:55:36 +0100 (CET) From: "Maciej W. Rozycki" To: Thomas Bogendoerfer cc: Tiezhu Yang , Oleg Nesterov , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Xuefeng Li , kernel test robot , Xingxing Su Subject: Re: [PATCH v2] MIPS: Add basic support for ptrace single step In-Reply-To: <20210212163335.GA12558@alpha.franken.de> Message-ID: References: <1612939961-8827-1-git-send-email-yangtiezhu@loongson.cn> <20210211102905.GE7985@alpha.franken.de> <20210212163335.GA12558@alpha.franken.de> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 12 Feb 2021, Thomas Bogendoerfer wrote: > > IMHO ptrace single step is for CPUs supporting single stepping and not > > for emulating it in the kernel. > > I've checked other arch how they implement single step, and looks like > I'm wrong. So I'm ok with applying your patch. Can you resend it again, > so I'll get the latest version in patchwork ? Huh? How is that supposed to work? Skimming over the code it hardcodes the breakpoint instruction, which is ISA-dependent and relies on branches or jumps to have a delay slot, which is not universally true. The kernel does not know all the exotic branches the MIPS ISA has (BC1ANY4F anyone?) either and IMHO should not. This is broken and belongs to the userland anyway. See how complex the handling is in GDB, specifically `mips16_next_pc', `micromips_next_pc' and `mips32_next_pc' in gdb/mips-tdep.c. We do have branch emulation code, but it was intended for a different purpose and is therefore not complete enough for single-stepping emulation. And I find it regrettable that the kernel has become so bloated here and attempts are made to make it even more bloated. All under the original excuse made by FP emulation code, which also should have been made in the userland. It all really does not belong to the kernel with its elevated privilege. It does not require the privilege. We do need a ptrace(2) request to stop on signal handler invocation though, which is something we have been missing and never got to implementing. Maciej