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 lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C7693C19F2A for ; Thu, 4 Aug 2022 16:24:15 +0000 (UTC) Received: from localhost ([::1]:49084 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJddu-0001gB-UI for qemu-devel@archiver.kernel.org; Thu, 04 Aug 2022 12:24:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37888) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJdcA-0007OL-Gs for qemu-devel@nongnu.org; Thu, 04 Aug 2022 12:22:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:33201) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJdc6-0007qT-75 for qemu-devel@nongnu.org; Thu, 04 Aug 2022 12:22:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659630140; 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=kZY43ewf+ib8Vt6r6QVJN8UofwYAQ5jdfhpe0hknl3E=; b=RdB3FXvloYCL0AVBQEaHL69vH2CnbLeto1KWsHe5fWjhEVjq27mZFoc+A3ukxkdHaFBLzB gZf7w5KFY4UOaMOuJNXBKjSe0Fged9LhOY3HdUwHQ6/R7PJ1sBr88CJxyYOvkCI5h4H0Yt YC1CJzMnM8BZ7Shv/qa8Ic4/H+E5gPs= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-544-nEGoolS_PIWUQyqkrcZQuw-1; Thu, 04 Aug 2022 12:22:19 -0400 X-MC-Unique: nEGoolS_PIWUQyqkrcZQuw-1 Received: by mail-wm1-f72.google.com with SMTP id r186-20020a1c44c3000000b003a4f1c1e24bso72416wma.5 for ; Thu, 04 Aug 2022 09:22:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc; bh=kZY43ewf+ib8Vt6r6QVJN8UofwYAQ5jdfhpe0hknl3E=; b=WX9BjJqc/szjzDF4npEyE4ya3MdFQcMCc6pWfK2V3TOWmauWHGteUM7/a8dmb1BPvR WPZVVljrgHNNzcVQ2e9w3MN/dL9I6kykbLOwxPLFbI0Cd2N8gddhuWfY4ynqVpDMjzFh wkCy3laSog8tByt3a75BAwtu5b17D6aq5NgL7eUknGO7hia1D8Y2FhMRCdM17zriawnj Q4bl52w4sZxEpuVt/vmok293+pxZahFVpq/LpMpVeyrhsc/Y5QXOJh8Bum4hXU5DIe/a UrTz9JCB7az2JQ7mBYa4/l1hsXOXZFbN0g19kLBZNstRocxcIs+yzWhVLDDh9h38MjaY lqTg== X-Gm-Message-State: ACgBeo0nUEmPSnmLEbe5zoqdJ1viEJ3aw3XhgsW5e6dDeGnrxDC4qHVt l7htsTSFqgikABYg+E/WyUZU9YyQqUZOeVS/+i2oW8Q3jBFWYWx9QhNDaj38XHWHULgRIXxBbxm CJCI5wHxNEKG7Hl0= X-Received: by 2002:a1c:f716:0:b0:3a1:8f0e:66b4 with SMTP id v22-20020a1cf716000000b003a18f0e66b4mr1990795wmh.140.1659630138271; Thu, 04 Aug 2022 09:22:18 -0700 (PDT) X-Google-Smtp-Source: AA6agR6iyrH4itpvX1SgihKbus0zoqc0Nyj+hj6PDFrnieuWTwAAXiZHk03M9aSfVodMPevRuByvOQ== X-Received: by 2002:a1c:f716:0:b0:3a1:8f0e:66b4 with SMTP id v22-20020a1cf716000000b003a18f0e66b4mr1990772wmh.140.1659630137975; Thu, 04 Aug 2022 09:22:17 -0700 (PDT) Received: from redhat.com ([2.54.191.86]) by smtp.gmail.com with ESMTPSA id f13-20020a05600c4e8d00b003a319b67f64sm21051094wmq.0.2022.08.04.09.22.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Aug 2022 09:22:17 -0700 (PDT) Date: Thu, 4 Aug 2022 12:22:13 -0400 From: "Michael S. Tsirkin" To: "Jason A. Donenfeld" Cc: Daniel =?iso-8859-1?Q?P=2E_Berrang=E9?= , Paolo Bonzini , qemu-devel@nongnu.org Subject: Re: [PATCH] pc: add property for Linux setup_data seed Message-ID: <20220804110025-mutt-send-email-mst@kernel.org> References: <20220804131320.395015-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Thu, Aug 04, 2022 at 04:31:06PM +0200, Jason A. Donenfeld wrote: > Hi Daniel, > > On Thu, Aug 04, 2022 at 02:31:06PM +0100, Daniel P. Berrangé wrote: > > On Thu, Aug 04, 2022 at 03:20:59PM +0200, Jason A. Donenfeld wrote: > > > On Thu, Aug 04, 2022 at 03:13:20PM +0200, Paolo Bonzini wrote: > > > > Using a property makes it possible to use the normal compat property > > > > mechanism instead of ad hoc code; it avoids parameter proliferation > > > > in x86_load_linux; and allows shipping the code even if it is > > > > disabled by default. > > > > > > Strong NACK from me here. > > > > > > If this kind of thing is off by default, it's as good as useless. Indeed > > > it shouldn't even be a knob at all. Don't do this. > > > > You're misunderstanding the patch. This remains on by default for > > the 7.1 machine type. > > Ahhh, I think you're right. Sorry for mis understanding. The "even if it > is disabled by default" of the commit message isn't quite true then, > right? I think it refers to the fact that we do not have a fix yet, and if we don't get one by release we might flip the default, but the feature will still be usable. > If I understand correctly, this is a yes/no/auto, which defaults to > auto on newer machine types. And auto triggers if the kernel has a newer > boot header. Is that correct? > > if (x86ms->linuxboot_seed != ON_OFF_AUTO_OFF && > (protocol >= 0x209 || x86ms->linuxboot_seed == ON_OFF_AUTO_ON)) { > > I think it's working as described (after applying the below fixup to > this broken patch). > > > The patch is merely exposing a knob so that users can override the > > built-in default if they need to. Imagine if we had shipped this > > existing code before today's bugs were discovered. The knob > > proposed her would allow users to turn off the broken pieces. > > This is a good thing. > > I'm still not really keen on adding a knob for this. I understand ARM > has a knob for it for different reasons (better named "dtb-randomness"). > If this knob thing is to live on here, maybe it should have > "-randomness" in the name also. > > > > Rather, let's fix the bug. The code as-is -- going back to the 2016 DTB > > > addition -- is problematic and needs to be fixed. So let's fix that. > > > Trying to cover up the problem with a default-off knob just ensures this > > > stuff will never be made to work right. > > > > It isn't covering up the problem, just providing a workaround > > option, should another bug be discovered after release. We > > still need to fix current discussed problems of course. > > Thanks for the explanation. I don't like adding a knob. But if it's on > by default for the default machine type, then that's a compromise I > could accept. > > Jason > > > diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c > index 00c21f6e4d..074571bc03 100644 > --- a/hw/i386/pc_piix.c > +++ b/hw/i386/pc_piix.c > @@ -446,6 +446,7 @@ DEFINE_I440FX_MACHINE(v7_1, "pc-i440fx-7.1", NULL, > > static void pc_i440fx_7_0_machine_options(MachineClass *m) > { > + PCMachineClass *pcmc = PC_MACHINE_CLASS(m); > pc_i440fx_7_1_machine_options(m); > m->alias = NULL; > m->is_default = false; > diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c > index 5bcf100b35..f3aa4694a2 100644 > --- a/hw/i386/pc_q35.c > +++ b/hw/i386/pc_q35.c > @@ -383,6 +383,7 @@ DEFINE_Q35_MACHINE(v7_1, "pc-q35-7.1", NULL, > > static void pc_q35_7_0_machine_options(MachineClass *m) > { > + PCMachineClass *pcmc = PC_MACHINE_CLASS(m); > pc_q35_7_1_machine_options(m); > m->alias = NULL; > pcmc->enforce_amd_1tb_hole = false; > diff --git a/hw/i386/x86.c b/hw/i386/x86.c > index 3fbab258a9..206ce6c547 100644 > --- a/hw/i386/x86.c > +++ b/hw/i386/x86.c > @@ -785,6 +785,7 @@ void x86_load_linux(X86MachineState *x86ms, > const char *dtb_filename = machine->dtb; > const char *kernel_cmdline = machine->kernel_cmdline; > SevKernelLoaderContext sev_load_ctx = {}; > + enum { RNG_SEED_LENGTH = 32 }; > > /* Align to 16 bytes as a paranoia measure */ > cmdline_size = (strlen(kernel_cmdline) + 16) & ~15; > @@ -1075,7 +1076,7 @@ void x86_load_linux(X86MachineState *x86ms, > } > > if (x86ms->linuxboot_seed != ON_OFF_AUTO_OFF && > - (data.protocol >= 0x209 || x86ms->linuxboot_seed == ON_OFF_AUTO_ON)) { > + (protocol >= 0x209 || x86ms->linuxboot_seed == ON_OFF_AUTO_ON)) { > setup_data_offset = QEMU_ALIGN_UP(kernel_size, 16); > kernel_size = setup_data_offset + sizeof(struct setup_data) + RNG_SEED_LENGTH; > kernel = g_realloc(kernel, kernel_size);