From owner-svn-src-all@freebsd.org Wed Nov 20 19:55:44 2019 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 630E41C0692; Wed, 20 Nov 2019 19:55:44 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47JD2S1jRpz4Ghv; Wed, 20 Nov 2019 19:55:44 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1DDA427BB5; Wed, 20 Nov 2019 19:55:44 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xAKJthav002337; Wed, 20 Nov 2019 19:55:43 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xAKJthPt002336; Wed, 20 Nov 2019 19:55:43 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201911201955.xAKJthPt002336@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: Conrad Meyer Date: Wed, 20 Nov 2019 19:55:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r354913 - head/sys/dev/random X-SVN-Group: head X-SVN-Commit-Author: cem X-SVN-Commit-Paths: head/sys/dev/random X-SVN-Commit-Revision: 354913 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Wed, 20 Nov 2019 19:55:44 -0000 Author: cem Date: Wed Nov 20 19:55:43 2019 New Revision: 354913 URL: https://svnweb.freebsd.org/changeset/base/354913 Log: random/ivy: Trivial refactoring It is clearer to me to return success/error (true/false) instead of some retry count linked to the inline assembly implementation. No functional change. Approved by: core(csprng) => csprng(markm) Differential Revision: https://reviews.freebsd.org/D22454 Modified: head/sys/dev/random/ivy.c Modified: head/sys/dev/random/ivy.c ============================================================================== --- head/sys/dev/random/ivy.c Wed Nov 20 19:43:34 2019 (r354912) +++ head/sys/dev/random/ivy.c Wed Nov 20 19:55:43 2019 (r354913) @@ -59,7 +59,7 @@ static struct random_source random_ivy = { .rs_read = random_ivy_read }; -static int +static bool x86_rdrand_store(u_long *buf) { u_long rndval; @@ -75,10 +75,10 @@ x86_rdrand_store(u_long *buf) "2:" : "+r" (retry), "=r" (rndval) : : "cc"); *buf = rndval; - return (retry); + return (retry != 0); } -static int +static bool x86_rdseed_store(u_long *buf) { u_long rndval; @@ -94,17 +94,17 @@ x86_rdseed_store(u_long *buf) "2:" : "+r" (retry), "=r" (rndval) : : "cc"); *buf = rndval; - return (retry); + return (retry != 0); } -static int +static bool x86_unimpl_store(u_long *buf __unused) { panic("%s called", __func__); } -DEFINE_IFUNC(static, int, x86_rng_store, (u_long *buf)) +DEFINE_IFUNC(static, bool, x86_rng_store, (u_long *buf)) { has_rdrand = (cpu_feature2 & CPUID2_RDRAND); has_rdseed = (cpu_stdext_feature & CPUID_STDEXT_RDSEED); @@ -127,7 +127,7 @@ random_ivy_read(void *buf, u_int c) KASSERT(c % sizeof(*b) == 0, ("partial read %d", c)); b = buf; for (count = c; count > 0; count -= sizeof(*b)) { - if (x86_rng_store(&rndval) == 0) + if (!x86_rng_store(&rndval)) break; *b++ = rndval; }