From nobody Mon Nov 25 09:46:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1716476540; cv=none; d=zohomail.com; s=zohoarc; b=Qd8iqIKh5S3lNb34uhl6ttqzpafQSgv7DNrlrChxtj0g1VAAS/vms+YHP92Tov6ZmoeS3p3gUQgTUR7QP4MJ6PapfX82wtwvG28nz228jgZDmk+ViiLRB9knDVwnKg8SzCQaheWW/tKbkc9FXCdmeuxQ7GBTO6uz3ZhWKeWVF+I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716476540; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=njYSO7HTB+sDeOmmffYU6ooE+v8Mi/U08DiKKYNjzGE=; b=B+aEbYWMskEY0YI/zzR10GHtEDH1DUD7Dzwh8BBpfR0Sghf3xAO0WRCvbDY8kfNPD7ypQzei/oOS91n0dfk3PQlQEfIsCfT3+WEX7R2feMuMV/u3cl6F5o8NQQnK21CLfktscZAYEDIuTbQSgYjuLY4k7buJza0/F/F7s4RjNCw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1716476540796102.7866367166539; Thu, 23 May 2024 08:02:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sA9w6-0005DK-Nl; Thu, 23 May 2024 11:00:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sA9w4-00052H-3O for qemu-devel@nongnu.org; Thu, 23 May 2024 11:00:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sA9w2-0004nl-7A for qemu-devel@nongnu.org; Thu, 23 May 2024 11:00:51 -0400 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-689-P7rGI563PRS9X---cgDlkQ-1; Thu, 23 May 2024 11:00:46 -0400 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a59aedbd9a9so131181966b.0 for ; Thu, 23 May 2024 08:00:46 -0700 (PDT) Received: from avogadro.local ([151.95.155.52]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a5a55afdea7sm1681003666b.141.2024.05.23.08.00.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 08:00:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716476448; 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=njYSO7HTB+sDeOmmffYU6ooE+v8Mi/U08DiKKYNjzGE=; b=LDIxoY9y/Byi0M5ErTlkeSrHUaGAa2z5ds4ubXEoqQYKiSPQGv3iEwEpeRFJE8xIaYdQQv YnzC2Q82JU0hGY0NmvdmpQLoK+GsKNWjat/eyYU+uxeZPwjNnCT+WLS5dyyHgjvy2HzBCO gfSc2fYnQhEe7Rky3gAxkaBoq/KGwZE= X-MC-Unique: P7rGI563PRS9X---cgDlkQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716476445; x=1717081245; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=njYSO7HTB+sDeOmmffYU6ooE+v8Mi/U08DiKKYNjzGE=; b=rVIiFdRTV0q7lpNcwFgWFw6QSa7Sd30T+7PquyO45mk0gIWckfT57LC1sASgNFjME7 jS+q9s+NuFozLYzNUtJ1E3VE+ZRzhJB96RQZ0aF1OTTDLDT6lrcuFixwFxJGHaQI+tbg oksPSsMoZ4RTo9+MUVI8Wq5rnqmFA3zU8BjrL7+20CsoEnGoBLDqSY+505xQcI2zZokl FHvbk28f1VWMnAsyqXRDE3+e3uXY5CmqDxtwTEOftpwhB/AyndK7Pc9wf9BbnOEwwMgU P357AwE0Sou9g/2ARQhQFTvjldyOnF6blgg9TMgDPP1vCGqXMV31q8YV4Oofg1oe/JLh Kf9w== X-Gm-Message-State: AOJu0Yxc6EeW/GV+OnYF5GS6Bpj6UxILLIXkh0L9QKOGn0sQkBApmWxW tnG8lG84cmC59bTfnoa7EK+YgO/BRuqu9w8cPjrJfjNZAkvsHHZ/jej3OADWXDODhxAYcBL5eok qvKKuSb0h7ZITJvzffOwW5kd2HyPMT5TPOUsoMhBxBDCeiq++ATTVZ3GecDy7M84L4Kjz/ZAPZR PnBkb0VzwmxVANEXmwLDWTcEFjESVMZcZ7C8IX X-Received: by 2002:a17:906:7158:b0:a59:cd18:92f5 with SMTP id a640c23a62f3a-a62280556d2mr355745866b.11.1716476445069; Thu, 23 May 2024 08:00:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFlWqwt6lkTcobGw3vOKvo57EmJ1TPORZQNO3mGjzdXQtQQ/rU3+v2oUuUlxw3gTnUg4YZ5DA== X-Received: by 2002:a17:906:7158:b0:a59:cd18:92f5 with SMTP id a640c23a62f3a-a62280556d2mr355744166b.11.1716476444545; Thu, 23 May 2024 08:00:44 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Bernhard Beschow Subject: [PULL 03/23] hw/i386/pc_sysfw: Alias rather than copy isa-bios region Date: Thu, 23 May 2024 17:00:16 +0200 Message-ID: <20240523150036.1050011-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240523150036.1050011-1-pbonzini@redhat.com> References: <20240523150036.1050011-1-pbonzini@redhat.com> MIME-Version: 1.0 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: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1716476542158100007 Content-Type: text/plain; charset="utf-8" From: Bernhard Beschow In the -bios case the "isa-bios" memory region is an alias to the BIOS mapp= ed to the top of the 4G memory boundary. Do the same in the -pflash case, but = only for new machine versions for migration compatibility. This establishes comm= on behavior and makes pflash commands work in the "isa-bios" region which some real-world legacy bioses rely on. Note that in the sev_enabled() case, the "isa-bios" memory region in the -p= flash case will now also point to encrypted memory, just like it already does in = the -bios case. When running `info mtree` before and after this commit with `qemu-system-x86_64 -S -drive \ if=3Dpflash,format=3Draw,readonly=3Don,file=3D/usr/share/qemu/bios-256k.bin= ` and running `diff -u before.mtree after.mtree` results in the following changes in the memory tree: --- before.mtree +++ after.mtree @@ -71,7 +71,7 @@ 0000000000000000-ffffffffffffffff (prio -1, i/o): pci 00000000000a0000-00000000000bffff (prio 1, i/o): vga-lowmem 00000000000c0000-00000000000dffff (prio 1, rom): pc.rom - 00000000000e0000-00000000000fffff (prio 1, rom): isa-bios + 00000000000e0000-00000000000fffff (prio 1, romd): alias isa-bios = @system.flash0 0000000000020000-000000000003ffff 00000000000a0000-00000000000bffff (prio 1, i/o): alias smram-region= @pci 00000000000a0000-00000000000bffff 00000000000c0000-00000000000c3fff (prio 1, i/o): alias pam-pci @pci= 00000000000c0000-00000000000c3fff 00000000000c4000-00000000000c7fff (prio 1, i/o): alias pam-pci @pci= 00000000000c4000-00000000000c7fff @@ -108,7 +108,7 @@ 0000000000000000-ffffffffffffffff (prio -1, i/o): pci 00000000000a0000-00000000000bffff (prio 1, i/o): vga-lowmem 00000000000c0000-00000000000dffff (prio 1, rom): pc.rom - 00000000000e0000-00000000000fffff (prio 1, rom): isa-bios + 00000000000e0000-00000000000fffff (prio 1, romd): alias isa-bios = @system.flash0 0000000000020000-000000000003ffff 00000000000a0000-00000000000bffff (prio 1, i/o): alias smram-region= @pci 00000000000a0000-00000000000bffff 00000000000c0000-00000000000c3fff (prio 1, i/o): alias pam-pci @pci= 00000000000c0000-00000000000c3fff 00000000000c4000-00000000000c7fff (prio 1, i/o): alias pam-pci @pci= 00000000000c4000-00000000000c7fff @@ -131,11 +131,14 @@ memory-region: pc.ram 0000000000000000-0000000007ffffff (prio 0, ram): pc.ram +memory-region: system.flash0 + 00000000fffc0000-00000000ffffffff (prio 0, romd): system.flash0 + memory-region: pci 0000000000000000-ffffffffffffffff (prio -1, i/o): pci 00000000000a0000-00000000000bffff (prio 1, i/o): vga-lowmem 00000000000c0000-00000000000dffff (prio 1, rom): pc.rom - 00000000000e0000-00000000000fffff (prio 1, rom): isa-bios + 00000000000e0000-00000000000fffff (prio 1, romd): alias isa-bios @s= ystem.flash0 0000000000020000-000000000003ffff memory-region: smram 00000000000a0000-00000000000bffff (prio 0, ram): alias smram-low @p= c.ram 00000000000a0000-00000000000bffff Note that in both cases the "system" memory region contains the entry 00000000fffc0000-00000000ffffffff (prio 0, romd): system.flash0 but the "system.flash0" memory region only appears standalone when "isa-bio= s" is an alias. Signed-off-by: Bernhard Beschow Message-ID: <20240508175507.22270-7-shentey@gmail.com> Signed-off-by: Paolo Bonzini --- include/hw/i386/pc.h | 1 + hw/i386/pc.c | 1 + hw/i386/pc_piix.c | 3 +++ hw/i386/pc_q35.c | 2 ++ hw/i386/pc_sysfw.c | 8 +++++++- 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index e52290916cb..ad9c3d9ba84 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -119,6 +119,7 @@ struct PCMachineClass { bool enforce_aligned_dimm; bool broken_reserved_end; bool enforce_amd_1tb_hole; + bool isa_bios_alias; =20 /* generate legacy CPU hotplug AML */ bool legacy_cpu_hotplug; diff --git a/hw/i386/pc.c b/hw/i386/pc.c index bfb46e9b548..4a2d6f5a97f 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1816,6 +1816,7 @@ static void pc_machine_class_init(ObjectClass *oc, vo= id *data) pcmc->has_reserved_memory =3D true; pcmc->enforce_aligned_dimm =3D true; pcmc->enforce_amd_1tb_hole =3D true; + pcmc->isa_bios_alias =3D true; /* BIOS ACPI tables: 128K. Other BIOS datastructures: less than 4K rep= orted * to be used at the moment, 32K should be enough for a while. */ pcmc->acpi_data_size =3D 0x20000 + 0x8000; diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 99efb3c45cb..ebb51de3809 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -526,12 +526,15 @@ DEFINE_I440FX_MACHINE(v9_1, "pc-i440fx-9.1", NULL, =20 static void pc_i440fx_9_0_machine_options(MachineClass *m) { + PCMachineClass *pcmc =3D PC_MACHINE_CLASS(m); + pc_i440fx_9_1_machine_options(m); m->alias =3D NULL; m->is_default =3D false; =20 compat_props_add(m->compat_props, hw_compat_9_0, hw_compat_9_0_len); compat_props_add(m->compat_props, pc_compat_9_0, pc_compat_9_0_len); + pcmc->isa_bios_alias =3D false; } =20 DEFINE_I440FX_MACHINE(v9_0, "pc-i440fx-9.0", NULL, diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index bb53a51ac18..bd7db4abacf 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -378,10 +378,12 @@ DEFINE_Q35_MACHINE(v9_1, "pc-q35-9.1", NULL, =20 static void pc_q35_9_0_machine_options(MachineClass *m) { + PCMachineClass *pcmc =3D PC_MACHINE_CLASS(m); pc_q35_9_1_machine_options(m); m->alias =3D NULL; compat_props_add(m->compat_props, hw_compat_9_0, hw_compat_9_0_len); compat_props_add(m->compat_props, pc_compat_9_0, pc_compat_9_0_len); + pcmc->isa_bios_alias =3D false; } =20 DEFINE_Q35_MACHINE(v9_0, "pc-q35-9.0", NULL, diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c index 82d37cb376b..ac88ad4eb91 100644 --- a/hw/i386/pc_sysfw.c +++ b/hw/i386/pc_sysfw.c @@ -135,6 +135,7 @@ static void pc_system_flash_map(PCMachineState *pcms, MemoryRegion *rom_memory) { X86MachineState *x86ms =3D X86_MACHINE(pcms); + PCMachineClass *pcmc =3D PC_MACHINE_GET_CLASS(pcms); hwaddr total_size =3D 0; int i; BlockBackend *blk; @@ -184,7 +185,12 @@ static void pc_system_flash_map(PCMachineState *pcms, =20 if (i =3D=3D 0) { flash_mem =3D pflash_cfi01_get_memory(system_flash); - pc_isa_bios_init(&x86ms->isa_bios, rom_memory, flash_mem); + if (pcmc->isa_bios_alias) { + x86_isa_bios_init(&x86ms->isa_bios, rom_memory, flash_mem, + true); + } else { + pc_isa_bios_init(&x86ms->isa_bios, rom_memory, flash_mem); + } =20 /* Encrypt the pflash boot ROM */ if (sev_enabled()) { --=20 2.45.1