From nobody Tue May 14 04:53:08 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=reject dis=none) header.from=hp.com ARC-Seal: i=1; a=rsa-sha256; t=1601005036; cv=none; d=zohomail.com; s=zohoarc; b=CYSfJZLIHNTlD34kjV9LhSQdcMkcGW/eHKie4eIIcLha5TxOGP8gPLWWyISbaO8EByP9LrODCmgskci6SocNQM7nyapXpDCPxOtdKnRzvBVOVFsErcyR84ZYu72q2HA2ZXGLNTdAnC0aiutcu911tTskFPrc432ikN09F/dGWc4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601005036; 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=8HcJX8q7ra1AQSCFKMeQ2WzJcs6XFlugjgqcUnZb5oE=; b=R89R7UwbIcGjdD8muOq/SULxsFXMaDhJoy9MRx8nx6mpHon4aLjXr8tL8Qy3RyyjOkQR4qveB644rrqI4uDuFT54JhcIZdaao1ww38C9Eh8dwr9eeDDtsx9r2FDXsbtg42AZU4NZX+xBQEmtg6nX+Prm1CgDYByvZTkXo4AMLxk= 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=reject dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1601005036185994.6120604429406; Thu, 24 Sep 2020 20:37:16 -0700 (PDT) Received: from localhost ([::1]:40434 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLeXq-0003cI-7a for importer@patchew.org; Thu, 24 Sep 2020 23:37:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52598) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLeXF-00037k-0F for qemu-devel@nongnu.org; Thu, 24 Sep 2020 23:36:37 -0400 Received: from us-smtp-delivery-162.mimecast.com ([63.128.21.162]:23022) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLeXC-0002tH-1F for qemu-devel@nongnu.org; Thu, 24 Sep 2020 23:36:36 -0400 Received: from g1t6213.austin.hp.com (g1t6213.austin.hp.com [15.73.96.121]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-468-Jybsn_LoObieL5RuZWTZxA-1; Thu, 24 Sep 2020 23:36:29 -0400 Received: from g2t4689.austin.hpicorp.net (g2t4689.austin.hpicorp.net [15.94.10.175]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by g1t6213.austin.hp.com (Postfix) with ESMTPS id 3B13423E; Fri, 25 Sep 2020 03:36:28 +0000 (UTC) Received: from localhost.localdomain (unknown [15.52.82.192]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by g2t4689.austin.hpicorp.net (Postfix) with ESMTPS id 01C00EB; Fri, 25 Sep 2020 03:36:26 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hp.com; s=mimecast20180716; t=1601004991; 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; bh=8HcJX8q7ra1AQSCFKMeQ2WzJcs6XFlugjgqcUnZb5oE=; b=RyobqoaqZFY0xoejYC9NXvMnjVHHbQZVMtT/Xoekf3yGx1tkmRK448UHpmYYAlVJkIypEg /UkpC5b9IdkeTg8yE7sAXOR0f13PE+IO92qR1tWBqS4ceUA21F7ESJUxV11hr1uO1cIjOj bpbYwWw9GZRihXEZHGeWtLoW7yebWGw= X-MC-Unique: Jybsn_LoObieL5RuZWTZxA-1 From: Erich Mcmillan To: qemu-devel@nongnu.org Cc: lersek@redhat.com, dgilbert@redhat.com, mst@redhat.com, marcel.apfelbaum@gmail.com, imammedo@redhat.com, kraxel@redhat.com, Erich McMillan Subject: [PATCH v5] hw/i386/pc: add max combined fw size as machine configuration option Date: Fri, 25 Sep 2020 03:36:23 +0000 Message-Id: <20200925033623.3968-1-erich.mcmillan@hp.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA62A171 smtp.mailfrom=erich.mcmillan@hp.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: hp.com 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=63.128.21.162; envelope-from=erich.mcmillan@hp.com; helo=us-smtp-delivery-162.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/24 23:36:31 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, 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_H3=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.23 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" X-ZohoMail-DKIM: pass (identity @hp.com) Content-Type: text/plain; charset="utf-8" From: Erich McMillan At HPi we have a need for increased fw size to enable testing of our custom= fw. Signed-off-by: Erich McMillan Change since v4: Add explicit return to pc_machine_set_max_fw_size. Remove /* default */ from max_fw_size initialization. --- hw/i386/pc.c | 52 ++++++++++++++++++++++++++++++++++++++++++++ hw/i386/pc_sysfw.c | 13 ++--------- include/hw/i386/pc.h | 2 ++ 3 files changed, 56 insertions(+), 11 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index d11daacc23..6e66cbbc41 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1869,6 +1869,51 @@ static void pc_machine_set_max_ram_below_4g(Object *= obj, Visitor *v, pcms->max_ram_below_4g =3D value; } =20 +static void pc_machine_get_max_fw_size(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + PCMachineState *pcms =3D PC_MACHINE(obj); + uint64_t value =3D pcms->max_fw_size; + + visit_type_size(v, name, &value, errp); +} + +static void pc_machine_set_max_fw_size(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + PCMachineState *pcms =3D PC_MACHINE(obj); + Error *error =3D NULL; + uint64_t value; + + visit_type_size(v, name, &value, &error); + if (error) { + error_propagate(errp, error); + return; + } + + /* + * We don't have a theoretically justifiable exact lower bound on the b= ase + * address of any flash mapping. In practice, the IO-APIC MMIO range is + * [0xFEE00000..0xFEE01000] -- see IO_APIC_DEFAULT_ADDRESS --, leaving = free + * only 18MB-4KB below 4G. For now, restrict the cumulative mapping to = 8MB in + * size. + */ + if (value > 16 * MiB) { + error_setg(errp, + "User specified max allowed firmware size %" PRIu64 " i= s " + "greater than 16MiB. If combined firwmare size exceeds " + "16MiB the system may not boot, or experience intermitt= ent" + "stability issues.", + value); + } + + pcms->max_fw_size =3D value; + + return; +} + static void pc_machine_initfn(Object *obj) { PCMachineState *pcms =3D PC_MACHINE(obj); @@ -1884,6 +1929,7 @@ static void pc_machine_initfn(Object *obj) pcms->smbus_enabled =3D true; pcms->sata_enabled =3D true; pcms->pit_enabled =3D true; + pcms->max_fw_size =3D 8 * MiB; =20 pc_system_flash_create(pcms); pcms->pcspk =3D isa_new(TYPE_PC_SPEAKER); @@ -2004,6 +2050,12 @@ static void pc_machine_class_init(ObjectClass *oc, v= oid *data) =20 object_class_property_add_bool(oc, PC_MACHINE_PIT, pc_machine_get_pit, pc_machine_set_pit); + + object_class_property_add(oc, PC_MACHINE_MAX_FW_SIZE, "size", + pc_machine_get_max_fw_size, pc_machine_set_max_fw_size, + NULL, NULL); + object_class_property_set_description(oc, PC_MACHINE_MAX_FW_SIZE, + "Maximum combined firmware size"); } =20 static const TypeInfo pc_machine_info =3D { diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c index b6c0822fe3..22450ba0ef 100644 --- a/hw/i386/pc_sysfw.c +++ b/hw/i386/pc_sysfw.c @@ -39,15 +39,6 @@ #include "hw/block/flash.h" #include "sysemu/kvm.h" =20 -/* - * We don't have a theoretically justifiable exact lower bound on the base - * address of any flash mapping. In practice, the IO-APIC MMIO range is - * [0xFEE00000..0xFEE01000] -- see IO_APIC_DEFAULT_ADDRESS --, leaving free - * only 18MB-4KB below 4G. For now, restrict the cumulative mapping to 8MB= in - * size. - */ -#define FLASH_SIZE_LIMIT (8 * MiB) - #define FLASH_SECTOR_SIZE 4096 =20 static void pc_isa_bios_init(MemoryRegion *rom_memory, @@ -182,10 +173,10 @@ static void pc_system_flash_map(PCMachineState *pcms, } if ((hwaddr)size !=3D size || total_size > HWADDR_MAX - size - || total_size + size > FLASH_SIZE_LIMIT) { + || total_size + size > pcms->max_fw_size) { error_report("combined size of system firmware exceeds " "%" PRIu64 " bytes", - FLASH_SIZE_LIMIT); + pcms->max_fw_size); exit(1); } =20 diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index fe52e165b2..f7c8e7cbfe 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -43,6 +43,7 @@ struct PCMachineState { bool smbus_enabled; bool sata_enabled; bool pit_enabled; + uint64_t max_fw_size; =20 /* NUMA information: */ uint64_t numa_nodes; @@ -59,6 +60,7 @@ struct PCMachineState { #define PC_MACHINE_SMBUS "smbus" #define PC_MACHINE_SATA "sata" #define PC_MACHINE_PIT "pit" +#define PC_MACHINE_MAX_FW_SIZE "max-fw-size" =20 /** * PCMachineClass: --=20 2.25.1