From owner-svn-src-head@freebsd.org Mon Apr 27 17:55:42 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 17C0A2C1260; Mon, 27 Apr 2020 17:55:42 +0000 (UTC) (envelope-from jhb@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 499srY6xwfz4PgM; Mon, 27 Apr 2020 17:55:41 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D06F4E87E; Mon, 27 Apr 2020 17:55:41 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 03RHtfBu052198; Mon, 27 Apr 2020 17:55:41 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 03RHtfKp052195; Mon, 27 Apr 2020 17:55:41 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <202004271755.03RHtfKp052195@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Mon, 27 Apr 2020 17:55:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r360387 - in head/sys: kern riscv/include riscv/riscv X-SVN-Group: head X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in head/sys: kern riscv/include riscv/riscv X-SVN-Commit-Revision: 360387 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Apr 2020 17:55:42 -0000 Author: jhb Date: Mon Apr 27 17:55:40 2020 New Revision: 360387 URL: https://svnweb.freebsd.org/changeset/base/360387 Log: Improve MACHINE_ARCH handling for hard vs soft-float on RISC-V. For userland, MACHINE_ARCH reflects the current ABI via preprocessor directives. For the kernel, the hw.machine_arch sysctl uses the ELF header flags of the current process to select the correct MACHINE_ARCH value. Reviewed by: imp, kp Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D24543 Modified: head/sys/kern/kern_mib.c head/sys/riscv/include/param.h head/sys/riscv/riscv/elf_machdep.c Modified: head/sys/kern/kern_mib.c ============================================================================== --- head/sys/kern/kern_mib.c Mon Apr 27 17:53:38 2020 (r360386) +++ head/sys/kern/kern_mib.c Mon Apr 27 17:55:40 2020 (r360387) @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include Modified: head/sys/riscv/include/param.h ============================================================================== --- head/sys/riscv/include/param.h Mon Apr 27 17:53:38 2020 (r360386) +++ head/sys/riscv/include/param.h Mon Apr 27 17:55:40 2020 (r360387) @@ -46,18 +46,16 @@ #define MACHINE "riscv" #endif #ifndef MACHINE_ARCH -/* - * Check to see if we're building with hardware floating instructions - * allowed. We check this instead of hard vs soft float ABI because we build the - * kernel with soft float ABI to avoid hard float instruction generation. If - * we ever allow a 'soft ABI but with hard floats' userland, then we'll need - * to rethink this. - */ -#ifdef __riscv_flen -#define MACHINE_ARCH "riscv64" -#else + +/* Always use the hard-float arch for the kernel. */ +#if !defined(_KERNEL) && defined(__riscv_float_abi_soft) #define MACHINE_ARCH "riscv64sf" +#else +#define MACHINE_ARCH "riscv64" #endif +#endif +#ifdef _KERNEL +#define MACHINE_ARCHES "riscv64 riscv64sf" #endif #ifdef SMP Modified: head/sys/riscv/riscv/elf_machdep.c ============================================================================== --- head/sys/riscv/riscv/elf_machdep.c Mon Apr 27 17:53:38 2020 (r360386) +++ head/sys/riscv/riscv/elf_machdep.c Mon Apr 27 17:55:40 2020 (r360387) @@ -58,6 +58,8 @@ __FBSDID("$FreeBSD$"); #include #include +static const char *riscv_machine_arch(struct proc *p); + u_long elf_hwcap; struct sysentvec elf64_freebsd_sysvec = { @@ -94,8 +96,19 @@ struct sysentvec elf64_freebsd_sysvec = { .sv_thread_detach = NULL, .sv_trap = NULL, .sv_hwcap = &elf_hwcap, + .sv_machine_arch = riscv_machine_arch, }; INIT_SYSENTVEC(elf64_sysvec, &elf64_freebsd_sysvec); + +static const char * +riscv_machine_arch(struct proc *p) +{ + + if ((p->p_elf_flags & EF_RISCV_FLOAT_ABI_MASK) == + EF_RISCV_FLOAT_ABI_SOFT) + return (MACHINE_ARCH "sf"); + return (MACHINE_ARCH); +} static Elf64_Brandinfo freebsd_brand_info = { .brand = ELFOSABI_FREEBSD,