From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from CAN01-YQB-obe.outbound.protection.outlook.com (mail-yqbcan01on2104.outbound.protection.outlook.com [40.107.116.104]) by sourceware.org (Postfix) with ESMTPS id 477EA3857B8B for ; Fri, 16 Feb 2024 20:19:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 477EA3857B8B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 477EA3857B8B Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.116.104 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1708114779; cv=pass; b=PLYoKUFBNoKRX+GOonifO3aKqILW+eNo0MC20UNprPs7I2VNkyyWqpb7zuevXwgUM1UPrgrfEZERNYyPr2I0xQrYXGBrM22rMR74NMPG66UiRyZhWGQeDT8INgza7ck+vmM1tXM3jyOluLrb5S8+FftvaGGTFH4UrXOEUrAhSLA= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1708114779; c=relaxed/simple; bh=PAf1wk7EELnoLYW/rVB4wEwZQbBVkWqLFzayafllde8=; h=DKIM-Signature:Message-ID:Date:Subject:From:To:MIME-Version; b=lnjJ2DEcBmr2VJzNbl5fBM9BhRdI+nL1drBEezK4tgYeAa8lbEtRirW2VUjQGfHu8fjHVoPTZYbRBc+cPrsYulYPsQ3E139Gxr7iVo7Uz8oeb0THZBOskOdXYPcD9D1vAgablZFsVJdUmSk0mavPY9Ldz6Sz8vFzfI8zq2OYszQ= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KPpBwxltKwfcTpQuWJW8EVKnfq4193gZrPHm3ZMk6ZkDm0NjMkLlM155QVfiVrdsnEdDO0kAg+Xu6/zbeFKX00fcE7QsyyXBflabF6m51tj7AiSrIy4kWhjxwxvvfvv0mLxaHAX7MOp+nuoYOzshis87o8PQ3I7cyyL280PSTrqo/ageNcwroFf+KIDGzaiu5Ys9LYuF9d6qvFu4x+LA9Cbl6EH8fstxSBh/uJ/i9BAXg5KMZRmrMgvynKzHvyWV6yTcBIVOwvkHNP3Uee2mQ/uMl99hx6bz4+yWf+WhGoDquz5q8WbIe8btnIZHryYGDlUjJwgZ8zOjb/7Nn2+Hiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=IzVY+CoI9z0/kPBOXPBswiu9v607r2qSlRaGnoOPmLE=; b=oVp/Sstz0uTfNpeuKQgkOIJzpgD2YnYc/skuBufiuItsglhGFYjvU0vhItNnj3Tv74tBqZswUU+ysYIDYp8SaY/+1ApnONvfH66lQEfEf8lwJydJWB4z/+O1I/WMEUPl76q2L5WOy7IltZPuHMK49NOOa0TmgzC6My8IA6srIDZ0moKW3uN1lnII+NRHBN+ERpjEjpvr5uUTUMPzs9TfJUyoPEAN3LGYLSqZg/CdhS1YJCKD7aVGRRTkxgYnTnsSPKTTYhILllWSOsx/N9BWQarZdZTwmQJHd21FWC9uUHIIAgRuf8+RSvzyR4VdR839c4CxZHxyPDF1CkAEYo++4g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=efficios.com; dmarc=pass action=none header.from=efficios.com; dkim=pass header.d=efficios.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IzVY+CoI9z0/kPBOXPBswiu9v607r2qSlRaGnoOPmLE=; b=CujpU9/hNeWkVnM7ozQCrGjudEYEPjbkPdPCDMUU6/GAityEvNr3+MYM5YMug1IlFdVxyvK4ozPwSdNLp+s9NyIcoVZj+1KTRvCAaXLmHcf+ohrM62ouhw6BHUEqmhzO+D1AyrR5MocC7DBaqkosE1dnl8qxDPCoShdLyjDtavdHKngwKz69xgLgk5X+1yZwl1EeNFO46gk2bCEqU7vri8Kri5/xHzKgNQQC32RLKAtG4LWOcM3nGupW+cuDz9Ysy6Cu4b6fR59KYd2mJ3Y6Z0XYQgjSqxiHlU4oZb2eN+R62S1sRH1UiAwouU+3f0pk0+12oxpcAEdBDg6waEqyiA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=efficios.com; Received: from YQBPR0101MB5080.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c01:24::5) by YT2PR01MB8600.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:b7::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.26; Fri, 16 Feb 2024 20:19:36 +0000 Received: from YQBPR0101MB5080.CANPRD01.PROD.OUTLOOK.COM ([fe80::c711:83ed:d711:ea0d]) by YQBPR0101MB5080.CANPRD01.PROD.OUTLOOK.COM ([fe80::c711:83ed:d711:ea0d%4]) with mapi id 15.20.7292.029; Fri, 16 Feb 2024 20:19:36 +0000 Message-ID: <05e890cb-94b1-4f10-8e10-c4b08dfc0b78@efficios.com> Date: Fri, 16 Feb 2024 15:19:35 -0500 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v8 2/8] Add rseq extensible ABI support Content-Language: en-US References: From: Michael Jeanson To: DJ Delorie Cc: libc-alpha@sourceware.org, mathieu.desnoyers@efficios.com In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: YQBPR0101CA0348.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c01:6b::25) To YQBPR0101MB5080.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c01:24::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: YQBPR0101MB5080:EE_|YT2PR01MB8600:EE_ X-MS-Office365-Filtering-Correlation-Id: e069c6ff-ed40-44ea-99f0-08dc2f2c9853 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /VKJrWWfFAItyc1S8YRYwPYOdmzqoSzbjz18CuPLXkllqbdSpaOCtruqfCVapfkVW0Nq23ZktbptgkHXYeXLcUYu1a6mDjt91B93rWuZWH7OI8z4wMqD6ipnSG1C6JEk2dk+IO9WZ1pP3UWp3cT+9F1cuLpMe2V3UeiL4oS76anNgjAdYpg0MHl1xnBgD3BZ/bebXse7L703eIbL++VBTtunI8jsBCd0trRjvRwnujIcbGbscihfxml39PE8G8VBPhKrwiKOqEWlSu7vRTrxyXikzsHaBYJTXEgK/XtJ1Fgsf3hzBmAUNa7fml4ovWizT1/AFaAc/4+NUVYkeLWjO1R0Kmu1t5lVxhMOKqdfgDcOvtWB3fERyW+/YJ+F+T/kuBWbSYqBOjfH0iikqvldQrXiz4d+8N1nwVZIfuuzRxE0qpyJRX39KcDHH7oLYpbhtijI8jp+GK4PZPIy3rlEwHDKrFJaEcXafe8/IoOcG+iGlZxEIh0la45s1mDKwEuWPQEdxTAn421noJWyjLVreFEYOxa66wcvilzoqKAPVsCErxAsjf5Q07CStw2CxVS9 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:YQBPR0101MB5080.CANPRD01.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230031)(346002)(366004)(396003)(39830400003)(376002)(136003)(230922051799003)(186009)(451199024)(64100799003)(1800799012)(5660300002)(2906002)(41300700001)(478600001)(6486002)(26005)(6506007)(2616005)(107886003)(8936002)(66476007)(6512007)(316002)(66946007)(6916009)(66556008)(8676002)(4326008)(83380400001)(86362001)(31686004)(36756003)(31696002)(38100700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?eW1ud01VN1JJc1g4Wno1akVwdUpFUzV6R29BdnZWWmVFUE5vWXpxdDNvdDJC?= =?utf-8?B?V3hxWkV4akhYK3JnVmcxbFAwcnl1eTR1TExCUGVGOVNyUDl4akhwblVwZjdz?= =?utf-8?B?WDNoNFY3MGt5RGl1a1pITmFqYUo3N3FqT0lCSmtsMFBSL3NYWHJyTHRFbTZq?= =?utf-8?B?Z1ZkSlgwaUhoRlk1d0dGbnFYWUV6K1oyMmFaeG1Hd3ErRCs4blRjNDJ5RUZv?= =?utf-8?B?U0RvdTlHQ1luOW5FRmpQTllobHVHRGxrVFQrcWxlTGl3NmRNSGUxb3pMWWk3?= =?utf-8?B?YXU1b3hvT0ZuU2J2THFQZnJxZWZUUXlIbHIydnhZS3dzclNhYytmWEU1amZS?= =?utf-8?B?R3E0VjM1VXB2M1hVbVBpQmt0S0hCZHJkZXRqTXJWTU1DRG0xK1l4TkwvbTJm?= =?utf-8?B?Umk2WWZzck8vVGUzK2s0dmhBNitvd1VsV2F6QnMrS2FRcGpaT1htL0YwU0Rj?= =?utf-8?B?M0oxYlZOYkp6aU1jcVBCaHNvTVRodVdXZU5mQTREcEhydDRQcmRIVGdjeWZs?= =?utf-8?B?R2psdWF1bWNreU9ETUdya2tQT0tGWUNpamJScW53c2VzN0h5aUNVU2pxcTZY?= =?utf-8?B?ejhDUXIwRDFLanlHeXhkTUlTb1F6MkltLzJUUGFXV21LQzMrV0hMZmdOTDZH?= =?utf-8?B?Y0NKdmxNaEU1ZFBlUWVzNy9Va0hnTHU4RDIyeHhDd2pMMi80NUpmVFROdTBQ?= =?utf-8?B?MXRoVGxBUkhuQ2dadWhuUGk3NmdQN0tVdUVqQmRUbjZVTStjK1AvMW9vS3ZW?= =?ut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ZnJUUkRQQ2xH?= =?utf-8?B?RTRyM1hmQ3M1RzIzOHkzd0RxR1ZkanhPbTN0MUpwb2ZQemtpWHFOZVAyQjlH?= =?utf-8?B?WEdzMFBBclhQUEEzM0laQlZhRHd2ckE0VUtTT1pkSXIzZHcvUldRWkpCZDAz?= =?utf-8?B?U01leUhQckdZYjd0eU5Hdk5seWNmTW5ZL09EdWFmZnUwY2FxTTBrWFJ0QXUy?= =?utf-8?B?ZTZBM1JhdWhRbGluekxBYWZuTUxjL0JSd253NSt0UDZBSzRWSnBWZHNJenpa?= =?utf-8?B?QlBydGpnbjlJeUFtb0xpQWJEZ1RlUTduLzlheHBZdU5ZTUEwSzc0SDNEWlEz?= =?utf-8?B?YXo2YVJzRDNKUWhPYzQyRWFWQW9PeWdGcFVlNmwvZUVpY2FhUmFIbjVuNDMx?= =?utf-8?B?dE5SZWJrNDRzaHR0czFHVXFJcmN2ZTFkT0ptcGpXRVJHQU02NE9sUXhWNzBu?= =?utf-8?Q?vD+LtkGsB550vmok3IU9W1qc5?= X-OriginatorOrg: efficios.com X-MS-Exchange-CrossTenant-Network-Message-Id: e069c6ff-ed40-44ea-99f0-08dc2f2c9853 X-MS-Exchange-CrossTenant-AuthSource: YQBPR0101MB5080.CANPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2024 20:19:36.1362 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4f278736-4ab6-415c-957e-1f55336bd31e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: qk8uqpse4wKurThJ983WcyV8oNE4d7/YuZ6CDUEGmJNxo8DRsGc5OEeG1cG1MrGJaZoE8afOCD//8H+r7zm5vg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: YT2PR01MB8600 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 2024-02-15 23 h 42, DJ Delorie wrote: > > One incorrect year > Could use more comments around the tcb math Ack, I'll address this in the next patch series. > Questions in sysdeps/unix/sysv/linux/tst-rseq-disable. > Michael Jeanson writes: >> This makes the size of the rseq area variable and thus requires to >> relocate it out of 'struct pthread'. We chose to move it after (in block >> allocation order) the last TLS block since it required a fairly small >> modification to the TLS block allocator and did not interfere with the >> main executable TLS block which must always be first. > > The TLS doesn't get resized, does it? Or am I thinking of the DTV? The terminology is a bit confusing and could be clarified, my understanding is that the 'static TLS block' is the area where the 'TLS blocks' from shared objects and the main executable are allocated and the DTV is the array of descriptors that point to each of these 'TLS blocks' inside the 'static TLS block'. What we are doing here is adding a 'fake' 'TLS block' at the end of the 'static TLS block' (in allocation order which differs depending of the TLS model). We move the offset so our fake block is included in dl_tls_static_used but we don't register it in the DTV since it's not a 'real' TLS block with the required metadata. I think I should rewrite the commit message to make the distinction between the 'static TLS block' and 'TLS blocks'. >> #if TLS_TCB_AT_TP >> + /* Before the the thread pointer, add the aligned tls block size and then >> + align the rseq area block on top. */ >> + tls_blocks_size = roundup (roundup (memsz, align ?: 1) + rseq_size, rseq_align); >> + >> + /* Record the rseq_area offset. The offset is negative with TLS_TCB_AT_TP >> + because the TLS blocks are located before the thread pointer. */ >> + GLRO (dl_tls_rseq_offset) = -tls_blocks_size; >> + > > So the allocated area will be at negative offsets to TP anyway; we add > at the beginning, so *our* location is at the beginning, and thus the > most negative offset. > > What if the rseq area needs alignment greater than what > _dl_early_allocate() guarantees? This code takes the time to round the > tls size up to rseq_align, but never aligns the actual address of the > rseq area after allocation. Ah, the adjustments to max_align cause this > to happen later, as long as the offsets are suitably aligned also. > > Perhaps a quick note in the comment that "max_align enforces the > alignment of the resulting pointer" or something like that? Ack, I'll add a comment. >> diff --git a/sysdeps/generic/dl-rseq.h b/sysdeps/generic/dl-rseq.h >> new file mode 100644 >> index 0000000000..0855981c89 >> --- /dev/null >> +++ b/sysdeps/generic/dl-rseq.h >> @@ -0,0 +1,26 @@ >> +/* RSEQ defines for the dynamic linker. Generic version. >> + Copyright (C) 2023 Free Software Foundation, Inc. > > 2023 ? Ack. >> diff --git a/sysdeps/unix/sysv/linux/tst-rseq-disable.c b/sysdeps/unix/sysv/linux/tst-rseq-disable.c >> index bbc655bec4..ae4143916b 100644 >> --- a/sysdeps/unix/sysv/linux/tst-rseq-disable.c >> +++ b/sysdeps/unix/sysv/linux/tst-rseq-disable.c >> @@ -26,27 +26,30 @@ >> #include >> >> #ifdef RSEQ_SIG >> +# include >> +# include "tst-rseq.h" >> + >> +static __thread struct rseq local_rseq; >> >> /* Check that rseq can be registered and has not been taken by glibc. */ >> static void >> check_rseq_disabled (void) >> { >> - struct pthread *pd = THREAD_SELF; >> + struct rseq *rseq_area = (struct rseq *) ((char *) __thread_pointer () + __rseq_offset); >> >> TEST_COMPARE (__rseq_flags, 0); >> - TEST_VERIFY ((char *) __thread_pointer () + __rseq_offset >> - == (char *) &pd->rseq_area); >> TEST_COMPARE (__rseq_size, 0); > > Isn't __rseq_size always at least 32 ? It's at least 32 when the registration succeeded, however if the registration failed or was disabled by tunable then it's set to 0. >> + TEST_COMPARE (sizeof (local_rseq), RSEQ_TEST_MIN_SIZE); > > This happens to be true at this point, but the comparison should really > be >= not ==, esp as the features patch changes the size of this > structure to be larger than MIN_SIZE. This test doesn't really make sense anymore, it's a leftover from a previous iteration, I'll remove it.