From patchwork Fri May 10 17:30:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163905 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:142:0:0:0:0 with SMTP id j2csp2666371ilr; Fri, 10 May 2019 10:31:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqynSSy9esNziWoFn8sXwegNnM5GZWuulqN3xVdOrthkB2MVn8D2H03iJRP18ZP9VjmisLsT X-Received: by 2002:a17:906:685:: with SMTP id u5mr9909952ejb.125.1557509489413; Fri, 10 May 2019 10:31:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557509489; cv=none; d=google.com; s=arc-20160816; b=aC6CAsZrUawX2b/CxaRu6MuSANpfLBr9JiyOF00ZEUG3VmxzbRN+DH3HfPbjQh+0Xx +lVAaMx08jHH6DtGdLaFx2WxtuD+GL6+3LIfQBQ/IWtqmY0h64u1GFGxQA+E6ljcr4u8 klD0VSStJuFzNlGFN0DzhjYV/sQcnXrXECQmGdHWwS7fdjUmcIZC/5ow6XLzLb6mki0Z wNJxjLrwxWyxkAcj8Fv/tnNeSRIqLQCoKBCgRIoSthzTb14QCCJyPuyFIKF0rqUgmsBa zpePV+OMGijX+x2Ldqdk6ERTo0IwdxPr50x4eJje4hNzIiKMrFzzXnwhUzg9C3KZ2OGy pdrg== 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=OkPZXGg0Nh2IXPIyKNC1R2CKYIGFO6z1RJMn2bktluY=; b=w555aRSPSfQdL7s1Bc2Niwmee2c/2nxLdI5V3XDoXAum/IvGwSuKSDunAutEZ7TLnh QecTUk+iPJMf4rx0P4OvzihQ3KCaYFlVVimWsdBnClBtMGDmmF9bWo91Gkm2wTUFBVdI J8kuAQLHwFH939qac1eCfHbYcD0Fabvrgr4C/AkTlVAVA7pepY5oQEvRnvABofyxVHYV DLiRsU0EGHxlh5xQ25RN33h5Rbea9r3SNfq24k70lafsBvpPDmLhdqthWVMEJOFbhj3Q E+mXSJCztLehmqcG5DlgLNVSG0SLGjU5i9OmPuGNDx6A7sHx3inXW6tNiXHSn4ziTIzf h9Vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=H1gLFe6V; 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 e3si1327018edm.104.2019.05.10.10.31.28 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 10 May 2019 10:31:29 -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=H1gLFe6V; 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]:47482 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hP9Ml-0007IL-RH for patch@linaro.org; Fri, 10 May 2019 13:31:27 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58945) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hP9ME-0007IB-JV for qemu-devel@nongnu.org; Fri, 10 May 2019 13:30:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hP9MD-0005xg-Gc for qemu-devel@nongnu.org; Fri, 10 May 2019 13:30:54 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]:40569) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hP9MD-0005x8-7i for qemu-devel@nongnu.org; Fri, 10 May 2019 13:30:53 -0400 Received: by mail-pl1-x635.google.com with SMTP id b3so3137677plr.7 for ; Fri, 10 May 2019 10:30:52 -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=OkPZXGg0Nh2IXPIyKNC1R2CKYIGFO6z1RJMn2bktluY=; b=H1gLFe6V2L72CHSW823jCArhXnGXhAJvGbyHVDxEQiqcb8GLXZJQO9563XNWZOHlaN 9zEZU6GRNQt63yI1tvTUTtpx0DGZHR4bDRwIFcvPVuwOqnUCGbsJbW5iWSHYaHry4fAD Q7SyAsQCBiNAF3pAGHkwU6GjwgTQri+C9EwWZi5nHCsUKmwxX1Ecf77fvzrmSzndHsdb F5OGef92vk34eNI3GCNMQ3/8c7Z/Pmg5jlIa2gKx5Lg/5SlITxJzQitMDEIZLk4Vrfjl bnLpfdeSGeM6qJtiGEnlfKJepEyizqsuo2ZkrdkMIwFTGs5FfaWEidn4bw55yWJf1yn3 WXNg== 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=OkPZXGg0Nh2IXPIyKNC1R2CKYIGFO6z1RJMn2bktluY=; b=imFQ+bMUR/DcrEaH929SXDBHmwVdoJL3baGhJXx2rm6TE3L5U6zLx+M4OnAl9Iqymw ve8aZ+oQ9KEQn/uXuYELEF5LG9K2o4oNFhmpvbtg+0hpnMCF1P6vygwU9v00lP4mOgQI 1jw1tTjJGiF1PVurjKi+2i6lV7N0yh/YCxHBWmp/UBVWbPgTv22F/RdeQ5frRqv9c5Md BpKXmDAxciIlRp4w1Da8zIkm3mICvG0IXqVjMf79+v1wp3WEQN3wM4EQJGx5Qp9Cna4I iz4KCUkfx70+Sc/Dp1APovmnE60gG2RIjljbqGhSpGsnWACHOdEVabPt9JF63dFntifZ 3tWQ== X-Gm-Message-State: APjAAAX5UEoMO4QKDoiCbSRuCwv1l1zT3nuuAlFbwiYL3pJneR2wA3TJ RRIFtDT+GMrazGn+ssBoSzsJbkTmGJE= X-Received: by 2002:a17:902:e104:: with SMTP id cc4mr12946897plb.254.1557509451309; Fri, 10 May 2019 10:30:51 -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.30.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 May 2019 10:30:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 10 May 2019 10:30:24 -0700 Message-Id: <20190510173049.28171-1-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 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::635 Subject: [Qemu-devel] [PATCH v6 00/25] 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" Only the new patch 24 lacks review. Changes since v5: * Merge crypto-obj-y into util-obj-y (patch 2). * Fix leftover crypto-obj-aes-y reference (patch 2). * Add ARM_CP_IO to the RNG registers (patch 22). * Issue gen_io_start/end around ppc DARN (new patch 24). * Issue gen_io_start/end around x86 rdrand (patch 25). Changes since v4: * Do not autoenable nettle or gcrypt if linking is broken. Fixes --static on fedora 30. * Delay removal of srand() for -seed. * Do not loop for -1 result for ppc64 DARN. Changes since v3: * Do not autoenable gnutls if linking is broken. Fixes --static on ubuntu 18.04. 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 (25): configure: Link test before auto-enabling crypto libraries 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_failed 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/ppc: Use gen_io_start/end around DARN target/i386: Implement CPUID_EXT_RDRAND Makefile | 14 ++-- 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 | 62 +++++++++++++---- target/ppc/int_helper.c | 39 +++++++---- target/ppc/translate.c | 21 ++++-- ui/vnc.c | 53 ++++++-------- util/guest-random.c | 93 +++++++++++++++++++++++++ vl.c | 4 ++ configure | 87 +++++++++++++++-------- crypto/Makefile.objs | 77 ++++++++++---------- qemu-options.hx | 10 +++ tests/Makefile.include | 3 +- util/Makefile.objs | 1 + 37 files changed, 644 insertions(+), 308 deletions(-) create mode 100644 include/qemu/guest-random.h create mode 100644 util/guest-random.c -- 2.17.1