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 AD64AC3DA79 for ; Mon, 26 Dec 2022 14:43:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C89AA900003; Mon, 26 Dec 2022 09:43:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C3816900002; Mon, 26 Dec 2022 09:43:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B0033900003; Mon, 26 Dec 2022 09:43:14 -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 9EA3B900002 for ; Mon, 26 Dec 2022 09:43:14 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 5E9711206A3 for ; Mon, 26 Dec 2022 14:43:14 +0000 (UTC) X-FDA: 80284725108.17.7A0830A Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf11.hostedemail.com (Postfix) with ESMTP id BE91E40008 for ; Mon, 26 Dec 2022 14:43:12 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=zx2c4.com header.s=20210105 header.b=ZbIWQ+F1; spf=pass (imf11.hostedemail.com: domain of "SRS0=Dxcw=4Y=zx2c4.com=Jason@kernel.org" designates 139.178.84.217 as permitted sender) smtp.mailfrom="SRS0=Dxcw=4Y=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=1672065792; 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=pnBVrkrJXTYl75Ql9lygETz8tLymjZhISCe1af4q/eI=; b=4pbMZNJsxITzLkpmxlR6ZZT4LguTsl+8f7GSxl3Q4/kuvWsyfIoXpu6ZXisBoPno0UutsL x2qM7KH63duje6kntUzSDcV0LPP/tJA4dPAbnVoiu0hdh++aXBONAO33d2cRnUA6fVuJyA W5CxOIy6AZ6IODeY7bjs4gXiVooaG2I= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=zx2c4.com header.s=20210105 header.b=ZbIWQ+F1; spf=pass (imf11.hostedemail.com: domain of "SRS0=Dxcw=4Y=zx2c4.com=Jason@kernel.org" designates 139.178.84.217 as permitted sender) smtp.mailfrom="SRS0=Dxcw=4Y=zx2c4.com=Jason@kernel.org"; dmarc=pass (policy=quarantine) header.from=zx2c4.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1672065792; a=rsa-sha256; cv=none; b=ShHbKbNbRdkLzJ32yzTNfcRaGq0MqQRj1/VYdwiuUzDVdUzqN5i4PaUv3yvYIBKNGstFvV irxMRg0mdHhTUR4dB7nPhoT70YxDXvOOZ0r1nWyGu/7P2QDr5ro44c6zxKc83oJkRS8nsV 8fLN3xc6Ttx5IdyG34fMhPdaXpY9bcM= 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 dfw.source.kernel.org (Postfix) with ESMTPS id D011160EA9; Mon, 26 Dec 2022 14:43:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E0DCC433EF; Mon, 26 Dec 2022 14:43:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1672065787; 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=pnBVrkrJXTYl75Ql9lygETz8tLymjZhISCe1af4q/eI=; b=ZbIWQ+F18f6FA9uYUVJmi4CxY0VRyeCh2v735fl4xjiVcimgSHK7EF6cz1svtcbcxkFxsq Ol6V8eOJ0aYxLPF7WW4zuM5V7yb9l6jQsyBbVBUlxysu2Ip1yFRoVGzlPoS/LUHPQDTkWK QVg5KzT40qiDlnPPz4cmL9fBUJIoXio= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 2d986e2f (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 26 Dec 2022 14:43:07 +0000 (UTC) Date: Mon, 26 Dec 2022 15:43:04 +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-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: BE91E40008 X-Stat-Signature: iqnus3f43bqnobygjm8hgy7aww3h7nqj X-Rspam-User: X-HE-Tag: 1672065792-740903 X-HE-Meta: U2FsdGVkX1+VDfOs6UTCP17XoN/M+EAhvinrRKHYMKaXKVB9u3zEyrYPQbCCP42U6rM6DQAwBiOy2h2tUk73jbEQb869ia0JdviA11MgQChOfPJzvYomPdjm8vejMYaFqL9883DVj9SwqhXZ2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ogosity: 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 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