From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B3F6C43381 for ; Thu, 11 Mar 2021 16:53:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2F8A764FFD for ; Thu, 11 Mar 2021 16:53:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229928AbhCKQwd (ORCPT ); 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?