From patchwork Tue May 14 19:16:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164247 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp3014606ili; Tue, 14 May 2019 12:34:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqyzYFDEULA5eXhU4fi97MMcyCX69ItnlmdDZJDXiz5ogEX+apt/BAYykMWEGI/Sf6I9IszC X-Received: by 2002:a50:d791:: with SMTP id w17mr38000441edi.223.1557862441993; Tue, 14 May 2019 12:34:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557862441; cv=none; d=google.com; s=arc-20160816; b=aIKJj1m41YsPMhmz+RMMSvmNeOz6MGBl1GL/3b/1hnPpItUdLk/rfKpRnzfnwGAb2R ctvzrLz6pgqGcxHcOQSXSboTBZ5DrfdKrFaROboR+IGwiE9M2LaX8lVk3UJLC8th4AII yfDqg/bzEcBpdRqumsdG/iCSyK7+IEsTw6IcBQbysS6bK+EwIkAZc6fBJ3aOHwi3m5sT aCxmogZd/zcNKY15laDK3SjWYW9xlm2xBbp3eIcVNs+uoq/JWz+P/1+rDu7IsQspj7wm Cvf+/S0NrzBRDPfgfdv6GvqSpdJK925rD83emNzoE/jvWPCHIL2MOQcZuOyR1ziPEcNI c3Og== 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=gZNiNYQQXuA93bC9AkQ3RkBuv003My9kgUQccuqjr10=; b=ec+pFPButEl6hPZWH2/Qk9ENvB/5Nx94nRXar4WjM/YyI450W/9Dhx7AXAt33l6Wc/ HWI6MMma4vEocL3mSohzHITgkfHAaiXjvlkMJmtH4MTe9/fXX23zCRYhXXdG/+gOIlFa 2U7iBfiADnjN/ysodoOKy0jiWp5XRB7MAUL0kLiN39EXIwQs8b+gMdeUjKB/3HGW0hMD 1FRO4vgswwX59aE0TBGMeR5vhzCAqpKsb9wc+K1IkBIZSFvlBo+xXWA8a606wSKQny2k TFFrVXm3ArT4Srb+QlJ3XeUVeO1JDNaBd04GYt5egP8cszZ/0cFQQFDQvalMhx8zvIbN X6Kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="wdyp/cs6"; 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 s19si3755373edx.375.2019.05.14.12.34.01 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 14 May 2019 12:34:01 -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="wdyp/cs6"; 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]:53147 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQdBY-00008T-SV for patch@linaro.org; Tue, 14 May 2019 15:34:00 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48927) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQcvR-0002d6-Hn for qemu-devel@nongnu.org; Tue, 14 May 2019 15:17:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQcvO-00070o-IO for qemu-devel@nongnu.org; Tue, 14 May 2019 15:17:20 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:33544) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hQcvO-0006zM-9X for qemu-devel@nongnu.org; Tue, 14 May 2019 15:17:18 -0400 Received: by mail-pf1-x443.google.com with SMTP id z28so18290pfk.0 for ; Tue, 14 May 2019 12:17:18 -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=gZNiNYQQXuA93bC9AkQ3RkBuv003My9kgUQccuqjr10=; b=wdyp/cs6Zycjdm7r/zoV+/gINfmq+a87JqC8wqYy9g4QWWQ2Ih3wvoSqi38BS4y10N dBE7kInnbygibVpGV8xlAgCow7QXo4s9KsjQa3+SDIN9jIrpJxW1L/NLb/K7OVhsXYcd yicu/NxBEdishimKpwxf1daCezCJ/0zeg4j+TWzwDbHgyEj2IHma/RuSqUOWco3Nyw6N QOvdRFNIp2TJB7Bh4CXiZbtN2LOWTyyoAJsDNkpJ/BVF8sFmFCNVn1+apMaCuwJqhDEc 9YIsOXH91TlsOQnIxu+X2jyQXCo3V7IXSNj1x0ro83Cgv1GhS2LDFXqvSeFYXlCS9tFp 9ZRg== 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=gZNiNYQQXuA93bC9AkQ3RkBuv003My9kgUQccuqjr10=; b=R6uqOhYsU/VAhwmiPX2vnkKooMdQN5PuAAlOKYeT7lVIWpag+hHmOFiJWawppB+Tc9 25+srYrRrqRLp/SZbs2Ac/lBtDEpX0sZQXlWmVs9d/GztcKxCR1m5baXLAwl1ZcTAE7p 22/ev/9VEJXCoa926fDbrsyagYucrk3W3y2L/jFU5sHY0YkEoBlijFY7+0pDtDM33Zks nSsLaE+2+fWUHUMJee8am0ki2UPCDqAoYNzdLJO63VK5oVC+RyVhSvZGwbwoqKIXDH1E 67XO4irGJtPqcg3sHwnvO9PQach67E5BjFPfh+JgxszzNs0cb/kkna2ujXu6vPidEPsl F78Q== X-Gm-Message-State: APjAAAVXd6wgWqa6EFOPuRkUVRIOo9XqH9ePrDv3Iug98OOSm8GPyVcD dMntiEeqbpmA1KmkApmBcr8AYFKKJGA= X-Received: by 2002:a63:b901:: with SMTP id z1mr29239919pge.102.1557861436949; Tue, 14 May 2019 12:17:16 -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.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 May 2019 12:17:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 14 May 2019 12:16:45 -0700 Message-Id: <20190514191653.31488-17-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::443 Subject: [Qemu-devel] [PATCH v7 16/24] aspeed/scu: Use qemu_guest_getrandom_nofail 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. Use the *_nofail routine instead of rolling our own error handling locally. Reviewed-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater Reviewed-by: Joel Stanley Signed-off-by: Richard Henderson --- hw/misc/aspeed_scu.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) -- 2.17.1 diff --git a/hw/misc/aspeed_scu.c b/hw/misc/aspeed_scu.c index c8217740ef..ab1e18ed4b 100644 --- a/hw/misc/aspeed_scu.c +++ b/hw/misc/aspeed_scu.c @@ -16,7 +16,7 @@ #include "qapi/visitor.h" #include "qemu/bitops.h" #include "qemu/log.h" -#include "crypto/random.h" +#include "qemu/guest-random.h" #include "trace.h" #define TO_REG(offset) ((offset) >> 2) @@ -157,14 +157,8 @@ static const uint32_t ast2500_a1_resets[ASPEED_SCU_NR_REGS] = { static uint32_t aspeed_scu_get_random(void) { - Error *err = NULL; uint32_t num; - - if (qcrypto_random_bytes((uint8_t *)&num, sizeof(num), &err)) { - error_report_err(err); - exit(1); - } - + qemu_guest_getrandom_nofail(&num, sizeof(num)); return num; }