From patchwork Wed May 22 18:42:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164862 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1230861ili; Wed, 22 May 2019 12:05:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqz+t5Tk2VnksW4Hlr8tDfI4nW1Oexrnh/hkixKZ8SkMgUao9O8eLPzG52iHQXP02HESivgH X-Received: by 2002:a17:906:abd9:: with SMTP id kq25mr56209464ejb.30.1558551936290; Wed, 22 May 2019 12:05:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558551936; cv=none; d=google.com; s=arc-20160816; b=DWlbJC0efGvcD/W1obnTuCg1gM+LlvJEfRSSlBgSMkAfxpsQoHoJ/86rTlI0AtzC5f eTx2VydGqMZma+BluoBJamDVBw671jj9ybbDG6U+yx2xTPbNbwAcXGDRPXhKLuFjdMKq mKfQAPI3eWzs7K47kU8qBF28GImyiUhT193L4H3orZibqrtEpuG0HaooskwRlMJzOgK0 A/nIoT2rq1gbo3D/8O5Tw6WC6rtk2L0c6N7qt8lmwjnOzKdQV8kdB3KcozmHA77hnon9 5ns+5N/MOUCgIvC1qhcG5SbRa7TCyVjST0sxHix6wZ4Ix2ccTwQ958Kf2d0b66nFFnQk xWkg== 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=XXhAPtYvtMlhkNiiH6cZEQQTlmdpOKHdKg1FRFOG4Is=; b=oCL7q4sR1DGeZC9C1IC/SL/eKKLF+tbNRJ4jo1RKPQpA2Xkb4LyOeJK46ynKlR9lyj KdM0CHUbAwY3zi3sKumSHFy4qp7TAa7W/78TYjZKm5VUzahlNkWJSoSwgxsVYSTZQRKQ LUZlpX6NVt07xg0DOye4XTRqd6auCQ8f6wylu+a4CSM7UuSscKEOLbN1GmMI8NrCfTED cqdgg89LTGU2w4VnO2GteuE/m8rIyC1HuhiPf7t10Jy7BR6WBPVcKAZJRsccrP4hX5cf /Mx9FUI1KDJYMpKAbBkrpnoVEVI2JLVVmO4o3llX0uxjC9DuLZa8QOKXaIqsO3h/WKRx zXxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dvoJpqts; 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 e36si2304942ede.438.2019.05.22.12.05.36 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 22 May 2019 12:05:36 -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=dvoJpqts; 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]:49782 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTWYR-0001JT-8W for patch@linaro.org; Wed, 22 May 2019 15:05:35 -0400 Received: from eggs.gnu.org ([209.51.188.92]:35163) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTWOp-0008Ln-6q 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 1hTWCJ-00086w-TM for qemu-devel@nongnu.org; Wed, 22 May 2019 14:42:45 -0400 Received: from mail-yb1-xb41.google.com ([2607:f8b0:4864:20::b41]:38879) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hTWCJ-00086K-P4 for qemu-devel@nongnu.org; Wed, 22 May 2019 14:42:43 -0400 Received: by mail-yb1-xb41.google.com with SMTP id x7so1256969ybg.5 for ; Wed, 22 May 2019 11:42:43 -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=XXhAPtYvtMlhkNiiH6cZEQQTlmdpOKHdKg1FRFOG4Is=; b=dvoJpqtsvIHw/G5jCKu4zDmr94LIm25PGcgVGME+GVWJJwUFHZbmE0WZVi5vWE2hJr bJMpWvPhU+X1OBBmyx4dL0/kONrpGaHE4IpoQDC5DzVAB8Q7MVOOXRSPLNUtIGoPIS9x 2TdKAdFxIFt2hySoIodgi3W5s+3ce3tb5GZJhXAz2eQG9+l6VPzF07sFnzxpZUC9TVQx upow7mqruQfrvfcO/+DEfUEvxSJTjNbsFQV5r3+uZFvLSM2cgWWwmdiwt46bvXHDByeY zEd6WRFBcig6J/8REHZ6ksDHji0r/8aiKS5ZQuVkfNi9uNXRvThGIyAxhHe4oqv/Hmsg r1lg== 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=XXhAPtYvtMlhkNiiH6cZEQQTlmdpOKHdKg1FRFOG4Is=; b=D4eoxiDKNauOcUyDouDupJ9Us3rtzaCeJTYvqG0BIRwjFFl4hMMMijhRQC9yfsWJ7M OwYncX+aCroE2P2fMcxTJmF+OcMcP8nnUb8FV8/GTsiLDHLqM036G4veiPuxJIwFZSOq leanezmPvnIBauqJfkTL0yBmwRHTaMaEniQBw1yYmSIOyKFLg8niZwenI2JmkG95e65S OhQFlkTXM4OkOAWEqdQUtRjNnuWlNb3ZTIbkTWcOC2xRwiEDHwsn3BJL6kMTuKZPH3sp m+wYnbPZHQ/+DkuOHEKsiWTpstosTmgV5SfmXyLt3cdpBQn1/LeoFi+uLhYWZFkfYoCZ AxDg== X-Gm-Message-State: APjAAAUQIv8gaZf10lUpC3wZljasMqxYVVRKOyHqPHsRwk7awAPhX+o/ 6jKCXhG/lfblyPTh1W1/EtEW0SNDOj8= X-Received: by 2002:a25:8109:: with SMTP id o9mr11702248ybk.132.1558550562385; Wed, 22 May 2019 11:42:42 -0700 (PDT) Received: from localhost.localdomain ([71.46.56.17]) by smtp.gmail.com with ESMTPSA id 206sm1299445ywq.74.2019.05.22.11.42.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 May 2019 11:42:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 22 May 2019 14:42:14 -0400 Message-Id: <20190522184226.17871-14-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::b41 Subject: [Qemu-devel] [PULL 13/25] linux-user: Call qcrypto_init if not using -seed 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" When not using -seed, we will use the crypto subsystem for random numbers. Reviewed-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/main.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) -- 2.17.1 diff --git a/linux-user/main.c b/linux-user/main.c index 7e704845c0..66c909a1a6 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -39,6 +39,7 @@ #include "trace/control.h" #include "target_elf.h" #include "cpu_loop-common.h" +#include "crypto/init.h" char *exec_path; @@ -688,17 +689,26 @@ int main(int argc, char **argv, char **envp) if (seed_optarg == NULL) { seed_optarg = getenv("QEMU_RAND_SEED"); } - if (seed_optarg != NULL) { - unsigned long long seed; + { + Error *err = NULL; + if (seed_optarg != NULL) { + unsigned long long seed; - /* This will go away with the last user of rand(). */ - if (parse_uint_full(seed_optarg, &seed, 0) != 0) { - fprintf(stderr, "Invalid seed number: %s\n", seed_optarg); - exit(EXIT_FAILURE); + /* This will go away with the last user of rand(). */ + if (parse_uint_full(seed_optarg, &seed, 0) != 0) { + fprintf(stderr, "Invalid seed number: %s\n", seed_optarg); + exit(EXIT_FAILURE); + } + srand(seed); + + qemu_guest_random_seed_main(seed_optarg, &err); + } else { + qcrypto_init(&err); + } + if (err) { + error_reportf_err(err, "cannot initialize crypto: "); + exit(1); } - srand(seed); - - qemu_guest_random_seed_main(seed_optarg, &error_fatal); } target_environ = envlist_to_environ(envlist, NULL);