From patchwork Tue Feb 20 10:34:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 203545 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp310196dyc; Tue, 20 Feb 2024 02:35:19 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWF1ONgy96ArTfu2kBunBDvmwM3UqDnxf8r2QqIuChsMCBNDN32YSVcRAMLnrHgDs+7CAlO8eXTazcdyitiq+H+9ecOoQ== X-Google-Smtp-Source: AGHT+IFwWUesHKYBy/U/CwB/UZwnOMKJwEy+m/doKzl696jv2HMO04XjF9P+RYb2WzB57da/kmCD X-Received: by 2002:a0c:da07:0:b0:68f:58b8:fa6d with SMTP id x7-20020a0cda07000000b0068f58b8fa6dmr9245437qvj.48.1708425319533; Tue, 20 Feb 2024 02:35:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708425319; cv=pass; d=google.com; s=arc-20160816; b=znymymiJPZ81Ghu5E7fDT/PPIGB5hQO8xd22QpMEyWebuIX1rEIJkmTTmDsPkVAgpN YYTpPDeWcbFJk3ORNEkEZowPb4SjMWWgDK1XVvikDCMg0TVgwsJvKZu1pCKBwT+HOJ9g TTqQXOpNZp2jhyuvlKWUhANOVXbHF0TjxQr3fiauKkb9TDcXBxywbsZnH6hyYVrCVMtJ Wd1D0oMMl+GTqevvDRT9yj+/OeI/K6eIVj+bzVihrFapM/e77WvFKd9EoV8RmMEZ3QeL eM5ISyCkfnOjXlD0C41SBHLc7GURU5WQXHhvvtB6zIuqX1+c9RCqjXAty8kTCfnm7it+ u5Tw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:reply-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=OrpLxL4QSbRk8xHTcYJAV3Evh/50G9SeSfXdYPj8XQ0=; fh=xhkLBVrfamW3D9oHP0ZGbkfs+/umOfyxpoLuXSj960g=; b=bHwIyzbIy3H68Oisy7AMKm57fek5ZoxrhOXHmfRmpZ9oo5BM0Qe6ix+6VGXrdpbt7P lrYToOR80tMaAMOtunRv9tfDw7fPQF4ujdvoNHejh08XCzLcAFQY7ddH7Q4J7+U08znI 8puAfSascX9OY2OnfkRnrIh34kZKhe3I7n0CkgjQDfmLUucdvIK2/8OfyV42VifGuV5C DuarUfp88R/EAPthqW/D5ORcm60LIyKfWRT5pOPetvrcwwp1cfR9ffsF8WXvTHshX5GM PCXWFNxGw+pqNReEDjuTblAALbjvuPRlEfP1qct3Nu4O/BT+EFkXoz+zhZwYHRiqtUP1 36lg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=GngDHy+g; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id gf12-20020a056214250c00b0068cb9532d74si8075222qvb.330.2024.02.20.02.35.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 02:35:19 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=GngDHy+g; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 36A483858C52 for ; Tue, 20 Feb 2024 10:35:19 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by sourceware.org (Postfix) with ESMTPS id E32F03858D20 for ; Tue, 20 Feb 2024 10:34:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E32F03858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E32F03858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::534 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708425277; cv=none; b=x8caeNLHUu9RnwPTEnrPFq/rtxBhupngDjoxF/1a8R7dyKnnUhzi6HXzTXAXYblNRAsdvO6OTB096UoFxlgoItzIGSqCGDJwdhGlkPEv2hH2NuvP7sUeoq61l8raOP2USnqs5Tnk8U69VPJ6EDIdxIEeVeTzEK9UOIBxJns4Msg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708425277; c=relaxed/simple; bh=f0NcbCs01LTvehv9mGjN+zNbZlih190RJr79btBcPAM=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=GvJlqnvObnBZgh98xNuVUGBQ4IDrDV5+yoo+PUsbQt+JyRDc+S03zQCWBYducSEcZYIqZuENIRksZ2u/HLf0IbNdiAKO6G6wa4TjhDaJmdM1j1QcvpFyomr7R1rla4N5XWAj4QtiWpZCbZOzUhcz0ViEshI5NrHFilOgO1Y7u4c= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-5645efb2942so3816691a12.1 for ; Tue, 20 Feb 2024 02:34:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708425272; x=1709030072; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:reply-to:message-id:date :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=OrpLxL4QSbRk8xHTcYJAV3Evh/50G9SeSfXdYPj8XQ0=; b=GngDHy+gSoZ4HzrAEb/mLxFlH9AZfFDKVNk+rfdR8zcUWdVR1TaVirHqRLoA0wM4CF a9bfnGFHvl99NZkdBBkJJREuiQ450cAI5qhc5dkCzvAiIljO9z8XhJYHSNfK7CjAKki6 eTX5mIi6IaAcJ6v/C3r16ODG5DNpOsdJMToHU3g4rFfSwAUbmOha33TsHxNyQuLXruZ9 LjQjMdh3JXl8nyOoSc8NqGuxHOZJTO7wTWyVDiKVuW4Iv47oXuD2gQHd1VTclL/TkDkS unJ/nSVevAKJ6VzX/G+41VULnZQw0S27CSF83mh3veqMY4wS8faGytmoWGA+1FKVyuIa M72A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708425272; x=1709030072; h=content-transfer-encoding:mime-version:reply-to:message-id:date :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=OrpLxL4QSbRk8xHTcYJAV3Evh/50G9SeSfXdYPj8XQ0=; b=dgyFthdbTdjaayhX1s8RHmCKIltvTC5H8eloh9/dycpRhGnqf/A7OHzI9pHIL3fv1z LVKpfng0eeagxk6XGffh7fKCJgJVLg+lKcK+IMInxoCA5O6kIoBdqnkalZMZWLsRQCK2 exkw1P83EnwqyR0j1W+/vezan5cPAu5kZzllVLDuNFfh7LHPLjRtbsp8MVuQ3laOYu4h zKUCQv2392EqKAPYOVsoKi/WcsBQHt7zcEO7iwQmK1+cGXTOJYfO9+OrJqpIEybG1KJf 7P3uffunCmcKErv1nrVOg2jGT1LtEBotbrkBZp1l7XfPbX0iOYpGoSU+XSIEnxZb+qUB jxIg== X-Gm-Message-State: AOJu0Ywn9odZzcq5KCK/aZ1lmmQ+VQ7CDMp33FjYp1cqzDO6GC+5yjbe 83rdY98qb2jhVVh7VpMdn3RQHAumJ4JRZwRzt4Kzvzq8HbQfKZFVh6xm01i9 X-Received: by 2002:a17:906:2659:b0:a3e:53d9:c7d5 with SMTP id i25-20020a170906265900b00a3e53d9c7d5mr5657337ejc.36.1708425272011; Tue, 20 Feb 2024 02:34:32 -0800 (PST) Received: from localhost.localdomain (host81-138-1-83.in-addr.btopenworld.com. [81.138.1.83]) by smtp.gmail.com with ESMTPSA id cu11-20020a170906ba8b00b00a3ee5c19ee5sm763682ejd.109.2024.02.20.02.34.31 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 20 Feb 2024 02:34:31 -0800 (PST) From: Iain Sandoe X-Google-Original-From: Iain Sandoe To: gcc-patches@gcc.gnu.org Cc: pinskia@gmail.com Subject: [PATCH] libgcc, aarch64: Allow for BE platforms in heap trampolines. Date: Tue, 20 Feb 2024 10:34:30 +0000 Message-Id: <20240220103430.40078-1-iain@sandoe.co.uk> X-Mailer: git-send-email 2.39.2 (Apple Git-143) MIME-Version: 1.0 X-Spam-Status: No, score=-8.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: iain@sandoe.co.uk Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791413787809633152 X-GMAIL-MSGID: 1791413787809633152 Andrew Pinski pointed out on irc, that the current implementation of the heap trampoline code fragment would make the instruction byte order follow memory byte order for BE AArch64, which is not what is required. This patch revises the initializers so that instruction byte order is independent of memory byte order. I have tested this on aarch64-linux-gnu, aarch64-darwin and on a cross to aarch64_be-linux-gnu (including compile tests on the latter, but I have no way, at present, to carry out execute tests). (Note that this patch is applied on top of the one for PR113971). OK for trunk, or what would be a way forward? thanks Iain --- 8< --- This arranges that the byte order of the instruction sequences is independent of the byte order of memory. libgcc/ChangeLog: * config/aarch64/heap-trampoline.c (aarch64_trampoline_insns): Arrange to encode instructions as a byte array so that the order is independent of memory byte order. (struct aarch64_trampoline): Likewise. Signed-off-by: Iain Sandoe --- libgcc/config/aarch64/heap-trampoline.c | 30 ++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/libgcc/config/aarch64/heap-trampoline.c b/libgcc/config/aarch64/heap-trampoline.c index 1e3460b1601..885df629da7 100644 --- a/libgcc/config/aarch64/heap-trampoline.c +++ b/libgcc/config/aarch64/heap-trampoline.c @@ -30,23 +30,23 @@ void __gcc_nested_func_ptr_created (void *chain, void *func, void *dst); void __gcc_nested_func_ptr_deleted (void); #if defined(__linux__) -static const uint32_t aarch64_trampoline_insns[] = { - 0xd503245f, /* hint 34 */ - 0x580000b1, /* ldr x17, .+20 */ - 0x580000d2, /* ldr x18, .+24 */ - 0xd61f0220, /* br x17 */ - 0xd5033f9f, /* dsb sy */ - 0xd5033fdf /* isb */ +static const unsigned char aarch64_trampoline_insns[6][4] = { + {0x5f, 0x24, 0x03, 0xd5}, /* hint 34 */ + {0xb1, 0x00, 0x00, 0x58}, /* ldr x17, .+20 */ + {0xd2, 0x00, 0x00, 0x58}, /* ldr x18, .+24 */ + {0x20, 0x02, 0x1f, 0xd6}, /* br x17 */ + {0x9f, 0x3f, 0x03, 0xd5}, /* dsb sy */ + {0xdf, 0x3f, 0x03, 0xd5} /* isb */ }; #elif __APPLE__ -static const uint32_t aarch64_trampoline_insns[] = { - 0xd503245f, /* hint 34 */ - 0x580000b1, /* ldr x17, .+20 */ - 0x580000d0, /* ldr x16, .+24 */ - 0xd61f0220, /* br x17 */ - 0xd5033f9f, /* dsb sy */ - 0xd5033fdf /* isb */ +static const unsigned char aarch64_trampoline_insns[6][4] = { + {0x5f, 0x24, 0x03, 0xd5}, /* hint 34 */ + {0xb1, 0x00, 0x00, 0x58}, /* ldr x17, .+20 */ + {0xd0, 0x00, 0x00, 0x58}, /* ldr x16, .+24 */ + {0x20, 0x02, 0x1f, 0xd6}, /* br x17 */ + {0x9f, 0x3f, 0x03, 0xd5}, /* dsb sy */ + {0xdf, 0x3f, 0x03, 0xd5} /* isb */ }; #else @@ -54,7 +54,7 @@ static const uint32_t aarch64_trampoline_insns[] = { #endif struct aarch64_trampoline { - uint32_t insns[6]; + unsigned char insns[6][4]; void *func_ptr; void *chain_ptr; };