From nobody Mon Mar 14 00:59:33 2022 X-Original-To: dev-commits-src-all@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 5F38F1A121DA; Mon, 14 Mar 2022 00:59:38 +0000 (UTC) (envelope-from rpokala@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (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 "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KGyqZ12trz4VQn; Mon, 14 Mar 2022 00:59:38 +0000 (UTC) (envelope-from rpokala@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1647219578; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XAhsgRdOwcpN00CNSyvUtg/Ij2PxMxR9CSw9dVjiNa4=; b=NmWk1d/7VhnZKr4IVTFrjtM1VloNb9NujNnBe5yIYxuAIL2oLutqQXQcUEky1mvZzPaT4k AtdQ9iRelR19dTedcNZ6utCQlsQFMlFoXIzykIZ7Jg/o49V2+mTpsivxbqAH1YK7XRmj/N pwggGRXB1SIdczfGQvtonuA12XPGKzyAheVfhkrA4V3FMtwrqpFymlf94R8Zl/uzZo7GRq FosADLWxEu0l7JtRX9rZXhC0OHS9g709G01aU5ujLSNOEChMFG/m9mt2g4bpj/7lCQa9W4 3UFhDcd5FVdHxjHvUWkxNlA40e443FDk8S9bvlP3MI7WdkyNS+AgruJqjUJBkw== Received: from [192.168.1.10] (unknown [98.42.164.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) (Authenticated sender: rpokala) by smtp.freebsd.org (Postfix) with ESMTPSA id 7938B2B5FD; Mon, 14 Mar 2022 00:59:37 +0000 (UTC) (envelope-from rpokala@freebsd.org) User-Agent: Microsoft-MacOutlook/16.58.22021501 Date: Sun, 13 Mar 2022 17:59:33 -0700 Subject: Re: 3781e77995e9 - main - riscv: actually enable sanitizers From: Ravi Pokala To: Piotr Kubaj CC: "src-committers@FreeBSD.org" , "dev-commits-src-all@FreeBSD.org" , "dev-commits-src-main@FreeBSD.org" Message-ID: Thread-Topic: 3781e77995e9 - main - riscv: actually enable sanitizers References: <202203131207.22DC7dTY000316@gitrepo.freebsd.org> <67FE3738-E963-4EBF-B01F-ECEA897CB154@panasas.com> In-Reply-To: List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org Mime-version: 1.0 Content-type: text/plain; charset="UTF-8" Content-transfer-encoding: quoted-printable ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1647219578; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XAhsgRdOwcpN00CNSyvUtg/Ij2PxMxR9CSw9dVjiNa4=; b=lbVi49v5+8uUlMgv3KuXDQAouOCDXTjMino3Z6NDVmGYU6STwiMde5/nrMBZlfZyLxLrTa I/B5w4DIC0HMxUlQOFJ3ngndIHkp4RDB5VmCXC9Rhjicw4rvsUVnj3NIKSXYuB8Om2eQOI 13IM2c9m0zdmSA4rkUE1mq53NFfKQV89P9vCQFM5R6am0/IPD/naW776HLXOgOy5MlL9+t tmVW60PDPXB0lc0olCz2ujqABbCxgP5ZL8SQnwrZJcy+h25218nDSE9IrQjlphYCGrADsv Zsa1FER8w/g0APuqAHTaRHfgLnsJ/pK/thFStE8d3u1285yg9wMUojVotIp5LA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1647219578; a=rsa-sha256; cv=none; b=dSrdVPRKzWfkGSfUSCC4ERZMP7qNx3W9lyfdE8DTsBQLcDVQWVGcZxvEXquExIbPTUUdRF 5xFUc7CTjAbR+nw4b8ICbEIYFn2tJWgtCUbmqlWmTEvsBM62HzddtkFAeUzXJrn96dWovy N2mhYzT/3ZsPKwYgR76LQ7tRjRKnVsKD+o2EX302ntXx1CBMEbI8U3uGfEctOrA7pN/sRU mb7YK8gquZSKW9wsciWU1fdbuupG6WXk+X1MIEG9ZOZI5j/mZ/ISvA4OJNqgAAVmyeuNSP us7ulNbK2NU+18EijJdBYsjhQpIN0n9sq2AnAHUe3Jaeq3eePE1Cr63ImQQR1A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N -----Original Message----- From: Piotr Kubaj Date: 2022-03-13, Sunday at 15:39 To: Ravi Pokala Cc: "src-committers@FreeBSD.org" , "dev-commits= -src-all@FreeBSD.org" , "dev-commits-src-ma= in@FreeBSD.org" Subject: Re: 3781e77995e9 - main - riscv: actually enable sanitizers On 22-03-13 21:29:19, Pokala, Ravi wrote: > Hi Piotr, >=20 > > --- a/lib/Makefile > > +++ b/lib/Makefile > > @@ -184,7 +184,7 @@ SUBDIR.${MK_STATS}+=3D libstats > > .if ${COMPILER_TYPE} =3D=3D "clang" && ${MK_CXX} !=3D "no" && \ > > (${MACHINE_CPUARCH} =3D=3D "aarch64" || ${MACHINE_CPUARCH} =3D=3D "amd= 64" || \ > > ${MACHINE_CPUARCH} =3D=3D "arm" || ${MACHINE_CPUARCH} =3D=3D "i386" ||= \ > > - ${MACHINE_CPUARCH} =3D=3D "powerpc") > > + ${MACHINE_CPUARCH} =3D=3D "powerpc" || ${MACHINE_CPUARCH} =3D=3D "risc= v") > > _libclang_rt=3D libclang_rt > > .elif (${MK_ASAN} !=3D "no" || ${MK_UBSAN} !=3D "no") && make(all) > > .error Requested build with sanitizers but cannot build runtime lib= raries! >=20 > I believe the conditional now covers all architectures. Couldn't / sh= ouldn't it simply be removed? It can, but I left it as it is for MFC'ing purposes. 13 still supports mips. Good point. Perhaps some post-MFC cleanup then. Thanks, Ravi (rpokala@) >=20 > Thanks, >=20 > Ravi (rpokala@) >=20 > =EF=BB=BF-----Original Message----- > From: on behalf of Piotr Kubaj > Date: 2022-03-13, Sunday at 05:07 > To: , , = > Subject: git: 3781e77995e9 - main - riscv: actually enable sanitizers >=20 > The branch main has been updated by pkubaj (ports committer): >=20 > URL: https://cgit.FreeBSD.org/src/commit/?id=3D3781e77995e9b81afcbf= 7b3dc84b33b864c48794 >=20 > commit 3781e77995e9b81afcbf7b3dc84b33b864c48794 > Author: Piotr Kubaj > AuthorDate: 2022-03-13 03:31:35 +0000 > Commit: Piotr Kubaj > CommitDate: 2022-03-13 12:06:57 +0000 >=20 > riscv: actually enable sanitizers >=20 > 1. Backport https://github.com/llvm/llvm-project/commit/b475c= e39e8b1de3a70ea242473f136a567be46e3. > 2. Enable libclang_rt for riscv. >=20 > Previous commit missed it. >=20 > MFC after: 3 days > Reviewed by: dim > Differential Revision: https://reviews.freebsd.org/D34543 > --- > .../lib/sanitizer_common/sanitizer_linux.cpp | 22 ++++++++= +++++++++----- > lib/Makefile | 2 +- > 2 files changed, 18 insertions(+), 6 deletions(-) >=20 > diff --git a/contrib/llvm-project/compiler-rt/lib/sanitizer_commo= n/sanitizer_linux.cpp b/contrib/llvm-project/compiler-rt/lib/sanitizer_commo= n/sanitizer_linux.cpp > index daa07c15490e..769e8029dfcb 100644 > --- a/contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanit= izer_linux.cpp > +++ b/contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanit= izer_linux.cpp > @@ -416,7 +416,7 @@ uptr internal_unlink(const char *path) { > } >=20 > 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)ol= dpath, AT_FDCWD, > (uptr)newpath, 0); > #elif SANITIZER_USES_CANONICAL_LINUX_SYSCALLS > @@ -1218,7 +1218,8 @@ void ForEachMappedRegion(link_map *map, voi= d (*cb)(const void *, uptr)) { > } > #endif >=20 > -#if defined(__x86_64__) && SANITIZER_LINUX > +#if SANITIZER_LINUX > +#if defined(__x86_64__) > // We cannot use glibc's clone wrapper, because it messes with t= he child > // task's TLS. It writes the PID and TID of the child task to it= s 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 fl= ags, 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 fl= ags, 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 >=20 > #if SANITIZER_LINUX > int internal_uname(struct utsname *buf) { > @@ -1918,7 +1920,11 @@ SignalContext::WriteFlag SignalContext::Ge= tWriteFlag() const { > u32 instr =3D *(u32 *)pc; > return (instr >> 21) & 1 ? WRITE: READ; > #elif defined(__riscv) > +#if SANITIZER_FREEBSD > + unsigned long pc =3D ucontext->uc_mcontext.mc_gpregs.gp_sepc; > +#else > unsigned long pc =3D ucontext->uc_mcontext.__gregs[REG_PC]; > +#endif > unsigned faulty_instruction =3D *(uint16_t *)pc; >=20 > #if defined(__riscv_compressed) > @@ -2137,9 +2143,15 @@ static void GetPcSpBp(void *context, uptr = *pc, uptr *sp, uptr *bp) { > *sp =3D ucontext->uc_mcontext.gregs[15]; > #elif defined(__riscv) > ucontext_t *ucontext =3D (ucontext_t*)context; > +# if SANITIZER_FREEBSD > + *pc =3D ucontext->uc_mcontext.mc_gpregs.gp_sepc; > + *bp =3D ucontext->uc_mcontext.mc_gpregs.gp_s[0]; > + *sp =3D ucontext->uc_mcontext.mc_gpregs.gp_sp; > +# else > *pc =3D ucontext->uc_mcontext.__gregs[REG_PC]; > *bp =3D ucontext->uc_mcontext.__gregs[REG_S0]; > *sp =3D ucontext->uc_mcontext.__gregs[REG_SP]; > +# endif > #else > # error "Unsupported arch" > #endif > diff --git a/lib/Makefile b/lib/Makefile > index d34f40616396..816374552f0a 100644 > --- a/lib/Makefile > +++ b/lib/Makefile > @@ -184,7 +184,7 @@ SUBDIR.${MK_STATS}+=3D libstats > .if ${COMPILER_TYPE} =3D=3D "clang" && ${MK_CXX} !=3D "no" && \ > (${MACHINE_CPUARCH} =3D=3D "aarch64" || ${MACHINE_CPUARCH} =3D=3D "a= md64" || \ > ${MACHINE_CPUARCH} =3D=3D "arm" || ${MACHINE_CPUARCH} =3D=3D "i386" = || \ > - ${MACHINE_CPUARCH} =3D=3D "powerpc") > + ${MACHINE_CPUARCH} =3D=3D "powerpc" || ${MACHINE_CPUARCH} =3D=3D "ri= scv") > _libclang_rt=3D libclang_rt > .elif (${MK_ASAN} !=3D "no" || ${MK_UBSAN} !=3D "no") && make(all) > .error Requested build with sanitizers but cannot build runtime = libraries! >=20