From patchwork Wed May 22 18:42:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164879 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1249527ili; Wed, 22 May 2019 12:23:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqwW7h/OoFwT+hSLUIayRGLwy8+5XClx+4nCl67oO06u9+gApUgYX5W9gPIfxQF0WNQRmQk6 X-Received: by 2002:aa7:d1d1:: with SMTP id g17mr93080233edp.19.1558553021875; Wed, 22 May 2019 12:23:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558553021; cv=none; d=google.com; s=arc-20160816; b=NQxzP849YXClEBygQ0obKskV5GvjbPS7ok5BZ0tQvzNW8YOcqRu045mNdG6wDvRuz9 90nYX0fpHNj5x6PxDTnMYomrFc3aDTdTDqiKTaKhNZe44bp3dBOYXnXuPZMjXo2YY0FO rTF81gn9XErq7czwwDGLjEebDo2p7aLZFGf2o7+2H69tRpLZaRe5/vuHij1CBuzq7hLy QjSwOVaxFPhCzKryHMLx1iBKczgyiwc2ZiI0FmCSA0Y+yCHDN65XrL4LX9L7cL1NRi2f DyifMpvCeFCrriApzttaSZzo6EJ7xH4Rsc9iRA/zu/OmS2K0tt5Tn8kNEqohNt0uSVMu 9Ieg== 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=jpXlXNY0x+M8BkY++1HPIyXcQVBkivpIqY1fuUmKmGkLl08HbFyS1ns2v+phQCsP8a sH5HhjW6lvLbOcLZTqULO9d3Ut8atMNuBjfNZNyZsQr3eGoSx5HRkrLvo8Y0FhyUKeBI AM7+GGCpYAVdNlxsuKm26uuUgXljy6NDHSTNj6fy9LxRk7p5bgYhzwxed6aHKzRBGBUM wzY7z5k27hE1ZmFilXpLcacHF7EV2IpgMhbInPRlqHhQ5MuzNlAysD4TY11cJ5+GeTYV lg1LwUaDfihEWAAmpl0iKSZ3rExFQ/z7c3/qfL8+408Ek+AeGcm3OypW6j3JFaBoH/6Z CSvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="B/PcVJ5J"; 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 d21si7826078edb.358.2019.05.22.12.23.41 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 22 May 2019 12:23:41 -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="B/PcVJ5J"; 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]:50048 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTWpw-0000BY-Nt for patch@linaro.org; Wed, 22 May 2019 15:23:40 -0400 Received: from eggs.gnu.org ([209.51.188.92]:35086) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTWOo-0008Ga-QJ for qemu-devel@nongnu.org; Wed, 22 May 2019 14:55:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hTWCN-00089U-Vl for qemu-devel@nongnu.org; Wed, 22 May 2019 14:42:49 -0400 Received: from mail-yb1-xb44.google.com ([2607:f8b0:4864:20::b44]:35241) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hTWCN-00088Q-Qi for qemu-devel@nongnu.org; Wed, 22 May 2019 14:42:47 -0400 Received: by mail-yb1-xb44.google.com with SMTP id s69so1085143ybi.2 for ; Wed, 22 May 2019 11:42:47 -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=B/PcVJ5JaoLFNLP3h/Y5MLrwQgrFOMJz4Nle0d731qT/PhTmK4OHsMjnEH3BY8zA+U xtiaTZU8swftv8jVV9AXxlY4xxMJEczk2CJf7s8VhSkRU4uuXxnUSE+8T7UaoBivxq2q RESa/ZuGE7xK+49GUAbv5u92GRVL+FS2ANCCHO2RrE62MRkGBsshub+9rINGYC1NmYEL iD2a0nrkNHO46kzsLqk+oNDdMIZdb0g1hGsSq6lsOBJCi2R07691mMRlg1ghxpkr5Vc5 FrwEfZUKQDUm9IMBq1Nc6fsPesZ/btYu8+MNq28dR0hx47T2rvYxDzPFLYEJXilqmrfe pRCg== 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=Rb7OjTBVOpljbu2yPJEsu8eJ07XUUZTrvk9YDioNNj91M9P2bM1ND3/F4YkmX5Qd2D xYVw9Y+EQu+FBBS/f9RCaWzvhkEFAUbJ2TdjlYaEFo1yyz4pDjrBLZ0JEzYQgRjHgoE4 c9NC43rwNWnlGdVutyO2HHAqa44IkOG5oYU549i8c8w/1gImyqCqLqOLo5cV5tZefHqf JXVdqkbfaaFvO478/ocwF+rGndI96NV4XJLbRXY9XnmwEXTZcSswBL20EI0TXiws71sg It7P9VyFbkK6QT0A9BdjksR78q0YtTKhhmlUtwSPtY8A4/7a0WUSuyEBjxJ52cKlkhfg 0MGg== X-Gm-Message-State: APjAAAXoMiBb9XmG92txaCoq9WAl+/ppAGab3ZPm+UOs14y4/0uF3cYS qgujCTMum7rv4BxoWEe9oRewHmXvSvo= X-Received: by 2002:a25:7502:: with SMTP id q2mr22098191ybc.31.1558550566459; Wed, 22 May 2019 11:42:46 -0700 (PDT) Received: from localhost.localdomain ([71.46.56.17]) by smtp.gmail.com with ESMTPSA id 206sm1299445ywq.74.2019.05.22.11.42.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 May 2019 11:42:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 22 May 2019 14:42:18 -0400 Message-Id: <20190522184226.17871-18-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::b44 Subject: [Qemu-devel] [PULL 17/25] 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: 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. 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; }