From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EDBADCA0ED3 for ; Mon, 2 Sep 2024 15:10:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=SRkPKnVj0Smne+63jjZ1NhSIeHgFDK73LITPEqXkiJE=; b=GhD2yUA8bi/UBVBZGSZ6GnM71w lATysilgX308r2TzSwWVpprpbMiTnZlze3IuzTUs68vTgJA9Mr5EpDAFMBgij7QEFhc5IySt1zp7G KxJKQnQalvrYbQyazs5BUkvGV1xDGjKowcXB/yQ2+kq5LignOfDmpnIIZ65etk8eKknO6DQ0xBHhh kxPjrfop+1lJm/lBDhd4d7/1vM8Fe1NyjgUR9c0kMX3bbe+FvqZLOY0Utg78n8WWJHqCTyxyq14Pu UgaDONTy3s/KNSK8KpCPT1ie5/1ZC35Ig42WldNARwFAHBcBIjq3qf4myU2tprejW4WGStb91N9Yw pbp3wzJg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sl8hH-0000000Enl9-2WQx; Mon, 02 Sep 2024 15:10:27 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sl8cT-0000000EmhC-11ho for linux-arm-kernel@lists.infradead.org; Mon, 02 Sep 2024 15:05:31 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 62F171063; Mon, 2 Sep 2024 08:05:54 -0700 (PDT) Received: from J2N7QTR9R3 (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 541483F66E; Mon, 2 Sep 2024 08:05:26 -0700 (PDT) Date: Mon, 2 Sep 2024 16:05:23 +0100 From: Mark Rutland To: "Jason A. Donenfeld" Cc: Adhemerval Zanella , Theodore Ts'o , linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arch@vger.kernel.org, Catalin Marinas , Will Deacon , Thomas Gleixner , Eric Biggers , Christophe Leroy Subject: Re: [PATCH v3] aarch64: vdso: Wire up getrandom() vDSO implementation Message-ID: References: <20240902125312.3934-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240902_080529_428959_C60D1B98 X-CRM114-Status: GOOD ( 17.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Sep 02, 2024 at 04:41:28PM +0200, Jason A. Donenfeld wrote: > On Mon, Sep 02, 2024 at 03:31:43PM +0100, Mark Rutland wrote: > > ssize_t __kernel_getrandom(void *buffer, size_t len, unsigned int flags, > > void *opaque_state, size_t opaque_len) > > { > > if (alternative_has_cap_likely(ARM64_HAS_FPSIMD)) { > > return __cvdso_getrandom(buffer, len, flags, > > opaque_state, opaque_len); > > } > > > > if (unlikely(opaque_len == ~0UL && !buffer && !len && !flags)) > > return -ENOSYS; > > > > return getrandom_syscall(buffer, len, flags); > > } > > > > ... though the conditions for returning -ENOSYS look very odd to me; why > > do we care about fast-pathing that specific case rather than forwarding > > that to the kernel, and does __cvdso_getrandom() handle that correctly? > > Adhemerval's code here is fine and correct. The opaque_len==~0UL thing > is a special vDSO case for getting the param struct back, not something > related to the kernel. See __cvdso_getrandom_data() for details. Ok, so this is to say "we cannot provide a vgetrandom_opaque_params". Is the syscall fallback just for the CRIU case mentioned in __cvdso_getrandom_data()? The comment above __cvdso_getrandom_data() says: If @buffer, @len, and @flags are 0, and @opaque_len is ~0UL, then @opaque_state is populated with a struct vgetrandom_opaque_params and the function returns 0; if it does not return 0, this function should not be used. ... so presumably the caller shouldn't bother to call again if it got -ENOSYS above. Mark.