From patchwork Fri May 17 02:39:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164378 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1611335ili; Thu, 16 May 2019 19:56:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqzYPZDJkrQiEDCn6o9h1uCeFEtnV6hoBvMbeSpafWqRIo0jsv6fP8mYP6AN5ljHx/ZR6BQU X-Received: by 2002:a05:6402:1610:: with SMTP id f16mr55106982edv.171.1558061803791; Thu, 16 May 2019 19:56:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558061803; cv=none; d=google.com; s=arc-20160816; b=FNxDT9PKmR+YphfvV2u7j3+6uUmyP26SaiRTQ90/aUy8DzDcLGjpCNXTVVWIitGC5Q 9nreeh8JxWIdaL469IYFR0wxESt+6Tn30/M+9v2V8jEJJPYY/XpucGU4no77l1bGR6J7 BA1R4+hjvbsNWjX5938RiPjSTW3CAVR60nsV4pu7qn+0DBlWoTsLFNMpinjFL513eZV9 Axsgt+F2b1iQlYDrEbHQcVcAZJ8TjQ6TTyrepEDQCitrnoQ361gO1gbaniFBHLax3mtT mP9Vsz7ZEZMgoWy/eN+882HErfglWZOm0oA7yWv4G9VmTFk/FNu2NMdfUgUiMVL1Aa3P lcjw== 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=rGrqjmaWjR9xTZkB9PgD2aBBVwPIwfF1sCI4kVh00x0lQRTMbxxxukB8KAEAhJbpUN q41Ebm/ySnlPkEVi4YF6im0/zwlsWXoa85EWvgQQ+/ux4CQ4IrHlkrpnLeFw+797ztVv JhFsAjmmBm4FF0G0lN+c26EuuxkrEc1Xcr+Zoft7zYbLnowMQL7sKlgcLQb6ojKZK+Vu AMotp3+3eGP4FAdnENsRY4QzkZojM1/S9NF+898oL0gEWDubgn1h1tXY8cskaRK4w3o+ Hf2B3S57RCWb+Z4uiOPmMxmZRXJ+kKEzzPGixv4AKi1F08UbM3vBZZwhQFj+GbtxXCMX gvkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=HqnN2aDQ; 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 o5si4933562ejh.34.2019.05.16.19.56.43 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 16 May 2019 19:56:43 -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=HqnN2aDQ; 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]:40347 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRT34-0002MF-P8 for patch@linaro.org; Thu, 16 May 2019 22:56:42 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39204) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRSn7-0005y9-Vc for qemu-devel@nongnu.org; Thu, 16 May 2019 22:40:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hRSmz-0002Hm-PW for qemu-devel@nongnu.org; Thu, 16 May 2019 22:40:10 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:43695) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hRSmv-0002E9-6F for qemu-devel@nongnu.org; Thu, 16 May 2019 22:40:02 -0400 Received: by mail-pf1-x444.google.com with SMTP id c6so2857759pfa.10 for ; Thu, 16 May 2019 19:39: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:in-reply-to:references; bh=bpjcbv60JSWpD1TbbxFv9kSVFeLonJbRE1N/VVDdCYY=; b=HqnN2aDQgiFqND352ve6KVLTaO4Q9XVPo7FXMkHVE1WdPJ9RBrME/+ujRRC+5mD4Gl yQb0yvKmninXLieoV5nYWKMq7w3iCbjq5nZECfsfnuQxGnoirZothbRwXt2xkf8L1Pej 7FASrYglahBrOJ511wPIIdA/AzVxVr1VlpY7hoTw5Frwxi5hQmUfmZAGsZQSVjRGkRTK xSCey+7Qn4PwNlgmdcc/WpJIOzeLB5F0DEdWru25r1lp+9STa3paYjxuSTDgHoH9YbsB w2kSdkS5R5jkkiY/X+t6SHNoT7WTBZkLeedOejqwXsD1Iw2p7sros9qNCe5BEZ8vq0e8 7Zew== 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=DNIfeGP0g2E46ihkOIobI9WdkgMTFYV5qcjAXa7+A1I81s0afhJH4/daDI0oEBPMV7 HHMI31SbQXPCS3Gj3k6aJ1Ox73WyEnkaA2ovu7sr8zxS47gxmPwFLUf9d5lypkG6W4ep RBa1DqKuz76Lb4JZPSa0CVkZRHn2oqgUEWHo5o3bV51KDdy9uK/KW3zbaUEEwBYSgdS5 emcWZcqj17ZZHv71zal+chXPHTI/YLpcXEf35uXOH+qkeKVrDqE3oFrLccAtykVB7SIC ojc7FQVGRARQ/Nj/nxLv/78ls+FEH2ppNsL4ZufEjzha7DGH6AtEzhBoYG+lmzO+eqoF CLuA== X-Gm-Message-State: APjAAAXcTzyL1sczLwOdr/OhomVr2+IJmHvfTfgltDz3DvggfDpp0fvL NV44T6D7tXAntv3wTkPOECKkbQAvL00= X-Received: by 2002:a65:5086:: with SMTP id r6mr54706673pgp.301.1558060796081; Thu, 16 May 2019 19:39:56 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id w6sm6984152pge.30.2019.05.16.19.39.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 May 2019 19:39:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 16 May 2019 19:39:23 -0700 Message-Id: <20190517023924.1686-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190517023924.1686-1-richard.henderson@linaro.org> References: <20190517023924.1686-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::444 Subject: [Qemu-devel] [PATCH v8 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: lvivier@redhat.com, berrange@redhat.com, armbru@redhat.com 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;