Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp492213lqt; Mon, 18 Mar 2024 14:03:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVd6KfUTz1h5RRP8yb8hJotlESFOqWTuDCY55P0/qfoLIfAIwzEF1YhTImoEbU1YRbkX1knuT7EqGqUNzQdXqOkYPbthQrXPAicRPidiQ== X-Google-Smtp-Source: AGHT+IHHN7Q1gKNq3DFrLYWV1LqcGDH2DITNDMRNvpkeHxohhItFU1ghFoRVocUBeknOZRXKRRyM X-Received: by 2002:a05:620a:24cb:b0:789:ee8e:bd9f with SMTP id m11-20020a05620a24cb00b00789ee8ebd9fmr9872782qkn.50.1710795816800; Mon, 18 Mar 2024 14:03:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710795816; cv=pass; d=google.com; s=arc-20160816; b=HRN56YKJIUB3HmG875+32H4MzjTrkGDun+XptljNUxg7hMxOWLR1M0kaG13t8R5Swr QEcZ0EeiMgXIwh3LHEnioYSpb0KxdWkRvMZoxT1EB/4qQgVewJpHZh4MME0UVw0vBIdn No4nqEk0NZHmjVHffYmIohbwIFFUYNrknCrKWNCyfQideaICdjcVsGITvOptvJquM4Yi WOx39J0v4K+6C4MLVUSYFQfkb3dD8zTGWeEN+1CyWHYiaKeLPKmoOf0/j6/M8deS0m3P UivLUW2UC/lrTYweEJcpskFLP2ceYB1Q36XQm68IZlkdmDX4U7NVhlPS/zgOeBGBtQu0 YDaw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=UmPCZS+23vmAnJgCoa+okS36dhoUEjEhsL1XUB+hRz0=; fh=KlN96dCfwYFgmOujbii8LqcVUvC3MkCRvFBzZ+y9LAg=; b=KytDQLftbyzq2d4fmKN4lnSlJv1LBbFaNQf6gXsLEMMmnhn9kmh3HYBT0kCV0fRvvo 1lmaIXVOIGLyLzS9v/dIKpwXP8q4u984ObrklEZ5G4ni1Wa2LID5iBR2RLHl1ZJfGkMP hQYktXZHnlZaPRH5LfTdRY05C/44/rVTZCc8otwgX5dAIqnXH01XlnSLKn3unoHtgDo7 JMCaVVABvWe9jSXbeJWGwQDBy2edO/V6osVZGRO8Yx7uPhsMAfllrPqc+yHG7gIAlcHu t5Kzk6ZKI5N2bD9Ztd2uGXXEu/IYJdodzX/155aHH3p0b7Je7h9AtzBw8cYUiDM4BX91 Xmyw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=D1Aevv10; arc=pass (i=1 dkim=pass dkdomain=zx2c4.com); spf=pass (google.com: domain of linux-kernel+bounces-106663-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106663-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zx2c4.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id l24-20020ae9f018000000b007885e71a1eesi9973790qkg.51.2024.03.18.14.03.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 14:03:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-106663-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=D1Aevv10; arc=pass (i=1 dkim=pass dkdomain=zx2c4.com); spf=pass (google.com: domain of linux-kernel+bounces-106663-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106663-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zx2c4.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 85E901C2123C for ; Mon, 18 Mar 2024 21:03:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7DCA858230; Mon, 18 Mar 2024 21:03:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="D1Aevv10" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 5A38058131; Mon, 18 Mar 2024 21:03:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710795808; cv=none; b=oXIBmbXpvKm5xEEoL4OatqQhd6tCBHNY2mzQk/Re4P+csrBW689GlmQA7Hq/R5DRLNb/Zawe9ZR/iVJEIhYInVKThUi4DuBhxHEl6/I5ytzLp/GHehRljT/J7Ys1eLyrH7Y4shEFX0NVSwBOLWEFyFpFnStuCYGa1b1ymKlSyeg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710795808; c=relaxed/simple; bh=KNXL8yB39oiiaWyS+GffR+XGWq4A3cnUOIdO5iI9gsE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=sC3u27OmxqfH86RH5YsjwypJQPbgP+s5fKXhJG1bgvDOTG7tq4H7aI77lP+arcBSNVp4ipN7tuoSyAzeNdQnORyjomI8kgfwyJ8KGgv9JZ4R1MzLncaoROZVHdyEjkWZ0j/r9uTrPd92gj+23BsRydQAMRP3BiCXnLcAP/NGb4s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b=D1Aevv10; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 32CA0C433C7; Mon, 18 Mar 2024 21:03:26 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="D1Aevv10" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1710795802; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=UmPCZS+23vmAnJgCoa+okS36dhoUEjEhsL1XUB+hRz0=; b=D1Aevv10LyR+ZL5FYo9+nIGr2xbCDWF52PSQ99g8mSEHCkqWZ3lgC7uyyJqeV8W6W71iGq T3wk0PBhGBIF6SJLXTdR6Ck3bXpibLdx9fr/lTRX4QB7VmeqLEHsRiGTKkKuhtgEQv7rol 0fhrn/Q86e/X3d7mhkfROjXe9ITzNsg= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 79ecf448 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 18 Mar 2024 21:03:22 +0000 (UTC) Date: Mon, 18 Mar 2024 22:03:21 +0100 From: "Jason A. Donenfeld" To: mhklinux@outlook.com Cc: haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, catalin.marinas@arm.com, will@kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, arnd@arndb.de, tytso@mit.edu, x86@kernel.org, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-arch@vger.kernel.org Subject: Re: [PATCH v3 1/1] x86/hyperv: Use Hyper-V entropy to seed guest random number generator Message-ID: References: <20240318155408.216851-1-mhklinux@outlook.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20240318155408.216851-1-mhklinux@outlook.com> Hi Michael, On Mon, Mar 18, 2024 at 08:54:08AM -0700, mhkelley58@gmail.com wrote: > From: Michael Kelley > > A Hyper-V host provides its guest VMs with entropy in a custom ACPI > table named "OEM0". The entropy bits are updated each time Hyper-V > boots the VM, and are suitable for seeding the Linux guest random > number generator (rng). See a brief description of OEM0 in [1]. > > Generation 2 VMs on Hyper-V use UEFI to boot. Existing EFI code in > Linux seeds the rng with entropy bits from the EFI_RNG_PROTOCOL. > Via this path, the rng is seeded very early during boot with good > entropy. The ACPI OEM0 table provided in such VMs is an additional > source of entropy. > > Generation 1 VMs on Hyper-V boot from BIOS. For these VMs, Linux > doesn't currently get any entropy from the Hyper-V host. While this > is not fundamentally broken because Linux can generate its own entropy, > using the Hyper-V host provided entropy would get the rng off to a > better start and would do so earlier in the boot process. > > Improve the rng seeding for Generation 1 VMs by having Hyper-V specific > code in Linux take advantage of the OEM0 table to seed the rng. For > Generation 2 VMs, use the OEM0 table to provide additional entropy > beyond the EFI_RNG_PROTOCOL. Because the OEM0 table is custom to > Hyper-V, parse it directly in the Hyper-V code in the Linux kernel > and use add_bootloader_randomness() to add it to the rng. Once the > entropy bits are read from OEM0, zero them out in the table so > they don't appear in /sys/firmware/acpi/tables/OEM0 in the running > VM. The zero'ing is done out of an abundance of caution to avoid > potential security risks to the rng. Also set the OEM0 data length > to zero so a kexec or other subsequent use of the table won't try > to use the zero'ed bits. > > [1] https://download.microsoft.com/download/1/c/9/1c9813b8-089c-4fef-b2ad-ad80e79403ba/Whitepaper%20-%20The%20Windows%2010%20random%20number%20generation%20infrastructure.pdf Looks good to me. Assuming you've tested this and it works, Reviewed-by: Jason A. Donenfeld Thanks for the v3. Jason