From patchwork Fri May 10 01:24:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1097765 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="PmKaoaZe"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 450Y1b1x2Lz9s9T for ; Fri, 10 May 2019 11:45:07 +1000 (AEST) Received: from localhost ([127.0.0.1]:35258 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOuav-0006BB-9m for incoming@patchwork.ozlabs.org; Thu, 09 May 2019 21:45:05 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58818) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOuHr-0006MG-MD for qemu-devel@nongnu.org; Thu, 09 May 2019 21:25:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hOuHq-0001HM-Gu for qemu-devel@nongnu.org; Thu, 09 May 2019 21:25:23 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:44641) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hOuHq-0001GO-Av for qemu-devel@nongnu.org; Thu, 09 May 2019 21:25:22 -0400 Received: by mail-pf1-x444.google.com with SMTP id g9so2244611pfo.11 for ; Thu, 09 May 2019 18:25:22 -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=NqFQGLUWEK2q+OruuYLxByccY86fvPfXVx23TDmISjI=; b=PmKaoaZexxoZh96Z5SSBy4MbrFYGDyGKI6XKBNjH7wuaKs10QNgrTo1r9QxWIm2Cxt o9BXZS6H/B/w1JbrIW62I5XQTVJ2JlkpYmG9vea9erBWiW8RnLJlcExHDm9tv4oWRvVy fn14ogW1auLxR6kQG1c07EiYK0NnlBTeh6377EL8KTopwKRG3l+gIsuBKJ6UTihSQioE r+HMobJf+sYB91Zk+V6XdadNcyhtm6c0ULvTP/pKGjhTt8SB6g6t8PXm1oAiaI/QlmsF F3jUIInF2+ic9gJ0zx/REhj82vTKXclXusWv6lzvAqUcitO/1FQs7rBqjnTDAZZSg1ft BMyw== 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=NqFQGLUWEK2q+OruuYLxByccY86fvPfXVx23TDmISjI=; b=mFfLX/azz4z0gdHbD8yk9OImpVoeLtCgXlNC+UrVzGmm/fOqSw5jdZUmvhqAKfPYT9 2xtcxdBr2V4K6jcbNdzVnuDvNHQqY7+SikXbDwI4p5usJ0d3nzlF2wLQrU3JrhR0Tla9 EgMyhH5TBuVIUVPA4k4iT9gaCueJtNBmTFk1l2kiOgEFJqMde/4m6QdCoueJhyI312gc OsqgNp5wWxIVzCixc+daSy6seSTRAfwhKx4KvmGCEEcZ3iteQkNHi547bO7yx+V6pRfM Mvz1aWI2jVuSsLXxM+sf5tZgOjUD61UP5wboWksHrW+dCGTY2yRaU/Bw2HlU1t4fuyTm fDyg== X-Gm-Message-State: APjAAAVgOlzajDOJsNFEKjlRzcW3yKkbzShRKsHXKvCgvH47TRRneOL8 uGzQIVu8jNzEMAYtdMdxJ9Hrgv1zSZs= X-Google-Smtp-Source: APXvYqyRZXio1LWolVpRtPVnE/YcnTKLBY3979p2EYKWUwZuhHQo+LKp4zgIesxuvO24236oMnXiIg== X-Received: by 2002:aa7:842f:: with SMTP id q15mr9927856pfn.161.1557451521062; Thu, 09 May 2019 18:25:21 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id n18sm8252700pfi.48.2019.05.09.18.25.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 May 2019 18:25:20 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 9 May 2019 18:24:51 -0700 Message-Id: <20190510012458.22706-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190510012458.22706-1-richard.henderson@linaro.org> References: <20190510012458.22706-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::444 Subject: [Qemu-devel] [PATCH v5 17/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: Andrew Jeffery , qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.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. Cc: qemu-arm@nongnu.org Cc: Andrew Jeffery 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(-) 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; }