Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp7317157imm; Tue, 28 Aug 2018 09:53:05 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZupBRQ2O+YLAKbr3pq6/4qpgh1Xpuo90KaSS4sQwcy1LFlvS7bx6OP5qGCGJ5e+df69XRc X-Received: by 2002:a63:b705:: with SMTP id t5-v6mr2193385pgf.366.1535475185696; Tue, 28 Aug 2018 09:53:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535475185; cv=none; d=google.com; s=arc-20160816; b=bdK70FuopKU0A5hWl77IL68khncOcUE9bE66Dj4TYzW7YXiRNPgCnNMF9c+Ng58Vhz v95997+V8jnmAwEkZhRtePknsFuRWQI4LSVumv8278J+Sj8ykwVDbdpJJ3tphcl9C6t1 CJfxjb3dIxQmsmYKY6NA4uCPS4VbyMYScOGPObt7iBtwBAWPJlA5DtqnkwiCqf5DvJTR WBn9bMk+4OhcDQqprdwFPVYUu8c4MD/UBsxbaCinG0XWCb0vh9IlK0shKQ7OOrzOPHaV 5ZAS8qKRQabyU2d9kyp0sZiWRJHCIWAWx4KZ5mkYju8LzjFs1j+oJHC5bScC1Cv4sMuT mAxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:to:from:cc:in-reply-to:subject:date:dkim-signature :arc-authentication-results; bh=+5OzEVheTPrXM1UrnfzO3M0cz2qMU0nrsN+pFLYL2To=; b=xty/j22rSr5t1bYWZZjFSXsFP9tZ+w7nLB04Xhvfd4CIiyP04hvvwAvhAXkXlSoSIC uwNiNC+bDEvFWJTwN6uy9sZ5clXIJ6SgFm0orFH2TtZNy/JmygtQZnNZBgGsDQ5DkbUx LLbBZA033qadSkr7aQ3nq7qHZYfKePNOgfgh+ZKnGJSoqCqjrgdqcPT0h5Pt+bzzUVvi xdlQDuAQzgcIjsexlWOT9pleNUxpEayJYdZA/VoOeoBXjX5u8q60ObXy3ZgbGegGsApz xsZ90tR197eS7akB9iO3qRW1jy0XrJvhykknO66s2ZdftNhQW2uzhcYXzprYWcSN01HR x7uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=bERC36OE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u7-v6si1419732pgn.191.2018.08.28.09.52.50; Tue, 28 Aug 2018 09:53:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=bERC36OE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727216AbeH1Un6 (ORCPT + 99 others); Tue, 28 Aug 2018 16:43:58 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:40666 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726128AbeH1Un6 (ORCPT ); Tue, 28 Aug 2018 16:43:58 -0400 Received: by mail-pf1-f194.google.com with SMTP id s13-v6so971297pfi.7 for ; Tue, 28 Aug 2018 09:51:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=date:subject:in-reply-to:cc:from:to:message-id:mime-version :content-transfer-encoding; bh=+5OzEVheTPrXM1UrnfzO3M0cz2qMU0nrsN+pFLYL2To=; b=bERC36OEyMBeps5LqWhC+dZRpDckJWozy78r7V/fNP5j582RZTipL3N2LW1ZSyG115 Neq8tvWWpRCizfDgUsL/Ls3gIeWvwhiTcvzIyPGIYs8yDgWTorBnYwTdziAu3ip0+KTV gaSlT8DYRPAQPvnOfwZ5CRVlrYBMWnJo5q0cpyQBcYfn3ICuf+rNUw60gYnmsED3pxHO fw0+IKexQacgeV02dVEFmBwLOipNmqXhzYp07e24zSKcS7N67ecM/w6Lj+dn4ud3Xssh Jg1zZSj+55Wu6+cglIDZrgfDcpJozNV/rluvMg3Cdy8kGoFMAAxXnlit/EJTJT4sUC+Y fvbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:subject:in-reply-to:cc:from:to:message-id :mime-version:content-transfer-encoding; bh=+5OzEVheTPrXM1UrnfzO3M0cz2qMU0nrsN+pFLYL2To=; b=heuBk5iftvHAbRwVBeO966l5/8uofWqk1Azn0dN6ylP/yckmR3mGXU34LeOBKhq6OC SzI5Q+ZTMaEvJIRm9vESD7PwdLz2T19/HhvCMEsfqxi5Po5NK5hvAAxilsZgCi5WEUJM gqdpLdNON13jbK2jbcwWp7OSA3lhOA6CBVD7q4TbUxsQ/bRWT3jV8uDiU/JrsYO6gLsA Hyj5sPEHvOt5c9nFOPyXrpCzovQnt5Q6qhCQlCo4WE00EKwJQubFtCar6Zd1PqvrWx/a GBVxviA3UfdqSM0gc0WXk+Q7d06newdfazHmjrGXxPZZQdbQb/WuSuLwmpC72ZRldomU P05w== X-Gm-Message-State: APzg51BiIgQzEX/yKfeJZorau3K2cTLVjKOvRnn/ZaqPUwoq7OQ3O9v6 mPmKYIcFc52z3upRbgQBYhVAwnEQ6AI= X-Received: by 2002:a65:448a:: with SMTP id l10-v6mr2345699pgq.382.1535475086813; Tue, 28 Aug 2018 09:51:26 -0700 (PDT) Received: from localhost ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id n79-v6sm7836808pfh.2.2018.08.28.09.51.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Aug 2018 09:51:25 -0700 (PDT) Date: Tue, 28 Aug 2018 09:51:25 -0700 (PDT) X-Google-Original-Date: Tue, 28 Aug 2018 09:41:29 PDT (-0700) Subject: Re: [PATCH] RISC-V: Mask out the F extension on systems without D In-Reply-To: <20180828071032.GA16806@andestech.com> CC: linux-riscv@lists.infradead.org, aou@eecs.berkeley.edu, linux-kernel@vger.kernel.org, greentime@andestech.com From: Palmer Dabbelt To: alankao@andestech.com Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 28 Aug 2018 00:10:32 PDT (-0700), alankao@andestech.com wrote: > Hi Palmer, > > On Mon, Aug 27, 2018 at 03:03:52PM -0700, Palmer Dabbelt wrote: >> The RISC-V Linux port doesn't support systems that have the F extension >> but don't have the D extension -- we actually don't support systems >> without D either, but Alan's patch set is rectifying that soon. For now >> I think we can leave this in a semi-broken state and just wait for >> Alan's patch set to get merged for proper non-FPU support -- the patch >> set is starting to look good, so doing something in-between doesn't seem >> like it's worth the work. >> >> I don't think it's worth fretting about support for systems with F but >> not D for now: our glibc ABIs are IMAC and IMAFDC so they probably won't >> end up being popular. We can always extend this in the future. >> >> CC: Alan Kao >> Signed-off-by: Palmer Dabbelt >> --- >> arch/riscv/kernel/cpufeature.c | 7 +++++++ >> 1 file changed, 7 insertions(+) >> >> diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c >> index 17011a870044..652d102ffa06 100644 >> --- a/arch/riscv/kernel/cpufeature.c >> +++ b/arch/riscv/kernel/cpufeature.c >> @@ -57,5 +57,12 @@ void riscv_fill_hwcap(void) >> for (i = 0; i < strlen(isa); ++i) >> elf_hwcap |= isa2hwcap[(unsigned char)(isa[i])]; >> >> + /* We don't support systems with F but without D, so mask those out >> + * here. */ >> + if ((elf_hwcap & COMPAT_HWCAP_ISA_F) && !(elf_hwcap & COMPAT_HWCAP_ISA_D)) { >> + pr_info("This kernel does not support systems with F but not D"); >> + elf_hwcap &= ~COMPAT_HWCAP_ISA_F; >> + } >> + > > The commit message does address the problem and this patch does provide checks > and helpful information to users, but I wonder if we really need this patch, for > two reasons: > > * Just as you mentioned, current glibc ABI does not support such a thing as > IMAFC, so probably no one has had trouble with this. To be honest, I suppose > that anybody (RISC-V enthusiasts or vendors) who really need F-only support > in kernel should get themself involved in the development by sending patches > to improve. > > * There are corner cases to let a F-only machine to pass the check in this > patch. For instance, a vendor decides to name her extension ISA as doom, > and supports single-precision FP only, so her ISA string would be > > IMAFCXdoom. > > The variable elf_hwcap is calculated at the loop in line 57,58, the 'd' > from Xdoom would bypass the check, while the underlying machine does not > support double-precision FP. Ah, yes, that makes sense. I'd go the other way here and just be strict about parsing the ISA string: it's defined to be listed in a particular order, so we should really only be accepting legal ISA strings. I'll submit a second patch to fix this behavior. > >> pr_info("elf_hwcap is 0x%lx", elf_hwcap); >> } >> -- >> 2.16.4 >> > > I don't know if the reasons make sense to you, but anyway that's all I > would like to say about this patch. > > Alan