Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1301711rdb; Tue, 30 Jan 2024 14:26:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IFxAFNDCXwaE+Hudztst/C85i3nnuHq+R4UXFN7604DGo3tEAl4Xj8TLkSC3FaTuH8psEUh X-Received: by 2002:a17:906:ca59:b0:a36:598b:e291 with SMTP id jx25-20020a170906ca5900b00a36598be291mr623291ejb.26.1706653578107; Tue, 30 Jan 2024 14:26:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706653578; cv=pass; d=google.com; s=arc-20160816; b=TO3BodoSXXPPJ8HY6tSHYv7afs73mGQwOqTYV8+zgd5Dt1bQ8m+wm4nQFyza/D2Oa5 kpdrbIlYtFtf/bSLKlRah08uWKLN7YNB5kJFhs1aQCeNM/ajEjeuZh3yFnMnkavUkfNt rMvN8AwzMP5NvdeGLPiqOyFuLMzKupOwMvHW1wrcmSD2wAkDvgK60/9g21LfUX34kanQ zHO/+lYk/OKz/yUbyPxdcLEmdDjQLqIforvjtIP+RtS6sdIwACxrHNSBdOD9UY8y3c2Z oUnVGVwKaTWgGtpD8ZWTbY06llzZvcbMzOpXjdjLze3QEGfvJpuMDKqtUqnlT+j2PV/t 5cXQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=OmKXw7+iY1nFCBFRgz7EQsnDLv0++W41b6LiWuQlMVE=; fh=qF//TTtsqcyDaVt1QIk6ERa2vYI7s0ae5Pj/TFfLls0=; b=gdUIFH/NzkV4eRTekHnw7Ugq0J46YsgunwZ1+LL7lZSfB9H9RV3MVymbEgRXQ9ypgy qhqmXdReM8E+kC5FKvfIOINu531Xu7AYc7s3Xwgj/+Xi2PnMhE40UepBEKJZvXRkF8PB gwKpqJE2iIjItPn/pq8EWX/oeHJx9kk2IgQFEwtjPKPDW6TFtbFUakCoZwClG4MbieX5 cuePFBOrFeOrFejt7hOKeUquYxrsr6UqWNzPYJE6TxnSRmdnDX7je9MYfMAxlA7HKxLv awvBuWx4nrE+GuiHaiGHeh3EQIhJt4OUo+BW4+qPMImsGIl1TXB1WkoAey/fcy13Y2Tr ja/Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=i2lSZ7GN; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-44877-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44877-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id j17-20020a170906255100b00a3654938f96si353430ejb.901.2024.01.30.14.26.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 14:26:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-44877-linux.lists.archive=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=i2lSZ7GN; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-44877-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44877-linux.lists.archive=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 45EE91F2266D for ; Tue, 30 Jan 2024 15:51:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DECA586129; Tue, 30 Jan 2024 15:50:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="i2lSZ7GN" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (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 50C588613E for ; Tue, 30 Jan 2024 15:50:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706629846; cv=none; b=fVaHh4c9YYipMJvztZU2HlLTZDVSFrkikj4JRjFd0hzEcLMFCsRyH6VU7eYV6on4J/peGx8B9cRcH8xMDjeTTHuKSczpZj9ei2bfDt96dxKnTdR6rtMVYFowVMdGRHdvfXFzcMvFnbAy6sGLr8rbG9TzO/yDYj8aO5CnqJV1ERc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706629846; c=relaxed/simple; bh=uKm+UW/Vo4GQhTpv3sxOiaQtBenqWb70/6yWKJn8914=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=DOh4ph1mzl0WSpbmpOi/M6QuFFXfH7Xy68YlftJE3dBbJgm/hv9UH73Al8SQSTIXbAP7yk9ZUZ0OmzbA5J+7kSdzWyNHOXLBHSNaeGD1gMENFQHoC2A0jLmrgM3UMp1PiTBf9LdxzNCxpVRiXfMvxoRrV3ohPZdN+E8tnD8qlYk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=i2lSZ7GN; arc=none smtp.client-ip=192.198.163.9 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.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706629843; x=1738165843; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=uKm+UW/Vo4GQhTpv3sxOiaQtBenqWb70/6yWKJn8914=; b=i2lSZ7GNx0KrR1gu3mTwRBo6qsHJ2R8O08guq24ceuffrBDKrcbtac8e +LRsD6v9ZfrqhSSX0F+SB21KZnAa3YnyIypf6tsdIPVD7kgSBo7golygV 14RBojHe6Y8OtnNwp/3sbaL+3x5MaW3yOs+L27WwhA4czhYAjgv6b3miF VE6qLsHXxBv4QQoMg3I2kwx2KcX2KyczvCe0fKHMRHYoggEsc2wyAcxL4 rTEem05iS34u7mbi5lxO/KsguAqz0GCtcifAcIv1h/ss9R7+EA1X3t7u4 Att0suSAZ71dZSGy/gd43XLozwNB0+s4UXnfNXi2Z0/PO/XxWIc7G2oXm w==; X-IronPort-AV: E=McAfee;i="6600,9927,10969"; a="10064935" X-IronPort-AV: E=Sophos;i="6.05,230,1701158400"; d="scan'208";a="10064935" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jan 2024 07:50:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10969"; a="737811733" X-IronPort-AV: E=Sophos;i="6.05,230,1701158400"; d="scan'208";a="737811733" Received: from pangchin-mobl3.amr.corp.intel.com (HELO [10.209.54.246]) ([10.209.54.246]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jan 2024 07:50:41 -0800 Message-ID: Date: Tue, 30 Jan 2024 07:50:40 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/2] x86/random: Issue a warning if RDRAND or RDSEED fails Content-Language: en-US To: "Kirill A. Shutemov" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , x86@kernel.org, Theodore Ts'o , "Jason A. Donenfeld" Cc: Elena Reshetova , Jun Nakajima , Tom Lendacky , "Kalra, Ashish" , Sean Christopherson , linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org References: <20240130083007.1876787-1-kirill.shutemov@linux.intel.com> <20240130083007.1876787-2-kirill.shutemov@linux.intel.com> From: Kuppuswamy Sathyanarayanan In-Reply-To: <20240130083007.1876787-2-kirill.shutemov@linux.intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 1/30/24 12:30 AM, Kirill A. Shutemov wrote: > 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. Did you come across a case where it fails? Wondering why add this warning now? > > 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) Why not use warn_once in both cases? > +#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; > } > -- Sathyanarayanan Kuppuswamy Linux Kernel Developer