From nobody Mon May 13 13:03:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1621613355; cv=none; d=zohomail.com; s=zohoarc; b=lV9On77jK8kH8VSff+j8H0PEyGFyk6jFVoNE7zQuBgK/9VWMaIHK/5DEOyR+Cz1ET4Y21mLqQApu6Xi81BmdgWSoZVtDCC68SQ8fadQo72kiuathD8MvU/DesQdQZVW3Lonq1MeDhDGiiNipPOo8FTk7yhPpMjvIdW8DvlsLIbU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621613355; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=aa5ut6mhXycqXilgeuT4o3/w/3VI76JuYAqtEUbLKlU=; b=aYA29kg1VUMRZuo9qBflmXdTgzM+cMUo6pL/WH6MTv1+I92atrFBIy2aUXpNu2eLoJd9V1D3nRvqkH3fvquSDXlXLvJjblgUPBiEBxL1kOCG3bKgVV3tDDXQy+B0vqoruQ49BjGwMW3O3iuqBWDgTTASAEgM4+gwTYZ13t83H8o= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1621613355416137.7933224575254; Fri, 21 May 2021 09:09:15 -0700 (PDT) Received: from localhost ([::1]:35974 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lk7i6-0007zT-0H for importer@patchew.org; Fri, 21 May 2021 12:09:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45484) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lk7gg-0006sY-Dj for qemu-devel@nongnu.org; Fri, 21 May 2021 12:07:46 -0400 Received: from us-smtp-delivery-44.mimecast.com ([205.139.111.44]:38394) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lk7gd-0005aS-LL for qemu-devel@nongnu.org; Fri, 21 May 2021 12:07:46 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-596-eemyiVXmO46NpFLBnTwI9Q-1; Fri, 21 May 2021 12:07:39 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3177B106BB2A; Fri, 21 May 2021 16:07:38 +0000 (UTC) Received: from bahia.redhat.com (ovpn-112-49.ams2.redhat.com [10.36.112.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id D5F4F10016FC; Fri, 21 May 2021 16:07:36 +0000 (UTC) X-MC-Unique: eemyiVXmO46NpFLBnTwI9Q-1 From: Greg Kurz To: qemu-devel@nongnu.org Subject: [PATCH] spapr: Don't hijack current_machine->boot_order Date: Fri, 21 May 2021 18:07:35 +0200 Message-Id: <20210521160735.1901914-1-groug@kaod.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kaod.org Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: softfail client-ip=205.139.111.44; envelope-from=groug@kaod.org; helo=us-smtp-delivery-44.mimecast.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, qemu-ppc@nongnu.org, Greg Kurz , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" QEMU 6.0 moved all the -boot variables to the machine. Especially, the removal of the boot_order static changed the handling of '-boot once' from: if (boot_once) { qemu_boot_set(boot_once, &error_fatal); qemu_register_reset(restore_boot_order, g_strdup(boot_order)); } to if (current_machine->boot_once) { qemu_boot_set(current_machine->boot_once, &error_fatal); qemu_register_reset(restore_boot_order, g_strdup(current_machine->boot_order)); } This means that we now register as subsequent boot order a copy of current_machine->boot_once that was just set with the previous call to qemu_boot_set(), i.e. we never transition away from the once boot order. It is certainly fragile^Wwrong for the spapr code to hijack a field of the base machine type object like that. The boot order rework simply turned this software boundary violation into an actual bug. Have the spapr code to handle that with its own field in SpaprMachineState. Also kfree() the initial boot device string when "once" was used. Fixes: 4b7acd2ac821 ("vl: clean up -boot variables") Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1960119 Cc: pbonzini@redhat.com Signed-off-by: Greg Kurz --- include/hw/ppc/spapr.h | 3 +++ hw/ppc/spapr.c | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index bbf817af4647..f05219f75ef6 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -223,6 +223,9 @@ struct SpaprMachineState { int fwnmi_machine_check_interlock; QemuCond fwnmi_machine_check_interlock_cond; =20 + /* Set by -boot */ + char *boot_device; + /*< public >*/ char *kvm_type; char *host_model; diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index c23bcc449071..4dd90b75cc52 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1005,7 +1005,7 @@ static void spapr_dt_chosen(SpaprMachineState *spapr,= void *fdt, bool reset) _FDT(chosen =3D fdt_add_subnode(fdt, 0, "chosen")); =20 if (reset) { - const char *boot_device =3D machine->boot_order; + const char *boot_device =3D spapr->boot_device; char *stdout_path =3D spapr_vio_stdout_path(spapr->vio_bus); size_t cb =3D 0; char *bootlist =3D get_boot_devices_list(&cb); @@ -2376,8 +2376,10 @@ static SaveVMHandlers savevm_htab_handlers =3D { static void spapr_boot_set(void *opaque, const char *boot_device, Error **errp) { - MachineState *machine =3D MACHINE(opaque); - machine->boot_order =3D g_strdup(boot_device); + SpaprMachineState *spapr =3D SPAPR_MACHINE(opaque); + + g_free(spapr->boot_device); + spapr->boot_device =3D g_strdup(boot_device); } =20 static void spapr_create_lmb_dr_connectors(SpaprMachineState *spapr) --=20 2.26.3