Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2730494rwb; Fri, 9 Dec 2022 05:49:28 -0800 (PST) X-Google-Smtp-Source: AA0mqf4AcJRA6g3iKfov1//wSXRh9fcOzCMy3tyiRNi/XWjsz0MmL6BlLyaHdkGcQ8pFT5cn1qKN X-Received: by 2002:a05:6402:913:b0:46c:fe2d:a588 with SMTP id g19-20020a056402091300b0046cfe2da588mr2182578edz.18.1670593768514; Fri, 09 Dec 2022 05:49:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670593768; cv=none; d=google.com; s=arc-20160816; b=t41MnK9jIV3UMDMIxZS7Auk4ZiW1bYydHxgCxV7BIGLaQ8x9SFR4tZAmCPQydXGQhy sZQ/yQpyjzjyZ1fzz7dPBbN8NWNBJvfRe5HJRmjbWXXXtzcGA8M4pnNPVJTmCO1pDuQ8 pGnUtPjXg8SlGaFbcnDzu8qVq5B2PpqOm9ioFoPmx2H3o1Lg1/3PbD1xWKK+WTcKbMrg h+V0t5OoddR3RWKrMyCydxCpktFwzK0QVXAHzudPREl2PpVQZASBJ9fu6SHeHqqlixYU k+NBnGzl3a4rg/pQ1DTc0HlxG+1YWFMC1FiV+4dT+s0PyenEaPnKA1RzQd9l+iMot+Np G+bA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:dkim-signature; bh=u/BEyjC9xsEH5NMQX3QDWEaGFLUECMG5L/7NnRTgxTM=; b=H1QvQ5d+F1V5b140uGnMipBcSEMf43vtZG4H+hEND6sqHtFlT4hwfIiEdVHqAJER3+ Iut+bgNnUkQ7BH4Se1UH8ikwrbxDTMGZMWR/U1dd5MwWOQiMyfSFSXja1s6gXTQcxmMF OkQmDPq4MP+T0S5Moasv7BPxEamg0twI3SgLjeRXfDuwo4Z8cR7DArE1BBvn5/IMUm7d IoAy/9W26uUtD4D+zUSHQ99vAZi+Ac2A9Oa3YmWPOcGDj4isXASzFwMVOPl/32SymZ85 v686If4MZfgp0ranj/dk4LGBCAULO0K/4DP9nZo3TBYfhgBu72tvRaUYWTxYvGefaRUe 7X3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XVERZTPz; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dz20-20020a0564021d5400b0046bb45ce1a6si1794309edb.405.2022.12.09.05.49.09; Fri, 09 Dec 2022 05:49:28 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=XVERZTPz; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229952AbiLINFc (ORCPT + 76 others); Fri, 9 Dec 2022 08:05:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229561AbiLINFa (ORCPT ); Fri, 9 Dec 2022 08:05:30 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 289DC1F2DE for ; Fri, 9 Dec 2022 05:04:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670591075; 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: in-reply-to:in-reply-to:references:references; bh=u/BEyjC9xsEH5NMQX3QDWEaGFLUECMG5L/7NnRTgxTM=; b=XVERZTPzvL9cjt3FNCozsrx79Wq59GEI0OMLJ0X8E9M1Hn1lp9IxIk9VsWh0crCD8vnwM3 SbS9Rmqo59r1QSZMixXcl2zwW+ThyGK/FoqX2X1x3AopmL3iA5L9A7EnP7XMr59dxc8uBS 0iPJTrzx8qgrcyrGeCEqW2lBCqZc3Gc= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-284-2lafMJoeOx-4oHYu3gC_QQ-1; Fri, 09 Dec 2022 08:04:33 -0500 X-MC-Unique: 2lafMJoeOx-4oHYu3gC_QQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8BCE41C087AA; Fri, 9 Dec 2022 13:04:31 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.193.168]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0D689C15BA5; Fri, 9 Dec 2022 13:04:26 +0000 (UTC) From: Florian Weimer To: Andrew Waterman Cc: Palmer Dabbelt , Vineet Gupta , stillson@rivosinc.com, Paul Walmsley , anup@brainfault.org, atishp@atishpatra.org, guoren@kernel.org, Conor Dooley , greentime.hu@sifive.com, vincent.chen@sifive.com, andy.chiu@sifive.com, arnd@kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, bjorn@kernel.org, libc-alpha@sourceware.org, christoph.muellner@vrull.eu, Aaron Durbin , linux@rivosinc.com Subject: Re: RISCV Vector unit disabled by default for new task (was Re: [PATCH v12 17/17] riscv: prctl to enable vector commands) References: <877cz0nbce.fsf@oldenburg.str.redhat.com> <874ju4lpum.fsf@oldenburg.str.redhat.com> Date: Fri, 09 Dec 2022 14:04:23 +0100 In-Reply-To: (Darius Rad's message of "Fri, 9 Dec 2022 07:42:52 -0500") Message-ID: <87zgbwk9t4.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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 * Darius Rad: > On Fri, Dec 09, 2022 at 01:32:33PM +0100, Florian Weimer via Libc-alpha wrote: >> * Darius Rad: >> >> > On Fri, Dec 09, 2022 at 11:02:57AM +0100, Florian Weimer wrote: >> >> * Andrew Waterman: >> >> >> >> > This suggests that ld.so, early-stage libc, or possibly both will need >> >> > to make this prctl() call, perhaps by parsing the ELF headers of the >> >> > binary and each library to determine if the V extension is used. >> >> >> >> If the string functions use the V extension, it will be enabled >> >> unconditionally. So I don't see why it's okay for libc to trigger this >> >> alleged UAPI change, when the kernel can't do it by default. >> >> >> > >> > Because the call to enable can fail and userspace needs to deal with that. >> >> Failure is usually indicated by an AT_HWCAP or AT_HWCAP2 bit remaining >> zero, or perhaps a special CPU register (although that is more unusual). > > That would indicate that the extension is not present, which is one of, but > not the only way it can fail. I think you should bring down the number of failure modes. HWCAP has the advantage that it communicates kernel/hypervisor/firmware/CPU support in a single bit, which simplifies the programming model and avoids hard-to-detect bugs. It's not clear why it would be beneficial to continue on ENOMEM failures here because the system must clearly be in bad shape at this point, and launching a new process is very unlikely to improve matters. So I think the simpler programming model is the way to go here. > The vector extension relies on dynamically allocated memory in the kernel, > which can fail. But this failure can be reported as part of execve and clone. > It also provides the opportunity for the kernel to deny access to the > vector extension, perhaps due to administrative policy or other future > mechanism. HWCAP can do this, too. Thanks, Florian