From patchwork Wed May 22 18:42:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164869 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1237582ili; Wed, 22 May 2019 12:12:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqz0UApSL0YBxnVqK0PbxIr9VNa/mzz9lEoDIwudJucDVMrx6ZQyMilxRZg0U3Zt+4BC2/V2 X-Received: by 2002:a50:b7bc:: with SMTP id h57mr76069108ede.77.1558552324986; Wed, 22 May 2019 12:12:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558552324; cv=none; d=google.com; s=arc-20160816; b=TDwVYS9r+y+YRin1n8eXsM93v8slAB5ujyGOoHpHJ9TG7kAsPYSQ10HjkuFU6huAF4 f7k+AmMzlGIVYsGjxXEIcLiccFu8+FbEsD3hTWYp1zDYqT0lkefUJfVjrrk1yeArzXr0 9rPDl+P7KmyFkuo9zzvhLp4xlbd+bF1fzalS3NjM1HQ6qJz6Unk99LDnCrovHfa/xoaR FOcrh4jQnw9BbT4d9bVfvfinVqNG3BaiqjaaHKJbrBdp4t2dboXg/yeo6S1jVPLdIvkE jpm5n7QXHEU+V6mKVCJMGttI+UZOtKF6kLScgZNcN7nl8ZsyQXVbsT5N2HhLOvZjTBmX IQBw== 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=/VWGaUBQJcHRh8ZCol9Bt7n9p31zv9AWS8bL9WKxKYs=; b=ac+wz0gN1dppCKO1bbJ+hFYiEjK5moFuR+YblJcNnpx2ymeAxLXUIKMIPITlasfXvB 3g1NuYy/owMmwWJZ8Tg0RfQvvyR50O2f/kORylkkX0BgiOcB30QTS4W4LJs762B3up3i b6pvuZmpRc4CjYhY5kTRI989TWQTxx1xMcf0FtHjz7I92KPT+ZCYY8n646WTPpsds1Nz gO17sWhyC0nC4I0O0/cdUBDcrCCkd5ky1i5RxB4IQQ211hm61UGO5ehQFcnmK9ozQp2c rdy//ObnzkSCqLbUkV2OZGwP2HNStIrTEAypnWbiDvweBuZaQh3hmfJwwpliB3xPD2IE mxyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=pIeas4e2; 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 k9si5042834ejp.58.2019.05.22.12.12.04 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 22 May 2019 12:12:04 -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=pIeas4e2; 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]:49869 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTWeh-0006Yz-Oz for patch@linaro.org; Wed, 22 May 2019 15:12:03 -0400 Received: from eggs.gnu.org ([209.51.188.92]:35052) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTWOn-0008Eq-Gw for qemu-devel@nongnu.org; Wed, 22 May 2019 14:55:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hTWCU-0008CI-1u for qemu-devel@nongnu.org; Wed, 22 May 2019 14:42:54 -0400 Received: from mail-yb1-xb43.google.com ([2607:f8b0:4864:20::b43]:32786) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hTWCS-0008B2-1G for qemu-devel@nongnu.org; Wed, 22 May 2019 14:42:52 -0400 Received: by mail-yb1-xb43.google.com with SMTP id k128so1268603ybf.0 for ; Wed, 22 May 2019 11:42:50 -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=/VWGaUBQJcHRh8ZCol9Bt7n9p31zv9AWS8bL9WKxKYs=; b=pIeas4e2eGmoShylW72dz3I+fq499gQC5L5yzxJlyyc95qlsW42IE94fKa3YpY1u9V WCio4iCMHCRVIOsRLpq/f3OiIfkycpcFeT0mhBSu7t3l6saUO1KtaEpQDYDmlUj1Nw+M 1eASOtVyS0YSVV29yxiCs0ttGAS1CPQEZFM2Y+cMZ+yECIpAsoedS+SBsFz9UO2yWQJ3 B+pwbDpB2vna94DhRjPpGJpzT0CwIYWHXOAF8TMmttfU6cC5tUUHBzRBmCAcmXI/dPzb /8cviERkCdPeqq21PvFmno4zMSHPGMywPt5DGL5WLhVu3HrcCJpwsBvg7fvqVnBc62zv sduA== 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=/VWGaUBQJcHRh8ZCol9Bt7n9p31zv9AWS8bL9WKxKYs=; b=Qbqe3sGESU5hH0yitN6CycIhuvQHzJvvf1/VPm0/pUAZp72TGBzLKosW/D6uur7UPT LxiBzdtpzw/K3G/ipK+bKAvjavzerWWCA0fb7SnYafOatesMzmUZvDE8glPCpaDPw9LF ZF2HO9jVqg519t7HblzC88UgnvrZ48EBEV0o1xzBCCknmSObxej8JPelMWkPn6vqURze fr/oMMtlRmSUlVZLJrr+E3Wdr2sb5UEDTc3sJ7mRePakUnw1f57Km3cfBHHFaiIOcCVX guW/Mx/IaezjsVryTTsOi/4aciuFuRhrmhmfRA16olWt+kMVlYXyFGFpLdeIrrwVZ9K1 wseA== X-Gm-Message-State: APjAAAW4tRnQEgr3yN8YvvbGbuifw5ay2l9WbA7BYgtYqhRs5zUXWtbp IdJ8n8FSvLMqxMAHYm2uF3x/L061+CY= X-Received: by 2002:a25:3c9:: with SMTP id 192mr15663764ybd.223.1558550569701; Wed, 22 May 2019 11:42:49 -0700 (PDT) Received: from localhost.localdomain ([71.46.56.17]) by smtp.gmail.com with ESMTPSA id 206sm1299445ywq.74.2019.05.22.11.42.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 May 2019 11:42:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 22 May 2019 14:42:21 -0400 Message-Id: <20190522184226.17871-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190522184226.17871-1-richard.henderson@linaro.org> References: <20190522184226.17871-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::b43 Subject: [Qemu-devel] [PULL 20/25] 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: peter.maydell@linaro.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. Reviewed-by: Laurent Vivier 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 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: