From patchwork Tue Nov 14 01:15:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhu Yijun X-Patchwork-Id: 10056973 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 48B96601D3 for ; Tue, 14 Nov 2017 01:21:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 383752969A for ; Tue, 14 Nov 2017 01:21:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2CFB2296A2; Tue, 14 Nov 2017 01:21:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0F4712969A for ; Tue, 14 Nov 2017 01:21:51 +0000 (UTC) Received: from localhost ([::1]:57166 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eEPvC-0006br-9W for patchwork-qemu-devel@patchwork.kernel.org; Mon, 13 Nov 2017 20:21:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35413) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eEPqC-0002ly-OM for qemu-devel@nongnu.org; Mon, 13 Nov 2017 20:16:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eEPq9-0003pa-Ga for qemu-devel@nongnu.org; Mon, 13 Nov 2017 20:16:40 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:2290) by eggs.gnu.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71) (envelope-from ) id 1eEPq8-0003nz-TK; Mon, 13 Nov 2017 20:16:37 -0500 Received: from 172.30.72.60 (EHLO DGGEMS412-HUB.china.huawei.com) ([172.30.72.60]) by dggrg05-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DKW85549; Tue, 14 Nov 2017 09:16:31 +0800 (CST) Received: from localhost (10.177.27.25) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.361.1; Tue, 14 Nov 2017 09:15:59 +0800 From: To: , , Date: Tue, 14 Nov 2017 09:15:54 +0800 Message-ID: <1510622154-17224-6-git-send-email-zhuyijun@huawei.com> X-Mailer: git-send-email 1.8.4.msysgit.0 In-Reply-To: <1510622154-17224-1-git-send-email-zhuyijun@huawei.com> References: <1510622154-17224-1-git-send-email-zhuyijun@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.27.25] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020204.5A0A43EF.00F2, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: fb5d816960baf9cd40ade15de84c2a3e X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] [fuzzy] X-Received-From: 45.249.212.191 Subject: [Qemu-devel] [RFC 5/5] hw/arm/virt-acpi-build: Build srat table according to mem_list X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, shameerali.kolothum.thodi@huawei.com, zhaoshenglong@huawei.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Zhu Yijun In case of accessing memory holes, we build srat table by traversing mem_list. Signed-off-by: Zhu Yijun --- hw/arm/virt-acpi-build.c | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 3d78ff6..e8dd7c9 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -487,7 +487,12 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) AcpiSratProcessorGiccAffinity *core; AcpiSratMemoryAffinity *numamem; int i, srat_start; - uint64_t mem_base; + hwaddr region_offset = 0; /* region base addr offset */ + hwaddr region_eat_size = 0; /* region consumed size */ + hwaddr node_mem_size = 0; + RAMRegion *begin_search_region = QLIST_FIRST(&vms->bootinfo.mem_list); + RAMRegion *reg; + MachineClass *mc = MACHINE_GET_CLASS(vms); const CPUArchIdList *cpu_list = mc->possible_cpu_arch_ids(MACHINE(vms)); @@ -504,12 +509,37 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) core->flags = cpu_to_le32(1); } - mem_base = vms->memmap[VIRT_MEM].base; for (i = 0; i < nb_numa_nodes; ++i) { numamem = acpi_data_push(table_data, sizeof(*numamem)); - build_srat_memory(numamem, mem_base, numa_info[i].node_mem, i, - MEM_AFFINITY_ENABLED); - mem_base += numa_info[i].node_mem; + node_mem_size = numa_info[i].node_mem; + QLIST_FOREACH(reg, &vms->bootinfo.mem_list, next) { + if (reg->base != begin_search_region->base) { + continue; + } + + if (node_mem_size >= (reg->size - region_offset)) { + region_eat_size = reg->size - region_offset; + } else { + region_eat_size = node_mem_size; + } + + build_srat_memory(numamem, reg->base + region_offset, + region_eat_size, i, MEM_AFFINITY_ENABLED); + + node_mem_size -= region_eat_size; + region_offset += region_eat_size; + begin_search_region = reg; + + /* The region is depleted */ + if (reg->size == region_offset) { + region_offset = 0; + begin_search_region = QLIST_NEXT(reg, next); + } + + if (node_mem_size == 0) { + break; + } + } } build_header(linker, table_data, (void *)srat, "SRAT",