From nobody Sun May 19 06:23:11 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1713816436; cv=none; d=zohomail.com; s=zohoarc; b=LNJJL4zJp9j00asasYvWpKcwWiy+lziIvEQu5hBprHiHmyiMdoZvtSX0S0RQBXyS89NL1XXnULk364orkJO6kDYYRSdi2WeglQ7i130ClYXBBx9Xh3Fj5HE/gdnI0Sv9awnheniIT1xDwwZWxA918/bl40CVCIsXmX+CCD2aJiw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1713816436; 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=PchXtO8ad4BByoR+U+nzto09/ZkQHiG8u94aXCkO74U=; b=KLVrAniAGzsIwFBbeNDku6o7ennSnFMw40t91uY4Uhr2ehUKHjafm0G1xqIfziUPlX1TNaTWgS7dc6ajIl4kASUC5K0hyW3BnTLuQRg3PFYLKeCmEUSMYAHHS0gtB+GAaZJZngGWv9yT3DGgtxzOI70jcL5YrcbBElRre9jAPlk= 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 1713816436672417.56961151905193; Mon, 22 Apr 2024 13:07:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ryzw1-0007SH-OP; Mon, 22 Apr 2024 16:06:41 -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 1ryzw0-0007Rt-9E for qemu-devel@nongnu.org; Mon, 22 Apr 2024 16:06:40 -0400 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ryzvy-0004h9-6E for qemu-devel@nongnu.org; Mon, 22 Apr 2024 16:06:40 -0400 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-51ae2e37a87so3349729e87.2 for ; Mon, 22 Apr 2024 13:06:37 -0700 (PDT) Received: from Provence.localdomain (dynamic-077-188-098-082.77.188.pool.telefonica.de. [77.188.98.82]) by smtp.gmail.com with ESMTPSA id z2-20020a17090665c200b00a55bbc4fd16sm1209230ejn.48.2024.04.22.13.06.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 13:06:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713816395; x=1714421195; 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=PchXtO8ad4BByoR+U+nzto09/ZkQHiG8u94aXCkO74U=; b=N8Um8+2ZtZS2lKm4CKe8dqrEt9AAQey4Glrs5Ma3BSnWiZn93fJ+av6hZjLzLCsik/ hU03LzfpsHxbPMA55Tq4SazEUZc+fLTxzByx9lGpro+/bdWihqiOmygz0u5YCM8T7+BZ nt981XYWBaDWBoYuYyPZiL792ryk1YVGnu8ZTao7a1aHtq81yzn7EFGDmgiws7qATJ+I EHtqUrqFa8MjA37YQR8/cVoWG3/gzMoSX2dQG+pymtQf65FUpEPeT1QIkhbZDGVYFlcE 2ZmIqUV10HcjQU0BQHhQT/FCgAlVP+PppyGZ+dkQu1ElDVml0QKzhSYofu0F3oF50VES ymBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713816395; x=1714421195; 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=PchXtO8ad4BByoR+U+nzto09/ZkQHiG8u94aXCkO74U=; b=ZYzIwtgTPQeYk5+n9rrG2is5HWBmEvWdpwBeRAkBhnareQ0aCx8nMKiUUOoMPCz+GJ 6mmYvdsQlOT2mCtA9yb5wztC+fKvQutUZITESMYuwlwlTXeHaiVG7nX9ybx891hgyhPz 0m/pARbKx1jI4E1ha89q4p4LmRkvHoGRM7GBAGJ9w7JVW6WXO/UN2/cQznWWOpS/PUTV P65GprSzcp001Pyymld1SHOPv39skOnsO9XaX5LAVWgSuUbJpFFrcUlJKMe8l60885UF p9BmJC5xHPLN6LS2OCuaaH1zoMBelUXhxxHcGTmMg1w1Bsm1SX2FaVLg6rAXIUT6VBuc EJlw== X-Gm-Message-State: AOJu0YxUmwAP8NumyV5IeH8eDactdKxuy2Z3mL0w6OtvfDWh1Xcoc5bP 3LsZC4/cIUX5yneGmyCADDKhQPT7ILW4iU7Bc3hXfRuVUlud2ihwvkK69A== X-Google-Smtp-Source: AGHT+IHmxnLq8JtJQdoTuWNwb51WI8eX14I4q/TTWOJlR+gnJXZ2LpJe4XdzMGaquhqw9WNDgCRzRQ== X-Received: by 2002:a19:5f41:0:b0:516:cd83:a96a with SMTP id a1-20020a195f41000000b00516cd83a96amr4014626lfj.37.1713816394816; Mon, 22 Apr 2024 13:06:34 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: Paolo Bonzini , "Michael S. Tsirkin" , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum , Bernhard Beschow Subject: [PATCH 1/4] hw/i386/pc_sysfw: Remove unused parameter from pc_isa_bios_init() Date: Mon, 22 Apr 2024 22:06:22 +0200 Message-ID: <20240422200625.2768-2-shentey@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240422200625.2768-1-shentey@gmail.com> References: <20240422200625.2768-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::133; envelope-from=shentey@gmail.com; helo=mail-lf1-x133.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: 1713816437651100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Bernhard Beschow Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/i386/pc_sysfw.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c index 3efabbbab2..87b5bf59d6 100644 --- a/hw/i386/pc_sysfw.c +++ b/hw/i386/pc_sysfw.c @@ -41,8 +41,7 @@ #define FLASH_SECTOR_SIZE 4096 =20 static void pc_isa_bios_init(MemoryRegion *rom_memory, - MemoryRegion *flash_mem, - int ram_size) + MemoryRegion *flash_mem) { int isa_bios_size; MemoryRegion *isa_bios; @@ -186,7 +185,7 @@ 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(rom_memory, flash_mem, size); + pc_isa_bios_init(rom_memory, flash_mem); =20 /* Encrypt the pflash boot ROM */ if (sev_enabled()) { --=20 2.44.0 From nobody Sun May 19 06:23:11 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1713816473; cv=none; d=zohomail.com; s=zohoarc; b=nnGsvOAhJhc6Qr1aCgE5mdTyR3VXn5F0s52Rnfce4Fp8FSQwOWezvqrvee+/88TBBuAfMUzQOBGPeIm5bTnVUv02B3/XAdJ2LX0xwqrc1/l50U3cL90dgd8h7yyR/Qmu0X3Td6JbFQv20UJw1621ow8oSA/e7g2k2NEL7ljzWIM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1713816473; 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=ZG/ndfe8xsvdvVaLhadRrtKayU/SCqRwtgihcJ0dO/Y=; b=UT9isqmVqOivopHq2F1kUmnkvXPw799m2bu5ryaRYZa07cIEZ0r+WkeFdP6b5UJP4XOPuErZXclhaHKgWwpN4iklhytMdPlzijJtUuPhFxFgLULonX3mQADqnA5DgSZGI5vnWtEHbaEKuDyf2Bj5xRkO3+2RJgzk44pF4SZtSBY= 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 171381647384217.37174134204963; Mon, 22 Apr 2024 13:07:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ryzw4-0007Sp-8v; Mon, 22 Apr 2024 16:06:44 -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 1ryzw1-0007S9-2b for qemu-devel@nongnu.org; Mon, 22 Apr 2024 16:06:41 -0400 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ryzvz-0004hN-GF for qemu-devel@nongnu.org; Mon, 22 Apr 2024 16:06:40 -0400 Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-a55911bff66so357185766b.0 for ; Mon, 22 Apr 2024 13:06:38 -0700 (PDT) Received: from Provence.localdomain (dynamic-077-188-098-082.77.188.pool.telefonica.de. [77.188.98.82]) by smtp.gmail.com with ESMTPSA id z2-20020a17090665c200b00a55bbc4fd16sm1209230ejn.48.2024.04.22.13.06.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 13:06:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713816397; x=1714421197; 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=ZG/ndfe8xsvdvVaLhadRrtKayU/SCqRwtgihcJ0dO/Y=; b=Oo9FUbyoPWuztsGt1U5p3/T9ag+DtQuIzPpTiyQMv1qG1wgkfBPEoy4Dw+jzcvH3oz 2FCpI7AiSkPp4iwE60j5ZTU6+/+F5azyFZ7WDYuVobb1xv5taPeWmw1dJQbuchImnAkX ADPwTscJjBG1/kMePEjwcGFdX5fzFV+9V4LSwlzBdM/0ka0Y51n9pDAHBtwdsfFMZ7Mf uqnyfNdFE7n0N/R572pJ6TQfMwmBbRrHZdYKkcnnqpnJCjieVs185DamiA4CfwPFDtaN Boh3oYIzlCANj/3B0cbrPzHBbPDwmnLKh4xj/Hu5ocjX+0jfPpXTMp8mB/hmxBGguKdK lV/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713816397; x=1714421197; 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=ZG/ndfe8xsvdvVaLhadRrtKayU/SCqRwtgihcJ0dO/Y=; b=PB42QqktVw+rqxHc68v0yD+XVuyORPMaJi1IbyC0KsVGPWzMnzUg/ULI1SrfFY7oFJ 2w/H2+LdN86gWWi/0HycmfgV8CzdEmA+WaRdff3ixhUgl4KDYNhPqiBD0bukS7KotTHr xyOfnQlDYKD/3PJCurEdX9mV1oFT6oXnb/uxusppHL6F/eHvQBi6Qk+X2K5F32Bg5lW0 BGHRP6UPPWh1HmOoF/c/zteZxVv9toaTO7Sjklx2mculSCqc02lQZrrbYw8sZ4GswLev d3uZUd4q/Z72Z7VjczU1ykNpYUUWzsm0GCFbeOo8JVaxKRHnAFgd4EU/QquY5wSAhaHe fFaA== X-Gm-Message-State: AOJu0YwuHXaaGmlqNfjtfS4LB2KfHRHLbWAGG9TYcoj5t1HPNhlZb5jA FA8Ww7Lw3kgjN1SnR3V+jdxTZZp+FFCA5noXKXyKFKTVgVeaFcD2VidOdw== X-Google-Smtp-Source: AGHT+IGwQeOjmolOLnPLCvf+xKdfiluk7k2+Xo1bCo26I6LCGGWFC3qn9AwjYtfJl25ru0eMLNIR9Q== X-Received: by 2002:a17:907:e8d:b0:a55:b9c6:bd99 with SMTP id ho13-20020a1709070e8d00b00a55b9c6bd99mr2562175ejc.56.1713816396956; Mon, 22 Apr 2024 13:06:36 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: Paolo Bonzini , "Michael S. Tsirkin" , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum , Bernhard Beschow Subject: [PATCH 2/4] hw/i386/pc_sysfw: Alias rather than copy isa-bios region Date: Mon, 22 Apr 2024 22:06:23 +0200 Message-ID: <20240422200625.2768-3-shentey@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240422200625.2768-1-shentey@gmail.com> References: <20240422200625.2768-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::636; envelope-from=shentey@gmail.com; helo=mail-ej1-x636.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: 1713816475775100001 Content-Type: text/plain; charset="utf-8" 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 to ha= ve common behavior. This also makes pflash commands work in the "isa-bios" reg= ion 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. Signed-off-by: Bernhard Beschow --- hw/i386/pc_sysfw.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c index 87b5bf59d6..6e89671c26 100644 --- a/hw/i386/pc_sysfw.c +++ b/hw/i386/pc_sysfw.c @@ -46,27 +46,18 @@ static void pc_isa_bios_init(MemoryRegion *rom_memory, int isa_bios_size; MemoryRegion *isa_bios; uint64_t flash_size; - void *flash_ptr, *isa_bios_ptr; =20 flash_size =3D memory_region_size(flash_mem); =20 /* map the last 128KB of the BIOS in ISA space */ isa_bios_size =3D MIN(flash_size, 128 * KiB); isa_bios =3D g_malloc(sizeof(*isa_bios)); - memory_region_init_ram(isa_bios, NULL, "isa-bios", isa_bios_size, - &error_fatal); + memory_region_init_alias(isa_bios, NULL, "isa-bios", flash_mem, + flash_size - isa_bios_size, isa_bios_size); memory_region_add_subregion_overlap(rom_memory, 0x100000 - isa_bios_size, isa_bios, 1); - - /* copy ISA rom image from top of flash memory */ - flash_ptr =3D memory_region_get_ram_ptr(flash_mem); - isa_bios_ptr =3D memory_region_get_ram_ptr(isa_bios); - memcpy(isa_bios_ptr, - ((uint8_t*)flash_ptr) + (flash_size - isa_bios_size), - isa_bios_size); - memory_region_set_readonly(isa_bios, true); } =20 --=20 2.44.0 From nobody Sun May 19 06:23:11 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1713816463; cv=none; d=zohomail.com; s=zohoarc; b=O5CQunLWt2WxkFy8IiwWujPm4nIfLKADeO7nLF/cgcOGRneFrNLPRnGC4FamB4SfDviYlXdpSbv/UosZy1H1X8ckD7hNtyts0awskn6Mxe/9jn/SjCGJD2DlbYqXPsQRgeySzsdgnl/9l4DN95mYNewmbIBRF1Aa7EnybbBHU48= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1713816463; 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=B3mpE8mPOXIfCN0iys//quAbHTgXlOuPmee5Oc6B/Lo=; b=FEg3KxWgu9S0Tgs2dOKCicT+VlEa+qY19YhE3I8514JM4lkWnAi+EPWW97oE6wjOXHlM6YLNUK+4NbjWhX5hQhKue3b4dxpV4i6rSYiQqMH9ffbE1I70XOHNH51NTLkUFoStsmbA4jARa8D+8I4U8vu3bqvb+Wolt8r6iGKereg= 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 1713816463874919.5211874825857; Mon, 22 Apr 2024 13:07:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ryzw7-0007TS-Bx; Mon, 22 Apr 2024 16:06:47 -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 1ryzw3-0007Se-08 for qemu-devel@nongnu.org; Mon, 22 Apr 2024 16:06:43 -0400 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ryzw1-0004he-Ay for qemu-devel@nongnu.org; Mon, 22 Apr 2024 16:06:42 -0400 Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-a5544fd07easo539900666b.0 for ; Mon, 22 Apr 2024 13:06:40 -0700 (PDT) Received: from Provence.localdomain (dynamic-077-188-098-082.77.188.pool.telefonica.de. [77.188.98.82]) by smtp.gmail.com with ESMTPSA id z2-20020a17090665c200b00a55bbc4fd16sm1209230ejn.48.2024.04.22.13.06.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 13:06:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713816398; x=1714421198; 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=B3mpE8mPOXIfCN0iys//quAbHTgXlOuPmee5Oc6B/Lo=; b=ZP7jFYbjMim/YjgmzvIyhGM7uqbS32dVqkgqdQfX15TkLJdnzFIZev5OeZ5/au6VdX vyL2TSmpRP2YF7/HqfreAgKFo1g8qo5OIVzikuDF8bwpS4G9GgQ67E1drme/i0q5MG1Y nLzxd1J0j8FHmmcXwX8cHrjO2uEsTpJKDLgRFg4aCPdZNWwFcHlF/fwhMqXgypsFnGEM 0Nz2UMUh/65JW0DrXBzoUAUdL9hRlW+A9EaEk2UQY/68nkC/9znBuA+l4qpkocF4XkQ3 Eafiyln7dNmG7j0jJIe2UzjRXSSSgNiTUEUNvoTb0biUdX3zFU1+9M/ReDxfnf2kB6P4 MpQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713816398; x=1714421198; 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=B3mpE8mPOXIfCN0iys//quAbHTgXlOuPmee5Oc6B/Lo=; b=o+2Qu3tzr5DjtW4nDiKld49vW/cfYjBvG6WYAtWXgoNz1d98KDWG23jvRq0QNF/ukg 1te3LX5t+UvwFTrDwF5ZGce7d+RCXoyOQHlbq6RDL4CuW7uaLJJ5KdanHi4PJq4dWIwn zGGDyev3gzlgqWDJjXUC0ZUkAGlmoJyWJg6uwGdZNpaAIcd+J5EIze45dU9vXPYhHG/H Bib5P0FXtOTuqKTr/mLYoDjgah12WoAB91MGmD/hZfP0QC1ABRGXXbsgu8mUb/tlfgh0 z/WwkuC9PPaTI/CA8BZ3Bi84HixetsrAe6oa8ghlo05E1i6YccCJRVbWHUJcnZQ+nKCj Qyxw== X-Gm-Message-State: AOJu0YwTmqVl4rdWkb/WZUU6t54NACDgmGIWqF+3GX8iTZPRhIugXnVY n8al95zlC4KxrMLEdwVNKT4DdIom+8PqRSzQcRVnnET7eJAhdq4DWz6LwQ== X-Google-Smtp-Source: AGHT+IG+1veOecIW/1kYH99vzn3ZTgbrGUQam27XQWVISaczGxRYJS4L9R0vrvLGGMJVWPDQElVlmw== X-Received: by 2002:a17:906:2491:b0:a52:6fcb:564a with SMTP id e17-20020a170906249100b00a526fcb564amr6270998ejb.9.1713816398422; Mon, 22 Apr 2024 13:06:38 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: Paolo Bonzini , "Michael S. Tsirkin" , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum , Bernhard Beschow Subject: [PATCH 3/4] hw/i386/x86: Eliminate two if statements in x86_bios_rom_init() Date: Mon, 22 Apr 2024 22:06:24 +0200 Message-ID: <20240422200625.2768-4-shentey@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240422200625.2768-1-shentey@gmail.com> References: <20240422200625.2768-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::62d; envelope-from=shentey@gmail.com; helo=mail-ej1-x62d.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: 1713816465747100003 Content-Type: text/plain; charset="utf-8" Given that memory_region_set_readonly() is a no-op when the readonlyness is already as requested it is possible to simplify the pattern if (condition) { foo(true); } to foo(condition); which is shorter and allows to see the invariant of the code more easily. Signed-off-by: Bernhard Beschow Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/i386/x86.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/hw/i386/x86.c b/hw/i386/x86.c index ffbda48917..32cd22a4a8 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -1171,9 +1171,7 @@ void x86_bios_rom_init(MachineState *ms, const char *= default_firmware, load_image_size(filename, ptr, bios_size); x86_firmware_configure(ptr, bios_size); } else { - if (!isapc_ram_fw) { - memory_region_set_readonly(bios, true); - } + memory_region_set_readonly(bios, !isapc_ram_fw); ret =3D rom_add_file_fixed(bios_name, (uint32_t)(-bios_size), -1); if (ret !=3D 0) { goto bios_error; @@ -1190,9 +1188,7 @@ void x86_bios_rom_init(MachineState *ms, const char *= default_firmware, 0x100000 - isa_bios_size, isa_bios, 1); - if (!isapc_ram_fw) { - memory_region_set_readonly(isa_bios, true); - } + memory_region_set_readonly(isa_bios, !isapc_ram_fw); =20 /* map all the bios at the top of memory */ memory_region_add_subregion(rom_memory, --=20 2.44.0 From nobody Sun May 19 06:23:11 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1713816464; cv=none; d=zohomail.com; s=zohoarc; b=MVnITduvqP72KjEdNZ/L/PYgnLbC93YpDyLjmxCBuBtWR4/f5cR8wsXm7kqOcPSLFsgzH/kkX3f/wdsFJL8mI+Pg/Me4JK0+MnwG0yWAHOTDN2s8MCBDo901Yfpg43WtD1T2Sd2V/nSPrUxZo5+6lXRy7vmm4LIk4vtRn47mXvg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1713816464; 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=PuRE8lv8XMhRFudEtOkTIi3D71/1B4iCJia6S9gyhAM=; b=Ejid4AiKfLXP49Pxq8FGIEQ6g2jPXFWBka+V2QltJKQswKQjbod2382r7oMfQeRh3Nh6kVfMlURtaOxQWs3LDGNufL1DQqNCOV53gGwIKaoPCxAH3wA6xt2bFZQdBVE3gChVzm92Xl5lqkWROCl3qsalsCBuWo6/jSWa1x6/9wQ= 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 1713816464760728.5975114050301; Mon, 22 Apr 2024 13:07:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ryzw8-0007Tb-94; Mon, 22 Apr 2024 16:06:48 -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 1ryzw4-0007TI-Vz for qemu-devel@nongnu.org; Mon, 22 Apr 2024 16:06:45 -0400 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ryzw3-0004i3-5t for qemu-devel@nongnu.org; Mon, 22 Apr 2024 16:06:44 -0400 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-518a3e0d2ecso7238032e87.3 for ; Mon, 22 Apr 2024 13:06:42 -0700 (PDT) Received: from Provence.localdomain (dynamic-077-188-098-082.77.188.pool.telefonica.de. [77.188.98.82]) by smtp.gmail.com with ESMTPSA id z2-20020a17090665c200b00a55bbc4fd16sm1209230ejn.48.2024.04.22.13.06.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 13:06:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713816400; x=1714421200; 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=PuRE8lv8XMhRFudEtOkTIi3D71/1B4iCJia6S9gyhAM=; b=RaBcF6JbwmesWsc70J66Amq4EqW6n1EH3HkWe/Nbd+qxwHZSKJMsLjjzEWcQkgwYa5 j4OzQKKvmnBPdAUX60D2vS1VBmnb0RSRFNf4+qjR4BScyTYCsX3wu5sq4ZXeFMoxQBpK 0bFYbW76MP7+C4nUMpV975NNDrH2Uv5+Mv30Dq8WphP+zQIJE9J5oe1rpPmm8X82aZ88 p5XcIohwqTW9jZw0TW1CS9/GtzVCwzEoGfcZWcMOPFg22/YU57cPUzW4I4Djw1v+7Ukp JdSKukvOFYqjrGbMVYaYCXzfkjX+H2U8bKqMwG+6PWeiKTu13TDbIJxO0Echg21QZPuX hOiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713816400; x=1714421200; 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=PuRE8lv8XMhRFudEtOkTIi3D71/1B4iCJia6S9gyhAM=; b=jh7C1tZR1P2Or9rhloQkp6xkljG9xqJSHh1H8WYKaJnjHpQTbu3kGgs/D0aZir7snC n+rAoOZEQcO2OHZ89Vnl1h29zCYH5BqCHe5zMeu9sQICFLgxtrdDFn0ugdOOg1NiKAfP vszqO7NO/n56z9EwqG0E3PuM7gEyuwf8gZqwOEGtj85T/gX/Hu0Cm40nZApejjMJtrOq rhTafBWwqsjYYppJrDBu3PCBRjthpaM5EcPmK93RBxYMMbjx6Y2upo3SntxRg2ajITFh 1W2aPKIf/rL0abDYgg4XY7KBRPuLBJ0WvCl54KaB/LWIUA7gRgyZ7f9/VDOIzyVpb/Lj oENQ== X-Gm-Message-State: AOJu0Yw92IRFVBx3ZqvpbTacU/cfkqqQmgxrXQV9mb+6A+aFhrK5FQSL NHNnThtfXkGIh69pAdSwmz5p3+JevsrGnhEGFZYsijN9qC8sXR9lJiUOKw== X-Google-Smtp-Source: AGHT+IG8PPgbvm8dHQQs8xUFYYvwr0/Kpj+ec6lTKs0tZIJc+wcvaidF8k1cvmlzYhxhlyqdl0ECyQ== X-Received: by 2002:ac2:5e8c:0:b0:519:6402:d19e with SMTP id b12-20020ac25e8c000000b005196402d19emr8470842lfq.68.1713816400149; Mon, 22 Apr 2024 13:06:40 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: Paolo Bonzini , "Michael S. Tsirkin" , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum , Bernhard Beschow Subject: [PATCH 4/4] hw/i386: Consolidate isa-bios creation Date: Mon, 22 Apr 2024 22:06:25 +0200 Message-ID: <20240422200625.2768-5-shentey@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240422200625.2768-1-shentey@gmail.com> References: <20240422200625.2768-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::132; envelope-from=shentey@gmail.com; helo=mail-lf1-x132.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: 1713816465775100004 Content-Type: text/plain; charset="utf-8" Now that the -bios and -pflash code paths work the same it is possible to h= ave a common implementation. While at it convert the magic number 0x100000 (=3D=3D 1MiB) to increase rea= dability. Signed-off-by: Bernhard Beschow --- include/hw/i386/x86.h | 2 ++ hw/i386/pc_sysfw.c | 28 ++++------------------------ hw/i386/x86.c | 29 ++++++++++++++++++----------- 3 files changed, 24 insertions(+), 35 deletions(-) diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h index 4dc30dcb4d..8e6ba4a726 100644 --- a/include/hw/i386/x86.h +++ b/include/hw/i386/x86.h @@ -116,6 +116,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 *rom_memory, MemoryRegion *bios, + bool isapc_ram_fw); void x86_bios_rom_init(MachineState *ms, const char *default_firmware, MemoryRegion *rom_memory, bool isapc_ram_fw); =20 diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c index 6e89671c26..e529182b48 100644 --- a/hw/i386/pc_sysfw.c +++ b/hw/i386/pc_sysfw.c @@ -28,7 +28,6 @@ #include "sysemu/block-backend.h" #include "qemu/error-report.h" #include "qemu/option.h" -#include "qemu/units.h" #include "hw/sysbus.h" #include "hw/i386/x86.h" #include "hw/i386/pc.h" @@ -40,27 +39,6 @@ =20 #define FLASH_SECTOR_SIZE 4096 =20 -static void pc_isa_bios_init(MemoryRegion *rom_memory, - MemoryRegion *flash_mem) -{ - int isa_bios_size; - MemoryRegion *isa_bios; - uint64_t flash_size; - - flash_size =3D memory_region_size(flash_mem); - - /* map the last 128KB of the BIOS in ISA space */ - isa_bios_size =3D MIN(flash_size, 128 * KiB); - isa_bios =3D g_malloc(sizeof(*isa_bios)); - memory_region_init_alias(isa_bios, NULL, "isa-bios", flash_mem, - flash_size - isa_bios_size, isa_bios_size); - memory_region_add_subregion_overlap(rom_memory, - 0x100000 - isa_bios_size, - isa_bios, - 1); - memory_region_set_readonly(isa_bios, true); -} - static PFlashCFI01 *pc_pflash_create(PCMachineState *pcms, const char *name, const char *alias_prop_name) @@ -121,7 +99,7 @@ void pc_system_flash_cleanup_unused(PCMachineState *pcms) * pcms->max_fw_size. * * If pcms->flash[0] has a block backend, its memory is passed to - * pc_isa_bios_init(). Merging several flash devices for isa-bios is + * x86_isa_bios_init(). Merging several flash devices for isa-bios is * not supported. */ static void pc_system_flash_map(PCMachineState *pcms, @@ -176,7 +154,9 @@ 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(rom_memory, flash_mem); + + /* Map the last 128KB of the BIOS in ISA space */ + x86_isa_bios_init(rom_memory, flash_mem, false); =20 /* Encrypt the pflash boot ROM */ if (sev_enabled()) { diff --git a/hw/i386/x86.c b/hw/i386/x86.c index 32cd22a4a8..7366b0cee4 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -1136,13 +1136,28 @@ void x86_load_linux(X86MachineState *x86ms, nb_option_roms++; } =20 +void x86_isa_bios_init(MemoryRegion *rom_memory, MemoryRegion *bios, + bool isapc_ram_fw) +{ + int bios_size =3D memory_region_size(bios); + int isa_bios_size =3D MIN(bios_size, 128 * KiB); + MemoryRegion *isa_bios; + + isa_bios =3D g_malloc(sizeof(*isa_bios)); + memory_region_init_alias(isa_bios, NULL, "isa-bios", bios, + bios_size - isa_bios_size, isa_bios_size); + memory_region_add_subregion_overlap(rom_memory, 1 * MiB - isa_bios_siz= e, + isa_bios, 1); + memory_region_set_readonly(isa_bios, !isapc_ram_fw); +} + void x86_bios_rom_init(MachineState *ms, const char *default_firmware, MemoryRegion *rom_memory, bool isapc_ram_fw) { const char *bios_name; char *filename; - MemoryRegion *bios, *isa_bios; - int bios_size, isa_bios_size; + MemoryRegion *bios; + int bios_size; ssize_t ret; =20 /* BIOS load */ @@ -1180,15 +1195,7 @@ void x86_bios_rom_init(MachineState *ms, 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); - isa_bios =3D g_malloc(sizeof(*isa_bios)); - memory_region_init_alias(isa_bios, NULL, "isa-bios", bios, - bios_size - isa_bios_size, isa_bios_size); - memory_region_add_subregion_overlap(rom_memory, - 0x100000 - isa_bios_size, - isa_bios, - 1); - memory_region_set_readonly(isa_bios, !isapc_ram_fw); + x86_isa_bios_init(rom_memory, bios, isapc_ram_fw); =20 /* map all the bios at the top of memory */ memory_region_add_subregion(rom_memory, --=20 2.44.0