From patchwork Tue Sep 20 12:14:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Kozlov X-Patchwork-Id: 1680023 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=uclibc-ng.org (client-ip=89.238.66.15; helo=helium.openadk.org; envelope-from=devel-bounces@uclibc-ng.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=synopsys.com header.i=@synopsys.com header.a=rsa-sha256 header.s=pfptdkimsnps header.b=D8WdQteY; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=synopsys.com header.i=@synopsys.com header.a=rsa-sha256 header.s=mail header.b=acWhGG5/; dkim-atps=neutral Received: from helium.openadk.org (helium.openadk.org [89.238.66.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MX0qs0Q2jz1ypH for ; Tue, 20 Sep 2022 22:15:37 +1000 (AEST) Received: from helium.openadk.org (localhost [IPv6:::1]) by helium.openadk.org (Postfix) with ESMTP id A6D3E3520788; Tue, 20 Sep 2022 14:15:21 +0200 (CEST) Authentication-Results: helium.openadk.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=synopsys.com header.i=@synopsys.com header.a=rsa-sha256 header.s=pfptdkimsnps header.b=D8WdQteY; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=synopsys.com header.i=@synopsys.com header.a=rsa-sha256 header.s=mail header.b=acWhGG5/; dkim-atps=neutral Received: from mx0b-00230701.pphosted.com (mx0b-00230701.pphosted.com [148.163.158.9]) by helium.openadk.org (Postfix) with ESMTPS id 1D3CF3520668 for ; Tue, 20 Sep 2022 14:14:37 +0200 (CEST) Received: from pps.filterd (m0297265.ppops.net [127.0.0.1]) by mx0a-00230701.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28K5pXmf007727 for ; Tue, 20 Sep 2022 05:14:35 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=synopsys.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pfptdkimsnps; bh=vATWxppTy8TcyZgleaHBjd0a0Rvd4Q/OWJZxnrv+1TU=; b=D8WdQteYxPrvdXmbKROw2/tcV0pVERB9bY4hYtxn47q1vDy1OhIufdtKMLuQgYWx3Ord iWEq2ef3BE9f25wVTwuADwtbalvuQF4itxrPCArPZk30j4U/SqxBSaLQcqciMmbwyRcO 9YEO+rucZwOidBED38ybXKjkn2sj1nfC4H/1u96/YoJmL1WEa/t6FL+1nmf2P3tvFqU3 SI9qmSojvnZI+QcyyECXol1b3sM3LYePmCNChKrrsep2Xw/3ITU9n/wdsV1xwTD576An ifvNcihUlz0JJdSAs6zx0xJRy8F+hD+FDawfgQVRGCzDRxfMBYId75mLkHiBQIiMPkow 5A== Received: from smtprelay-out1.synopsys.com (smtprelay-out1.synopsys.com [149.117.87.133]) by mx0a-00230701.pphosted.com (PPS) with ESMTPS id 3jnd5txfye-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 20 Sep 2022 05:14:35 -0700 Received: from mailhost.synopsys.com (mdc-mailhost1.synopsys.com [10.225.0.209]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client CN "mailhost.synopsys.com", Issuer "SNPSica2" (verified OK)) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id 3114FC07EB for ; Tue, 20 Sep 2022 12:14:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1663676074; bh=/1QxuVy6Kgn2bYWYthNt9qGAPEe7jG2EVYg3WMq9GLs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=acWhGG5/6ZFl6NOd2CmLo3tz8sR8GQGgE1B6jNs+9oGYQJ8b/CjPC/BPEFguCqfS3 r5ECa35wFU9DMlebC/KUspOGdTPT6D5yLMHVNpk22lNlXJB6fudsVhs45JJPa3rH55 WBoqZogU0ZW4zXINiIWqVCno7VUSk1vCfbZufS+Ib9J4BGk+LS6LvzqbPcOzhLyIyg a/vEZMhCFeQgK5cmvM8RtBUJK7SHwN538yL+qgvSO6guft3HrsKOJZ6oAvAxDhZIck CGr4b4pV0QYJLZ8jWoI2BW0K+dwMYmbGVDg13ZRIPT7nUVZAMvICFhx5QjR6DlM5kc WonG2QJWOTzLQ== Received: from SNPS-o0WHuHJU73.internal.synopsys.com (snps-o0whuhju73.internal.synopsys.com [10.116.108.115]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client did not present a certificate) by mailhost.synopsys.com (Postfix) with ESMTPSA id 41B57A0234; Tue, 20 Sep 2022 12:14:32 +0000 (UTC) X-SNPS-Relay: synopsys.com From: Pavel.Kozlov@synopsys.com To: devel@uclibc-ng.org Date: Tue, 20 Sep 2022 16:14:21 +0400 Message-Id: <20220920121421.31618-5-kozlov@synopsys.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220920121421.31618-1-kozlov@synopsys.com> References: <20220920121421.31618-1-kozlov@synopsys.com> MIME-Version: 1.0 X-Proofpoint-GUID: GB8gviFcBrOmE83PzYOZIz1xiffK9FqH X-Proofpoint-ORIG-GUID: GB8gviFcBrOmE83PzYOZIz1xiffK9FqH X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-20_04,2022-09-16_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_active_cloned_notspam policy=outbound_active_cloned score=0 bulkscore=0 phishscore=0 adultscore=0 suspectscore=0 impostorscore=0 mlxlogscore=716 spamscore=0 mlxscore=0 malwarescore=0 priorityscore=1501 clxscore=1015 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2209200073 Message-ID-Hash: SCMSNOBC26FGLVFBHB24MIQ36BXY2Z77 X-Message-ID-Hash: SCMSNOBC26FGLVFBHB24MIQ36BXY2Z77 X-MailFrom: Pavel.Kozlov@synopsys.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Alexey.Brodkin@synopsys.com X-Mailman-Version: 3.3.3 Precedence: list Subject: [uclibc-ng-devel] [PATCH 4/4] arc: add support for ARCv3 32-bit processors List-Id: uClibc-ng Development Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Sergey Matyukevich New ARCv3 ISA includes both 64-bit and 32-bit CPU family. This patch adds support for 32-bit ARCv3 HS5x processors. Signed-off-by: Sergey Matyukevich Signed-off-by: Pavel Kozlov --- include/elf.h | 1 + ldso/ldso/arc/dl-sysdep.h | 3 +++ libc/sysdeps/linux/arc/asm.h | 24 ++++++++++++++++++++++++ libc/sysdeps/linux/arc/bits/syscalls.h | 4 ++-- libc/sysdeps/linux/arc/crt1.S | 4 +++- utils/ldd.c | 5 +++++ 6 files changed, 38 insertions(+), 3 deletions(-) diff --git a/include/elf.h b/include/elf.h index 018ff1550dae..b7edbade2e46 100644 --- a/include/elf.h +++ b/include/elf.h @@ -273,6 +273,7 @@ typedef struct #define EM_ARCV2 195 /* Synopsys ARCv2 Cores */ #define EM_RISCV 243 /* RISC-V */ #define EM_CSKY 252 /* C-SKY Cores */ +#define EM_ARCV3_32 255 /* Synopsys ARCv3 32-bit Cores */ #define EM_KVX 256 /* Kalray VLIW core of the MPPA processor family */ /* NEXT FREE NUMBER: Increment this after adding your official arch number */ diff --git a/ldso/ldso/arc/dl-sysdep.h b/ldso/ldso/arc/dl-sysdep.h index ed8b37205cc4..c8915511a761 100644 --- a/ldso/ldso/arc/dl-sysdep.h +++ b/ldso/ldso/arc/dl-sysdep.h @@ -75,6 +75,9 @@ do { \ #elif defined(__HS__) #define MAGIC1 EM_ARCV2 #define ELF_TARGET "ARCv2" /* For error messages */ +#elif defined(__ARC64_ARCH32__) +#define MAGIC1 EM_ARCV3_32 +#define ELF_TARGET "ARCv3_32" /* For error messages */ #endif #undef MAGIC2 diff --git a/libc/sysdeps/linux/arc/asm.h b/libc/sysdeps/linux/arc/asm.h index f98eb239fe15..f15dff841aec 100644 --- a/libc/sysdeps/linux/arc/asm.h +++ b/libc/sysdeps/linux/arc/asm.h @@ -7,6 +7,29 @@ #ifndef _ARC_ASM_H #define _ARC_ASM_H +#if defined (__ARC64_ARCH32__) + +.macro PUSHR reg + push \reg +.endm + +.macro PUSHR_S reg + push \reg +.endm + +.macro POPR reg + pop \reg +.endm + +.macro POPR_S reg + pop \reg +.endm + +#elif defined (__ARC64_ARCH64__) + +# error ARCv3 64-bit is not supported by uClibc-ng + +#else /* ARCHS || ARC700 */ .macro PUSHR reg push \reg @@ -24,5 +47,6 @@ pop_s \reg .endm +#endif #endif /* _ARC_ASM_H */ diff --git a/libc/sysdeps/linux/arc/bits/syscalls.h b/libc/sysdeps/linux/arc/bits/syscalls.h index c858d788be8c..000b6b6310b1 100644 --- a/libc/sysdeps/linux/arc/bits/syscalls.h +++ b/libc/sysdeps/linux/arc/bits/syscalls.h @@ -100,7 +100,7 @@ extern long __syscall_error (int); #ifdef __A7__ #define ARC_TRAP_INSN "trap0 \n\t" -#elif defined(__HS__) +#else #define ARC_TRAP_INSN "trap_s 0 \n\t" #endif @@ -182,7 +182,7 @@ extern long __syscall_error (int); #ifdef __A7__ #define ARC_TRAP_INSN trap0 -#elif defined(__HS__) +#else #define ARC_TRAP_INSN trap_s 0 #endif diff --git a/libc/sysdeps/linux/arc/crt1.S b/libc/sysdeps/linux/arc/crt1.S index 70a06e058d3b..ff36d252e9d7 100644 --- a/libc/sysdeps/linux/arc/crt1.S +++ b/libc/sysdeps/linux/arc/crt1.S @@ -40,7 +40,9 @@ __start: ld_s r1, [sp] ; argc mov_s r5, r0 ; rltd_fini - add_s r2, sp, 4 ; argv + /* Use the universal 32-bit add instruction as 16-bit add_s was excluded from + ARCv3 ISA */ + add r2, sp, 4 ; argv #ifdef L_Scrt1 ld r0, [pcl, @main@gotpc] ld r3, [pcl, @_init@gotpc] diff --git a/utils/ldd.c b/utils/ldd.c index 3accd78391d7..46cd97170433 100644 --- a/utils/ldd.c +++ b/utils/ldd.c @@ -34,6 +34,11 @@ #define ELFCLASSM ELFCLASS32 #endif +#if defined(__ARC64_ARCH32__) +#define MATCH_MACHINE(x) (x == EM_ARCV3_32) +#define ELFCLASSM ELFCLASS32 +#endif + #if defined(__arm__) || defined(__thumb__) #define MATCH_MACHINE(x) (x == EM_ARM) #define ELFCLASSM ELFCLASS32