From patchwork Tue May 14 19:16:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164230 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp3003130ili; Tue, 14 May 2019 12:20:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqyWySdxONdcJRNorHGAMRndn8DmcQrRoeuOtV+Petma9kRoaQhq2ayBtWSnvDhbug3VNjR3 X-Received: by 2002:a50:87b5:: with SMTP id a50mr36993107eda.118.1557861628732; Tue, 14 May 2019 12:20:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557861628; cv=none; d=google.com; s=arc-20160816; b=sseP6Jp2Qf4kg+cUnVpJUoFGpIzi97kNnX7nRAuleLZYqs//H38Vvg6om2a4iQSyIq VAU1yxUxwPM9/8NtC3rFKgodQKJIqp1XxeLlWpPBt3gDgHECW2vVm09GdXR2wcYFP0vp 6PJHVxrACfQkwknOf1iXkgzGx/Ac8Pw5i4TVlaaWT8RUqciEa/uiVTl4VHZSy6VJCV+1 O+lSmuQa2N8IjNCqaT/6vFNGqXjEE6K+NmAogiXdnCfTwDxk5A0oGIC+MByrq268RvA0 2V+WHrN88BEOn5MAk81VzTUy4yTcnSRBfzVE5cxp3Rs219f40IbeM541Ip7BbZH4x8RU olUQ== 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:message-id:date:to:from :dkim-signature; bh=Jmxq8pOlAwfl3F50eFuuzmJLrdIBBNFUSo2LQdUjDJU=; b=aaTbugD1yTh08LaKDtuBw+ck43eA0hW+viKMM/k5k8ca23iyX+IGf/unhtzfNARvEh dQ93JXA5JVEZobMqgxHEVx7WMBZS3zCE0xMCT7YpO56t+iF8OcjSpfDBA1I1AwBBhmUs fXIDNG/VqsPIpzvU5teN4l5+MnKTqRfOpHtul+k5OwPYVcvSlmXbMtlvcmTgihq3NWGe /070mZxlV4vWjIqOjbFz5ASvr95Hy9EN3N3o2BF9IQzzYUi70yVLAW2smu7Mpmm9NpKa kl0Pjqmd329LuQUe7L4a7LJV0udPDr9AY/NiMamSqNXfbD55oL9KLOnjG8cmskRIixK4 /rKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=R0gudha+; 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 p18si10240546eju.338.2019.05.14.12.20.28 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 14 May 2019 12:20:28 -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=R0gudha+; 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]:52957 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQcyR-0004k9-FU for patch@linaro.org; Tue, 14 May 2019 15:20:27 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48681) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQcv4-0002P0-KO for qemu-devel@nongnu.org; Tue, 14 May 2019 15:16:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQcv3-0006Wo-IG for qemu-devel@nongnu.org; Tue, 14 May 2019 15:16:58 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:38180) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hQcv3-0006Vj-B2 for qemu-devel@nongnu.org; Tue, 14 May 2019 15:16:57 -0400 Received: by mail-pf1-x441.google.com with SMTP id b76so5074pfb.5 for ; Tue, 14 May 2019 12:16:57 -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:mime-version :content-transfer-encoding; bh=Jmxq8pOlAwfl3F50eFuuzmJLrdIBBNFUSo2LQdUjDJU=; b=R0gudha+BWDi5tb4vB+mC0H86MENW7byMaalyOt05Ru/0nU5aEtzMv4rKOt4gFNn5k N939mNlMauI52C/VVignFzQ0YtCGQYBOgLUbUZ1cBlvVuY/p8HY9esmG45xtcQ+o8vn4 xtZa/TRp/U0fYGS54q6ZJdwE3J22YVOLtaTlvPdePsAQ/8IGtNOPlp400l4mrAP7uQAt JJ4JDkddH0AjGExzvdeqna6xOSznrZL0Lgia+ZjvIoF+OH3D+hHqWuAbn22DTEEnyNsr 6kVkqdOFjK/LkWt99rnP+To0O8izseEr65CMzyAt3fLFHrKWFAW8bGZzCopF0GuUUUT/ dEng== 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:mime-version :content-transfer-encoding; bh=Jmxq8pOlAwfl3F50eFuuzmJLrdIBBNFUSo2LQdUjDJU=; b=YTDcg2mCkDKssJPxnjwdvltj51cHnufy7jbU/hFaTpkPAjETfBPPKWsQuA6BStxOwW jWmZaHJ6s9ZYQb0qxOpMHveGCqKUZr3+26agd0aouzGolcH/j70XzQtSHw4hWshMXD8h OdyCKcxwTstBr+4wQuIrZorr8utp59T/QORgpbkq4GCCgTrpTOwY7hKcS4hgb20zQKI8 7TKsv8mqdgk3cHcYVaouE0VBBScIq/1Akz1xx3HDKtylfp+PZNhJuWY85LH6u8tSr2eY T+X1vcqyaqifOy3CLvF/EhJS27OWcYX2o21zS73vgMR9N8T8k8IW3NJVAp0vCRhnBfLl gNsg== X-Gm-Message-State: APjAAAWB/P3sSVd5hIUvGj+tCrMKQb2Wg5jiZTZVQT1ZhBmhysDGfaT5 mZp5ojsepaFgtgsui4rNROroCvnh7ks= X-Received: by 2002:a62:5b81:: with SMTP id p123mr43856746pfb.158.1557861415403; Tue, 14 May 2019 12:16:55 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id o6sm18682982pfa.88.2019.05.14.12.16.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 May 2019 12:16:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 14 May 2019 12:16:29 -0700 Message-Id: <20190514191653.31488-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::441 Subject: [Qemu-devel] [PATCH v7 00/24] 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: , Cc: lvivier@redhat.com, berrange@redhat.com, armbru@redhat.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Changes since v6: * Drop the crypto-obj-y, crypto-aes-obj-y, and configure changes. This fixes the regression visible in make check-unit, due to objects not being pulled in from libqemuutil.a. * Add a crypto-rng-obj-y, and force it to be random-platform.o. This avoids attempting to link the crypto libraries into the user-only binaries. Which in turn means we can drop all of the configure changes to cope with the crypto libraries not having the static libraries packaged by recent distros. 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 (24): build: Link user-only with crypto-rng-obj-y 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_random_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 | 6 +- Makefile.objs | 1 + Makefile.target | 3 +- 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 | 33 +++++---- 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 | 18 ++++- crypto/Makefile.objs | 1 + qemu-options.hx | 10 +++ util/Makefile.objs | 1 + 36 files changed, 566 insertions(+), 221 deletions(-) create mode 100644 include/qemu/guest-random.h create mode 100644 util/guest-random.c -- 2.17.1