From patchwork Mon May 6 17:33:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163443 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:81:0:0:0:0 with SMTP id l1csp272120ilm; Mon, 6 May 2019 10:54:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqwVUfOrh4Vx0kL69KoU+tkTdZMw92d6lUIx2p1Lz19Oar6BM4xPLMxBKcW7JHiewjVvQHar X-Received: by 2002:a1c:3982:: with SMTP id g124mr17545174wma.25.1557165242492; Mon, 06 May 2019 10:54:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557165242; cv=none; d=google.com; s=arc-20160816; b=OI8E4HjXcRgFzuZxVQ3s0wuOr8G/15yi6hXBeEGOL2kj2j//qDkEFJ+GwMLlgK6Je6 H3Jvl47EjhrnKql1Tz484r/4NK+umdf/Zkp8niuaN48vCGT1TQrSA9WiPeehNh47hFwE w18HN7e2bkjnzicQ/Q1tuk6xt4YtIBk5cVJvGucYEyN+ugMehH2rgdl+w9w8AoEs+0qC EhCXAUVFylai8L4Bj8n5lMwruCE7Nww3E/X0EJKn+lPzveSKiMqoE+sPsjLE5OYXm2F7 X+EI2pPWKK2U7zZeeWu6uGAd1uYIKFUn+YuHQSYh/rscdqDmi7f30qzKxVnNxGuzFxDw S0yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=WkMgXREw0aoSQxhQGI3jtOyJDuRA2/EcPM5PhnT27hg=; b=x0RV/2mQVHOoqncRJYsyquMFPCpj08SOcwQ75DPA21UlACp1bePdVPXdOx4I+lw72n HL+QEALNxubjrpPyGtzg4a4a03uO0ID8vOt3eVqT4U72SF+Fg3gu5jVXq7T6OnGdEc0x DWBTGwq39vItOeaUc4wGmzAnpUPl5GK2GBnbeQ0cOYwm32Qgvgh3+qDqfjrV+sPZOT4L tNzVbwc4b++/qVHvXHCLIYLleEgM+XDeSVXQm7pCQWrn3ZmvxJbG9nT+OGKo+4TimGtl 30aGuw7Rm+6izY5zgxbFebf/5Rgl5tAI/1XUsUsnnry8we/xbofJ3ej1KnIWS/k4psDT 5tTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=M0lQsOCD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 63si128037wrp.222.2019.05.06.10.54.02 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 06 May 2019 10:54:02 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=M0lQsOCD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:60188 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hNhoP-0001im-FF for patch@linaro.org; Mon, 06 May 2019 13:54:01 -0400 Received: from eggs.gnu.org ([209.51.188.92]:40083) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hNhVS-0001Lo-6v for qemu-devel@nongnu.org; Mon, 06 May 2019 13:34:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hNhVQ-0001ZM-BT for qemu-devel@nongnu.org; Mon, 06 May 2019 13:34:26 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:39619) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hNhVO-0001Uh-Cf for qemu-devel@nongnu.org; Mon, 06 May 2019 13:34:23 -0400 Received: by mail-pg1-x544.google.com with SMTP id w22so5482385pgi.6 for ; Mon, 06 May 2019 10:34:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WkMgXREw0aoSQxhQGI3jtOyJDuRA2/EcPM5PhnT27hg=; b=M0lQsOCDnQ1jXB8oOlUdFWQEnQl2GKBcG39v9z7yxfTA5yax80UsmGLJL3XbgGwRIZ w8RJlHAQ+ehS6e7VcrU2IsXp+KANuR7/iwP+VM7eBCxb8meC1VxMltyitzx7SzJSURXB DGQ5EC3fnwwcmYznShqkqR/yg6BzPaEQ/6GBcRCBPo46g8zOui0qUU6qqeB7ZAqfrPXh fJS+HIVgnBy55567Zj7eJvPEHlLg/tjyAnB3ndc9hC4scZhErZmcpqtLnYs1mCIWagY4 clTC+PnhZ5/8tS9DSZg0TRAnlj2cFe22ajUUea5otUju4fD5s2PThdjBIe4zBwyBSs98 T+Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WkMgXREw0aoSQxhQGI3jtOyJDuRA2/EcPM5PhnT27hg=; b=hSElmU8AHGFTwkK6Q9lM7jrNlzJXFolzf+O9FiI2ITk5g17O9KBCkj7eplVzVQHGxE lsQZy1VZ/5HakDufIw54mTcjWup/40IU16Kx+ISx1xS+ak/rpEoc/gyLJRozgCVHDBfB bgG3Ho7y/j9LWPbPxnP18792JY/jV5q2zfokpwxdYiPBo/b7dm8vm9XLv2iO+ruyeeFF ubWlVrYgJSseqh/RhyQ79SJlb0KsMXxMVNKQO+Lu89kmIEbi56vaLkQDHAnqVj/MRnvv TYEv5rNec0ztXH65SFiO5ne4btQUzKJtncWGqsYJP6LgzGGBE62rTVNmSgk/ZwmBMK93 ZEhg== X-Gm-Message-State: APjAAAW8R7Ojs2b3j9oCEUD6W6ihyUOP7RlM0LFRahB0Ic4uiWnTR+ri 8LmXcoC8yj9m82ov5JONocO89bGQkOs= X-Received: by 2002:a62:5915:: with SMTP id n21mr34013649pfb.180.1557164059592; Mon, 06 May 2019 10:34:19 -0700 (PDT) Received: from localhost.localdomain (97-113-189-189.tukw.qwest.net. [97.113.189.189]) by smtp.gmail.com with ESMTPSA id k9sm2268839pfa.180.2019.05.06.10.34.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 May 2019 10:34:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 6 May 2019 10:33:49 -0700 Message-Id: <20190506173353.32206-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190506173353.32206-1-richard.henderson@linaro.org> References: <20190506173353.32206-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::544 Subject: [Qemu-devel] [PATCH v4 20/24] hw/misc/exynos4210_rng: Use qemu_guest_getrandom X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Igor Mitsyanko , qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The random number is intended for use by the guest. As such, we should honor the -seed argument for reproducibility. Cc: qemu-arm@nongnu.org Cc: Igor Mitsyanko Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- hw/misc/exynos4210_rng.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) -- 2.17.1 Reviewed-by: Laurent Vivier diff --git a/hw/misc/exynos4210_rng.c b/hw/misc/exynos4210_rng.c index 4ecbebd2d7..0e70ffb404 100644 --- a/hw/misc/exynos4210_rng.c +++ b/hw/misc/exynos4210_rng.c @@ -18,10 +18,10 @@ */ #include "qemu/osdep.h" -#include "crypto/random.h" #include "hw/sysbus.h" #include "qapi/error.h" #include "qemu/log.h" +#include "qemu/guest-random.h" #define DEBUG_EXYNOS_RNG 0 @@ -109,7 +109,6 @@ static void exynos4210_rng_set_seed(Exynos4210RngState *s, unsigned int i, static void exynos4210_rng_run_engine(Exynos4210RngState *s) { Error *err = NULL; - int ret; /* Seed set? */ if ((s->reg_status & EXYNOS4210_RNG_STATUS_SEED_SETTING_DONE) == 0) { @@ -127,13 +126,11 @@ static void exynos4210_rng_run_engine(Exynos4210RngState *s) } /* Get randoms */ - ret = qcrypto_random_bytes((uint8_t *)s->randr_value, - sizeof(s->randr_value), &err); - if (!ret) { + if (qemu_guest_getrandom(s->randr_value, sizeof(s->randr_value), &err)) { + error_report_err(err); + } else { /* Notify that PRNG is ready */ s->reg_status |= EXYNOS4210_RNG_STATUS_PRNG_DONE; - } else { - error_report_err(err); } out: