From patchwork Fri Mar 15 03:26:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 160388 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp16274186jad; Thu, 14 Mar 2019 20:51:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqw4ilZ3Z5QN4VFQw27iTU17D8EY2DFzQ2QzL/EW+EFYHtySqGnT1CGOLTz5gPIskhkt6AZn X-Received: by 2002:a5d:4887:: with SMTP id g7mr748352wrq.51.1552621877003; Thu, 14 Mar 2019 20:51:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552621876; cv=none; d=google.com; s=arc-20160816; b=u0ckNJVkJocbo3hHL/8QMN0OCH7VqAdytUIMlP3LQNyHe4unPDhiIC5gwUEt2J/12e UHMd+wrjxeuNl1g8RI73cKrH7VC44sq1ccqvRxiE1gSWtlp4+ydYUphzRc1+2USsDpr4 FkP+oh0dRe89thmEhHTUJ8Mv+oHcfQq5sI57aKLmm+gQdccoGaonLpCszzeR95UhcOvi DiGNfP3c9th31vEI1SDG4sN7qCJQ0rYp6uaL7tug6NWpVw5KSkv03noZcZ3snhpR/Qsr /5pQfycfztYlsrp9keg8S5P9k8HJ/F3dT1npncVT615MgZ7/EEoHm3e/i/7fg3xFx7Mt idRA== 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:message-id:date:to:from :dkim-signature; bh=Eu+pEzuF7HsLwj7NZPeC5wIAZpy30CCYDYxipWLNakg=; b=ko1RZkgzakLwFsxjgoMd9GDJHj6fJLzKv0dd2yvbp/aDKz+ymJ3U2ZuMd4XJk/oJdi YbbtW4qtIzRyodagTeKZPweEEE4fHJkaMUOEeRldv13D5jPnBmZ2wXT6g8AFbAjY0poU G9xZQecOROhhnc6PARZOP9eN57aiGimyUtoRbtgA1uSttd918eK18OLrs4Gy1T1cFUlu irkDV86Q/IZRZO5Qe6SYrkfDB9buAnZQMHI37L6zX0CNQTGzS7FpzJuqjGjMEbxIkcGR X9HDyp1ZSUA8kEdNSiZJoZi6wfleqWpPAVEF7VFRV2Nhz9scWxKg9xkJsMppuMgCzPT7 vweQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=DkvKPFqM; 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 d9si510174wrf.304.2019.03.14.20.51.16 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 14 Mar 2019 20:51:16 -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=DkvKPFqM; 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]:48991 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h4dsJ-0001kb-Te for patch@linaro.org; Thu, 14 Mar 2019 23:51:15 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43949) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h4dcM-0005E9-97 for qemu-devel@nongnu.org; Thu, 14 Mar 2019 23:34:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h4dUQ-0002gw-I9 for qemu-devel@nongnu.org; Thu, 14 Mar 2019 23:26:35 -0400 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]:46976) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h4dUP-0002ff-U2 for qemu-devel@nongnu.org; Thu, 14 Mar 2019 23:26:34 -0400 Received: by mail-pg1-x529.google.com with SMTP id a22so5378607pgg.13 for ; Thu, 14 Mar 2019 20:26:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=Eu+pEzuF7HsLwj7NZPeC5wIAZpy30CCYDYxipWLNakg=; b=DkvKPFqM0eFlbt9d/akpy1tHO8N2V1Oy23yCieJGHUpH7LiY+y/rmitsfQdLfRh1rK 58P1pA+0Z4b2OdugoUvcD8xzL5zgN9W4zODQtTLXkApXaVUuXNanQi78Sbppyqj8axgl 1g40DKT/+XYjFvThXitnpPs3/auxNZ0oKqJBS9QCGrJvqvJC9Sj9NdtzdY6evCspIljA V934Xu3TRZnh9zD4Smz2CwGkHW5eJJ6NMvrsXXB311VMTGWOe7IIQx/7pEo2ApiaBlFw 3qPEFXEzX2viSRDwpwTABJIqWvbw9jZRYRZkWLtApNnuYLV0H+Aw4tAwzZ2W9qhrTHM1 yNCA== 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:mime-version :content-transfer-encoding; bh=Eu+pEzuF7HsLwj7NZPeC5wIAZpy30CCYDYxipWLNakg=; b=s8CJCB5HiGOyTe5NZy/EvOuYXN2U/wn18XfkN4ttM29hJmzPiKWb1xL/PwlR2SMgAF X4Vco3hw6pAQc87H86BYDqI2luDCRRtmeTMLrQYr5RovrZ0XZ6VuO4aGhxjE4uMEP5Rn KQg1Y5tqPrjjO6CbOY01p8b1nvIRezDNGOkhsObYTExfLnwXUvPplU1WaEP9d5eArzwG vwVwFmnI2zFX/xlsfx80mTjmgz4bjrLUIGFoioGC3YOxP9yntHQSjLV/3cwmQKGevRHn cAnQb7PAAaKE2FkNTvnXpel5CaoM6i8QbodvP8j+TCOShjtMQ3OGlUsq5FyvE1VXCjgZ ILmQ== X-Gm-Message-State: APjAAAXOXXsUWfm3VlqAeqyucMSznJz1eZ4OMGaC/CIgM5xE93he30t4 ekAty30V0boF9zm8Q6ojmMeFs34d4VI= X-Received: by 2002:a17:902:290b:: with SMTP id g11mr1790888plb.269.1552620391885; Thu, 14 Mar 2019 20:26:31 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id d26sm690816pfn.86.2019.03.14.20.26.30 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Mar 2019 20:26:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 14 Mar 2019 20:26:06 -0700 Message-Id: <20190315032629.21234-1-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 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::529 Subject: [Qemu-devel] [PATCH v3 00/23] Add qemu_getrandom and ARMv8.5-RNG etc 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" Changes since v2: * Changes from review. - getrandom is not exclusive of /dev/urandom fallback. - vnc fails gracefully on crypto failure. - a great renaming. * Drop the "nonblock" argument, as it's not deliverable from the backend. * Propagate Error back through qemu_guest_getrandom. * Add qemu_guest_getrandom_nofail to centralize "Argh! Death!". * Convert hw/misc/ * Implement ppc darn. * Implement x86 rdrand. Changes since v1: * Build crypto-obj-y for linux-user as well. * Several patches to tidy crypto/random-platform.c. * Use getrandom(2) in crypto/random-platform.c. * Use qcrypto_random_bytes in ui/vnc.c. * In qemu_getrandom: - Use g_rand_int instead of srand48. - Use qcrypto_random_bytes instead of getrandom directly. r~ Richard Henderson (23): crypto: Merge crypto-obj-y into libqemuutil.a crypto: Reverse code blocks in random-platform.c crypto: Do not fail for EINTR during qcrypto_random_bytes crypto: Use O_CLOEXEC in qcrypto_random_init crypto: Use getrandom for qcrypto_random_bytes crypto: Change the qcrypto_random_bytes buffer type to void* ui/vnc: Split out authentication_failure ui/vnc: Use gcrypto_random_bytes for start_auth_vnc util: Add qemu_guest_getrandom and associated routines cpus: Initialize pseudo-random seeds for all guest cpus linux-user: Initialize pseudo-random seeds for all guest cpus linux-user: Call qcrypto_init if not using -seed linux-user: Use qemu_guest_getrandom_nofail for AT_RANDOM linux-user/aarch64: Use qemu_guest_getrandom for PAUTH keys linux-user: Remove srand call aspeed/scu: Use qemu_guest_getrandom_nofail hw/misc/nrf51_rng: Use qemu_guest_getrandom_nofail hw/misc/bcm2835_rng: Use qemu_guest_getrandom_nofail hw/misc/exynos4210_rng: Use qemu_guest_getrandom target/arm: Put all PAC keys into a structure target/arm: Implement ARMv8.5-RNG target/ppc: Use qemu_guest_getrandom for DARN target/i386: Implement CPUID_EXT_RDRAND Makefile | 12 ++-- Makefile.objs | 8 +-- Makefile.target | 4 -- include/crypto/random.h | 2 +- include/qemu/guest-random.h | 68 ++++++++++++++++++ include/qom/cpu.h | 1 + linux-user/aarch64/target_syscall.h | 2 - target/arm/cpu.h | 17 +++-- target/i386/helper.h | 2 + cpus.c | 9 +++ crypto/random-gcrypt.c | 2 +- crypto/random-gnutls.c | 2 +- crypto/random-platform.c | 104 +++++++++++++++++----------- hw/misc/aspeed_scu.c | 10 +-- hw/misc/bcm2835_rng.c | 32 ++++----- hw/misc/exynos4210_rng.c | 11 ++- hw/misc/nrf51_rng.c | 4 +- linux-user/aarch64/cpu_loop.c | 25 +------ linux-user/elfload.c | 8 +-- linux-user/main.c | 34 +++++---- linux-user/syscall.c | 34 +++++++-- target/arm/cpu64.c | 1 + target/arm/helper.c | 64 ++++++++++++++--- target/arm/pauth_helper.c | 18 ++--- target/i386/cpu.c | 5 +- target/i386/int_helper.c | 21 ++++++ target/i386/translate.c | 55 +++++++++++---- target/ppc/int_helper.c | 38 +++++++--- ui/vnc.c | 53 ++++++-------- util/guest-random.c | 93 +++++++++++++++++++++++++ vl.c | 4 ++ configure | 27 ++++++-- crypto/Makefile.objs | 5 +- qemu-options.hx | 10 +++ util/Makefile.objs | 1 + 35 files changed, 548 insertions(+), 238 deletions(-) create mode 100644 include/qemu/guest-random.h create mode 100644 util/guest-random.c -- 2.17.2