From nobody Sun May 5 21:53:41 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=1600434763; cv=none; d=zohomail.com; s=zohoarc; b=cg2H0anJGfUwFTnrxJMnGv8tgh+1lvuqTRtHGriov6ZXnor4RsWPQlsK5xF4kShUTFSnbzFbm1FrvbRoglwVQ3WZvHw2gVlQYBI9D19qSapY5JdpSqpvdoG5KymC3zFCxtAsEztFEnqEp1SVbZ9IGN0WfKB/FxysJqsg2IJnYCM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600434763; 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=nWNZhrlqd6yDB4doEV3nw1YN5UEOhs+qnTiCaQQiVtp8yt/TPAJt7AuCn/LZr/XKyEQXPZVhc/0ZddTMNjfVwSXjFSGp6j6rF6hvfgdwQ//Wi93Ud/nSMr4GLaD76VK6Vt17WLcAHchMYNKiWiGU8FeeXCzDPubLNQNSou93hBE= 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 1600434763303190.7848230095525; Fri, 18 Sep 2020 06:12:43 -0700 (PDT) Received: from localhost ([::1]:46362 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJGBt-0000Zp-S7 for importer@patchew.org; Fri, 18 Sep 2020 09:12:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59090) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJFTN-0006HN-0v; Fri, 18 Sep 2020 08:26:41 -0400 Received: from mail6.tencent.com ([220.249.245.26]:37246) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJFTK-0002gO-MR; Fri, 18 Sep 2020 08:26:40 -0400 Received: from EX-SZ022.tencent.com (unknown [10.28.6.88]) by mail6.tencent.com (Postfix) with ESMTP id 26F65CC24B; Fri, 18 Sep 2020 20:27:54 +0800 (CST) Received: from EX-SZ004.tencent.com (10.28.6.25) by EX-SZ022.tencent.com (10.28.6.88) 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:26:30 +0800 Received: from EX-SZ006.tencent.com (10.28.6.30) by EX-SZ004.tencent.com (10.28.6.25) 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:26:30 +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:26:30 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tencent.com; s=s202002; t=1600432074; bh=IYMzpBxT8A12a+KpXqGnLrWB0pAtzJXfRZDIOY56Ki4=; h=From:To:CC:Subject:Date; b=J20t3HhkgnshsdRAZAE4gI8tz9VZDQA8+QkIc1+qPrbc7Nqp/f3akCykWVUeN9VhZ 9O1e8U/2Gh2jo53NBG6jM0h+WKQ0M+ZH0s4sxeRjUuXISpICs1S7V3oyq6FxBj6y0z l5jBwQxDfTfzGNrHp3im1LJVadRrM9GJedoCQrZ8= From: =?gb2312?B?aGFpYmluemhhbmco1cW6o7HzKQ==?= To: Peter Maydell , "qemu-arm@nongnu.org" 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: AQHWjbbv4P90hmic9Uq+Paekk/9thQ== Date: Fri, 18 Sep 2020 12:26:30 +0000 Message-ID: <790EEEF3-0799-4507-BF30-DA85440E766F@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.115] Content-ID: 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=220.249.245.26; envelope-from=haibinzhang@tencent.com; helo=mail6.tencent.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/18 08:26:31 X-ACL-Warn: Detected OS = Linux 3.1-3.10 X-Spam_score_int: 11 X-Spam_score: 1.1 X-Spam_bar: + X-Spam_report: (1.1 / 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, 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