From patchwork Fri May 10 17:30:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163931 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:142:0:0:0:0 with SMTP id j2csp2690977ilr; Fri, 10 May 2019 10:55:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqwdzo7XE/OnvJAOXGQB35GVhcpHSL9nHp/cZ1VZ4yLxIliiz9hkMcceaBU8S0si0cKXXQ9I X-Received: by 2002:a50:92a3:: with SMTP id k32mr12615530eda.123.1557510910518; Fri, 10 May 2019 10:55:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557510910; cv=none; d=google.com; s=arc-20160816; b=RjTD/op2Rft5xK7WQVHZeMS2cx+5giDJoz3EPxVhLh9zXHsCwbmL1bUkbb1lAWTzs8 i46gzchtlE6y8E3Hyps1YHoAc637c4kT7n1/YPq3rv9c7XD38RLMJNOJHnio3U31D/uO 0nRwzf0diOoKjcvh9cKJhK5VdVzpP52v4OXlJd3cJRU9dWRV3XkAwIAeQUkVJtojWHjX vxvKulKzM/IROSucE4MqRdnzmZG9osCD559EinaZf9rsCzDh3bunSfC3j77nR7hAKTP6 Z79vDY5YWSPJmm4BNwljYKF14fgAHa0shtHORytEITm4rZzoiU8jPfitrJh2+5Q4nHpN 8RJg== 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:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=U7V1DU2sIBLR4xyyuIblisrMELcV0ZOXk8BQM7uyeGA=; b=lUH3WDC1S4RQ5ozVWNbrYeaKRlRYKz5alP3bulctPcEQfkExvKmy/jErg002YmMzq5 w9E/8Mean2QpB1wmp/c09RPBUU0NdrxCYN1lTrRtiOBtnTDb2OSvjK09hl5+PYuehaWS +C+TQ+0JD2NYs9o6jud/P7HnbHtpsa3AG6Fjgd8wFNqpIb9ylDO01kGpLwvfIEu4bWCV to1dZUQA3o73GOL24FE3wo7qeLIlv+MlzlzdQY13obxxDU3l4pUKsHRdTFf6lV0uqtba U9z+yEvq/8Qx6SzXTnvzY+XmDb8IX6BHDSNDxXcMDXapYhBq6jyJsXuDNrpJE0kY+p1d yOcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=lLB+U6uj; 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 t12si3565147ejb.124.2019.05.10.10.55.10 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 10 May 2019 10:55:10 -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=lLB+U6uj; 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]:47848 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hP9jh-0005Bt-EY for patch@linaro.org; Fri, 10 May 2019 13:55:09 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59312) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hP9Mg-0007br-3A for qemu-devel@nongnu.org; Fri, 10 May 2019 13:31:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hP9Mf-0006EJ-48 for qemu-devel@nongnu.org; Fri, 10 May 2019 13:31:22 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:44200) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hP9Me-0006E7-UY for qemu-devel@nongnu.org; Fri, 10 May 2019 13:31:21 -0400 Received: by mail-pl1-x642.google.com with SMTP id d3so3130070plj.11 for ; Fri, 10 May 2019 10:31:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=U7V1DU2sIBLR4xyyuIblisrMELcV0ZOXk8BQM7uyeGA=; b=lLB+U6ujZVJ6L4XThI1HmZzsFwQkCilJF2kR0pCk0VB700ZOMTfW+27s5Lcr3dCz4o lUU7mlOdzzySUgVSVl6cJgm/3y/yoDVJdD+zgmYM/qwfqKWQVhYiWnbspflLxb3LQThX x2i32RAZncGat5Uw512Yv6XoK3sVBKo49XLawnjVvA0BFoDcT4qBkGDphdyb/cDcUJkm zH/0yTvkGHC0Qq5ujjkWa3K3+JBMLDVf6ERFuVfjFgMu6TR+JltjLkEhX3Bm+mmyFH6W epYmWhNCJFVi9ooIOVovD45qcxExbPAl8HQEPuWmHnFZmjmwuCIs5HuurcNmpPkIusDC Fk0A== 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:in-reply-to :references; bh=U7V1DU2sIBLR4xyyuIblisrMELcV0ZOXk8BQM7uyeGA=; b=t8mx7XkjJCRJRSdNNzlRxod4v6QMChokG1cd410aStSbm6DvNhZ5EeHRhThBlqw+d2 OOTn/G7uqXp3N494xONLzZWjKDpqrJ9YZGTb9UuFGi0dkSqwAe0rnhj6RV0QTNYF6cfy 0RspP6X1l7xfIGN8ZM6DqVyp1H+yKeSmHcaBh2BnTvxL1Iom9u8kytcEB64EwXzhen1B DngnHlsrbAF3r5MpZOXbaDQwcW+8O5xITFpo44OTgfFoN8LSYzA36LXRcfdkd5lPbdaY NEKtTZyBF5FtK7a0E+uh9J/IaG5RnF1abAV6m4UxGsgqeHuhJ4LpRjPh638Rl6s0XMSL Ex6w== X-Gm-Message-State: APjAAAU6znQBfIXyHn2QgAldJrAxaI+SbGCEFN7FcVbAM2RcsGRiysa4 +aoueLEhpbsq63c7FSxRiAXpsUHBRos= X-Received: by 2002:a17:902:2b87:: with SMTP id l7mr10116770plb.11.1557509479776; Fri, 10 May 2019 10:31:19 -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.31.18 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 May 2019 10:31:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 10 May 2019 10:30:47 -0700 Message-Id: <20190510173049.28171-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190510173049.28171-1-richard.henderson@linaro.org> References: <20190510173049.28171-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::642 Subject: [Qemu-devel] [PATCH v6 23/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: , 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 --- v5: Do not loop for darn64; use sizeof. --- 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;