From patchwork Tue Jan 30 08:30:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kirill A. Shutemov" X-Patchwork-Id: 194177 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1222481dyb; Tue, 30 Jan 2024 05:36:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IGhML0o92gFobubOTY3C7+HWm4dzmKPjtBqTY0Iua4Q02dQwe9ntzvg6F2W3t8f/qe9y/ZE X-Received: by 2002:a17:906:f2d6:b0:a31:5941:4f7 with SMTP id gz22-20020a170906f2d600b00a31594104f7mr6296141ejb.39.1706621782437; Tue, 30 Jan 2024 05:36:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706621782; cv=pass; d=google.com; s=arc-20160816; b=uP8zK8NJfPoxfLQ8nJhoeAadJVAdMETnwP2oC8ol6wO6aKq0zTAZ7BrOAIvE6/5BRo cCAQJnegq/I5J2yJlOXv3XRi7NPb4b4o/2ga+AcmMLcY0x5+Fhkdv3dwezFlkrbd4jCR ARvV9k0hzm0fDDOpFNBnLL2Car+bJyaeXel+z+QfvJvHjIUJpiWOvEJOyr/4HW1jwp0u E+F6+uTwVibPB/lhdD5Lzf29S64LzQpVPINxgP6EkceyZxGhAFi4fiGLuiMqubPyP9w7 myL1I9QX0PCloyjS5lHQJ8OuoV0N15VwZNsPYNcGpz9UeoV4+pEfxAhw8A+nr0GNegfJ TTqQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=q1U0xxr7NbDQ1APeZApOThkxr40MUek3YuM/FrkqZvU=; fh=ODt9kxcTNWB7X1EmolPcmJdx0Rxj6DM5rRkwFDfN79c=; b=YBRIXW+i+3/7ws5/hHxgBW3Vv+eVoRuzOx9UnEH4P8xFn9gOrzSKsDj52Ot05TQUmf boWL+CHUS2bdVA2FT+8vh2AkehdxFa9m/Ove59lORCwtXv2vnJ3AUci1Pq4D4Yu7+fLU 1JqWty9O4oit4Y3zKF2hatwPvYp7qVVlGHm5B3lMzx+BjfBRZw4+qktnr2Nrov1f/cNw UIjXIdGtEaKXZ6bkf0BaYWqvPG8LLalmc+NifofC9JyFQBFQvPlzg7u67Dj+BoNAVBXK bnU5UCVpY57tC7DqqNHsihLWU0QTgUPiKWiqrJXAknJSPByhcRiDBJlto0U1BnyeQXf3 6tAw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="W/e4fGrO"; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-44136-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44136-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id bl23-20020a170906c25700b00a35a69ff2a2si2148745ejb.864.2024.01.30.05.36.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 05:36:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-44136-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="W/e4fGrO"; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-44136-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44136-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 5DA911F24B84 for ; Tue, 30 Jan 2024 08:31:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E405757881; Tue, 30 Jan 2024 08:30:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="W/e4fGrO" Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 80BF41E52C for ; Tue, 30 Jan 2024 08:30:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=134.134.136.31 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706603457; cv=none; b=TWnaD69fo2seLR77TK1FfGMVq8nsxJhI3WIFY2Ayf3DYgvIa0ZN/3sZVw7lkypkFZx1IZCXGUdBPKc41tSasXB4T6JrD4HsIZYPAh0fZx2xKUtoiEk3fbj4sJFLpKPnlUqjHUfv0c1Xv6BokHQapI6Bmuw/m+EtwXpruUtkVyqg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706603457; c=relaxed/simple; bh=bboqiXpspNty+IUr75AIb5o8t24UN3eTB7gE/wxTugU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=pVyfO9DK+tFLFMt1QRtp5QIO3Zdoa6v70vxakR+bTRBorhixEaoxWL2VopVuLOFhUW50fj2+U7lh7UeabAOnEh34Rhulv0P/pmrpUYnf0yhCC0pncQdzb68B0yXCv9s1i/Cmm9ib1Rph8askSF0EPidIEyPHmsvi9Etuqb9fTcY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.helo=mgamail.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=W/e4fGrO; arc=none smtp.client-ip=134.134.136.31 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.helo=mgamail.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706603455; x=1738139455; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=bboqiXpspNty+IUr75AIb5o8t24UN3eTB7gE/wxTugU=; b=W/e4fGrOycPonf5ZB6fkIRXhcv4JHn4gKUHXqvzVih9cnrDoSp/zrr9F O7deKy+fFG0GtAH5mCl5VI9n0NnlRMuXW8QBf5dJylzJd3NQ5UJGtOcU8 PVH84BJ245h6jqMIOm9OSYdWpL0D0Sb0yol61x3iVd2+pxqgc1xiFFCIJ QAo6+0dpS2hOIXKaW5drqlmo81gbrLY0y8kzRxLmoCYlJPsmtztQnK0bi 66Ik8utqNG8za/qZv0UBGt5+5WEZHeM06viCsqkTk8/51kewlDBF8bxLi xocIwiae3fZDJxpjp0R7UO6e5UYVdkRsE9heH6OzyXatZIgKRH4FviVc3 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10968"; a="467464323" X-IronPort-AV: E=Sophos;i="6.05,707,1701158400"; d="scan'208";a="467464323" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jan 2024 00:30:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10968"; a="822120351" X-IronPort-AV: E=Sophos;i="6.05,707,1701158400"; d="scan'208";a="822120351" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga001.jf.intel.com with ESMTP; 30 Jan 2024 00:30:13 -0800 Received: by black.fi.intel.com (Postfix, from userid 1000) id 751D5DE; Tue, 30 Jan 2024 10:30:12 +0200 (EET) From: "Kirill A. Shutemov" To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , x86@kernel.org, "Theodore Ts'o" , "Jason A. Donenfeld" Cc: Kuppuswamy Sathyanarayanan , Elena Reshetova , Jun Nakajima , Tom Lendacky , "Kalra, Ashish" , Sean Christopherson , linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" Subject: [PATCH 1/2] x86/random: Retry on RDSEED failure Date: Tue, 30 Jan 2024 10:30:06 +0200 Message-ID: <20240130083007.1876787-1-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789518447278626787 X-GMAIL-MSGID: 1789522642077369852 The function rdrand_long() retries 10 times before returning failure to the caller. On the other hand, rdseed_long() gives up on the first failure. According to the Intel SDM, both instructions should follow the same retry approach. This information can be found in the section titled "Random Number Generator Instructions". To align the behavior of rdseed_long() with rdrand_long(), it should be modified to retry 10 times before giving up. Signed-off-by: Kirill A. Shutemov Reviewed-by: Kuppuswamy Sathyanarayanan --- arch/x86/include/asm/archrandom.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/archrandom.h b/arch/x86/include/asm/archrandom.h index 02bae8e0758b..918c5880de9e 100644 --- a/arch/x86/include/asm/archrandom.h +++ b/arch/x86/include/asm/archrandom.h @@ -33,11 +33,19 @@ static inline bool __must_check rdrand_long(unsigned long *v) static inline bool __must_check rdseed_long(unsigned long *v) { + unsigned int retry = RDRAND_RETRY_LOOPS; bool ok; - asm volatile("rdseed %[out]" - CC_SET(c) - : CC_OUT(c) (ok), [out] "=r" (*v)); - return ok; + + do { + asm volatile("rdseed %[out]" + CC_SET(c) + : CC_OUT(c) (ok), [out] "=r" (*v)); + + if (ok) + return true; + } while (--retry); + + return false; } /* From patchwork Tue Jan 30 08:30:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kirill A. Shutemov" X-Patchwork-Id: 194065 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1180873dyb; Tue, 30 Jan 2024 04:24:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IHSTviFkB8ekuxjHOM3a/DaOxo6hmBruuDxDeI9KMH0kkbfr+QnFH/u6VQLoVc/CjGZ028n X-Received: by 2002:a05:6a21:9208:b0:19c:5651:adc1 with SMTP id tl8-20020a056a21920800b0019c5651adc1mr9492896pzb.38.1706617443346; Tue, 30 Jan 2024 04:24:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706617443; cv=pass; d=google.com; s=arc-20160816; b=KyrftwFRZ1aqnZa4pB0LpKDhTMsO/gzJo5abkXBs4NyFsL/4rzv0CN9QDFgyo6eKn6 wGRw+KCNd/FDEmU+Gfy49b+gEpdszIZg+xleI1cU2+YQ542vMAxp4QOzbexkXwfjs8bH 6tESPPh3Vd6KrvPPcsR6ZU8AoRV9dwEwWLhe2G0c6N7U4ILa187oXqoVU0Ee6u4Fw56L hR+cSumTC+eWk8LoReVd4YapqUgE6EdFi+GGsUyf10egRzZmykFdbrd0e4xcE3x5zMBx Om3RYLSoayW4bt3mSC8KaNZKkIBJJMB5skxsnmaMmrKmjnbMqx9YYrYMVcZaJGRWaDIu zDCg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=g9Gg7GOC7ceT8fJCI8ET/aa/MNX+stJNIpevBzV6luA=; fh=ODt9kxcTNWB7X1EmolPcmJdx0Rxj6DM5rRkwFDfN79c=; b=O5jYLzwXdadZRPhcNe6O8MW+d1IKl46my1kXVD+Dn5MXZPXpocC1LHafdIuJ0fu2Yo QxyKy1iVX2S4Q2bm92VRMhPxOOAdhA6GNWXMOv1YvRkQ4N5xnSiAT/dyKulJ6cT2WGY2 ztNjD/csOTjcOUbVIr+h5chVGl/BbfsSTtMdrJ/oyVJQHwQTu9hDrtruDjkCm6EmJbMn 9fUdRgIfbgfI9e7ZWu6d3jaFP+vrJ1OA9Xl2DCG3mt8Sy85cUr5wI5Fx3IL0oFybkUwI oQ8KVXaKLA9dhENMpoAuRn37tMTIw1j/OXk0/dPllnGrnJmI3fGHkPQQuWsTR9Ji1wQR hp9A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TNME18jA; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-44137-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44137-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id q6-20020aa79826000000b006dd9213a323si7425497pfl.333.2024.01.30.04.24.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 04:24:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-44137-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TNME18jA; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-44137-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44137-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 1E259289E55 for ; Tue, 30 Jan 2024 08:31:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A570058108; Tue, 30 Jan 2024 08:31:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="TNME18jA" Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BDAE633CE5 for ; Tue, 30 Jan 2024 08:30:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=134.134.136.31 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706603458; cv=none; b=CUbG8FLsGRSTTkSBbK/UHLmFao4/hsKRbT6Y9/6GKhsumN2dp980qa7UNt5wUn8doY/YIfkxyrDOgZFN1/UguUqCg+o1BTKeHOJhDZ8jDmg1482moV/17HI/XUXLe1RH021nUoIlOpdHTT9f/+/uukl2rsXXLwKJnEcBjfShGCI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706603458; c=relaxed/simple; bh=AwZwJ5cYVLV4jd8F8avXy7jN4r8TxDP5NN7KpZbNqJY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mrNikCBxuNuNg9x+qU57TAi9ShvJeFeuzIQzpCn6zRcaWcHO1dhkUApnLUVqIsUoI07T86U2S2dGNaBq2cBD1e9m3I0RUjsKbp15TgShcZJbkJlwID8lXf9ElGvSUfpzU2UspKSEVF0gYydJXfz3Le/x+3cPFYM8sIFkTgPEySQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.helo=mgamail.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=TNME18jA; arc=none smtp.client-ip=134.134.136.31 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.helo=mgamail.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706603455; x=1738139455; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AwZwJ5cYVLV4jd8F8avXy7jN4r8TxDP5NN7KpZbNqJY=; b=TNME18jATKnZBMKyxYHwkR7Y/H06oinPcSuEtyjCzxYuScMTBO1cEQfQ AnLBb/JGfqas6gAMN0DCjkfnR+dbRSiyLkaB3TRtdthL87NgCPXICG4e1 YE2dxl1gwOXsetIKTlYkTY/eIXucdOeqHHYnctpu/CLOhgkP2pXCBubR/ /N9ERVF9Q+HOm1n9fy2/rmQpHiz+1LY0GH3+M3QYgAFpKAt/6Z8ZS3ODC F5cI4LLIWqj93nAEjT+TVMlVDdpw5wMGNTClauYcFb+Qxpq1aTwcBCgFW KkuHEhVYi7SgAqACIs8awSP34+QeIi8uwAy72Ed4ITvGLi81LMjZYJl8U w==; X-IronPort-AV: E=McAfee;i="6600,9927,10968"; a="467464334" X-IronPort-AV: E=Sophos;i="6.05,707,1701158400"; d="scan'208";a="467464334" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jan 2024 00:30:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10968"; a="822120353" X-IronPort-AV: E=Sophos;i="6.05,707,1701158400"; d="scan'208";a="822120353" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga001.jf.intel.com with ESMTP; 30 Jan 2024 00:30:13 -0800 Received: by black.fi.intel.com (Postfix, from userid 1000) id 81FFBB8; Tue, 30 Jan 2024 10:30:12 +0200 (EET) From: "Kirill A. Shutemov" To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , x86@kernel.org, "Theodore Ts'o" , "Jason A. Donenfeld" Cc: Kuppuswamy Sathyanarayanan , Elena Reshetova , Jun Nakajima , Tom Lendacky , "Kalra, Ashish" , Sean Christopherson , linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" Subject: [PATCH 2/2] x86/random: Issue a warning if RDRAND or RDSEED fails Date: Tue, 30 Jan 2024 10:30:07 +0200 Message-ID: <20240130083007.1876787-2-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240130083007.1876787-1-kirill.shutemov@linux.intel.com> References: <20240130083007.1876787-1-kirill.shutemov@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789518092425050511 X-GMAIL-MSGID: 1789518092425050511 RDRAND and RDSEED instructions rarely fail. Ten retries should be sufficient to account for occasional failures. If the instruction fails more than ten times, it is likely that the hardware is broken or someone is attempting to exceed the rate at which the random number generator hardware can provide random numbers. Issue a warning if ten retries were not enough. Signed-off-by: Kirill A. Shutemov --- arch/x86/include/asm/archrandom.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/x86/include/asm/archrandom.h b/arch/x86/include/asm/archrandom.h index 918c5880de9e..fc8d837fb3b9 100644 --- a/arch/x86/include/asm/archrandom.h +++ b/arch/x86/include/asm/archrandom.h @@ -13,6 +13,12 @@ #include #include +#ifdef KASLR_COMPRESSED_BOOT +#define rd_warn(msg) warn(msg) +#else +#define rd_warn(msg) WARN_ONCE(1, msg) +#endif + #define RDRAND_RETRY_LOOPS 10 /* Unconditional execution of RDRAND and RDSEED */ @@ -28,6 +34,9 @@ static inline bool __must_check rdrand_long(unsigned long *v) if (ok) return true; } while (--retry); + + rd_warn("RDRAND failed\n"); + return false; } @@ -45,6 +54,8 @@ static inline bool __must_check rdseed_long(unsigned long *v) return true; } while (--retry); + rd_warn("RDSEED failed\n"); + return false; }