From nobody Tue Feb 10 08:41:03 2026 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=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1658250514; cv=none; d=zohomail.com; s=zohoarc; b=UUw2S8jqO/rZKdKGHq4xIynPTWM9z7ytLKgtO7PxDmQl7tK5XceV7Jub6kn9Bdilp7zkwmRPL2mdP3eIxa9skKTCMsZDXsldhHqQB0C4Q3xo8uSEeU+BTjgCoTzEZmuil7RjTU3FLNmpix/G2m/W8JOM42xP2tp6XJMLgc1v4ik= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658250514; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=ixN0oPpoS+BsioWh9j1I9yIvREwF2/BAEzfPmo0kQ74=; b=bwOx/cfg4qCs3WwJixkUz+I592YchNGYoOe7GmRg0NYc1hlbWLlbK9Hm4br3+17xp6Y2/vHKsN+OfksOPbzDyvxLQaTA1Oqyik/fm2YbD5hl2b8GYfN1tyosxPuzcmsOno+ZBw+DWwW6lieyXpocskAtBSO1ZsgjsH0APyk1Q4w= 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 1658250514356479.24550271785733; Tue, 19 Jul 2022 10:08:34 -0700 (PDT) Received: from localhost ([::1]:43352 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oDqhy-0005Z2-Qu for importer@patchew.org; Tue, 19 Jul 2022 13:08:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41892) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDqb0-0005Cm-43 for qemu-devel@nongnu.org; Tue, 19 Jul 2022 13:01:18 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:34810) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDqax-0002fE-9t for qemu-devel@nongnu.org; Tue, 19 Jul 2022 13:01:17 -0400 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26JF4wj7030726; Tue, 19 Jul 2022 17:01:04 GMT Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3hbkrc71s5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 19 Jul 2022 17:01:03 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 26JGMwPY009844; Tue, 19 Jul 2022 17:01:02 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3hc1ggpau2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 19 Jul 2022 17:01:02 +0000 Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 26JH0i54032177; Tue, 19 Jul 2022 17:01:01 GMT Received: from paddy.uk.oracle.com (dhcp-10-175-221-30.vpn.oracle.com [10.175.221.30]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3hc1ggpaer-6; Tue, 19 Jul 2022 17:01:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2022-7-12; bh=ixN0oPpoS+BsioWh9j1I9yIvREwF2/BAEzfPmo0kQ74=; b=2lrBiVG7vr6akADrfRsCzxLkRh6MGO9LlZjqQHnXZpzGkTEe69Awf1jGw1jE+DihFFya hBv5fXaTcTNKMpt1tczDBh6xMOmepTpfY7JXfrd/Tl52Ml63gyMphEsZTzej9HuHKBM1 zQQYjCm5E8zXkhJPqLdEoxJdSVu22eQn/5Ls+f4QLADPiUh9JmmUBIG8lhpZHM9kk85V ZGogpL90mNx3CVkaBwbi3sY73Ti49to+RRMssagVd3PBe5masryGjHAWwPcIzx4Nwqph 8CNtEUdVTGiqdB60ZaB0uRe3aRk87SJHj8OOfcHbL77fNzBO1wUUfWxyePS/1tJuNPnL AA== From: Joao Martins To: qemu-devel@nongnu.org Cc: Igor Mammedov , Eduardo Habkost , "Michael S. Tsirkin" , Richard Henderson , Alex Williamson , Paolo Bonzini , Ani Sinha , Marcel Apfelbaum , "Dr. David Alan Gilbert" , Suravee Suthikulpanit , Joao Martins , Jonathan Cameron Subject: [PATCH v9 05/11] i386/pc: factor out cxl range end to helper Date: Tue, 19 Jul 2022 18:00:08 +0100 Message-Id: <20220719170014.27028-6-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20220719170014.27028-1-joao.m.martins@oracle.com> References: <20220719170014.27028-1-joao.m.martins@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-19_05,2022-07-19_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=703 spamscore=0 bulkscore=0 malwarescore=0 adultscore=0 mlxscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207190072 X-Proofpoint-GUID: WZSnWbRTpRxKL2P4L0jo_Npx_AtFKV00 X-Proofpoint-ORIG-GUID: WZSnWbRTpRxKL2P4L0jo_Npx_AtFKV00 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=205.220.177.32; envelope-from=joao.m.martins@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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" X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1658250515638100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Move calculation of CXL memory region end to separate helper. This is in preparation to a future change that removes CXL range dependency on the CXL memory region, with the goal of allowing pc_pci_hole64_start() to be called before any memory region are initialized. Cc: Jonathan Cameron Signed-off-by: Joao Martins Acked-by: Igor Mammedov --- hw/i386/pc.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 6c898a86cb89..3fc3e985086a 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -825,6 +825,25 @@ static hwaddr pc_above_4g_end(PCMachineState *pcms) return x86ms->above_4g_mem_start + x86ms->above_4g_mem_size; } =20 +static uint64_t pc_get_cxl_range_end(PCMachineState *pcms) +{ + uint64_t start =3D 0; + + if (pcms->cxl_devices_state.host_mr.addr) { + start =3D pcms->cxl_devices_state.host_mr.addr + + memory_region_size(&pcms->cxl_devices_state.host_mr); + if (pcms->cxl_devices_state.fixed_windows) { + GList *it; + for (it =3D pcms->cxl_devices_state.fixed_windows; it; it =3D = it->next) { + CXLFixedWindow *fw =3D it->data; + start =3D fw->mr.addr + memory_region_size(&fw->mr); + } + } + } + + return start; +} + void pc_memory_init(PCMachineState *pcms, MemoryRegion *system_memory, MemoryRegion *rom_memory, @@ -1020,16 +1039,8 @@ uint64_t pc_pci_hole64_start(void) MachineState *ms =3D MACHINE(pcms); uint64_t hole64_start =3D 0; =20 - if (pcms->cxl_devices_state.host_mr.addr) { - hole64_start =3D pcms->cxl_devices_state.host_mr.addr + - memory_region_size(&pcms->cxl_devices_state.host_mr); - if (pcms->cxl_devices_state.fixed_windows) { - GList *it; - for (it =3D pcms->cxl_devices_state.fixed_windows; it; it =3D = it->next) { - CXLFixedWindow *fw =3D it->data; - hole64_start =3D fw->mr.addr + memory_region_size(&fw->mr); - } - } + if (pcms->cxl_devices_state.is_enabled) { + hole64_start =3D pc_get_cxl_range_end(pcms); } else if (pcmc->has_reserved_memory && ms->device_memory->base) { hole64_start =3D ms->device_memory->base; if (!pcmc->broken_reserved_end) { --=20 2.17.2