From patchwork Mon Nov 27 14:56:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christoph_M=C3=BCllner?= X-Patchwork-Id: 80826 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 99D05386075C for ; Mon, 27 Nov 2023 14:56:27 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by sourceware.org (Postfix) with ESMTPS id 6A35738582B9 for ; Mon, 27 Nov 2023 14:56:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6A35738582B9 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=vrull.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=vrull.eu ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6A35738582B9 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::22b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701096973; cv=none; b=bZ6JghQ3BZNM47400Bw4ZhIZzjamKePGc9AImaPOe4whi3wrOcqeTQaf7YmIYx/hpqjIbyAvdkhuuULIsgHL/V11x/WSvwRhUkXI4RqNPolrQjO8JfK+Rt3vlgPv5VtZsAXxaO8tTuOGZBEK/LD4h3HdJkLTjcLbOJN16XbD5OU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701096973; c=relaxed/simple; bh=ri4VXIdA2Bmp5e5z7/vGG2rgXG6FAeEQiKxsgS68wA0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=JQZjwlAJZ82nAvX75dYk5EmOw2NIvXo0K47p7RzrOhSaTCE55yHgGSzN0oY85cYVkIkdA4JGOQIT53W/Td/8z2H835Ejw4aRDbjJGznWMJVds+LT9ABaglvIJ+N/0qPLGKgnWZ2OsnebKGgZn8mJgjwGZPJhgSQlf+4XhMhMdQo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2c876e44157so53171071fa.2 for ; Mon, 27 Nov 2023 06:56:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull.eu; s=google; t=1701096970; x=1701701770; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EqhoT1n3t/3K2V277mEEFBGy3D9lkqOVwlaUcVuGWNM=; b=IEg8l1SlO2kVHjSApEv+sdCfo2iV7XRdfO124c681Vk1vEMx8+zt3wrMfPMoNnSb53 ODcJlPGbvxfFbAvFzcS7dukmF5UhZTk3+LaSFriXHpIsmIyFW/C0vPYelIuD+H1+N+rW jg+xEy5qg5fAba3I8V8FS+KjptLOsaYKb5eBYHCe4vmb3ndZpIyuYpQSAzxcfuhxpCzH Y5xFUc8Ahfvcf1WYaODf+/ZyEYXOigD9tT5/LqOqvBb0YguVsf8yOZBhM+VIOe2z47ov LlppiwI3QjCJ8p/JkS+tvb/ezwPfAo+KGBTVMsrzXk7tmjYvnJhFXqtJ42CzK1w07+p5 gUdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701096970; x=1701701770; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EqhoT1n3t/3K2V277mEEFBGy3D9lkqOVwlaUcVuGWNM=; b=btq0Sybh/LiQQalTt0fFZqoQZJtN/fhSD+vUKf565ikQWCiH0jnqwcBnPHPa6C1ODW 1Y8T6x6u22MJOuPWXuHxXbVkzk1p5AnDQ2Lq5by9Ei/ORxrhcDhNW72tvrC+nkFsxnND UdTToowmqN4o9Jj69Nj1CzutcDii6IdC5M7d43o7qk8LMMi2oWMdUUx8zK7CAHW1cTmE 67yfNfyihiq0GGtnWpstOEmfxy/FJ28XuVMAllItP+KMSD7ysIXUztxTTEJBRDwT5c8v Dfbm7bbpJc97eHtivQIGnrKRGWaW906OBbaVyzS3OnHyafQJ+nJ6ILbsNHDpcdE69yWK jyhA== X-Gm-Message-State: AOJu0YxLglscXlV3qCatSH80FVkmYPz1/NRwj4xhJwEit/4zvVabXFD0 wWlIVCCkSfEuBPGCgzJ8EqaneGEQyJcYvYYuMw5mGw== X-Google-Smtp-Source: AGHT+IF67geGko/EvqC348V1G1+RMkzjI5d6j9LtXNQpqPFKL8XCSOlJR1+52tL4FxLTV+yyPuE4/g== X-Received: by 2002:a05:651c:c7:b0:2c8:83c4:9069 with SMTP id 7-20020a05651c00c700b002c883c49069mr8633768ljr.2.1701096970292; Mon, 27 Nov 2023 06:56:10 -0800 (PST) Received: from beast.fritz.box (62-178-148-172.cable.dynamic.surfer.at. [62.178.148.172]) by smtp.gmail.com with ESMTPSA id a20-20020a1709063e9400b00a0369e232bfsm5753427ejj.75.2023.11.27.06.56.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 06:56:09 -0800 (PST) From: Christoph Muellner To: libc-alpha@sourceware.org, Palmer Dabbelt , Darius Rad , Andrew Waterman , Philipp Tomsich Cc: =?utf-8?q?Christoph_M=C3=BCllner?= Subject: [RFC PATCH 1/2] RISC-V: Move TSO check to elf_machine_matches_host() Date: Mon, 27 Nov 2023 15:56:02 +0100 Message-ID: <20231127145603.2339644-2-christoph.muellner@vrull.eu> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231127145603.2339644-1-christoph.muellner@vrull.eu> References: <20231127145603.2339644-1-christoph.muellner@vrull.eu> MIME-Version: 1.0 X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, JMQ_SPF_NEUTRAL, 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: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org From: Christoph Müllner The current implementation does not support ELF files which have the EF_RISCV_TSO ELF flag set. This is implemented in process_elf64_file(), with the assumption that no TSO-capable hosts exists. In order to weaken this restriction, let's move the TSO flag check into elf_machine_matches_host(), where compatibility with the host can be checked. This patch serves as a preparation for further changes and does not intend to implement any functional changes. Signed-off-by: Christoph Müllner --- sysdeps/riscv/dl-machine.h | 4 ++++ sysdeps/unix/sysv/linux/riscv/readelflib.c | 5 ++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/sysdeps/riscv/dl-machine.h b/sysdeps/riscv/dl-machine.h index c0c9bd93ad..ce537731dd 100644 --- a/sysdeps/riscv/dl-machine.h +++ b/sysdeps/riscv/dl-machine.h @@ -72,6 +72,10 @@ elf_machine_matches_host (const ElfW(Ehdr) *ehdr) return 0; #endif + /* Execution of TSO binaries is not supported at this time. */ + if (ehdr->e_flags & EF_RISCV_TSO) + return 0; + return 1; } diff --git a/sysdeps/unix/sysv/linux/riscv/readelflib.c b/sysdeps/unix/sysv/linux/riscv/readelflib.c index 788eba8305..e2bd4d7727 100644 --- a/sysdeps/unix/sysv/linux/riscv/readelflib.c +++ b/sysdeps/unix/sysv/linux/riscv/readelflib.c @@ -30,10 +30,9 @@ int process_elf64_file (const char *file_name, const char *lib, extension, we can still support libraries compiled without that extension so we just ignore this flag. - EF_RISCV_RVE: glibc (and Linux) don't support RV32E based systems. - - EF_RISCV_TSO: The TSO extension isn't supported, as doing so would require - some mechanism to ensure that the TSO extension is enabled which doesn't + - EF_RISCV_TSO: Accepted with restrictions (see elf_machine_matches_host). currently exist. */ -#define SUPPORTED_ELF_FLAGS (EF_RISCV_FLOAT_ABI | EF_RISCV_RVC) +#define SUPPORTED_ELF_FLAGS (EF_RISCV_FLOAT_ABI | EF_RISCV_RVC | EF_RISCV_TSO) /* Returns 0 if everything is ok, != 0 in case of error. */ int