Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp348307ybg; Mon, 1 Jun 2020 03:01:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyw1BMuoV9jKHuB4Mn5RGVa5hxXo2biv5UFENm3rb6xrL4Ir1bJuu9PrHQ/xXB722Y2qQe/ X-Received: by 2002:a17:906:ac3:: with SMTP id z3mr12160600ejf.311.1591005719293; Mon, 01 Jun 2020 03:01:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591005719; cv=none; d=google.com; s=arc-20160816; b=sqVVyArbsXpbeB1Ks7ER9Ll+ngUSR2JrwmlGSy2QAQBDLaluirPSBHq+/NSWMjguzd j+9iqNumlsI+dSOPFJ4ZNTOd+TQZGFNk2N2k7UBGXf5eYmuQPEhkEjcsYsj7EhvLlQOB bk/tvHOe3KfQSYWHrcRYHUAqh3WJ2TxsnrOYEwNlBidnmRvVapsFiz5r3eqH1hF/oN0u TIXWGgd14WdsFYtoBIsW0lqCBcSA/wKH2JBHO8M+v3DxB787WmP4suQXIfPhPZonF0a4 DpK8O/HzW/tMjVwRdljmgMso0gArYLeE6URzNztc51HuOgm/4BJPkcMw3U+FAN8xXRf8 DSAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=tcsdlInoJEbTdAC0eBr+p1NGBGrapx4HsBHO40AopZA=; b=wkP1L816stsGahevugBnQnuk5Kt+6xAXrGhBSmj0o+Kua0uPHDf6BJio0Y4YwV/Rhr 8qRElHP6d9PlXW/EpeMOmBbDzY75cEMt+07MnCSZCttJGfd4uZAiY/TWJrFkgRD4JR0I sqhLkGeWjkLq4xb/4ZibelBIYNqUSO11s4crxXLy6chxQWV6fXYBQrKGUr1gMe8kjXhB awINMNRq1cP6Xcqc4naLLYdmBFmoDSlG8kN4m5IyiSLyso+BcKuTLke9WSDFH+eDXN0t 2lfJJeh3lLcQ/6JSno0Mdx6sU6SddxdNq4fL0+JRcZyERC0vu2c5fBHCmMnfoDKcy0xv 78aw== 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 a19si5556041ejf.724.2020.06.01.03.01.35; Mon, 01 Jun 2020 03:01:59 -0700 (PDT) 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 S1726078AbgFAJ73 (ORCPT + 99 others); Mon, 1 Jun 2020 05:59:29 -0400 Received: from foss.arm.com ([217.140.110.172]:35832 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725788AbgFAJ73 (ORCPT ); Mon, 1 Jun 2020 05:59:29 -0400 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 956831FB; Mon, 1 Jun 2020 02:59:28 -0700 (PDT) Received: from arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 799EB3F305; Mon, 1 Jun 2020 02:59:27 -0700 (PDT) Date: Mon, 1 Jun 2020 10:59:25 +0100 From: Dave Martin To: Keno Fischer Cc: Kyle Huey , Catalin Marinas , Oleg Nesterov , Linux Kernel Mailing List , Will Deacon , linux-arm-kernel@lists.infradead.org Subject: Re: arm64: Register modification during syscall entry/exit stop Message-ID: <20200601095925.GZ5031@arm.com> References: <20200519081551.GA9980@willie-the-truck> <20200520174149.GB27629@willie-the-truck> <20200527095528.GC11111@willie-the-truck> <20200527101929.GT5031@arm.com> <20200601092329.GX5031@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 01, 2020 at 05:40:28AM -0400, Keno Fischer wrote: > On Mon, Jun 1, 2020 at 5:23 AM Dave Martin wrote: > > > > Can't PTRACE_SYSEMU be emulated by using PTRACE_SYSCALL, cancelling the > > > > syscall at the syscall enter stop, then modifying the regs at the > > > > syscall exit stop? > > > > > > Yes, it can. The idea behind SYSEMU is to be able to save half the > > > ptrace traps that would require, in theory making the ptracer > > > a decent amount faster. That said, the x7 issue is orthogonal to > > > SYSEMU, you'd have the same issues if you used PTRACE_SYSCALL. > > > > Right, I just wondered whether there was some deeper difference between > > the two approaches. > > You're asking about a new regset vs trying to do it via ptrace option? I meant SYSEMU versus SYSCALL + cancellation and emulating the syscall at the syscall exit stop. i.e., I was trying to understand whether SYSEMU is just a convenience, or does some magic that can't be reproduced by other means. > I don't think there's anything a ptrace option can do that a new regset > that replicates the same registers (I'm gonna propose adding orig_x0, > while we're at it and changing the x0 semantics a bit, will have > those details with the patch) wouldn't be able to do . The reason I > originally thought it might have to be a ptrace option is because > the register modification currently gets applied in the syscall entry > code to the actual regs struct, so I thought you might have to know > to preserve those registers. However, then I realized that you could > just change the regset accessors to emulate the old behavior, since > we do already store all the required information (what kind of stop > we're currently at) in order to be able to answer the ptrace > informational queries. So doing that it probably just all around > easier. I guess NT_PRSTATUS might also rot, but I guess strace > doesn't really have to stop using it, since it doesn't care about > the x7 value nor does it need to modify it. I think NT_PRSTATUS probably doesn't need to change. Having a duplicate regset feels like a worse outcome that having a new ptrace option. Undocumentedly different things already happen to the regs depending on how the tracee stopped, so adding a new special case doesn't seem to justify creating a new regset. Cheers ---Dave