From patchwork Thu Mar 14 04:55:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 160294 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp15077997jad; Wed, 13 Mar 2019 22:05:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqwvkROB5vWoXORCurbSI1C7o4dz2PDSjBGpfsD0mUeZG4VfvQzf1bbvrhh7ScwY+HPBgJQb X-Received: by 2002:a25:9101:: with SMTP id v1mr40395576ybl.20.1552539908371; Wed, 13 Mar 2019 22:05:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552539908; cv=none; d=google.com; s=arc-20160816; b=ItXPFv5vnb/nz0PBmfIdyC/yvhLCmsP+G6lHf9OOll35Jf60Tr19db+uUY76d8SNy7 +0o/e7mbIgQWbsVvzhOEQEbsYeodY1tgl2YGnsHepC6i+QLPxO9Pbt2GgLEWpMTTl7K1 pMx0uWYJEieR4EGLpAPPV0IbOO8FseFjNfUVF1956yxFpntUoWbXCxUtnVAfdZjyBbl6 moviAhC8GHzOMdeV8uq1mWfZLVzG95PhfprN9CvOiEWWia+ZiuIoJMYr+8ivnBkoyXKp fgOUrB9z8/XgVngJchJQyj4dkgUajtcodI/ELE6gFHk4X/gDoHhwjU5UsdBMLcEefUjU bq9A== 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=I39zQahYJfO4v9BtHWnWSXDEM3G+gAshBbiSOHHVUzY=; b=sYOokG1M0zCKG1eaIvM5rBG2ukTfnrO3FFIcyUrazrYU+N/clqHnwTw+Q6a+4JTdJx SS+qOu1AFIFZlss+b5TbA2ntRXjf/OoA8cTQgTa6rUGXJGpyK/Npix8abph/pqnOIND/ xuPF8r35q/BmD6LoOku0IrMlVrm0mpMpLc7GTAY1HM3thg4L2P0QPrwJEiesaCGRQaFC DIiV9mGxw+CBw89LT79/WiqENOOJv3h900LzkJ0r3tF+KJ5lz79BTeDu4skvRTeASwy8 +cvxxKF6sofOiwe73bSx3lBNXAwpUb+l6+GLopyAOhM5kVQ2Aye9AOmyX2ziSQY8i+ak pptA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=c4zxkyFc; 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 123si8063178yws.279.2019.03.13.22.05.08 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 13 Mar 2019 22:05:08 -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=c4zxkyFc; 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]:56955 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h4IYF-0002uu-Tp for patch@linaro.org; Thu, 14 Mar 2019 01:05:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:56245) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h4IPB-0004ak-F9 for qemu-devel@nongnu.org; Thu, 14 Mar 2019 00:55:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h4IPA-0007Rt-GH for qemu-devel@nongnu.org; Thu, 14 Mar 2019 00:55:45 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:33575) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h4IPA-0007RP-7D for qemu-devel@nongnu.org; Thu, 14 Mar 2019 00:55:44 -0400 Received: by mail-pg1-x542.google.com with SMTP id h11so3168991pgl.0 for ; Wed, 13 Mar 2019 21:55:44 -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=I39zQahYJfO4v9BtHWnWSXDEM3G+gAshBbiSOHHVUzY=; b=c4zxkyFcR1EPcjyQUpS85K+hU1gkfAYx9NGMRqQyEC1y1uwU0Ao9Y5MVCSLZorrX6O +gcPAGlmHwsjYSzuEBZDM4A/CzZOdz8a8EPMdoCEYE1TntJsxoFyYLdlwe2aSrPGnFeW PQm8iNoCQpi+MQCFtWNMTvGnSKiRFCnktTjohAOCV3fTgdoMcW1qLbbHYSvkofJyXM1V 1JlJac2v6WluNjf1ywbdMOOCHhlnCOy/HrrOVeAGihrvbxOB1ISB6aZiXeLtmU66bxdc pPXGNUb8TGdlxn+8BL6zOCzxcoYWdW4dQjFASgfLqEROmtmzYMUlqKJ33OaUAjOXixIP q5VA== 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=I39zQahYJfO4v9BtHWnWSXDEM3G+gAshBbiSOHHVUzY=; b=D1mNJttzGOc2eZIjSPZZe+8wMwqtZP1jtlrxYNDblv5R6bo6QF+hTpqDHhM/hdEliM S81XDjJL8fFT31gPGIl0e3tiAikQzrLFUciJwN6vOsY0hfvOBGT45vrUIT5pSCgZTEpj WZVfjNJuEsPqi1w8/vH7L8RnS4g+nerQRcvTJn7zMNgPF+a86kNBosHoaiGW73zNuLdW orn3eXncDDKEbjGkifGzCotRU0HVOlWV78Dv07MNj8UV4Ua+rUdhqYWVuDOrL2UPx9+m IiqEe5ZltzH/b22ahnHC0YQrH7HEKtm74YZvX8kae/yTiTng1UAUyep3m8c9ytd6VUe4 Mp0A== X-Gm-Message-State: APjAAAX2Z/oZ74GBpATaA9/HWWHMfi4KukK6Wj9Cmc2SXUx4WLCyoKQL rn2gpVyLNwkaMh9f5sOTgUootIEtzHo= X-Received: by 2002:a17:902:6b47:: with SMTP id g7mr50367586plt.100.1552539342964; Wed, 13 Mar 2019 21:55:42 -0700 (PDT) Received: from localhost.localdomain (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id d9sm16185027pgq.6.2019.03.13.21.55.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Mar 2019 21:55:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 13 Mar 2019 21:55:24 -0700 Message-Id: <20190314045526.13342-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190314045526.13342-1-richard.henderson@linaro.org> References: <20190314045526.13342-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::542 Subject: [Qemu-devel] [PATCH v2 12/14] linux-user/aarch64: Use qemu_getrandom for arm_init_pauth_key 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 , Laurent Vivier Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Use a better interface for random numbers than rand * 3. Cc: Laurent Vivier Cc: Peter Maydell Signed-off-by: Richard Henderson --- linux-user/aarch64/cpu_loop.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) -- 2.17.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c index d75fd9d3e2..ad30cab52d 100644 --- a/linux-user/aarch64/cpu_loop.c +++ b/linux-user/aarch64/cpu_loop.c @@ -20,6 +20,7 @@ #include "qemu/osdep.h" #include "qemu.h" #include "cpu_loop-common.h" +#include "qemu/random.h" #define get_user_code_u32(x, gaddr, env) \ ({ abi_long __r = get_user_u32((x), (gaddr)); \ @@ -147,22 +148,9 @@ void cpu_loop(CPUARMState *env) } } -static uint64_t arm_rand64(void) -{ - int shift = 64 - clz64(RAND_MAX); - int i, n = 64 / shift + (64 % shift != 0); - uint64_t ret = 0; - - for (i = 0; i < n; i++) { - ret = (ret << shift) | rand(); - } - return ret; -} - void arm_init_pauth_key(ARMPACKey *key) { - key->lo = arm_rand64(); - key->hi = arm_rand64(); + qemu_getrandom(key, sizeof(*key), false); } void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)