From nobody Sat May 4 08:20:02 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=tencent.com ARC-Seal: i=1; a=rsa-sha256; t=1600434760; cv=none; d=zohomail.com; s=zohoarc; b=izA3yu/7FLZgbIIPIj9XICV1k95qaNZj7hFnjpJC1DrRX4z+GMU7G0loUUyoN6CRsmd0m4XBnDb2wMdnT5AH6FmOBrH8X+2KoMucgh6Cq6Z2DFd8Ee1z7rVnWsPqJPpwdyrb9sUADD50FyduQLttRE0sfyNAjAnWUruvK+uITgY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600434760; h=Content-ID: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=IYMzpBxT8A12a+KpXqGnLrWB0pAtzJXfRZDIOY56Ki4=; b=JZH276asydAUFeBNVVlPkPz8ta8XysNZOwqwTNPcec2HN5P/DfW9xLlaqNzKqUUyerGOVNYO0cASDiS+H6Se/j9BgnGyfYnXP3QeIlG1ezcSIcXwtBRzpjKpuHb+tlhteOeBfqaLDVZywtWTxl6FZXjFDi0C3v3MSJuCU9ilqcI= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600434759397371.95707231481117; Fri, 18 Sep 2020 06:12:39 -0700 (PDT) Received: from localhost ([::1]:46204 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJGBp-0000Va-W0 for importer@patchew.org; Fri, 18 Sep 2020 09:12:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58282) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJFOp-0003QZ-HC for qemu-devel@nongnu.org; Fri, 18 Sep 2020 08:21:59 -0400 Received: from mail4.tencent.com ([183.57.53.109]:44434) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJFOe-0002AK-3H for qemu-devel@nongnu.org; Fri, 18 Sep 2020 08:21:55 -0400 Received: from EX-SZ020.tencent.com (unknown [10.28.6.40]) by mail4.tencent.com (Postfix) with ESMTP id 00962725C0; Fri, 18 Sep 2020 20:21:35 +0800 (CST) Received: from EX-SZ008.tencent.com (10.28.6.32) by EX-SZ020.tencent.com (10.28.6.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1847.3; Fri, 18 Sep 2020 20:21:34 +0800 Received: from EX-SZ006.tencent.com (10.28.6.30) by EX-SZ008.tencent.com (10.28.6.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1847.3; Fri, 18 Sep 2020 20:21:34 +0800 Received: from EX-SZ006.tencent.com ([fe80::a84e:872e:7c90:2930]) by EX-SZ006.tencent.com ([fe80::a84e:872e:7c90:2930%2]) with mapi id 15.01.1847.007; Fri, 18 Sep 2020 20:21:34 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tencent.com; s=s202002; t=1600431695; bh=IYMzpBxT8A12a+KpXqGnLrWB0pAtzJXfRZDIOY56Ki4=; h=From:To:CC:Subject:Date; b=Uq0/KDujb9rU0krgpCkUXlQYPQqrw6qD6doJCVpXo48Q7K7Sn4+Ya1Qp3CxWaWC0h v0NHYfbaXAZ5AgVh3s4bPbOWOWXpEFDddRhwXTZbXcZeYbudXUaBR1HNwrzZF6X90p NiajSOh1IvYrVdN+pfjBmHVcOA6RdCalUw3wQJZU= From: =?gb2312?B?aGFpYmluemhhbmco1cW6o7HzKQ==?= To: "peter.maydell@linaro.org" , "qemu-arm@nongnu.or" Subject: [PATCH] hw/arm/virt: use pflash image real size when mapping Thread-Topic: [PATCH] hw/arm/virt: use pflash image real size when mapping Thread-Index: AQHWjbY/cNIz15wmREu2TaM+k+G3MQ== Date: Fri, 18 Sep 2020 12:21:34 +0000 Message-ID: <8084C510-D407-4DC2-9A48-E3341E36B188@tencent.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [9.19.161.113] Content-ID: <585A42339384304595A377FA9C957283@tencent.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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=183.57.53.109; envelope-from=haibinzhang@tencent.com; helo=mail4.tencent.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/18 08:21:38 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -11 X-Spam_score: -1.2 X-Spam_bar: - X-Spam_report: (-1.2 / 5.0 requ) BAYES_00=-1.9, CHARSET_FARAWAY_HEADER=3.2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Fri, 18 Sep 2020 09:10:55 -0400 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: "qemu-devel@nongnu.org" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @tencent.com) Content-Type: text/plain; charset="utf-8" Default size of arm-virt pflash image is 64MB which will cost extra 128MB(64MBx2) memory per qemu process and 12.5GB for 100 qemu processes. Host memory is precious and it is valuable to reduce pflash image size. For compatibility arm-virt uses real size when mapping. Signed-off-by: Haibin Zhang --- hw/arm/virt.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index acf9bfbece..3545e12865 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -50,6 +50,7 @@ #include "sysemu/sysemu.h" #include "sysemu/tpm.h" #include "sysemu/kvm.h" +#include "sysemu/block-backend.h" #include "hw/loader.h" #include "exec/address-spaces.h" #include "qemu/bitops.h" @@ -1001,10 +1002,27 @@ static void virt_flash_map(VirtMachineState *vms, */ hwaddr flashsize =3D vms->memmap[VIRT_FLASH].size / 2; hwaddr flashbase =3D vms->memmap[VIRT_FLASH].base; + int64_t realsize; + BlockBackend *blk; - virt_flash_map1(vms->flash[0], flashbase, flashsize, + realsize =3D flashsize; + blk =3D pflash_cfi01_get_blk(vms->flash[0]); + if (blk) { + realsize =3D blk_getlength(blk); + realsize =3D realsize < flashsize ? realsize : flashsize; + } + + virt_flash_map1(vms->flash[0], flashbase, realsize, secure_sysmem); - virt_flash_map1(vms->flash[1], flashbase + flashsize, flashsize, + + realsize =3D flashsize; + blk =3D pflash_cfi01_get_blk(vms->flash[1]); + if (blk) { + realsize =3D blk_getlength(blk); + realsize =3D realsize < flashsize ? realsize : flashsize; + } + + virt_flash_map1(vms->flash[1], flashbase + flashsize, realsize, sysmem); } -- 2.23.0