From patchwork Sun Jun 28 07:02:27 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesse Huang X-Patchwork-Id: 137962 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6B5294BA2E2F for ; Sun, 28 Jun 2026 07:05:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6B5294BA2E2F Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=sifive.com header.i=@sifive.com header.a=rsa-sha256 header.s=google header.b=f0aMz6w5 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-dy1-x132d.google.com (mail-dy1-x132d.google.com [IPv6:2607:f8b0:4864:20::132d]) by sourceware.org (Postfix) with ESMTPS id 00F364BA2E27 for ; Sun, 28 Jun 2026 07:02:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 00F364BA2E27 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=sifive.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 00F364BA2E27 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::132d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1782630172; cv=none; b=GYrSfbmoUjiDesUsSWsCDfLMVm2STwhjLI39Tv1Yeg+gdZlTqd0bE/LN5C5obcuAXN06YZT1i7+vBwUavQFzeXLquF76CPzcm3nj4F2Us3sJ8+GiToVrhLaJ95h9OUX5tjlzkh4rQta05AoqWqs1zgHndKRsnjsoMTVNGZ/cd08= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1782630172; c=relaxed/simple; bh=B8bLWSo7Sbn9MuGKqFzIimB4PcbmO7NlxXesHV/qNRc=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=j8ePv7jwl+ww7/LL4t9YdmqCzPGfy1m/EGBYdPt12akSEDFFCATn6izGd/qc1GSWNmbTtYosJFAzh+hGK9kXg3EWjAjRorTRyDHBs5EXV6+28c7bYF5ntqAjGgOiFwBEOJXQ2Q7Jl/q8jF9m9RAI+V5jQilFDzG33QQIeJ8o6S0= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=sifive.com header.i=@sifive.com header.a=rsa-sha256 header.s=google header.b=f0aMz6w5 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 00F364BA2E27 Received: by mail-dy1-x132d.google.com with SMTP id 5a478bee46e88-30c965eab27so3617686eec.0 for ; Sun, 28 Jun 2026 00:02:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1782630171; x=1783234971; 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=WxqN7Cre2Jy1QdVMykdHC8Gk2itD80yth9BkgzqfFFY=; b=f0aMz6w5Irj69lPBjBKPLO1QhxgYzVL6YH/p2dYAwnXzcVEiwgG/2EHaJf/K5K4pyx CgjqksPkPGZlj98pFSF5lPgyZO2TBkK7NdCz0IzIesrNec8wOsj9H7oql/3Pu/P6CP6U oYhfpKKIaNiyel/o7lzbDIXNgrTQnCxciPE2vTZcvfFkOKSRrC1r29htbfQHVnFCa9Q0 LyqPX4oGyCEqHUtyge7c5xSl/60L+FctqfhNZ0oXbo3KtWXM15/BEtYXJ/MIHMkVvZ1K GhE3ijayjPapbqH482vA6I5kV9wBFwnDDV3wN4NM6Tyi+d+43I+qqGUlj43l4l3vu1mo ddFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782630171; x=1783234971; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=WxqN7Cre2Jy1QdVMykdHC8Gk2itD80yth9BkgzqfFFY=; b=D8uQnrtCY42Alp5sOQD2d8/lTpCoPhiPPYEmmYlNvbBlIrP6kdYrP+ZMu9/Gwyji12 nEuHu9g8DfphjgygVYGAGIj/5yJ6JAneuZnDogOTS/KNF/UJwBg1pngyc2bM2gghVYQ4 qUS0nI1CWmOFFPbBcxnnVWfCofmim+rk473LXBADq8Pv56r1N+kQC6PM1oiSTUZUm5qp epTEMV1RKt3Y/irMHyPRxFfp5IsTMseFFYuAwIvUDd/6sHu9PjRPTLKSywgcztcb2NzH N3eloDGg7LBFUfbBOPPp2plSIjQua9gusAM0n2Kq5M7rdmHE8QRI3ROgVsZ7a4/C7O6v 09Ng== X-Gm-Message-State: AOJu0Yyks33UuoFD41NcpFUpKknuBTqzc0eIH6AwN6sMgZ4Oxeb9q8kZ N3zAMFgimcBom6H7rDN9OKuGHqRfwP6/nGe6s/MEoBJqPFiU5JStyPGo5qChFvxR73a1fzAwmEk ucDHw8kV5YY2utYyxls+YLwWuL2i7K46VmJHo3CfxOgUOlbBONNIQLFo672dzaRNZQRSlzh2XR1 7NGFtPM1K7CtNy+yrjN7fjU7cFevcqgX5zEhA86EeNK46mFCkzou8= X-Gm-Gg: AfdE7cl2zUkpdSnhSruSbLid51YDhM2Us5nb2Q8rIutF2yZcT950kpZaISGFHAgPj6l wxlHNIMnQZ/naC1mRi5jYg4ElP6gJKPGV+yKnZgVwgOW6uJcVSw29uv92zWa4ITnHdWQcV2NUbF HprrQmu4bVZGAOmAFipwkxJOKckV0Ihq7AiaSn6TdWBnRrYHekz+paihnEV3IExvkJU8T+NSwLn SHGehzHej/GYqh5lWV4lp8WAyN6i6cRor417s8wbSmCKW12PY4fq+bGXA2VquEvttjyN0FkEyRZ Id9K8E32pKV+Mj9pcrNUmsgYykhLkYN4cbDOJvc5w+aKXEPnCBGhPNS/Q94vSlEZ3qifqbyDXzA 0IPVR0jOVBQSiARD84P3AtInwbcy2pgfshUEpbP/3XhbEqRSfC1brs30/Huqh9itOdTb8ySs4Jq MZhQXnZggODjaqCPyqI/2n86q+ZtYcXA== X-Received: by 2002:a05:693c:8816:20b0:30c:8656:6db0 with SMTP id 5a478bee46e88-30c865672dcmr8121908eec.27.1782630170697; Sun, 28 Jun 2026 00:02:50 -0700 (PDT) Received: from sw08.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-30c7c8afc91sm35435166eec.14.2026.06.28.00.02.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jun 2026 00:02:49 -0700 (PDT) From: Jesse Huang To: libc-alpha@sourceware.org Cc: andrew@sifive.com, darius@bluespec.com, debug@rivosinc.com, jeffreyalaw@gmail.com, kito.cheng@sifive.com, palmer@dabbelt.com, schwab@suse.de, Jesse Huang , Hau Hsu Subject: [PATCH v5 02/16] riscv/cfi: Set up necessary options for --enable-cfi Date: Sun, 28 Jun 2026 00:02:27 -0700 Message-Id: <20260628070241.88310-3-jesse.huang@sifive.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20260628070241.88310-1-jesse.huang@sifive.com> References: <20260628070241.88310-1-jesse.huang@sifive.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on 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 Co-authored-by: Hau Hsu Reviewed-by: Deepak Gupta --- sysdeps/riscv/Makefile | 9 +++++++++ sysdeps/riscv/preconfigure | 2 ++ sysdeps/riscv/preconfigure.ac | 1 + 3 files changed, 12 insertions(+) diff --git a/sysdeps/riscv/Makefile b/sysdeps/riscv/Makefile index c08753ae8a..99976fddad 100644 --- a/sysdeps/riscv/Makefile +++ b/sysdeps/riscv/Makefile @@ -15,3 +15,12 @@ ASFLAGS-.os += -Wa,-mno-relax ASFLAGS-.o += -Wa,-mno-relax sysdep-CFLAGS += -mno-relax endif + +# Enable RISC-V CFI +ifeq (yes,$(riscv-enable-cfi)) +CFLAGS-.o += -fcf-protection=full +CFLAGS-.os += -fcf-protection=full +CFLAGS-.op += -fcf-protection=full +CFLAGS-.oS += -fcf-protection=full +asm-CPPFLAGS += -fcf-protection=full -include sysdep.h +endif diff --git a/sysdeps/riscv/preconfigure b/sysdeps/riscv/preconfigure index 57fe6822cf..b480c53d5f 100755 --- a/sysdeps/riscv/preconfigure +++ b/sysdeps/riscv/preconfigure @@ -79,6 +79,8 @@ riscv*) printf "%s\n" "#define RISCV_ABI_FLEN $abi_flen" >>confdefs.h + config_vars="$config_vars +riscv-enable-cfi = $enable_cfi" ;; esac diff --git a/sysdeps/riscv/preconfigure.ac b/sysdeps/riscv/preconfigure.ac index 52414919ae..15c61e9305 100644 --- a/sysdeps/riscv/preconfigure.ac +++ b/sysdeps/riscv/preconfigure.ac @@ -77,5 +77,6 @@ riscv*) AC_DEFINE_UNQUOTED([RISCV_ABI_XLEN], [$xlen]) AC_DEFINE_UNQUOTED([RISCV_ABI_FLEN], [$abi_flen]) + LIBC_CONFIG_VAR([riscv-enable-cfi], [$enable_cfi]) ;; esac