From nobody Wed Feb 11 02:07:32 2026 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1714489703; cv=none; d=zohomail.com; s=zohoarc; b=KchWB7avLgjWwSrTttEpBqoZvRX0yxQ8l6DixtkLD+WoU2z4b61tTluE9S0Hm5YiY769k5pUWc5vsL6cxXzKjA/5CH/nfJynhOBFJkHmKYcyvESjsEwFAsj4bAwgWz5RTKTrEoECkVUhbNVdxeVuQBQHW9Di3Dwg8J4C6Cn/Xl4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1714489703; h=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=rRgm75PlnTxOQz8vg7A+phJJKx6kz6lMxdJhZ2IMl6o=; b=ep91tcmauZ9NsU23ew/k/DNc37a+FKlb+mDYxvQOLcwXWMCc45NkUyqs5HxTAJlvO9qF6/nAHUju3ZipKc7+l4rUbbtbZ3ThPxeQsnbQRTh2jfbpvWq/rjkhSzK6KhD9qT/bXd827t6uOrx5eRq5cZCPBpcVS7w4uJzSF+Ljuaw= 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 171448970375031.571753129474814; Tue, 30 Apr 2024 08:08:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s1p4w-0001BW-HA; Tue, 30 Apr 2024 11:07:34 -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 1s1p4Q-0000zD-Bl for qemu-devel@nongnu.org; Tue, 30 Apr 2024 11:07:02 -0400 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s1p4O-0000A9-Bv for qemu-devel@nongnu.org; Tue, 30 Apr 2024 11:07:02 -0400 Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-56e69888a36so6131479a12.3 for ; Tue, 30 Apr 2024 08:06:58 -0700 (PDT) Received: from archlinux.. (pd9ed788d.dip0.t-ipconnect.de. [217.237.120.141]) by smtp.gmail.com with ESMTPSA id 11-20020a0564021f4b00b005727e826977sm2345741edz.19.2024.04.30.08.06.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 08:06:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714489617; x=1715094417; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rRgm75PlnTxOQz8vg7A+phJJKx6kz6lMxdJhZ2IMl6o=; b=LCuBY0yNgpQj7XtGng/pn/bb1UyyebwX89TaLlI4onMgRhYAUECMtlxPo/HUnQZ+k+ 66r6e6D5j0CSZ6zNKNjspvSdsLxrw/4nCe31r+F+powR0njOvswBtKjeMqa9jCSdQfRx c0jOyNQPRqMfkBExD3Dfx6UTGOBEXWCGZL/0yfwAJk02dF7IDG+i/tJ/ggYBgoJxMxjE R6Pr7jcGRPqksnRY7HViiwGqhZZru1glO3G64BcpIFDl/6uYcztmftUDG0bRodp7GQQo Vd4CFgmyh8UpHApqrqp7cPoYo0Bz+PMt2fJKQesX8BNA+GNGrqt1oOFDmTPBajgRbYgR f5yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714489617; x=1715094417; 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=rRgm75PlnTxOQz8vg7A+phJJKx6kz6lMxdJhZ2IMl6o=; b=nMolnr0STNGG8mq5ThkQgBtmOfvAWD/TsT6lJdYfTaWqtIXYDekcdJUcUOKUdUHrgp 5L6Gwk4m4tN+SVSe2b7boe2UNjhr28H3kq68JCpCx3yF0xjI7CA5pvXkK5Akkm4OkOkP 2S8OiCAjwb9kWL1LRyIoXzgHPg8Y8NahXBVPgInLLr5JXS7moSKujQp0GLquZ5KBx3gT NKRVpbvRyAqz2hyR+eA78/bhvtIWRvYUv05fmEcvgC0GXufbnPcW/ENl5e4CyJ+UQbSA Pr7T0BDaW1znwUpf2L0HFW3wgdJuXYwYemkprQvustv7V3kZXHZBeMVm6qziYnn61j1B 1xwg== X-Gm-Message-State: AOJu0YySFRRshVT6k8LDDq37FShfUlQxO7/wjtdiGd0t1mvMfLQRQW4t cc91YYTwuv3EKwwhd6leXDrUSjwrCZTW52M0+K5tSS4B7xUNVs7BocT9VA== X-Google-Smtp-Source: AGHT+IEQIhNkOpKrzXM4VqkWubKD2NvCz6qoRTpbCaUl5t1e4lfMTekm9P7cLlqfvIMvdtz66+B4wQ== X-Received: by 2002:a50:9556:0:b0:56e:2d93:3f84 with SMTP id v22-20020a509556000000b0056e2d933f84mr54530eda.4.1714489617346; Tue, 30 Apr 2024 08:06:57 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Eduardo Habkost , Sergio Lopez , Marcel Apfelbaum , Michael Roth , Paolo Bonzini , Bernhard Beschow Subject: [PATCH v2 5/6] hw/i386/x86: Extract x86_isa_bios_init() from x86_bios_rom_init() Date: Tue, 30 Apr 2024 17:06:42 +0200 Message-ID: <20240430150643.111976-6-shentey@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240430150643.111976-1-shentey@gmail.com> References: <20240430150643.111976-1-shentey@gmail.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=2a00:1450:4864:20::52b; envelope-from=shentey@gmail.com; helo=mail-ed1-x52b.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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 @gmail.com) X-ZM-MESSAGEID: 1714489705835100003 Content-Type: text/plain; charset="utf-8" The function is inspired by pc_isa_bios_init() and should eventually replac= e it. Using x86_isa_bios_init() rather than pc_isa_bios_init() fixes pflash comma= nds to work in the isa-bios region. While at it convert the magic number 0x100000 (=3D=3D 1MiB) to increase rea= dability. Signed-off-by: Bernhard Beschow Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/i386/x86.h | 2 ++ hw/i386/x86.c | 25 ++++++++++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h index fb41263b9d..e92a226d13 100644 --- a/include/hw/i386/x86.h +++ b/include/hw/i386/x86.h @@ -119,6 +119,8 @@ void x86_cpu_unplug_request_cb(HotplugHandler *hotplug_= dev, void x86_cpu_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp); =20 +void x86_isa_bios_init(MemoryRegion *isa_bios, MemoryRegion *isa_memory, + MemoryRegion *bios, bool read_only); void x86_bios_rom_init(X86MachineState *x86ms, const char *default_firmwar= e, MemoryRegion *rom_memory, bool isapc_ram_fw); =20 diff --git a/hw/i386/x86.c b/hw/i386/x86.c index 29167de97d..c61f4ebfa6 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -1128,12 +1128,25 @@ void x86_load_linux(X86MachineState *x86ms, nb_option_roms++; } =20 +void x86_isa_bios_init(MemoryRegion *isa_bios, MemoryRegion *isa_memory, + MemoryRegion *bios, bool read_only) +{ + uint64_t bios_size =3D memory_region_size(bios); + uint64_t isa_bios_size =3D MIN(bios_size, 128 * KiB); + + memory_region_init_alias(isa_bios, NULL, "isa-bios", bios, + bios_size - isa_bios_size, isa_bios_size); + memory_region_add_subregion_overlap(isa_memory, 1 * MiB - isa_bios_siz= e, + isa_bios, 1); + memory_region_set_readonly(isa_bios, read_only); +} + void x86_bios_rom_init(X86MachineState *x86ms, const char *default_firmwar= e, MemoryRegion *rom_memory, bool isapc_ram_fw) { const char *bios_name; char *filename; - int bios_size, isa_bios_size; + int bios_size; ssize_t ret; =20 /* BIOS load */ @@ -1171,14 +1184,8 @@ void x86_bios_rom_init(X86MachineState *x86ms, const= char *default_firmware, g_free(filename); =20 /* map the last 128KB of the BIOS in ISA space */ - isa_bios_size =3D MIN(bios_size, 128 * KiB); - memory_region_init_alias(&x86ms->isa_bios, NULL, "isa-bios", &x86ms->b= ios, - bios_size - isa_bios_size, isa_bios_size); - memory_region_add_subregion_overlap(rom_memory, - 0x100000 - isa_bios_size, - &x86ms->isa_bios, - 1); - memory_region_set_readonly(&x86ms->isa_bios, !isapc_ram_fw); + x86_isa_bios_init(&x86ms->isa_bios, rom_memory, &x86ms->bios, + !isapc_ram_fw); =20 /* map all the bios at the top of memory */ memory_region_add_subregion(rom_memory, --=20 2.45.0