Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1957269ybh; Tue, 14 Jul 2020 11:37:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5PbCfAWYAXNIWZ+ZmXeIw2wlXOe5l7qDYz6P6z1I2Eaiw4hTBGE50f28xL5Ce1YZb/0JZ X-Received: by 2002:a17:906:1747:: with SMTP id d7mr5800377eje.39.1594751845842; Tue, 14 Jul 2020 11:37:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594751845; cv=none; d=google.com; s=arc-20160816; b=jWqH848bv4e3gteI6DLVuwAhA/QXBlyh6yLxIAJUBY3DNzg9HOVTi+IG7Umn6Cru6S 4JmrbKN8rWyWgjLbCKKBISRMjXbYveiDDIhcckAjIUPjkBIqtapqD3T7wb4CDVyPMVRK DtFPZuKRUZLHaA0s5EMsiaeYQm21gAZsjig8fPaOi1BGQQApLw+ZnD29e/UeOxmFinKd l5yVnZTSxh88f343kqS4mv4CYjEwCmC3ETJ6doZSqX4bX6dbKYmpl7LHvHYJ8TJURB5m GmZCVmYSDXGT0buBpVYUDXxSQovC6xRcnhJQqGP/sBll6upiOkxS/RUTG8YZNF5ZTVqn Zpaw== 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=yyP3ZHSQbiIJkgfhj+w2LY9l2YJKPJ+qK594IrEb58E=; b=j5pB0g7uxbySp0taCGzAF8UthhEknWUHWscv3TeRM2FqTOGs5I15uOOOunIZKNOvFg 0qI7cUjsjfAahHHa/c45WLa2Ukc3KA5N74/0b7tg7vhfPZ8Oi8ZinacEO0n1bALenzbZ cjq2RJU3N8OeJ0jeOQ6SaqgF6d6J1UMo9m1RQv/oQqhfhKub5McRUdTePA43DByWQ8ZS uZPeOo3YgUXldfHmH51zYkoJgZrfnoNn9dJOwJVUL+rFoTPjcbzEMu2DeAXBO8Zwd9m7 i8Y48nUYZOZYuzfjo2LCdceRoGMgM5KkU7VeFQ6Gqu/S9Xq0KVJINfoBZTClLkNI8XJv Yfwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=qYKY00ME; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f1si11077436eje.610.2020.07.14.11.37.02; Tue, 14 Jul 2020 11:37:25 -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=@google.com header.s=20161025 header.b=qYKY00ME; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729226AbgGNSd6 (ORCPT + 99 others); Tue, 14 Jul 2020 14:33:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726817AbgGNSd5 (ORCPT ); Tue, 14 Jul 2020 14:33:57 -0400 Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B4CBC061755 for ; Tue, 14 Jul 2020 11:33:57 -0700 (PDT) Received: by mail-lj1-x243.google.com with SMTP id e4so24640512ljn.4 for ; Tue, 14 Jul 2020 11:33:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=yyP3ZHSQbiIJkgfhj+w2LY9l2YJKPJ+qK594IrEb58E=; b=qYKY00MEabqGiQ7om+FCgRsF3qL/GSt4BdQ+DC3BjaBjVRtPavSO7I+bKn2fn9H/+A 4YBy0mJ2n+3/LWK/rIvkJW2EI4G8dmOhSmAUXBD8hThIgdANEqiZViODGTy4FbwROfPK tRn5nCWI7UiPloxZ1mwja90xAyhlIvln/CUboMoCeo0trcdTJyJjV/oBdcYI1stqk/wA l7D4atz2mu0OIXlrT1I7Sjl4Zhb6DLYCoG6xROrOmWi4z+5tAVUy1jbIiVFPQUIr88t7 Q357PW73mz4a2VcF94WK8yu4QOJCbCniyE4OnjqjHoCYNlA/Y6U+x+hheWnzedDV4r0a OqOQ== 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=yyP3ZHSQbiIJkgfhj+w2LY9l2YJKPJ+qK594IrEb58E=; b=X5YXFTLPyQMaAO9IUv6boITJZRCDKiSKNJz3JRAv3ubUoIZhD9vpXpcEkEvdHmPeyI HJp8YNj2sjIaQg8HAcAU5KehpCinIt9Uh6wSSR+LyCKvD6SjM6pZehqtte/CGsMT2J6j BjX1Qe0MugsOv6wJ7wpjH4dqFCK1LiCrnM8ZDrosX20pyKFJ/nf9HGKJPx6DxGeHXxLm yXf0CPe4NJ7Z/OaLw1PVwxpSffMSqZcDwZdnJJUFl2xuKgPXu9OcHm6kijdE5M0P14/H K2pGaTiwhXCQ8tNjTRJUvgKacK5DPLLDjwwzbtMj+RPOPLqzlX2Hw4RH+lEbHQi8Q0RC gpSg== X-Gm-Message-State: AOAM530YJyFS0IQVap1u4aZc1q43GQxspuFW+AByjsO+dt1BpB/YFTi9 J/EVCzXTZ/IpQbMhO34ly3kKc7U7JagpWa9ZguXRQw== X-Received: by 2002:a2e:9b87:: with SMTP id z7mr186034lji.80.1594751635653; Tue, 14 Jul 2020 11:33:55 -0700 (PDT) MIME-Version: 1.0 References: <20200714030348.6214-1-mathieu.desnoyers@efficios.com> <20200714030348.6214-3-mathieu.desnoyers@efficios.com> <775688146.12145.1594748580461.JavaMail.zimbra@efficios.com> In-Reply-To: <775688146.12145.1594748580461.JavaMail.zimbra@efficios.com> From: Peter Oskolkov Date: Tue, 14 Jul 2020 11:33:44 -0700 Message-ID: Subject: Re: [RFC PATCH 2/4] rseq: Allow extending struct rseq To: Mathieu Desnoyers Cc: Peter Oskolkov , Peter Zijlstra , linux-kernel , Thomas Gleixner , paulmck , Boqun Feng , "H. Peter Anvin" , Paul Turner , linux-api , Christian Brauner , Florian Weimer , carlos , Chris Kennelly 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 Tue, Jul 14, 2020 at 10:43 AM Mathieu Desnoyers wrote: > > ----- On Jul 14, 2020, at 1:24 PM, Peter Oskolkov posk@posk.io wrote: > > > At Google, we actually extended struct rseq (I will post the patches > > here once they are fully deployed and we have specific > > benefits/improvements to report). We did this by adding several fields > > below __u32 flags (the last field currently), and correspondingly > > increasing rseq_len in rseq() syscall. If the kernel does not know of > > this extension, it will return -EINVAL due to an unexpected rseq_len; > > then the application can either fall-back to the standard/upstream > > rseq, or bail. If the kernel does know of this extension, it accepts > > it. If the application passes the old rseq_len (32), the kernel knows > > that this is an old application and treats it as such. > > > > I looked through the archives, but I did not find specifically why the > > pretty standard approach described above is considered inferior to the > > one taken in this patch (freeze rseq_len at 32, add additional length > > fields to struct rseq). Can these be summarized? > > I think you don't face the issues I'm facing with libc rseq integration > because you control the entire user-space software ecosystem at Google. > > The main issue we face is that the library responsible for registering > rseq (either glibc 2.32+, an early-adopter librseq library, or the > application) may very well not be the same library defining the __rseq_abi > symbol used in the global symbol table. Interposition with ld preload or > by defining the __rseq_abi in the program's executable are good examples > of this kind of scenario, and those use-cases are supported. > > So the size of the __rseq_abi structure may be larger than the struct > rseq known by glibc (and eventually smaller, if future glibc versions > extend their __rseq_abi size but is loaded with an older program/library > doing __rseq_abi interposition). > > So we need some way to allow code defining the __rseq_abi to let the kernel > know how much room is available, without necessarily requiring the code > responsible for rseq registration to be aware of that extended layout. > This is the purpose of the __rseq_abi.flags RSEQ_FLAG_TLS_SIZE and field > __rseq_abi.user_size. > > And we need some way to allow the kernel to let user-space rseq critical > sections (user code) know how much of those fields are actually populated > by the kernel. This is the purpose of __rseq_abi.flags RSEQ_FLAG_TLS_SIZE > with __rseq_abi.kernel_size. Thanks, Mathieu, for the explanation. Yes, multiple unrelated libraries having to share struct rseq complicates matters. Your approach appears to be a way to reconcile the issues you outlined above. Thanks, Peter > > Thanks, > > Mathieu > > -- > Mathieu Desnoyers > EfficiOS Inc. > http://www.efficios.com