Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp2114761rwn; Fri, 9 Sep 2022 08:42:41 -0700 (PDT) X-Google-Smtp-Source: AA6agR4C45efim+B0H5JTItXC8v9hzSZAyXgFQ1r3+qGaTqqM92/A+iqBTnd/d5yWCk6jDxerfSz X-Received: by 2002:a17:907:a06b:b0:73d:dde9:75a7 with SMTP id ia11-20020a170907a06b00b0073ddde975a7mr10423963ejc.52.1662738161217; Fri, 09 Sep 2022 08:42:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662738161; cv=none; d=google.com; s=arc-20160816; b=VdOx3m/Rpd4iTcNMeMOM0b4EVitFKV3j/M30nrLbkRZ/DaxMgJEN7klee6dWjby2nu fdtMLQ0qUNLa1Mhbwt1psK85j+42m0Mdxvv1mX/INDuItyt1aE5IRPO2h/+rbU8tSF6V ZUf+RnwQMZrfdJBNMc3d2HRUbk46+bQz9uoYi+/TP7l7J/IRs5vaFFCaV63galilkaXd /6LaVFYEiP6kEq1Ziounq+wGc3pzfeQNDWgtPojaaAe7tENLMOih7GlP6jNd15xz/+h3 6P4Eu+E2pRc+5LkPhYbwcxkT9APzb49SLBB4P1/Jc6O9dOoHmXRnMAfvVuZVP++Srwb1 TtZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=bCvNKZoLydGpNHfnmbhPHdRB0xcZW5gv/VnZsrr3nIY=; b=zy6QwfMTJlsd8K5W2uHiMtVQbyM6fPLnIBBEGk2j9ABZ6KmFW4vI+yQP75DqQKUqVr AKENLWrqoiScoJqlK4VV+AS2QRPFmCZx1uCHfeoB9FQxKrmkC8zb7uWNygcooiRMIL4B MUuMg4PWFWEz3D9EukbC0fqGbVHwm5R8MdlloCSsXhO1QyL4xDd2LbFL2+fqE/+OSN9S d6/lNILZbXOrGJay1mIciSImW0u50lezxAHyFqiagr3nROyHdPZPhwgo/x2a3tMEJw3Y eGQY+xhKAicZDtksN6PKn0brDOBAVHA3wABWSbeeYLKtLSVlwVMFXavp04wrCR0lbJEF oAFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=aROr7p19; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id js19-20020a17090797d300b0073d87835a30si766787ejc.961.2022.09.09.08.42.15; Fri, 09 Sep 2022 08:42:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=aROr7p19; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232085AbiIIOzU (ORCPT + 99 others); Fri, 9 Sep 2022 10:55:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232280AbiIIOzH (ORCPT ); Fri, 9 Sep 2022 10:55:07 -0400 Received: from mail-qt1-x829.google.com (mail-qt1-x829.google.com [IPv6:2607:f8b0:4864:20::829]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75F3A33A26 for ; Fri, 9 Sep 2022 07:55:05 -0700 (PDT) Received: by mail-qt1-x829.google.com with SMTP id z18so1442794qts.7 for ; Fri, 09 Sep 2022 07:55:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=bCvNKZoLydGpNHfnmbhPHdRB0xcZW5gv/VnZsrr3nIY=; b=aROr7p194S8QWVGn8J27yn15HcdwP8Pmes6eH9lKtOyxkH/EKF0u6qGFTZF5C+q2b2 xtqBzLQfuRBO5m7giVDzdyenhsv4d27DhLrGJK6p4dOKGCOE9pEZjHNh6lQAVz40hG7Z ratrOQIt7Mtn6hUQ2qmb06eGZVA2Id8QTA8Ngmcax8fO7a1YJ51UErXeS0WHj7s4neFn 4Z4JSG5U/LIrpMEtk3rKDnRFBmZ508smDREdKFxBiTto6ztzkrlgBElrYPdJ1olVodHj VFwTrQN2AZ8IjHKvAdxQbSPsPgkItJyN5sBJj6UsKi6VwMIHwBpEgP2lMPQryhDvaUlo NbsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=bCvNKZoLydGpNHfnmbhPHdRB0xcZW5gv/VnZsrr3nIY=; b=nZV/XgKo+P2mbzR5Kzeytpro9Z8nuwrOlGkFIaXhBggM2MNNqomSIUwp4lUL76Goft ytx9zymnwnzK2q5siNjqpbDOCoNmWPuSaQeIuVEUsaFw8+/UDmcG/3sCnIExbA4p/S5c Ly515Zih8PD4arHnRGARqxIE9FzEpdUcFWPSAloogAoHrV1alcdDwsW52wzhka+aV+az SxgvrvpDW6MYHLqPoFr9U/Pb2zmeR3k4DS0+zMxGieMo2CILHbb3cXRL//kXXhrf48gS frj1DK7B+6QY9bl1DmkkfQqCA/Q3aOFV/+rPpYu8DUYKyCXoASgqAKNOcNeh+6+RPVmd BqxA== X-Gm-Message-State: ACgBeo0OvK9D56JiNDCgL3aPz5ouAHMvkrc2m4cm9kjSVK6boPM6P6Jb dRtAHYS3RqIkZV+zEUPmxh15V0JpcJ1zh+kg+7RoUuQzUSgp2w== X-Received: by 2002:ac8:5fc8:0:b0:344:5ac5:c8e4 with SMTP id k8-20020ac85fc8000000b003445ac5c8e4mr12651106qta.113.1662735303638; Fri, 09 Sep 2022 07:55:03 -0700 (PDT) MIME-Version: 1.0 References: <20220901141307.2361752-1-georgepee@gmail.com> <28b35935-4e7f-2bd5-dda5-ed81402a527e@arm.com> In-Reply-To: <28b35935-4e7f-2bd5-dda5-ed81402a527e@arm.com> From: George Pee Date: Fri, 9 Sep 2022 09:54:52 -0500 Message-ID: Subject: Re: [PATCH] Report support for optional ARMv8.2 half-precision floating point extension To: Robin Murphy Cc: Russell King , "Russell King (Oracle)" , Catalin Marinas , "Kirill A. Shutemov" , Austin Kim , Ard Biesheuvel , Mike Rapoport , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org That makes a lot of sense. How's this? Flipping the HWCAP2_FPHP bit is already in a CONFIG_VFPv3 check. diff --git a/arch/arm/include/uapi/asm/hwcap.h b/arch/arm/include/uapi/asm/hwcap.h index 990199d8b7c6..5d635dce8853 100644 --- a/arch/arm/include/uapi/asm/hwcap.h +++ b/arch/arm/include/uapi/asm/hwcap.h @@ -37,5 +37,6 @@ #define HWCAP2_SHA1 (1 << 2) #define HWCAP2_SHA2 (1 << 3) #define HWCAP2_CRC32 (1 << 4) +#define HWCAP2_FPHP (1 << 5) #endif /* _UAPI__ASMARM_HWCAP_H */ diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S index c39303e5c234..161f8df852e1 100644 --- a/arch/arm/kernel/entry-armv.S +++ b/arch/arm/kernel/entry-armv.S @@ -625,11 +625,12 @@ call_fpe: ret.w lr @ CP#6 ret.w lr @ CP#7 ret.w lr @ CP#8 - ret.w lr @ CP#9 #ifdef CONFIG_VFP + W(b) do_vfp @ CP#9 (VFP/FP16) W(b) do_vfp @ CP#10 (VFP) W(b) do_vfp @ CP#11 (VFP) #else + ret.w lr @ CP#9 ret.w lr @ CP#10 (VFP) ret.w lr @ CP#11 (VFP) #endif diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index 1e8a50a97edf..8887d0f447d6 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -1258,6 +1258,7 @@ static const char *hwcap2_str[] = { "sha1", "sha2", "crc32", + "fphp", NULL }; diff --git a/arch/arm/vfp/vfpmodule.c b/arch/arm/vfp/vfpmodule.c index 2cb355c1b5b7..fb774fd5c614 100644 --- a/arch/arm/vfp/vfpmodule.c +++ b/arch/arm/vfp/vfpmodule.c @@ -831,6 +831,8 @@ static int __init vfp_init(void) if ((fmrx(MVFR1) & 0xf0000000) == 0x10000000) elf_hwcap |= HWCAP_VFPv4; + if ((fmrx(MVFR1) & 0x0f000000) == 0x03000000) + elf_hwcap2 |= HWCAP2_FPHP; } /* Extract the architecture version on pre-cpuid scheme */ } else { On Fri, Sep 9, 2022 at 9:17 AM Robin Murphy wrote: > > On 2022-09-09 14:34, George Pee wrote: > > Adding the hwcap was part of the diagnosis process-- I added it just > > to make sure that the cpu in question supported the optional > > extension. > > It seems like it could be useful to be able to check for support in > > /proc/cpuinfo. > > Sure, but "support" is about more than just what happens to be present > in hardware. Observe that you can build the 32-bit kernel with > CONFIG_VFP=n, and it then does not report and VFP or NEON hwcaps, > because those features will not be usable in that configuration, even if > you know the hardware implements them. > > Note that this looks different on arm64, since there we always expect to > have FPSIMD hardware available, so support in the kernel is > unconditional, plus that kernel support is also a lot simpler since we > don't have a soft-float ABI with all the corresponding trapping stuff > either. > > It might just be the case here that the call_fpe logic needs a bit of > tweaking to provide proper support, but I'm not sufficiently familiar > with the ARM VFP code in general to be sure. > > Thanks, > Robin. > > > On Fri, Sep 9, 2022 at 7:46 AM Robin Murphy wrote: > >> > >> On 2022-09-01 15:13, george pee wrote: > >>> Report as fphp to be consistent with arm64 > >> > >> Wasn't the original problem that the VFP support code doesn't understand > >> the new FP16 instruction encodings, so in practice they don't actually > >> work reliably? Exposing a hwcap to say they're functional doesn't > >> inherently make them functional - if there is already another patch > >> somewhere for that, it should be made clear that this depends on it. > >> > >> Robin. > >> > >>> Signed-off-by: george pee > >>> --- > >>> arch/arm/include/uapi/asm/hwcap.h | 1 + > >>> arch/arm/kernel/setup.c | 1 + > >>> arch/arm/vfp/vfpmodule.c | 2 ++ > >>> 3 files changed, 4 insertions(+) > >>> > >>> diff --git a/arch/arm/include/uapi/asm/hwcap.h b/arch/arm/include/uapi/asm/hwcap.h > >>> index 990199d8b7c6..f975845ce5d3 100644 > >>> --- a/arch/arm/include/uapi/asm/hwcap.h > >>> +++ b/arch/arm/include/uapi/asm/hwcap.h > >>> @@ -28,6 +28,7 @@ > >>> #define HWCAP_IDIV (HWCAP_IDIVA | HWCAP_IDIVT) > >>> #define HWCAP_LPAE (1 << 20) > >>> #define HWCAP_EVTSTRM (1 << 21) > >>> +#define HWCAP_FPHP (1 << 22) > >>> > >>> /* > >>> * HWCAP2 flags - for elf_hwcap2 (in kernel) and AT_HWCAP2 > >>> diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c > >>> index 1e8a50a97edf..6694ced0552a 100644 > >>> --- a/arch/arm/kernel/setup.c > >>> +++ b/arch/arm/kernel/setup.c > >>> @@ -1249,6 +1249,7 @@ static const char *hwcap_str[] = { > >>> "vfpd32", > >>> "lpae", > >>> "evtstrm", > >>> + "fphp", > >>> NULL > >>> }; > >>> > >>> diff --git a/arch/arm/vfp/vfpmodule.c b/arch/arm/vfp/vfpmodule.c > >>> index 2cb355c1b5b7..cef8c64ce8bd 100644 > >>> --- a/arch/arm/vfp/vfpmodule.c > >>> +++ b/arch/arm/vfp/vfpmodule.c > >>> @@ -831,6 +831,8 @@ static int __init vfp_init(void) > >>> > >>> if ((fmrx(MVFR1) & 0xf0000000) == 0x10000000) > >>> elf_hwcap |= HWCAP_VFPv4; > >>> + if ((fmrx(MVFR1) & 0x0f000000) == 0x03000000) > >>> + elf_hwcap |= HWCAP_FPHP; > >>> } > >>> /* Extract the architecture version on pre-cpuid scheme */ > >>> } else {