From patchwork Tue May 14 19:16:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164251 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp3018009ili; Tue, 14 May 2019 12:37:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqzojbiWBIItivMG4WhFgSNKQm/oXdtW/NlncUA+Jmx0p/n5CQ432HAdvaHTpldhhBDI6zon X-Received: by 2002:a17:906:2518:: with SMTP id i24mr17662505ejb.169.1557862674857; Tue, 14 May 2019 12:37:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557862674; cv=none; d=google.com; s=arc-20160816; b=BYu/FMVkGxC9M3IGAzw8wZxygkaBaHZLD5vN0scdWZIlyhdaXFPXVYIwsVSJ3I1Jmz k97ByEhd+wlrqYB4qPfi+/Gcw0azqhUKSKchmlw4roTtYO710WOZF++EPtHV5DTOs7qq uAZaBxMNPz4iltuIII7cnkaeCniwheBqKm+Azh6Y0mwr64fDAgIvT56DPaEeCvy1lSYZ 5ZBBwZyrPXsh5YpY09hEqvaKP9eQEnRdrvqfqpd+hoEYaaxPi1g3f+6QN1MJAYdGOTyj RLuzHn5sD/twfzX516S3NqoQKOw+FBBaBMzo2goOp+bRgxNaKjLRzBKq19EFifLicMpV BoYg== 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=reaS3bVbCpHYOvsHFM6YB8TYfi2poSIUM6n+S6omLTxuRGP7QMgfyDdZ8jkzPNHMv4 p410KOxKDGxzwT8qs/xbACsrHlBH6IgPS8YBmHSYZtA2kW/77OCNDZWaj+Zfvx5B1cKS ch4/91dxO6pLpo2BIc+z2KBLH0OzB39LxkiEtJpakUHyc4WT/WdurKs2OQ95DXksQ2T3 XpxplK9SJw485P4zYI65o2lc62j1bqdwbt4CnoY6iaxp68LjiyTUrA4TN50fHfq+nMvN 8Jwz1f8lsTd0AEo/vnYLVqfY4jCL6gq4CDJvByBYwSVT/2rGDS1w4TNMJ3czOUH1sx/i 4K/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ry6QEhMe; 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 d4si6257717ejb.324.2019.05.14.12.37.54 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 14 May 2019 12:37:54 -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=ry6QEhMe; 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]:53225 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQdFJ-0003B6-Ol for patch@linaro.org; Tue, 14 May 2019 15:37:53 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48958) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQcvV-0002hK-BM for qemu-devel@nongnu.org; Tue, 14 May 2019 15:17:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQcvT-00077L-GS for qemu-devel@nongnu.org; Tue, 14 May 2019 15:17:25 -0400 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:40051) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hQcvT-00075U-2N for qemu-devel@nongnu.org; Tue, 14 May 2019 15:17:23 -0400 Received: by mail-pl1-x643.google.com with SMTP id g69so73586plb.7 for ; Tue, 14 May 2019 12:17:21 -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=ry6QEhMeXE+0og9mw97zNWAEloNKkbE7ODLUz0iLgJwFzeY9WxkiukGjsbexWRwrto NGmnfgcOedsNVxI5363MkVUJOsLhTHN0dFpJg6tZGwL3Wv7QdZ/CY8/WRCvjTxwXhL/4 Qv8X8QngWVyFPouabU56oeHedFPDQaAEujSZAbcSGhMkXltt9tmjWU13N9g91OalpwvW FqmVFAxc9iphkhv9DsIrK74utN9okF3A8jbDU+son2vluXc2YQIdhIzr8m0OWOrwUGDO rb9fsGlXAcNjL+QYhiw2jgsu5+TWQUtbmWMdTridweG+dOaUaGl1PtRFbY0mX1gd8Zxz 0iiw== 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=cnZhoB0qXn7vvQ3liI0xpoZL63bjdBOji35uBG1SE/VGkXnzSxfQPAmFqK1EyUHb4g zDSmDxVfvzXV08md5ZcaWEixla0wFiIzDNzlzbd9ZoGYn/i9CPf+MS3qFsx851l8iX6z eVSzL4ROv7hTdYPeYi+O4jzscPF/0U06KcY6zy+C7ZZ7MHtPMR2cho0UQn3Qy9FUbn35 r0D3B9+idi+vk5Gk4y0/CKhHgFXYDNG5UD1u4ePD6Ibr2DL9SMQutkw0U4t3kpOO0Np5 nGV0VFG8rhusDhJeg6o86ar3NLTa/JrCU/tQxkZ+Qq3TZtmOjHBPa3RTNekNsk41rNVD F2aA== X-Gm-Message-State: APjAAAVkezsSZIsHkBoO6yzzBG2JJXT7Wg3vjbhFeRjQfZpEfD5K8rhm WMqZWmLq/G2V+uI9Qkgb/B6Q3ly+xuQ= X-Received: by 2002:a17:902:b606:: with SMTP id b6mr40343627pls.100.1557861440862; Tue, 14 May 2019 12:17:20 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id o6sm18682982pfa.88.2019.05.14.12.17.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 May 2019 12:17:20 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 14 May 2019 12:16:48 -0700 Message-Id: <20190514191653.31488-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190514191653.31488-1-richard.henderson@linaro.org> References: <20190514191653.31488-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::643 Subject: [Qemu-devel] [PATCH v7 19/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: lvivier@redhat.com, berrange@redhat.com, armbru@redhat.com 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: