From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D95BC4332F for ; Tue, 27 Dec 2022 13:37:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CC84A8E0002; Tue, 27 Dec 2022 08:37:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C515B8E0001; Tue, 27 Dec 2022 08:37:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ACA898E0002; Tue, 27 Dec 2022 08:37:07 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 97AA08E0001 for ; Tue, 27 Dec 2022 08:37:07 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 68D25A028E for ; Tue, 27 Dec 2022 13:37:07 +0000 (UTC) X-FDA: 80288187294.22.8F3C899 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf01.hostedemail.com (Postfix) with ESMTP id 886054000A for ; Tue, 27 Dec 2022 13:37:04 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=zx2c4.com header.s=20210105 header.b=HsbP5xOE; spf=pass (imf01.hostedemail.com: domain of "SRS0=Y2YX=4Z=zx2c4.com=Jason@kernel.org" designates 145.40.68.75 as permitted sender) smtp.mailfrom="SRS0=Y2YX=4Z=zx2c4.com=Jason@kernel.org"; dmarc=pass (policy=quarantine) header.from=zx2c4.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1672148225; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=A6Tpz+0nHRofFNKNlRnj1MkH2P/4zYKJXoIQP8XxImY=; b=w+CRBPmoQD0iI4UdDLvdfG4TF6iw73gmt7EQBozzHUM9X9bbj+l34F2bD5Cyv6Ljocg1OJ ZZHO71a68plsJJDHPAp/vy4Yww7WvH5vqwpfh02MsZPSnwnr/E7JVMcZVfDh2qTtjFtt08 5S0nxXWr6NyAWICbTHyi3A5S+TQneUs= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=zx2c4.com header.s=20210105 header.b=HsbP5xOE; spf=pass (imf01.hostedemail.com: domain of "SRS0=Y2YX=4Z=zx2c4.com=Jason@kernel.org" designates 145.40.68.75 as permitted sender) smtp.mailfrom="SRS0=Y2YX=4Z=zx2c4.com=Jason@kernel.org"; dmarc=pass (policy=quarantine) header.from=zx2c4.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1672148225; a=rsa-sha256; cv=none; b=i7tcBsQG/ubNFM87iHeN717fBSQnAQitm3KTJZTd+HtX16yarFw7mwzajh2qUZ7uWsRv+1 Okx4s0x6zR3bwRNunUQ+c5lGc1l39aeGUOUUSbrXpSDiOzufsb0KV5l77mrcR0hbvewhRH V9PA2G9ka8md7W/9wl4rVXCg/Cwwu/0= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 8FB8FB80FEA; Tue, 27 Dec 2022 13:37:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B5AE9C433D2; Tue, 27 Dec 2022 13:36:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1672148217; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=A6Tpz+0nHRofFNKNlRnj1MkH2P/4zYKJXoIQP8XxImY=; b=HsbP5xOEiKYJiyasySa0UMT4zXobhsSaqEJ35giVI7EZRf61AbjyX7fN31v632JdItsaV2 MBWd8YE7QyAHDJ3fJ+/019DHifr+V48SBeiIb7fTg2vE+f61Ve186jv7+jTTDHKf2tODgZ FO+gIFwmrkQbTJUnAOihliiilMNydhI= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 217de33c (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 27 Dec 2022 13:36:57 +0000 (UTC) Date: Tue, 27 Dec 2022 14:36:54 +0100 From: "Jason A. Donenfeld" To: Eric Biggers , x86@kernel.org, linux-mm@kvack.org Cc: pbonzini@redhat.com, qemu-devel@nongnu.org, Laurent Vivier , "Michael S . Tsirkin" , Peter Maydell , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Richard Henderson , Ard Biesheuvel , Gerd Hoffmann , kasan-dev@googlegroups.com, Dmitry Vyukov Subject: Re: [PATCH v5 4/4] x86: re-enable rng seeding via SetupData Message-ID: References: <20220921093134.2936487-1-Jason@zx2c4.com> <20220921093134.2936487-4-Jason@zx2c4.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 886054000A X-Stat-Signature: 4afottz8k56fzbh19c5ag6rhjdnq8fzn X-HE-Tag: 1672148224-995857 X-HE-Meta: U2FsdGVkX1/Zi7QavgkYjpGbNqJab6dtX6IjXg/uFPAYvM6943ZOgB2Spxp129a52Lw8pEAfuQjLkgd5O0tX/OwA8lwBy7xB1aqGkbyWcB0Kf1d6nkj3uwyzipcVyGD7zPpzT3CPtqVFmO5/sfoT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1 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Dec 26, 2022 at 05:57:30PM +0100, Jason A. Donenfeld wrote: > On Mon, Dec 26, 2022 at 03:43:04PM +0100, Jason A. Donenfeld wrote: > > On Mon, Dec 26, 2022 at 03:24:07PM +0100, Jason A. Donenfeld wrote: > > > Hi, > > > > > > I'm currently stumped at the moment, so adding linux-mm@ and x86@. Still > > > working on it though. Details of where I'm at are below the quote below. > > > > > > On Sat, Dec 24, 2022 at 05:21:46AM +0100, Jason A. Donenfeld wrote: > > > > On Sat, Dec 24, 2022 at 04:09:08AM +0100, Jason A. Donenfeld wrote: > > > > > Hi Eric, > > > > > > > > > > Replying to you from my telephone, and I'm traveling the next two days, > > > > > but I thought I should mention some preliminary results right away from > > > > > doing some termux compiles: > > > > > > > > > > On Fri, Dec 23, 2022 at 04:14:00PM -0800, Eric Biggers wrote: > > > > > > Hi Jason, > > > > > > > > > > > > On Wed, Sep 21, 2022 at 11:31:34AM +0200, Jason A. Donenfeld wrote: > > > > > > > This reverts 3824e25db1 ("x86: disable rng seeding via setup_data"), but > > > > > > > for 7.2 rather than 7.1, now that modifying setup_data is safe to do. > > > > > > > > > > > > > > Cc: Laurent Vivier > > > > > > > Cc: Michael S. Tsirkin > > > > > > > Cc: Paolo Bonzini > > > > > > > Cc: Peter Maydell > > > > > > > Cc: Philippe Mathieu-Daudé > > > > > > > Cc: Richard Henderson > > > > > > > Cc: Ard Biesheuvel > > > > > > > Acked-by: Gerd Hoffmann > > > > > > > Signed-off-by: Jason A. Donenfeld > > > > > > > --- > > > > > > > hw/i386/microvm.c | 2 +- > > > > > > > hw/i386/pc_piix.c | 3 ++- > > > > > > > hw/i386/pc_q35.c | 3 ++- > > > > > > > 3 files changed, 5 insertions(+), 3 deletions(-) > > > > > > > > > > > > > > > > > > > After upgrading to QEMU 7.2, Linux 6.1 no longer boots with some configs. There > > > > > > is no output at all. I bisected it to this commit, and I verified that the > > > > > > following change to QEMU's master branch makes the problem go away: > > > > > > > > > > > > diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c > > > > > > index b48047f50c..42f5b07d2f 100644 > > > > > > --- a/hw/i386/pc_piix.c > > > > > > +++ b/hw/i386/pc_piix.c > > > > > > @@ -441,6 +441,7 @@ static void pc_i440fx_8_0_machine_options(MachineClass *m) > > > > > > pc_i440fx_machine_options(m); > > > > > > m->alias = "pc"; > > > > > > m->is_default = true; > > > > > > + PC_MACHINE_CLASS(m)->legacy_no_rng_seed = true; > > > > > > } > > > > > > > > > > > > I've attached the kernel config I am seeing the problem on. > > > > > > > > > > > > For some reason, the problem also goes away if I disable CONFIG_KASAN. > > > > > > > > > > > > Any idea what is causing this? > > > > > > > > > > - Commenting out the call to parse_setup_data() doesn't fix the issue. > > > > > So there's no KASAN issue with the actual parser. > > > > > > > > > > - Using KASAN_OUTLINE rather than INLINE does fix the issue! > > > > > > > > > > That makes me suspect that it's file size related, and QEMU or the BIOS > > > > > is placing setup data at an overlapping offset by accident, or something > > > > > similar. > > > > > > > > I removed the file systems from your config to bring the kernel size > > > > back down, and voila, it works, even with KASAN_INLINE. So perhaps I'm > > > > on the right track here... > > > > > > QEMU sticks setup_data after the kernel image, the same as kexec-tools > > > and everything else. Apparently, when the kernel image is large, the > > > call to early_memremap(boot_params.hdr.setup_data, ...) returns a value > > > that points some place bogus, and the system crashes or does something > > > weird. I haven't yet determined what this limit is, but in my current > > > test kernel, a value of 0x0000000001327650 is enough to make it point to > > > rubbish. > > > > > > Is this expected? What's going on here? > > > > Attaching gdb to QEMU and switching it to physical memory mode > > (`maintenance packet Qqemu.PhyMemMode:1 `) indicates that it > > early_memremap is actually working fine and something *else* is at this > > address? That's kinda weird... Is KASAN populating physical addresses > > immediately after the kernel image extremely early in boot? I'm seeing > > the crash happen from early_reserve_memory()-> > > memblock_x86_reserve_range_setup_data(), which should be before > > kasan_init() even runs. Is QEMU calculating kernel_size wrong, when it > > goes to determine where to put the setup_data data? But that's the same > > calculation as used everywhere else, so hmm... > > > > Jason > > If bzImage is 15770544 bytes, it does not boot. If bzImage is 15641776 > bytes, it does boot. So something is happening somewhat close to the > 16MB mark? > Okay, the issue is that it's being decompressed to an area that overlaps the source. So for example in my test kernel: input_addr: 0x3f112bf output_addr: 0x1000000 output_len: 0x3a5d7d8 Since 0x3a5d7d8 + 0x1000000 > 0x3f112bf, eventually this corrupts the setup_data at the end there. Now digging into what can be done about it. Jason