From patchwork Tue Nov 22 20:39:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 24556 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2428779wrr; Tue, 22 Nov 2022 12:41:06 -0800 (PST) X-Google-Smtp-Source: AA0mqf5PiDj4utjqBwV1H9eeI7cObWfqCXo/+tir7GVf1LHcmhcQYMxzr8VLo3QMaTA8XFDgLYQ6 X-Received: by 2002:a17:90b:4a46:b0:218:bdfa:1ef with SMTP id lb6-20020a17090b4a4600b00218bdfa01efmr9244065pjb.100.1669149666350; Tue, 22 Nov 2022 12:41:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669149666; cv=none; d=google.com; s=arc-20160816; b=yEkk0KSBHCj1+KvLOy/o/aPG1bf742DXJHCjREh9bx417u6DLEPf0XbMyBqoRx7125 eSdZKkIW8S8MA8o5RbF33qfvvVmd0nTCdLLtcRjLzp5V2Mchv6QhCUfG/qc5cRfoKBhe dduho9lY++HLrfPzHXnFvXuXzkgesmd7bubk/Zuo1b3jRfTaHnNQVH15+nP1Ri9n9K1m 7c8aUugCtZzhCFsBIVsHpdqWMjXHEB2CWRntMwpKB3SdRoEMZE+ux1y4mUR5zVwclXS7 fThlBPv3PB/1XSobAa9Zzz0ShGtJvVpxdJwcuzyCmBQTe02wF4Kg6HBSA5dw+Pi7op5q w32w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=i6XTSsk7DOXSZF3ceW0m6RsyJxZFbIzbQ8FhLufxsXs=; b=gbB/GnIcPouRMcoQ17OHFi7arhr2Bpy/NHz4hQUmMl/AhCpVODVOwbTm01/SoDmSyY s+OMTdeao57zmUsQMsum0b6wHqxusqfK/z78USBaoUxeJpbGapv29gUXHMvoRJcOTUxd /Lwkc0Yxl6wcoc38ahx1QeuzhPS+/WTZKOGMxQU07LSkdmNColzDic7zYgOLAkgLve4f eyRoeHdsGIJekZ6pzs8xfj4llb3AE7fu0gGUN6cH+NqUCFHCvCkRRY04IvFnIGJHDT1n apBopcmyOQ7hvKzjKSfc+PLpKRTmowNp2DcZ3nfRTx/t5TP8MrBi5P/iKX8elTjMDrL2 Jrmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=q9bdwhko; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id il3-20020a17090b164300b002024f3f1f8bsi15919342pjb.70.2022.11.22.12.40.51; Tue, 22 Nov 2022 12:41:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=q9bdwhko; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234933AbiKVUkE (ORCPT + 99 others); Tue, 22 Nov 2022 15:40:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233916AbiKVUju (ORCPT ); Tue, 22 Nov 2022 15:39:50 -0500 Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54873725E0; Tue, 22 Nov 2022 12:39:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1669149585; bh=3FQzak7NFQCeQ17sM6xyWBPLJooy+CEjUwRxboNNo2U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q9bdwhkoIOl3a0a7KUDXD2xTHcVGHLg70EzMk8dzd7kKvWoiP9zK1zw0uOUsB0w0Y 0gkW7B7aYlcWy75DJWmWiQ+yFiEF6zhGY0++WOyErXmhRKXD/3wNRgHZZ9zX2yA6+O ZAFi7p5Wr3/JKQY5OGjfZ7t0eKpB7H9J7+pylRJ2+FtSTP90X8j0Dp6j+jt7HZNi2l WNvM5bxlU5+wck+OMG26oaEgnPxB5tykmc5N8x5NO8mA3wbhVIPtuWaiEVH6pwt6tc FFZLxBfY6c3WY3fPNYkX7Jiw60mnAAMMdPR9n3u4/DP1EnBwxAv6Zxuka5JFLkRIK+ punpFFYFoLKmg== Received: from localhost.localdomain (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4NGx2S6wLhzXR9; Tue, 22 Nov 2022 15:39:44 -0500 (EST) From: Mathieu Desnoyers To: Peter Zijlstra Cc: linux-kernel@vger.kernel.org, Thomas Gleixner , "Paul E . McKenney" , Boqun Feng , "H . Peter Anvin" , Paul Turner , linux-api@vger.kernel.org, Christian Brauner , Florian Weimer , David.Laight@ACULAB.COM, carlos@redhat.com, Peter Oskolkov , Alexander Mikhalitsyn , Chris Kennelly , Mathieu Desnoyers Subject: [PATCH 02/30] rseq: Introduce feature size and alignment ELF auxiliary vector entries Date: Tue, 22 Nov 2022 15:39:04 -0500 Message-Id: <20221122203932.231377-3-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221122203932.231377-1-mathieu.desnoyers@efficios.com> References: <20221122203932.231377-1-mathieu.desnoyers@efficios.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750230280817168543?= X-GMAIL-MSGID: =?utf-8?q?1750230280817168543?= Export the rseq feature size supported by the kernel as well as the required allocation alignment for the rseq per-thread area to user-space through ELF auxiliary vector entries. This is part of the extensible rseq ABI. Signed-off-by: Mathieu Desnoyers --- fs/binfmt_elf.c | 5 +++++ include/uapi/linux/auxvec.h | 2 ++ include/uapi/linux/rseq.h | 5 +++++ 3 files changed, 12 insertions(+) diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 63c7ebb0da89..04fca1e4cbd2 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -288,6 +289,10 @@ create_elf_tables(struct linux_binprm *bprm, const struct elfhdr *exec, if (bprm->have_execfd) { NEW_AUX_ENT(AT_EXECFD, bprm->execfd); } +#ifdef CONFIG_RSEQ + NEW_AUX_ENT(AT_RSEQ_FEATURE_SIZE, offsetof(struct rseq, end)); + NEW_AUX_ENT(AT_RSEQ_ALIGN, __alignof__(struct rseq)); +#endif #undef NEW_AUX_ENT /* AT_NULL is zero; clear the rest too */ memset(elf_info, 0, (char *)mm->saved_auxv + diff --git a/include/uapi/linux/auxvec.h b/include/uapi/linux/auxvec.h index c7e502bf5a6f..6991c4b8ab18 100644 --- a/include/uapi/linux/auxvec.h +++ b/include/uapi/linux/auxvec.h @@ -30,6 +30,8 @@ * differ from AT_PLATFORM. */ #define AT_RANDOM 25 /* address of 16 random bytes */ #define AT_HWCAP2 26 /* extension of AT_HWCAP */ +#define AT_RSEQ_FEATURE_SIZE 27 /* rseq supported feature size */ +#define AT_RSEQ_ALIGN 28 /* rseq allocation alignment */ #define AT_EXECFN 31 /* filename of program */ diff --git a/include/uapi/linux/rseq.h b/include/uapi/linux/rseq.h index 77ee207623a9..05d3c4cdeb40 100644 --- a/include/uapi/linux/rseq.h +++ b/include/uapi/linux/rseq.h @@ -130,6 +130,11 @@ struct rseq { * this thread. */ __u32 flags; + + /* + * Flexible array member at end of structure, after last feature field. + */ + char end[]; } __attribute__((aligned(4 * sizeof(__u64)))); #endif /* _UAPI_LINUX_RSEQ_H */