From patchwork Wed May 22 18:42:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164860 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1223071ili; Wed, 22 May 2019 11:59:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqyMY9zJmk2NTBNLoJwDTJVlSx3NfdYneV62v/+M6492xDz4A3UcCSD1RuzFUFPmpNm/dmiX X-Received: by 2002:a50:d717:: with SMTP id t23mr35242167edi.248.1558551542533; Wed, 22 May 2019 11:59:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558551542; cv=none; d=google.com; s=arc-20160816; b=WnDU7q2eNeogwd5yFG6qptp9zoJDEIQIROOARhzHj4FqIA5pNImA1bucTcO1BjG4Wu 8u7n0aJI0FfoVX60feA+apJBZcsS56jKDTjC+ABqJ9bIEW5tajwsKz54Ljzi4DGCpn/+ lWuVn5XNhsnwUW0QFx1pbz1z3XU3kbioEK9x6IiIj+PTrJv733kwyeWdNVGkAKtGAGdU aykCQvhf7KK3laXoj/+80tuV4m5phft0o3wp1K+QGbVUiW9aIbMlZt3JQfzAHlf91YFv oVonX1A8UPmfSJih/ZeeOk09bzQUnqx2EJHqZMCVfRC9TmXC7RnIdpM/puW/HSg76DJX Ds/g== 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:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=bpjcbv60JSWpD1TbbxFv9kSVFeLonJbRE1N/VVDdCYY=; b=JUL7J18Xe7WiJFQvayfbTVzVb0VV3mcrakSFzteDPqsad98Dv6Xol3vtjFo9YLajqv jST17NKRV0TbdMWEiyE+berUDxLxAnUfeRUhdy9F7MXxDevjgDDkFiQNFHoizdn8WLlv PnyCIztOxpTJqgKbttIzY9zaa9+kasrf4hT+p96Mp+jAbOR+Gp8oi+eTtq21S25sQQ6i UvmxKep5lrgJ0qGnt5UaqtIhJij0keA3kmJNq7P5HN8h/xULkZ5J1pso17FagDxIpMKP VsAOCHWKPFpIBxCziIgkyC02ISoCXff9yDYjVTZ3pqLZ0rDrQkx9wz224sx+7d4Ar9Zu ms1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=obXPQmve; 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 t10si6797370eju.219.2019.05.22.11.59.02 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 22 May 2019 11:59:02 -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=obXPQmve; 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]:49671 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTWS5-000318-FX for patch@linaro.org; Wed, 22 May 2019 14:59:01 -0400 Received: from eggs.gnu.org ([209.51.188.92]:35158) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTWOm-0008Lh-RQ for qemu-devel@nongnu.org; Wed, 22 May 2019 14:55:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hTWCU-0008Cz-NV for qemu-devel@nongnu.org; Wed, 22 May 2019 14:42:55 -0400 Received: from mail-yw1-xc2a.google.com ([2607:f8b0:4864:20::c2a]:44152) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hTWCU-0008Cn-JK for qemu-devel@nongnu.org; Wed, 22 May 2019 14:42:54 -0400 Received: by mail-yw1-xc2a.google.com with SMTP id e74so1232055ywe.11 for ; Wed, 22 May 2019 11:42:54 -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; bh=bpjcbv60JSWpD1TbbxFv9kSVFeLonJbRE1N/VVDdCYY=; b=obXPQmveNKyNSXpvyCvQgGuL84HmN38d+ocQ4xu6Hy01Ako0r2YNybJi3sRWYgL+L+ vwdcq9wugcF7ZN1vN1Sro1ztACdStOwROqJYX5n9Kx7PHT3tne4Pm6I5qJnq4fuAW7eX 8syO7oe2HUAdAHIFe+fNyMGHHtU1vUpDVZmeYHB6O/oU8H/oUlro/vl+A8GGP7KZk4DI Z+vu0eg9D42r5+pS6S1fPUTUDu1RfDNTZAGf+ttHjebL1EpUNAO0RT9OS7RQDDNRwo6H ycmRoNuq3sRHPNsovVxSMUSJbQ9Gr50NTbAIc4zSH1otjeUSzHPPJoHRmVMoOayrI0/T Remg== 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; bh=bpjcbv60JSWpD1TbbxFv9kSVFeLonJbRE1N/VVDdCYY=; b=a0eCcq1tzvUHZKRmTvBR9v28no1C1mx8aa3bDZUuozTsjq8rSe+DYDZ64JDk0RB4rJ 31areLsoRuOF1pzdGvCdFRMcjM8SrRDx1HhrbN0jKoAfGcfPdoj3qUaxU/4bn3oedsFh Beg0XV5Z1NXkuTxUCQ9VNhDfQf4+uvnEm+JoxwOY8pD9WGtPabBpJQW6aYegZFMzBKqa e/Ls1sUTbuJav7ezN42anCbNHii6k9d6OlNT1jjEgh3GU81/a+ehf8LFd1S2ohMihou8 PKfIhxUyBUapMfQ2JLWYc00sg9FL+pVnYt2K2hxOTs8aZKK4ER90hf2xNDY9fw+/gTvf Xd7g== X-Gm-Message-State: APjAAAWDjyBTDqA2+/nAPevy8vDPYPyB5qOPCbovTEyXFSL379oothyI 63JFYN31IXVa00IqWD/zgZwXxu+TkIo= X-Received: by 2002:a81:924f:: with SMTP id j76mr40316861ywg.199.1558550573715; Wed, 22 May 2019 11:42:53 -0700 (PDT) Received: from localhost.localdomain ([71.46.56.17]) by smtp.gmail.com with ESMTPSA id 206sm1299445ywq.74.2019.05.22.11.42.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 May 2019 11:42:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 22 May 2019 14:42:25 -0400 Message-Id: <20190522184226.17871-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190522184226.17871-1-richard.henderson@linaro.org> References: <20190522184226.17871-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::c2a Subject: [Qemu-devel] [PULL 24/25] target/ppc: Use qemu_guest_getrandom for DARN 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: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We now have an interface for guest visible random numbers. Acked-by: David Gibson Reviewed-by: Laurent Vivier Signed-off-by: Richard Henderson --- target/ppc/int_helper.c | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) -- 2.17.1 diff --git a/target/ppc/int_helper.c b/target/ppc/int_helper.c index f6a088ac08..9af779ad38 100644 --- a/target/ppc/int_helper.c +++ b/target/ppc/int_helper.c @@ -23,6 +23,8 @@ #include "exec/helper-proto.h" #include "crypto/aes.h" #include "fpu/softfloat.h" +#include "qapi/error.h" +#include "qemu/guest-random.h" #include "helper_regs.h" /*****************************************************************************/ @@ -158,25 +160,38 @@ uint32_t helper_cmpeqb(target_ulong ra, target_ulong rb) #undef hasvalue /* - * Return invalid random number. - * - * FIXME: Add rng backend or other mechanism to get cryptographically suitable - * random number + * Return a random number. */ -target_ulong helper_darn32(void) +uint64_t helper_darn32(void) { - return -1; + Error *err = NULL; + uint32_t ret; + + if (qemu_guest_getrandom(&ret, sizeof(ret), &err) < 0) { + qemu_log_mask(LOG_UNIMP, "darn: Crypto failure: %s", + error_get_pretty(err)); + error_free(err); + return -1; + } + + return ret; } -target_ulong helper_darn64(void) +uint64_t helper_darn64(void) { - return -1; + Error *err = NULL; + uint64_t ret; + + if (qemu_guest_getrandom(&ret, sizeof(ret), &err) < 0) { + qemu_log_mask(LOG_UNIMP, "darn: Crypto failure: %s", + error_get_pretty(err)); + error_free(err); + return -1; + } + + return ret; } -#endif - -#if defined(TARGET_PPC64) - uint64_t helper_bpermd(uint64_t rs, uint64_t rb) { int i;