From patchwork Fri May 10 17:30:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163920 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:142:0:0:0:0 with SMTP id j2csp2678453ilr; Fri, 10 May 2019 10:42:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqxk4BYSKBFxoTdL2TZ7jvKEIWLCT9DJXIM67i85qL9ayzAikohGgJ2ixRJ3in/Sd0U1HLlY X-Received: by 2002:a17:906:314b:: with SMTP id e11mr9685050eje.259.1557510177744; Fri, 10 May 2019 10:42:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557510177; cv=none; d=google.com; s=arc-20160816; b=Mq+E/YMSSmm4NFjH9AaR+QvD/bXjdgKgtIAq2rF9SGi1+H/nsEHEp0WxXYJHkPF/BO dVWelmVEzWCiR2xd25Carcb/CM6EzmJL4jT+R8NkRVZ4/1ou0lHULYO+sLtE0FiPWJId nOpe7wc8XKVq6T9qZmdOR+KdgB+CVrSoVhMnv7Uj0nu9nIXS+ZN/GvcuhEdc3Mqe/tLk 872SD8K2yK+XNBAL4Mv7HKC9wp9UdVzXKSSU5icM7mtWGeJLZwclhpyysJY61/et5z7p wPfeTywwgqgZSo7tJ2dIucRsw1Sr57fLI9nMr+T9qd31l6/risJEKxgA/MzmKKwUz+Cv h2pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=fAXpZvlDsepPUFQXEdmtR99aNvFnqvXET4zfpT6bZ/Q=; b=ZoOkrsJXCsNSbHHKKs9stCZNqw70WS8Y4a4/O7AmuRZkZx5hWMJcAcgqRwC5EZ/H/7 w/upaoE5NiWS8/iFf0ViAIQ93bcggrJcxXypovXREO5+SJLqDSPtsjym1NsBDo7NWp05 pcSJf6kKye5DHobpADbnFvS2+lf6bd5BJJjW36XcaxCQkcyvhUL/eaTpgmHVB37+2ozh Csp1bdS1x1KbNIvJo5HJtbu4t4/6XGfh1iMAkRtMclheEbJ7rCr/tdvZTZ4PNKSNj6PR nnshl4Glk4hIEl5xF3ICMDXqG5Z9T6ZcY9sFI26xsUWgOalQmOMccMRPTlWBq3dPGt3u ytWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=qzAQeB+R; 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 a20si4370710edd.180.2019.05.10.10.42.57 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 10 May 2019 10:42:57 -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=qzAQeB+R; 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]:47643 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hP9Xs-0002jH-Lv for patch@linaro.org; Fri, 10 May 2019 13:42:56 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59124) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hP9MU-0007SI-0U for qemu-devel@nongnu.org; Fri, 10 May 2019 13:31:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hP9MT-000672-0W for qemu-devel@nongnu.org; Fri, 10 May 2019 13:31:09 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:44199) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hP9MS-00066i-Qb for qemu-devel@nongnu.org; Fri, 10 May 2019 13:31:08 -0400 Received: by mail-pl1-x642.google.com with SMTP id d3so3129847plj.11 for ; Fri, 10 May 2019 10:31:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=fAXpZvlDsepPUFQXEdmtR99aNvFnqvXET4zfpT6bZ/Q=; b=qzAQeB+RIATfRdck8iCJFBZ5cOBmMRdlNXKP+kiT0oaPRt+Fmi4QG9IFqEhHUXbHBQ 5fLlQMW9PKxqIPmW81yLXaTzRjgpsor3L/CQeX4Q0MiKSufnwSpBO2P1mpYSw5PIxDSX N6JpSgHv5NBG/2zKOvfx8ZNtpPBRtNZcsnV/DtU8/St5qDIY0SDoGS+G/sJEkl8ih3uo sRKq5/icAOkOkn1WN53mVritvZnGi0rYUpUV95HYWfjqs5J2b0h5DuQVfSThH6Jmzjg3 JHnWCSAHuKQInQTe/pVVv+geVzMZ2TojV2STVtk2rGhcp6BeZKn7l3vbsmDvsEE6qTH8 YErg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fAXpZvlDsepPUFQXEdmtR99aNvFnqvXET4zfpT6bZ/Q=; b=R99T7L4XTcSIsx0jm4hl3AC3ffLtS5UcTDC7uia0NxYA2afNMc02hUnFsGrmriK7kD WCXmEaAVUJQ4viPCAw7o+vKv+sbDrW9YzdrXSGPdRaDxGkOiqZsmIT8x1XJX3FZfx6ew +juH7U4uDUDb2jNpsjGKjdiUhBL/coUA+arTCkIsutuh7lMvTYhBAYpGoEoHBRTczch2 8NuXDPXpSvsRdJOGv6BFBhk1J3w2T21RUJs+v2kSu91MDLqXrZfMsPuT8cC/vQrjSLEV A+4sLRwOPFaeHXkrO9WOcJWX4bbq2gUAgjMF6yxg47ah/F6re2v7Y6NiovEPGxbR+8/1 qKFQ== X-Gm-Message-State: APjAAAWebavP8jEFJZrScpvYeBnj7jR5IC5IA34rDQwFgTg5ryWKYhXa Bp7b6dpSwzZRQhiB7qgtmPWbiAaFwGU= X-Received: by 2002:a17:902:9a4a:: with SMTP id x10mr14592810plv.113.1557509467521; Fri, 10 May 2019 10:31:07 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id v64sm7936792pfv.106.2019.05.10.10.31.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 May 2019 10:31:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 10 May 2019 10:30:37 -0700 Message-Id: <20190510173049.28171-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190510173049.28171-1-richard.henderson@linaro.org> References: <20190510173049.28171-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::642 Subject: [Qemu-devel] [PATCH v6 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/main.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) -- 2.17.1 diff --git a/linux-user/main.c b/linux-user/main.c index 7e704845c0..e455bff1b7 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,27 @@ 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 { + /* ??? Assumes qcrypto is only used by qemu_guest_getrandom. */ + 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);