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 94B38C4332F for ; Mon, 26 Dec 2022 16:57:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CE69A900003; Mon, 26 Dec 2022 11:57:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C6EFA900002; Mon, 26 Dec 2022 11:57:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AE9A6900003; Mon, 26 Dec 2022 11:57:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 97689900002 for ; Mon, 26 Dec 2022 11:57:43 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 6F1EB14010F for ; Mon, 26 Dec 2022 16:57:43 +0000 (UTC) X-FDA: 80285064006.11.E80161E Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf06.hostedemail.com (Postfix) with ESMTP id 8D8B618000D for ; Mon, 26 Dec 2022 16:57:41 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=zx2c4.com header.s=20210105 header.b=b6POVW8y; spf=pass (imf06.hostedemail.com: domain of "SRS0=Dxcw=4Y=zx2c4.com=Jason@kernel.org" designates 145.40.68.75 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=1672073861; 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=WIE3Z+cKtBnA8yyHSJ3TV6iPDq1ETA37GJq6ok6agec=; b=NEHl+euJT6fcms9yKQBv4BUH+ZObEmh1TKLScnogvIcYvkGKEyOqq0grwkNpQm0frwmfZ6 vc+Lm3zbcPXKb+FTWeEQ593XT9fPUW/kTRuMu7r3Q2tKulZ8Dm40WiF0FVXgw4JwFluvyE w3UxoDEHROdXxIxi9blqDLtWHcH5Bjk= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=zx2c4.com header.s=20210105 header.b=b6POVW8y; spf=pass (imf06.hostedemail.com: domain of "SRS0=Dxcw=4Y=zx2c4.com=Jason@kernel.org" designates 145.40.68.75 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=1672073861; a=rsa-sha256; cv=none; b=vdo4OkrQseqrkx7y/urdVoja9Crpe6ZyL0vf7Swwcuu2PtDcNSeG20cp8JPWJuk5elRFSZ kw/7Oy11Ehj6jU2cYwglBng+3v9y5n9HxYeN+vAQTtKQw1uubqJjEOM3Xkzq8YSzFmVkyx 7y+850DBeC1MQh9jW/nwNzvafkdN9oY= 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 AEACEB80D68; Mon, 26 Dec 2022 16:57:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD4B7C433EF; Mon, 26 Dec 2022 16:57:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1672073853; 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=WIE3Z+cKtBnA8yyHSJ3TV6iPDq1ETA37GJq6ok6agec=; b=b6POVW8yEcfP7tPgzQ7TRtlOal2frw2gJhyxTHnfPwvZLzRkfcu/ZvZo9GN3NYBv0WGWum Gs4ULzuh3nXE7ld7n+E8K1bpyHRb9AbbcdaTcAb16aydVznl/eWc6Hg3p92r263zpwS3os WFupn1O+/WUSx2mfPn2ca2VDAuU7uwo= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id abdc5615 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 26 Dec 2022 16:57:33 +0000 (UTC) Date: Mon, 26 Dec 2022 17:57:30 +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-Queue-Id: 8D8B618000D X-Stat-Signature: 4boredfju6yabos3po7sxhp1cs1ofwh5 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1672073861-255435 X-HE-Meta: U2FsdGVkX18jfCfp3iYuXft//MXZG5pxd+ED+8ZMuqLvB98C1TPScvwUgLHhFIrFbtJK8YsSJTQM8u2c2RXlyYK6AoBVVKjcMIsKXvVUrF9xLmWCltgLIUNst9XOs0wy7RYpd8S2YqmLVt8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jgQmm3pRgM9tM3GpP 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 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?