Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp530981pxf; Thu, 11 Mar 2021 08:54:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJzXV6HJWcnLolJgAQ8EVy5+i0Kdy8eFi2oHyArZlBB+91o3ArR696M03H1YojRXBMGLIaMx X-Received: by 2002:a17:906:8447:: with SMTP id e7mr4056816ejy.523.1615481688723; Thu, 11 Mar 2021 08:54:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615481688; cv=none; d=google.com; s=arc-20160816; b=oFgCTKWcg7AmDMe8LWigiLETO/jkRRI63uI7NjpJy+WqTXzog+M8aoO/w5ycTG6+D2 tC5tkDeLYqLEo0udUy0E5sFYhSw7ZUwXJEoseHSClXVLFwJJZuYWbynPjaNl6UPvDPhL k8IBE7tAZZ/e3mfpiITPCdBmahrnmGBqPUVAYKCAJ5GMkgAKYppxaTO9kPXzxB2TXZ6g 2yq7PlSBh0VhONUfQ1XCKSc90seiuVQpjHW0tsxMhFlophMvn2V0yLIWb47LM4hGGNbS EjE1Qmc1SIubJZwuiyMHDb+eK8ZBeBGMftI/uZZMrri2JBAhz0vzU2QAL17xE27pOHFL jzEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=jojXJ42UMX7xPogeR/Mx0xX5P7m6PdT89qs91n08TWo=; b=e/w1ZJ/ESxqvng6pU4ITXkBK/7Vwwk5qrwKIFwoEke5jby0JfBdqE/ucnat2fJiymF pzj4OyvdnX8soYk5zgepkcdIKXnELCr9ueCBW4Mw3Pn2MicJGdFi6wkvVwu8jsz473mb W0eqf7DqDle+VKGVFGVR+zWhvSgQmxZwZiKSWf+krP86K95vfCiUd1hjOqI19gecFsPg nJFxhgyzkgdBFPovihodgG2gIJ9FXZN341UgTm8QJcHmOs+9t0HNOm/hz2kpLuQtPd5g tQsQdCwGuYFnICJZq477vLFMh5gys1w/DNTuy4s0rVG0eGJW/TeIHkBmuQ3uRCxROQb5 53hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=QtzkLjJC; 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 ay21si2135607ejb.527.2021.03.11.08.54.25; Thu, 11 Mar 2021 08:54:48 -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; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=QtzkLjJC; 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 S229883AbhCKQwd (ORCPT + 99 others); Thu, 11 Mar 2021 11:52:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229735AbhCKQw0 (ORCPT ); Thu, 11 Mar 2021 11:52:26 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29F30C061574; Thu, 11 Mar 2021 08:52:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=jojXJ42UMX7xPogeR/Mx0xX5P7m6PdT89qs91n08TWo=; b=QtzkLjJCe42eAwZ5cWDdaH3YGv Z1LcAP8aoAk5vnC910BVd4LtywBRSTrl9hlFggmzXruMJCyyBoMTBIYvjQhgir0HgupnuL8PUNVXf lHl3yD/h+0nPv8WLTpdJuaBELGVsYAil6MImW+dkHkfd/NXn0qs4epBtUPwIVFsH6nIvw+Q8mOp8m gfBePz0ulbeUoJICMI2OqLbmdFSrN5bDqaAUBWN6zCQfdhnMEeDniH5/CtT//D9Y32QD2NLtfPQk7 yQSUs6aZLVZ6cUpwxZ+/O6T5MnqhwLBcXrppHBJXaGwJ8uTzHDVY7CCKnZzSooboClxHgAZJE1KzY nbMMotLA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1lKOXK-007qGS-Fc; Thu, 11 Mar 2021 16:51:54 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 59AE2301959; Thu, 11 Mar 2021 17:51:45 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 464BD2BF461C2; Thu, 11 Mar 2021 17:51:45 +0100 (CET) Date: Thu, 11 Mar 2021 17:51:45 +0100 From: Peter Zijlstra To: Mathieu Desnoyers Cc: Piotr Figiel , Andrew Morton , paulmck , Boqun Feng , Oleg Nesterov , "Dmitry V. Levin" , Florian Weimer , Alexey Dobriyan , Andrei Vagin , linux-kernel , Peter Oskolkov , Kamil Yurtsever , Chris Kennelly , Paul Turner , emmir , linux-man , linux-api Subject: Re: [PATCH v2] ptrace: add PTRACE_GET_RSEQ_CONFIGURATION request Message-ID: References: <20210226135156.1081606-1-figiel@google.com> <1173189328.5477.1615474316906.JavaMail.zimbra@efficios.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1173189328.5477.1615474316906.JavaMail.zimbra@efficios.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 11, 2021 at 09:51:56AM -0500, Mathieu Desnoyers wrote: > > > ----- On Feb 26, 2021, at 8:51 AM, Piotr Figiel figiel@google.com wrote: > > > For userspace checkpoint and restore (C/R) a way of getting process state > > containing RSEQ configuration is needed. > > > > There are two ways this information is going to be used: > > - to re-enable RSEQ for threads which had it enabled before C/R > > - to detect if a thread was in a critical section during C/R > > > > Since C/R preserves TLS memory and addresses RSEQ ABI will be restored > > using the address registered before C/R. > > > > Detection whether the thread is in a critical section during C/R is needed > > to enforce behavior of RSEQ abort during C/R. Attaching with ptrace() > > before registers are dumped itself doesn't cause RSEQ abort. > > Restoring the instruction pointer within the critical section is > > problematic because rseq_cs may get cleared before the control is passed > > to the migrated application code leading to RSEQ invariants not being > > preserved. C/R code will use RSEQ ABI address to find the abort handler > > to which the instruction pointer needs to be set. > > > > To achieve above goals expose the RSEQ ABI address and the signature value > > with the new ptrace request PTRACE_GET_RSEQ_CONFIGURATION. > > > > This new ptrace request can also be used by debuggers so they are aware > > of stops within restartable sequences in progress. > > > > Signed-off-by: Piotr Figiel > > Reviewed-by: Michal Miroslaw > > Reviewed-by: Mathieu Desnoyers How do we route this? Do I stick this in tip/sched/core as being an rseq patch?