From nobody Mon Feb 9 23:39:54 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=1656692819; cv=none; d=zohomail.com; s=zohoarc; b=CLKRAPcA+7cz0eD4Nczl4kfJm+xOe+Kc/XO1lnHQMXV+x8AnZPGlLpKu6KyAUETmg3RzSn/XNEk+hBLeSpNbhV2pUWf2/A2+nFGK+OUloeFKIm6u5lHqfcQ2lutD9+3ZQfY9oFIOLCF29otfVJPCvUKrU9cVBlQ+3LGNZbGFDwo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1656692819; 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=O4pTTLxZV+n0/VuPRBbRciJ+yiI5rPj2CVwAg/SdhcE=; b=i93GGt9sm19NmibuNhqy9bsUMkZ3bENIYw+pqb9SueuPcF0a0xo6l6+tQ6KTDX11b+K1JIEb3p5iEW7H7U2BMwjcv10LTHsXWw2+z2cnsB9rgGjT21hrWWAK4XUbFMzCuX/mkFudHkyLhqYrgYPVPsiF+SD11cTtentwWkcA0L8= 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 1656692819233370.9969741086071; Fri, 1 Jul 2022 09:26:59 -0700 (PDT) Received: from localhost ([::1]:49380 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o7JTu-00014G-7W for importer@patchew.org; Fri, 01 Jul 2022 12:26:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46936) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o7JEj-0000eC-GH for qemu-devel@nongnu.org; Fri, 01 Jul 2022 12:11:17 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:53348) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o7JEg-0002ms-R8 for qemu-devel@nongnu.org; Fri, 01 Jul 2022 12:11:17 -0400 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 261G3HOF015598; Fri, 1 Jul 2022 16:11:06 GMT Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3gwsysqenm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 01 Jul 2022 16:11:06 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 261G5hka016148; Fri, 1 Jul 2022 16:11:05 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3gwrt4sw6s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 01 Jul 2022 16:11:05 +0000 Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 261GAftO029065; Fri, 1 Jul 2022 16:11:05 GMT Received: from paddy.uk.oracle.com (dhcp-10-175-184-247.vpn.oracle.com [10.175.184.247]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3gwrt4svtm-7; Fri, 01 Jul 2022 16:11:04 +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-2021-07-09; bh=O4pTTLxZV+n0/VuPRBbRciJ+yiI5rPj2CVwAg/SdhcE=; b=c/QLCaeAICXDXebPrtvSVRcHNPowJ5Ja07994doxyFJouvhTppYnw/I0kI2p/YJxAkJC xAzEuBxaDC7KIYoOfQRhNNWhcN3IInIJWmsPb71+qjNNi5IOP0/ZYMaUs9fHYlilnN5f szSGM80Icl8fqEL4Wy8AJpkK4l9BsRXmb2IKF4AmlkeSwoGz+rkLgGhtPbJ9M8KKYGb1 t4VjN6X0PRhxFt/sVf2cqQPjlRJRtw8YfZp7+KNBCB4m+vEMfzlT98DlLAksx+0OP4C8 xj6wTaLIPnbhzKyKAvlKqDTJQf05U8AwXre4UFzxGS1MAGneWQV99FuVwuwQ8bOrB8B+ iA== 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 v6 06/10] i386/pc: factor out cxl range start to helper Date: Fri, 1 Jul 2022 17:10:10 +0100 Message-Id: <20220701161014.3850-7-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20220701161014.3850-1-joao.m.martins@oracle.com> References: <20220701161014.3850-1-joao.m.martins@oracle.com> X-Proofpoint-ORIG-GUID: 76_xH_wqoQTg3jlpckUgWri9EaxnUiaR X-Proofpoint-GUID: 76_xH_wqoQTg3jlpckUgWri9EaxnUiaR 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: 1656692819991100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Factor out the calculation of the base address of the MR. It will be used later on for the cxl range end counterpart calculation and as well in pc_memory_init() CXL mr initialization, thus avoiding duplication. Cc: Jonathan Cameron Signed-off-by: Joao Martins --- hw/i386/pc.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 0abbf81841a9..8655cc3b8894 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -825,6 +825,24 @@ 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_start(PCMachineState *pcms) +{ + PCMachineClass *pcmc =3D PC_MACHINE_GET_CLASS(pcms); + MachineState *machine =3D MACHINE(pcms); + hwaddr cxl_base; + + if (pcmc->has_reserved_memory && machine->device_memory->base) { + cxl_base =3D machine->device_memory->base; + if (!pcmc->broken_reserved_end) { + cxl_base +=3D memory_region_size(&machine->device_memory->mr); + } + } else { + cxl_base =3D pc_above_4g_end(pcms); + } + + return cxl_base; +} + static uint64_t pc_get_cxl_range_end(PCMachineState *pcms) { uint64_t start =3D 0; @@ -946,15 +964,7 @@ void pc_memory_init(PCMachineState *pcms, MemoryRegion *mr =3D &pcms->cxl_devices_state.host_mr; hwaddr cxl_size =3D MiB; =20 - if (pcmc->has_reserved_memory && machine->device_memory->base) { - cxl_base =3D machine->device_memory->base; - if (!pcmc->broken_reserved_end) { - cxl_base +=3D memory_region_size(&machine->device_memory->= mr); - } - } else { - cxl_base =3D pc_above_4g_end(pcms); - } - + cxl_base =3D pc_get_cxl_range_start(pcms); e820_add_entry(cxl_base, cxl_size, E820_RESERVED); memory_region_init(mr, OBJECT(machine), "cxl_host_reg", cxl_size); memory_region_add_subregion(system_memory, cxl_base, mr); --=20 2.17.2