From nobody Mon Mar 28 16:30:15 2022 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 6427B1A43899; Mon, 28 Mar 2022 16:30:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KRypw1yj2z3tr1; Mon, 28 Mar 2022 16:30:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648485016; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ZhT6JIxBCQ1xRrDZgvgEmbXK15d3rL+2cKMQSYZzHSw=; b=J7r54fxcHgPTrlUBM7hnJyASU4X/taPr6InrumVmiWqg08RBy7x/Vj1S2Vgsm2PbbkdKrG RauuaXr2GyYgbwovS+238wfCgANf8UuRwQCSVpjHTg9JEuBMEnUbEjY/vssEJ8MUlcR+6H mkSy2FKIc6VFD0THOaDNIQalLsto8+Ek2ZBw8QJrS4nGheAy9CKnA1uu1lnM6XS+4O96BT HOfMmUCbcpJS4VnIWq2UQJmAa96U+TEd/ugONtwd1I0kGjC6aF50QMfyCBX/DmGb6/YP7+ nrf0yEfLU48d42bkZNR9zy4ZUL+5WBSYcmvGQYgehds8PG1UBGT7HU2iQwH+5w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1325F54C5; Mon, 28 Mar 2022 16:30:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 22SGUFSV073098; Mon, 28 Mar 2022 16:30:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22SGUFfx073092; Mon, 28 Mar 2022 16:30:15 GMT (envelope-from git) Date: Mon, 28 Mar 2022 16:30:15 GMT Message-Id: <202203281630.22SGUFfx073092@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Piotr Kubaj Subject: git: d30aac1297a2 - releng/13.1 - riscv: actually enable sanitizers List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pkubaj X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.1 X-Git-Reftype: branch X-Git-Commit: d30aac1297a29a6628c2ee1659ac6fe6914fd753 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648485016; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ZhT6JIxBCQ1xRrDZgvgEmbXK15d3rL+2cKMQSYZzHSw=; b=Ro8amXaYlWKYPXXniitTmGzuSb5x6yhvXR3L5IR1h/Zhxf9UFu1nQtrawPp86HM3d9KDeE EgFJaNSZLKKO0P34NESr33kzRIaspznH1uWR3NqcFsRC62xqc+pvRbe5CVA/0dBuuuSIAY s960jIY4wmuNuhqCPCuDn5jM6CIm21arrXfDVEWy+zX4zOFTOB5RfLg7W5CndwUKLjzqZ9 06z49WFANpi9BcVEpgvy+wT7hCzl6uFwxr5ZB/kp0yMIm3dU0kWAQ7iaVXjzY8i2hEUHwi 7o/R0xKEsS2K1N9F9uwLlUBW30eXOz14ECPnYi7yCDYL1E3vuqlK9OSV6jf8mw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1648485016; a=rsa-sha256; cv=none; b=ri/g9WGzXJMw6DFTINYlIKRpOw6lbctNQ+Cu01VrByInR4ZxZ8FgwUvugsAzOp8aBwhvi8 bGQ4+VtyKloE8rgo9hqH2Pqay85eUQIsg58IF/DZKV0MfBFFGjZcOtylgAlI0jf+uwaDgi ORtgAZt+5WtTBzs4D/holWMCn6j6ay8OKCi4iVtWaadFKO0bxznqvKgYkgLSblSspM/Hw4 sBqmSvq7FaIzFrmR336ZP54T+SaHVZv94kGkjMHuF8dDflrL7zIxQ43KDfYFVIyGZ11vzv rumcnEnOmLK1mEhZ1F8Rvlt4OCXTnqn3mTcv7TAXbPxYyTpGumhya8lzyElSxA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch releng/13.1 has been updated by pkubaj (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=d30aac1297a29a6628c2ee1659ac6fe6914fd753 commit d30aac1297a29a6628c2ee1659ac6fe6914fd753 Author: Piotr Kubaj AuthorDate: 2022-03-13 03:31:35 +0000 Commit: Piotr Kubaj CommitDate: 2022-03-28 16:29:53 +0000 riscv: actually enable sanitizers 1. Backport https://github.com/llvm/llvm-project/commit/b475ce39e8b1de3a70ea242473f136a567be46e3. 2. Enable libclang_rt for riscv. Previous commit missed it. Reviewed by: dim Differential Revision: https://reviews.freebsd.org/D34543 Approved by: re (gjb) (cherry picked from commit 3781e77995e9b81afcbf7b3dc84b33b864c48794) (cherry picked from commit e58a146c5d24172b53f18b953b3d29ee25bdb90c) --- .../lib/sanitizer_common/sanitizer_linux.cpp | 22 +++++++++++++++++----- lib/Makefile | 2 +- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp b/contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp index daa07c15490e..769e8029dfcb 100644 --- a/contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp +++ b/contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp @@ -416,7 +416,7 @@ uptr internal_unlink(const char *path) { } uptr internal_rename(const char *oldpath, const char *newpath) { -#if defined(__riscv) +#if defined(__riscv) && defined(__linux__) return internal_syscall(SYSCALL(renameat2), AT_FDCWD, (uptr)oldpath, AT_FDCWD, (uptr)newpath, 0); #elif SANITIZER_USES_CANONICAL_LINUX_SYSCALLS @@ -1218,7 +1218,8 @@ void ForEachMappedRegion(link_map *map, void (*cb)(const void *, uptr)) { } #endif -#if defined(__x86_64__) && SANITIZER_LINUX +#if SANITIZER_LINUX +#if defined(__x86_64__) // We cannot use glibc's clone wrapper, because it messes with the child // task's TLS. It writes the PID and TID of the child task to its thread // descriptor, but in our case the child task shares the thread descriptor with @@ -1557,7 +1558,7 @@ uptr internal_clone(int (*fn)(void *), void *child_stack, int flags, void *arg, : "cr0", "cr1", "memory", "ctr", "r0", "r27", "r28", "r29"); return res; } -#elif defined(__i386__) && SANITIZER_LINUX +#elif defined(__i386__) uptr internal_clone(int (*fn)(void *), void *child_stack, int flags, void *arg, int *parent_tidptr, void *newtls, int *child_tidptr) { int res; @@ -1622,7 +1623,7 @@ uptr internal_clone(int (*fn)(void *), void *child_stack, int flags, void *arg, : "memory"); return res; } -#elif defined(__arm__) && SANITIZER_LINUX +#elif defined(__arm__) uptr internal_clone(int (*fn)(void *), void *child_stack, int flags, void *arg, int *parent_tidptr, void *newtls, int *child_tidptr) { unsigned int res; @@ -1688,7 +1689,8 @@ uptr internal_clone(int (*fn)(void *), void *child_stack, int flags, void *arg, : "memory"); return res; } -#endif // defined(__x86_64__) && SANITIZER_LINUX +#endif +#endif // SANITIZER_LINUX #if SANITIZER_LINUX int internal_uname(struct utsname *buf) { @@ -1918,7 +1920,11 @@ SignalContext::WriteFlag SignalContext::GetWriteFlag() const { u32 instr = *(u32 *)pc; return (instr >> 21) & 1 ? WRITE: READ; #elif defined(__riscv) +#if SANITIZER_FREEBSD + unsigned long pc = ucontext->uc_mcontext.mc_gpregs.gp_sepc; +#else unsigned long pc = ucontext->uc_mcontext.__gregs[REG_PC]; +#endif unsigned faulty_instruction = *(uint16_t *)pc; #if defined(__riscv_compressed) @@ -2137,9 +2143,15 @@ static void GetPcSpBp(void *context, uptr *pc, uptr *sp, uptr *bp) { *sp = ucontext->uc_mcontext.gregs[15]; #elif defined(__riscv) ucontext_t *ucontext = (ucontext_t*)context; +# if SANITIZER_FREEBSD + *pc = ucontext->uc_mcontext.mc_gpregs.gp_sepc; + *bp = ucontext->uc_mcontext.mc_gpregs.gp_s[0]; + *sp = ucontext->uc_mcontext.mc_gpregs.gp_sp; +# else *pc = ucontext->uc_mcontext.__gregs[REG_PC]; *bp = ucontext->uc_mcontext.__gregs[REG_S0]; *sp = ucontext->uc_mcontext.__gregs[REG_SP]; +# endif #else # error "Unsupported arch" #endif diff --git a/lib/Makefile b/lib/Makefile index 5e740edc78a5..5896a6812a5b 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -180,7 +180,7 @@ SUBDIR.${MK_STATS}+= libstats .if ${COMPILER_TYPE} == "clang" && ${MK_CXX} != "no" && \ (${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64" || \ ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "i386" || \ - ${MACHINE_CPUARCH} == "powerpc") + ${MACHINE_CPUARCH} == "powerpc" || ${MACHINE_CPUARCH} == "riscv") _libclang_rt= libclang_rt .endif