From owner-svn-src-all@freebsd.org Mon Feb 24 19:26:27 2020 Return-Path: Delivered-To: svn-src-all@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 0EDC2240844 for ; Mon, 24 Feb 2020 19:26:27 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48RBrK2bT7z4FCK for ; Mon, 24 Feb 2020 19:26:25 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-qk1-x744.google.com with SMTP id 145so3551778qkl.2 for ; Mon, 24 Feb 2020 11:26:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hRJJKQNXPS8Y+hdsBnsxx9ZnNlDJDb4fpM7svDKtvLg=; b=zoesnVogoI/Jq9NLEPkywU9S/qTHqygPfsKskd0+sH2MRdYylRPsHj0klgYnXZhBMv XMPaovYk3AIwoqK5Cy/mgsah+Ij14CrldvFhmEWPdCEhkX0WCBEUlK1ioUoX2ep6dNMv q/RFftzgAZ9piBUegV8SoUpJhJVyL7HIiIfHMzJxOH7xYK0cyWxDmVYz9Xl7DyCfD9Br /oovp+r0Ojkg1xfKJQEwx11T6kjPAl3e50PLsjZEAg4dkfX2u+eRFViP3axzuoQi8oei ZDJOz4APHPIj48kqOTOS1tnyOUKEgNVR4Xw5vFciC8lGVpmpdswRDDv5R/fq8pASdnGU 0mGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hRJJKQNXPS8Y+hdsBnsxx9ZnNlDJDb4fpM7svDKtvLg=; b=ovxSYZBLdw14gRDpZR0QrN5c3lBa03o6ZU+GU+N0G0xU/3ZfLxpPn5ZeNtJe4IcLTE 6W030aZAA/henpaSmVLgUeNOcCOzUQmej9sqrsMU5xuFTpa0xeUAmgBoaVjP2VffL8Cb B5TqbLbr9x/tm5AJ67X1gyweI2/kYJqrZlRjjE+UyPhuxvWHwrNdu0j5+IsvzKhLTewu K14jkuNVwhsIGqgfwmp1PCbuh+kxei8HK5TfyRSYZXj6Glo5w4FSWZE+D8qcYTdM0rem E+WmdvuWa+b3yNpjD4yBSA3plowFD1Glbu0SrPDZnczBNl2gpI8OCDhyVanw4kX4WnVe nwvA== X-Gm-Message-State: APjAAAVIyYoCTkZHlI2dO6/Qg61SqCBK3HZQ0RZAvyybZBHdsmNK65tx 7OYj4a5EmLWKVM9q0uFVSH0LT9wG4AtCcr+mxFoCZA== X-Google-Smtp-Source: APXvYqx0h1J8/dJsYyar3cWDwUnjDJtD4GQYderbfb/kh3+2gESUWgUzLUqACI1xUdVkJXhDjSodMYWybtO+CYzlq3E= X-Received: by 2002:a37:9fd0:: with SMTP id i199mr36836101qke.60.1582572383281; Mon, 24 Feb 2020 11:26:23 -0800 (PST) MIME-Version: 1.0 References: <202002221323.01MDNSX9063377@repo.freebsd.org> <0029f80e-5480-da66-0bcd-c2699e046cab@FreeBSD.org> In-Reply-To: <0029f80e-5480-da66-0bcd-c2699e046cab@FreeBSD.org> From: Warner Losh Date: Mon, 24 Feb 2020 12:26:12 -0700 Message-ID: Subject: Re: svn commit: r358247 - in head/sys: conf riscv/include To: John Baldwin Cc: Kristof Provost , src-committers , svn-src-all , svn-src-head X-Rspamd-Queue-Id: 48RBrK2bT7z4FCK X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=bsdimp-com.20150623.gappssmtp.com header.s=20150623 header.b=zoesnVog; dmarc=none; spf=none (mx1.freebsd.org: domain of wlosh@bsdimp.com has no SPF policy when checking 2607:f8b0:4864:20::744) smtp.mailfrom=wlosh@bsdimp.com X-Spamd-Result: default: False [-2.39 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; R_DKIM_ALLOW(-0.20)[bsdimp-com.20150623.gappssmtp.com:s=20150623]; FROM_HAS_DN(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[svn-src-all@freebsd.org]; DMARC_NA(0.00)[bsdimp.com]; RCPT_COUNT_FIVE(0.00)[5]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TO_DN_ALL(0.00)[]; DKIM_TRACE(0.00)[bsdimp-com.20150623.gappssmtp.com:+]; RCVD_IN_DNSWL_NONE(0.00)[4.4.7.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.b.8.f.7.0.6.2.list.dnswl.org : 127.0.5.0]; R_SPF_NA(0.00)[]; FORGED_SENDER(0.30)[imp@bsdimp.com,wlosh@bsdimp.com]; MIME_TRACE(0.00)[0:+,1:+,2:~]; IP_SCORE(-0.39)[ip: (1.65), ipnet: 2607:f8b0::/32(-1.88), asn: 15169(-1.67), country: US(-0.05)]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; FROM_NEQ_ENVFROM(0.00)[imp@bsdimp.com,wlosh@bsdimp.com]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Feb 2020 19:26:27 -0000 On Mon, Feb 24, 2020 at 11:08 AM John Baldwin wrote: > On 2/22/20 5:23 AM, Kristof Provost wrote: > > Author: kp > > Date: Sat Feb 22 13:23:27 2020 > > New Revision: 358247 > > URL: https://svnweb.freebsd.org/changeset/base/358247 > > > > Log: > > riscv: Set MACHINE_ARCH correctly > > > > MACHINE_ARCH sets the hw.machine_arch sysctl in the kernel. In > userspace > > it sets MACHINE_ARCH in bmake, which bsd.cpu.mk uses to configure the > > target ABI for ports. > > > > For riscv64sf builds (i.e. soft-float) that needs to be riscv64sf, but > > the sysctl didn't reflect that. It is static. > > > > Set the define from the riscv makefile so that we correctly reflect our > > actual build (i.e. riscv64 or riscv64sf), depending on what TARGET_ARCH > > we were built with. > > > > That still doesn't satisfy userspace builds (e.g. bmake), so check if > > we're building with a software-floating point toolchain there. That > > check doesn't work in the kernel, because it never uses floating point. > > > > Reviewed by: philip (previous version), mhorne > > Sponsored by: Axiado > > Differential Revision: https://reviews.freebsd.org/D23741 > > I actually think this is kind of busted as the kernel is always the same, > and we have the same problem on MIPS which also already does this wrong. > I think instead we should treat soft-float as an alternate ABI (though > very light weight as it doesn't need a separate syscall handler, etc.) and > make the sysctl handler smart enough to return the right value based on the > ELF header of the binary. > > I saw the later followup commit to add GENERICSF and I think that is > possibly > even farther down the wrong path. The kernel is _always_ soft-float in > terms > of the ABI it is built with. However, kernel with FPE support can run > binaries > with either ABI. It's true that on RISC-V there is not a nice way to > detect > if the FPU is present (I haven't looked at OpenSBI, but the SBI used with > bbl > doesn't provide misa to S-mode to know if it is present or not). You could > just try to execute an FPU instruction during boot to see if you get an > illegal instruction fault (subject to your SBI choosing to emulate that). > We talked about this on IRC, and here's a summary of my understanding Short term, we'll keep GENERICSF so that we can build ports correctly. I'll post a couple of fixes to it, but generally it will stay as is for the short term. Longer term, we need to formalize the many to many relationships between userland ABI and kernel ABI in a number of ways. We need them for MIPS as well as CHERI work. To that end, we'll move for riscv to having a single kernel that can execute multiple ABIs. we'll update the hw.machine_arch to return the ABI of the binary that's running. We'll also make sure that we make the FPU stuff more dynamic in some way. Here 'we' is hazily defined, but I think it's mostly John :). There will also need to be some minor tweaks to the build system that I'm investigating (things mostly work today, but there are times that we get mismatches that matter and go undetected I think -- which is what I'm looking into). Warner