From patchwork Fri May 10 01:24:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163796 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:142:0:0:0:0 with SMTP id j2csp1724580ilr; Thu, 9 May 2019 18:31:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqzFYpZJXrvX+c0OKcvnW7nyoXVZLTEMbF1Vh2RQcOqAP1Wmf07VZJMpe5KFSH7+qCl+Az8e X-Received: by 2002:a5d:534b:: with SMTP id t11mr1306953wrv.297.1557451893189; Thu, 09 May 2019 18:31:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557451893; cv=none; d=google.com; s=arc-20160816; b=TMoOIUbmosJAFtEXwMM556Owdw+/tPURwuM0Ja9BNoVoixaLg6PlGjpl+lLeAL4Nvv 93Psw6qBZUUSeQQfVTkfy4Nt5+2jHe9aEHVQdObnBfy2sGr3a14GPL9k0REEGwOQEJ0i 5l1OZy5mM3qH6MpC/8Y6uu+jTs2L+E3J77VDSm8ASVvrf+UISrTDC2/DuOjF31wq/PwY /aG25kPOUdbpZ+lMSgCdz2NcyVFk45xF72RL3NP4ll2/m+3CX7Vn+B3zVCNrQC5O4svv fKJ6ElkCkVPfohc5919OZVBcfmR3R27IrkkvQzqz4MVVk9GNUbNcybjNYyqF5C0XamT0 ravQ== 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=tONOpjcj0FxXSSZHZXrkhjP/KybbzntorN3yULUFX+s=; b=Ri3UXyrFlIHHEdUwWm+Nr24NKgOAGuXfKMwQNW8Cl/ad5xj0qZq6DLKQer34epfTN7 vtly5Md0+vK7JMtb7VHuwWfrm0efj7v2KDtIC5BwHCIEBprZhMhSrici7IWCFVTC071T oUz9e7dlrylE3rw8Yjx0AosbIuYkFmf8hUevG7OQzP/XsCQeSRMdZp9KbsKRx6io0LAk K1onH/1QRO6pO66ZAVJY55lo1wD54hHfTCJm5QK4JcPCGTTic7ivkf0Hj6ZA+N9K3LHH xBF/I/vOb6HF+2n7jyk9ljLJIGew7ZjKrwXRrG7HMgYnY75Ps+1fVqTf/MMN+kVRxwHS tUGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Hn0kJtcI; 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 h2si2610645wmc.12.2019.05.09.18.31.32 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 09 May 2019 18:31:33 -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=Hn0kJtcI; 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]:35086 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOuNo-0003VZ-4K for patch@linaro.org; Thu, 09 May 2019 21:31:32 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58733) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOuHm-0006Jw-M2 for qemu-devel@nongnu.org; Thu, 09 May 2019 21:25:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hOuHl-0001AH-JG for qemu-devel@nongnu.org; Thu, 09 May 2019 21:25:18 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:46793) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hOuHl-00017d-AA for qemu-devel@nongnu.org; Thu, 09 May 2019 21:25:17 -0400 Received: by mail-pg1-x542.google.com with SMTP id t187so2111125pgb.13 for ; Thu, 09 May 2019 18:25:17 -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=tONOpjcj0FxXSSZHZXrkhjP/KybbzntorN3yULUFX+s=; b=Hn0kJtcIGSs8sY/Top0YETZFmIkr6AZJr+Zvn08N4c6b5XAl4b4BnZZfYg5XNg8dvF gKMWFE+0Gq/JvtQMhoqehkIs5hzmdPKk0ri28OhD7aAz+1PFj558c/COZwSCz3ZiLRCi yllE1d0a7prfOdDO3sdIF97vHAv82Is8K4Mf3G5ciDV7pt6HtMY78jotQ/lHrD5xmgOO Mx4QDoXPSC/cSGdgHsERuJyhuwx8OkeQOjQ24ikgu6VwFLb7jGhXUcoIsxe1wBAV7x/D 5f3ogj3Gr3SfEb/6TclFLRuqgz1FYXgYmWeMeomc5gVOFA09WiW/+I9KBoscYIOA41uL iriA== 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=tONOpjcj0FxXSSZHZXrkhjP/KybbzntorN3yULUFX+s=; b=FNBuqsCzC2/vY0gyq2MlgXiYlcXwcV9fSNmc5SanoUPNff2eLWcrgH3WGlakA10PMD Oqp98E1SwILPDOlvXp5GjWr0nHmFsymcJVPjADhYDm9/QVkKU8b1dvSilM6k+0miiqC6 TrDEfDBtxmreuVZTRDiXq9E9yLirBM1l5VCIV5fw8elvwdCQhCPMhncO6B8TeAWApCTP Foigmm3f6+qBzzSlBX9Vlye0bZITniJ7Fv0REX2/59ZQlpmdCVpLLq1Lmnn2yipuT67E /DMS5vF2XKsmg8nvbaEITqzn0PJty0ALlPcHZfDaP6jHorDO3ZPx1LDEmFz6f7d3+lm2 uHeg== X-Gm-Message-State: APjAAAU4Jc+7C8p+/DvVstpuhTjD9+kS3I7xdjgIr0wo2kbJERCQ0px3 f7Wayw6zZe3Z8ATKSIysftG5eplQfUs= X-Received: by 2002:a62:6497:: with SMTP id y145mr9981088pfb.255.1557451516085; Thu, 09 May 2019 18:25: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 n18sm8252700pfi.48.2019.05.09.18.25.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 May 2019 18:25:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 9 May 2019 18:24:47 -0700 Message-Id: <20190510012458.22706-14-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::542 Subject: [Qemu-devel] [PATCH v5 13/24] 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: Laurent Vivier Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Cc: 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 Reviewed-by: Laurent Vivier 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);