Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp21058rdb; Wed, 21 Feb 2024 15:35:36 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWEmfSFU+KIoTcWAA44EeLLx2YhaGyywI8oC4Kbdn5850QoAsjp+zZWL+nmf2259BUx5OtMrwm+KuJC+Gk2xzBYq/sPTEcbESnzzKIsaA== X-Google-Smtp-Source: AGHT+IFMLjHksc9OTeyx/CKUuzDgRx6/Wrsi2mCUDY4nRcWACZEtayDImkfeoR27V/K63I64Vb8M X-Received: by 2002:a05:620a:a8a:b0:787:4e73:1391 with SMTP id v10-20020a05620a0a8a00b007874e731391mr12454501qkg.53.1708558536346; Wed, 21 Feb 2024 15:35:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708558536; cv=pass; d=google.com; s=arc-20160816; b=c6c+1zgKk/cLhsdm1VafUzHegf0vyt/gJF9J6EbKNSZMisJpAyD8w26f+oWa9sE4Zz QJ5fBwErjACgx8mRCYB5Mt9BH3IFRnRSOy+yxD5HDvvI+bQZCbUVtWPsM8WjGzsMoag4 b+bL9hUnLR/lcWaWTIG2eH9nUIS/1x/LXJPuI6kKLWuoyeCsIeW9zBqseCG5UttzX9Hl blabCS5X1W45tcrGlWnXQ2OLr5zcAV+U1XldGUOEa8cRmVW71uhEIYPncrbORDn4BsCw X8FWEuzcjlEcfx1qXyQeWJvfcHZFCvbchAmkhtMQ+9mV//gVN29CPTq1iZPtUW2+s2zC fBYA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=F37A95fxSAByaglVBqYbLRaz6iFc73ZOjUVKjcu1XTQ=; fh=SBDxtqlB4iPhp5qQiaFBiixTpsz+dnO6jUQCfve0HHM=; b=Qp54116m+w0G6foWKEPf6v06QhIqw8Fn6ycL9dkhO3uVn84HU612d9vNTAwM9ssisD aUe10/E/wuxukLhavJEudi755z3xHcKwLgpRdgocQdWJXYNFT9SDrC8EtV8G8UcM7V9U UYEAgfbCRh/4o/wECoAplYTUDcY+bVksdrvaLG+9VU3pR2JmJecPup8H3WUFN4ztRN37 gVDBZuqU3wRYVM6BRJyEO+BcjKeydHlDGYnhv0S4C8XZsXC/iS2nTsCjeeMTRBrGOZde J3A0A3XoEWneJPLcmJ5nCYARfu6ts0CDlFAJHvPhGpGtfhcXfpFbNsEe5QDFm9IyAj00 tf8Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZiC3pkZB; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-75661-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75661-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id xb17-20020a05620a5ad100b00787273438fcsi11731426qkn.352.2024.02.21.15.35.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 15:35:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-75661-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZiC3pkZB; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-75661-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75661-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 11AD41C21776 for ; Wed, 21 Feb 2024 23:35:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7D164126F37; Wed, 21 Feb 2024 23:35:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ZiC3pkZB" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (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 E475A126F00 for ; Wed, 21 Feb 2024 23:35:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708558530; cv=none; b=MYybaJPR7zl58lNxzMP59G0rPhsLghVfFf1m6afsCLigBJ8RDdUSv00zKt+7KnkZXtqFyxUDPr9e4Lsxe/vLhLTNO0NG4zqhR2zbVDP9pk4BLkuAB5kEnNxQzeZd9ddC3on4nqvna59Em2JF3T9MzqkBBoh48UJfe6poeSG/4gA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708558530; c=relaxed/simple; bh=7OauMgVsT3HrSDBYzevjreykklBEY0CoOi6bqg94xpI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=n2/wEF/ijsgJQNsw4eMfcOA9UVKUqeWN93icYdXAX/cI6GTdVoej5d3pK30jQW1Zep9dbB5d8XPpjpvaZrfZ/EP1cPcApVXSiQelLTSWwOtaC2wAb+jqjX2app1AmPU3WMdP/JnTCZ06eLQIXMIh3hYroOPvHdfB2dl79z5uCBk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ZiC3pkZB; arc=none smtp.client-ip=198.175.65.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708558529; x=1740094529; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=7OauMgVsT3HrSDBYzevjreykklBEY0CoOi6bqg94xpI=; b=ZiC3pkZBJtn/pnxMrQvTpdajtcTGfJCQsHRpvU0RKGjD8qF2wwh6GcLN gLjEToQSo+JMslDe4rRpvco7BwZTvc+DrVMRU4FORHhs2H4YIo8XICRXD nEWYvwSodMKcQ8pVezXqK1N2PmySrOq4HGXt8Q3o8asDo0+MhdN/fRrbh 8v95ZgXOIPG85OxmKmQ8/CBGy/W/O6nFRwvAQnsL51GfsRtFrQQfNayxl jBAnS4RSFbxqbeKT3llAQxRqKEjet2YOFnT57+8KfAabMZRzQtzOveXlI 3el9zAKdy6/OqBnpAj43PQtjAq/dkqbIeOb6OI0HkhNEI2P2+nzIACDuR g==; X-IronPort-AV: E=McAfee;i="6600,9927,10991"; a="2666184" X-IronPort-AV: E=Sophos;i="6.06,176,1705392000"; d="scan'208";a="2666184" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Feb 2024 15:35:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10991"; a="936722442" X-IronPort-AV: E=Sophos;i="6.06,176,1705392000"; d="scan'208";a="936722442" Received: from remiller-mobl1.amr.corp.intel.com (HELO [10.209.48.179]) ([10.209.48.179]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Feb 2024 15:35:26 -0800 Message-ID: <5648f43d-76e4-4396-b626-411d60657c93@intel.com> Date: Wed, 21 Feb 2024 15:35:28 -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 v3] x86/coco: Require seeding RNG with RDRAND on CoCo systems Content-Language: en-US To: "Jason A. Donenfeld" Cc: x86@kernel.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, Borislav Petkov , =?UTF-8?Q?Daniel_P_=2E_Berrang=C3=A9?= , Dave Hansen , Elena Reshetova , "H . Peter Anvin" , Ingo Molnar , "Kirill A . Shutemov" , Theodore Ts'o , Thomas Gleixner References: <20240221123248.25570-1-Jason@zx2c4.com> <7a8c04bb-214b-4031-bdd6-59dad62f88a7@intel.com> From: Dave Hansen Autocrypt: addr=dave.hansen@intel.com; keydata= xsFNBE6HMP0BEADIMA3XYkQfF3dwHlj58Yjsc4E5y5G67cfbt8dvaUq2fx1lR0K9h1bOI6fC oAiUXvGAOxPDsB/P6UEOISPpLl5IuYsSwAeZGkdQ5g6m1xq7AlDJQZddhr/1DC/nMVa/2BoY 2UnKuZuSBu7lgOE193+7Uks3416N2hTkyKUSNkduyoZ9F5twiBhxPJwPtn/wnch6n5RsoXsb ygOEDxLEsSk/7eyFycjE+btUtAWZtx+HseyaGfqkZK0Z9bT1lsaHecmB203xShwCPT49Blxz VOab8668QpaEOdLGhtvrVYVK7x4skyT3nGWcgDCl5/Vp3TWA4K+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CoACVNhnXg/R0g90g8iV8Q+IBZyDkG0tBThaDdw1B2l asInUTeb9EiVfL/Zjdg5VWiF9LL7iS+9hTeVdR09vThQ/DhVbCNxVk+DtyBHsjOKifrVsYep WpRGBIAu3bK8eXtyvrw1igWTNs2wazJ71+0z2jMzbclKAyRHKU9JdN6Hkkgr2nPb561yjcB8 sIq1pFXKyO+nKy6SZYxOvHxCcjk2fkw6UmPU6/j/nQlj2lfOAgNVKuDLothIxzi8pndB8Jju KktE5HJqUUMXePkAYIxEQ0mMc8Po7tuXdejgPMwgP7x65xtfEqI0RuzbUioFltsp1jUaRwQZ MTsCeQDdjpgHsj+P2ZDeEKCbma4m6Ez/YWs4+zDm1X8uZDkZcfQlD9NldbKDJEXLIjYWo1PH hYepSffIWPyvBMBTW2W5FRjJ4vLRrJSUoEfJuPQ3vW9Y73foyo/qFoURHO48AinGPZ7PC7TF vUaNOTjKedrqHkaOcqB185ahG2had0xnFsDPlx5y In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 2/21/24 15:09, Jason A. Donenfeld wrote: > On Wed, Feb 21, 2024 at 11:47 PM Dave Hansen wrote: >> OK, so we're trying to get 256 bits of seed data from RDRAND? > > Yes. This fills a 32-byte buffer of longs up with output from > arch_get_random_longs(). That's what it's doing mechanically, but what's the end goal? >> But no pattern I could discern. Did you mean something different by >> "platform drivers"? > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/um/kernel/um_arch.c#n413 > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/char/random.c#n655 Gotcha. > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/scripts/gcc-plugins/latent_entropy_plugin.c#n90 Isn't that one 32 HOST_WIDE_INTs and not 32 bytes? :) >> If we're going to have arch/x86-specific crud, it would be great to make >> it obvious and straightforward to those of us simple folk that are >> familiar with arch/x86 code. > > If you insist, I'll stick a local `enum { RANDOM_BYTES_COUNT = 32 }` > in that function or something. Seems unnecessary to me but if that's > what you need no problem. Would that suffice? Or a different variable > name? Or a comment on "what is 32 about?" "what is 32 about?" would be great. What's the goal, and why is 32 enough to reach that goal?