Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp337912ybg; Mon, 1 Jun 2020 02:43:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUmWF4C4qL5VPYyhJfETMjbHxSsJOSo3LIagdXJWgPAEPBcsnW8YBm8B+zEWoshvSh/ObV X-Received: by 2002:a17:906:264a:: with SMTP id i10mr5454007ejc.210.1591004594939; Mon, 01 Jun 2020 02:43:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591004594; cv=none; d=google.com; s=arc-20160816; b=mZNTJAXdVOCRlgehMdmVBL7TMssiDXUVNNJq3yOYkQdvJMUGOXOUytf2cPy245VZL9 /sW2nuDU6Brg/3Vc883oAKmGwyAMZWO0NfPNomcIWSBEZnefPVOBANB9tcnrLh9+cd23 i4adAsLCPOSBasK3ZTjMjyB85D/0KC7wnyn7TDIn/YTwQjDNwmemqEjEvmEWVq8T+q+f YT8OSbpRrKhhOW04CpXPELbnxJwE9fBM87LlwWGyIc8CqodYSdCTU+6Iss6S/nunNw+1 g7F/5tTs6TlcUiXohET6SaKfQRlB9mNGerp4Z8MaRjCORLYi3TOBzZvaj58VHf2NcD60 rcVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=nO7elIn75rXMDTmbGX5CwrU6GxaesMXHLlCbJsq5rEQ=; b=IFgVTWljyZLdX2HVgGI0HzVB77Nlz+0qA+LczIGevLKdLnl14gZ4L9J8OvE4EyJZo5 o4c5Wht993J+k+16q5Q65kKhndmlCjiIexw/tiC0BgKxOhq2De0VmPo6P2bWvzQihiJX rX2qWFJNaL13rsWZXTiEJVNU1klQtGGMLAXbzUJ7Y8GT4uWdg0UOvhmwJWgBJ4p3K2J8 WVrfQEVx/POkXWhgUBk52VbuweVP1UK8ovPr+u+9PRxNYCDrQe6itN4QGx9LK8ngMQ0m arUDv3i5DU6RtW8uUwYDcVoPJxeeIFWQ3w8eIYJUd8jGsvU1rRGQABhINfL40Aag14Vg HvCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@juliacomputing-com.20150623.gappssmtp.com header.s=20150623 header.b=cLgpUZDi; 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 dr10si1654855ejc.204.2020.06.01.02.42.52; Mon, 01 Jun 2020 02:43:14 -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; dkim=pass header.i=@juliacomputing-com.20150623.gappssmtp.com header.s=20150623 header.b=cLgpUZDi; 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 S1726022AbgFAJlF (ORCPT + 99 others); Mon, 1 Jun 2020 05:41:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725831AbgFAJlF (ORCPT ); Mon, 1 Jun 2020 05:41:05 -0400 Received: from mail-il1-x142.google.com (mail-il1-x142.google.com [IPv6:2607:f8b0:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11555C061A0E for ; Mon, 1 Jun 2020 02:41:05 -0700 (PDT) Received: by mail-il1-x142.google.com with SMTP id 18so8716170iln.9 for ; Mon, 01 Jun 2020 02:41:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=juliacomputing-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=nO7elIn75rXMDTmbGX5CwrU6GxaesMXHLlCbJsq5rEQ=; b=cLgpUZDiWZDwAN2vx/sytkpCsMzPnswW25yhXlVOp7mvVpeRlJOUcL6ONESsHq4N5X HH2yxwDti5i1GdDd4YCHAfPTiWSoyXWJxirYGBbpZDuEGo9JLmODxeuxOXEeKzLCB9+C l7vGuRn6j6t3VTQiJVZq5T2MzB9ClqZ6VP+bNNVn8ZUM4GYX9hNpIDTbFVB/Jjh/UT/l /7o7vY5W2BcCYbuGhcjIItQQeq6n7o6igNnkuw3WivgXrRHJoIRI8dDzPGEKi9pDWVXi 9om6exEDZE16d0x4y+jjS1v1SxPgLbzLu1EyvD2GvI+iRK8xDBnMidpRDhiCnt2pEJX/ RUWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=nO7elIn75rXMDTmbGX5CwrU6GxaesMXHLlCbJsq5rEQ=; b=AoVJfSxYctb6zncYtL+p8hCqDwszGgttOuyozluMWkiA085Ica/Pkh/Uzc/3WJX/u2 HwJNr/sUQufbfS74glTH63ZjucE87mx0apE9XdhtIqj2TWzKRYDCRtwvUH7H/rC7zOeJ ZG5F3nzB2pllSDk0hSDWjZsEdQOosWFpIo0OeLtCtFHpKXN8kitdxD+Vpn5igV7GxBEq ahKkAjbg+DgjmfTPWoIra761lMSxc1aasfxIuEY1EK3pBbyaJMGM0tKOOlHWvjhUMPpl 8LGyZrw/nrpSSnNfmyVwhDsp0bOub0GmQUuZDxacKrzvMyuKC87dYKk4wsSdLirCHySr Dpbw== X-Gm-Message-State: AOAM530Z7zhC2EAxzrBm1ODOZ0/fc141H64LxcKxLz8tUOyTaZ4WwNzN AujGbmYFbGeb3CuUr+PpihaqN6GMUDfBsGZMCxrFBg== X-Received: by 2002:a92:c04d:: with SMTP id o13mr7724607ilf.201.1591004464341; Mon, 01 Jun 2020 02:41:04 -0700 (PDT) MIME-Version: 1.0 References: <20200519081551.GA9980@willie-the-truck> <20200520174149.GB27629@willie-the-truck> <20200527095528.GC11111@willie-the-truck> <20200527101929.GT5031@arm.com> <20200601092329.GX5031@arm.com> In-Reply-To: <20200601092329.GX5031@arm.com> From: Keno Fischer Date: Mon, 1 Jun 2020 05:40:28 -0400 Message-ID: Subject: Re: arm64: Register modification during syscall entry/exit stop To: Dave Martin Cc: Kyle Huey , Catalin Marinas , Oleg Nesterov , Linux Kernel Mailing List , Will Deacon , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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. Keno