From nobody Mon May 20 01:26:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=fail (Bad Signature) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 156461539872862.502588509074485; Wed, 31 Jul 2019 16:23:18 -0700 (PDT) Received: from localhost ([::1]:45012 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsxwD-0003LS-R5 for importer@patchew.org; Wed, 31 Jul 2019 19:23:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50783) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsxtr-0006qI-J0 for qemu-devel@nongnu.org; Wed, 31 Jul 2019 19:20:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsxtq-0008LC-E5 for qemu-devel@nongnu.org; Wed, 31 Jul 2019 19:20:51 -0400 Received: from mail-eopbgr760058.outbound.protection.outlook.com ([40.107.76.58]:41104 helo=NAM02-CY1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hsxtq-0008JS-97 for qemu-devel@nongnu.org; Wed, 31 Jul 2019 19:20:50 -0400 Received: from DM5PR12MB2471.namprd12.prod.outlook.com (52.132.141.138) by DM5PR12MB2550.namprd12.prod.outlook.com (52.132.141.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2115.15; Wed, 31 Jul 2019 23:20:47 +0000 Received: from DM5PR12MB2471.namprd12.prod.outlook.com ([fe80::ecb0:375b:9347:fe67]) by DM5PR12MB2471.namprd12.prod.outlook.com ([fe80::ecb0:375b:9347:fe67%7]) with mapi id 15.20.2136.010; Wed, 31 Jul 2019 23:20:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YJWvKKkoK7Ni6rhi5lro38yANCdDXrw8prpruevS0FbTTQdVrT2igKISQlOFiMDTcVd1ufHCuiw3YtnNqHPqWYCFVrpojamN1OusMxuFz/PfUkmKb0rKMgUyB8zEsNn0ptteuK0E1A4j+BYXnVKBNSwBL7IYY3MnpWsFG1ev/JqnL0dzxr3LhWUFxJugV/Lmw8XHEpkd9e8DLtE3dc7Si3SxvE8VAPfkrNOI87uYtOXaM18YSzlOV/6G8tlB1aCmhMOGcV4ZsavILcRvefP7gC0OEqAw7OcAvKW9xLPl/NdqmufxPPiPpzkA2LlTd8wr70cKPshD3FjGtzt/SDearA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=c6sFDgWbAq8TJDAg7wykmL5vrYP49jvqWhrlVCwSXwk=; b=TeDSb3Y6gM+bigz4d6sHrnwBtzzIKYLR3gyV3UhpoaVtQg6n/ItSSuWRsi3Ujdi/ixOlWrx1zV5Hn7lV8eUmRgKsyCEZ7xNGH5whJL04nubUA7HvTPXhGQ7BdBVfTlHHiuOEVjC59+UMD3cgyaDaKYs6ugis3PNkIuG4BhkmRW11y6sFyS3Ku3myFP5VSSQUhGiXGNvvSDxfguusmxe7lHvreymMNd7BSMiOnCMaC3TKeVyqv6sMs2jRWJYmDKcXLoKJHvU5VEZODU36ZLw5E8hyx+nJxtLpG+HJmCJsjDm1XAPo68WvbeDM60KCBl3IcJOLOfR4SrdJJlI3Qrot+g== ARC-Authentication-Results: i=1; mx.microsoft.com 1;spf=pass smtp.mailfrom=amd.com;dmarc=pass action=none header.from=amd.com;dkim=pass header.d=amd.com;arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=c6sFDgWbAq8TJDAg7wykmL5vrYP49jvqWhrlVCwSXwk=; b=sZ4SZqV6dTI3UT73NY+c0SONuFxQXSSUdC7savJOfRQ7nXBWpr5Oz0PNuXqBrguWYVZcmnjlt6AcpN51omK3MjZTB8k/KExbUXw2abRA0H7jXkPbj/EKNlPymj6PBuFDTFGoKCB8kVJAtK9RF8ztrRRn7YFNGIDlY8JeRxTK3yI= From: "Moger, Babu" To: "ehabkost@redhat.com" , "marcel.apfelbaum@gmail.com" , "mst@redhat.com" , "pbonzini@redhat.com" , "rth@twiddle.net" , "imammedo@redhat.com" Thread-Topic: [RFC PATCH 1/5] hw/boards: Add sockets in CpuTopology structure Thread-Index: AQHVR/aVBapKuUuGJEu2eneWm/XN9Q== Date: Wed, 31 Jul 2019 23:20:46 +0000 Message-ID: <20190731232032.51786-2-babu.moger@amd.com> References: <20190731232032.51786-1-babu.moger@amd.com> In-Reply-To: <20190731232032.51786-1-babu.moger@amd.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: SN1PR12CA0050.namprd12.prod.outlook.com (2603:10b6:802:20::21) To DM5PR12MB2471.namprd12.prod.outlook.com (2603:10b6:4:b5::10) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Babu.Moger@amd.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-originating-ip: [165.204.78.2] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 733e30e4-3113-4b40-7eff-08d7160db793 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:DM5PR12MB2550; x-ms-traffictypediagnostic: DM5PR12MB2550: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4714; x-forefront-prvs: 011579F31F x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(396003)(39860400002)(346002)(136003)(376002)(366004)(199004)(189003)(8936002)(7736002)(2501003)(50226002)(36756003)(1076003)(11346002)(8676002)(6436002)(81166006)(81156014)(305945005)(68736007)(54906003)(110136005)(53936002)(6486002)(66066001)(478600001)(64756008)(2906002)(316002)(5660300002)(14454004)(66556008)(102836004)(386003)(256004)(71200400001)(6506007)(71190400001)(86362001)(486006)(26005)(99286004)(76176011)(186003)(66476007)(3846002)(66946007)(4326008)(6512007)(66446008)(6116002)(2201001)(25786009)(2616005)(476003)(52116002)(446003); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR12MB2550; H:DM5PR12MB2471.namprd12.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: pass (zoho.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: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 2Pdz3eTAKr2RauXl+VnD3iM18EvCnhAk46McAdkjcZ5QCR63FcxSz6jIMiUdl2qhsfqD6p3zP0QskZluqXvzCvPu7b0CuInz4FmFo/R6TbEVWKV/Jz1+zED2BATGmiEgjRBmYdETXDqpASKG+V6a074LC9YNbpeKu2h2LIBupCYTFzgLktlmkExpn6XEyxHHC3RfSsqM7FyAGtsXx89aANPNYQamANL5AJc39dlom7OlmbJp4jrwOPs2wjepMZ9HZcJvmE/fi0/z1fQ9vZvJCZhhBuhdRUz0tEEiflUZSHbffyb+3WIXK/aeOh0gVZZfX/MaRV8/BHL62lmAFt0WLwV5y4GLDc6PgS10JgkPe4dyT3WkE+oMuVgUbvYmKxSNEgjfBENFkrGXuVjYKqfgZ54VZn/BB9BqiCGR8bzCSbo= Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 733e30e4-3113-4b40-7eff-08d7160db793 X-MS-Exchange-CrossTenant-originalarrivaltime: 31 Jul 2019 23:20:46.9935 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: bmoger@amd.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB2550 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.76.58 Subject: [Qemu-devel] [RFC PATCH 1/5] hw/boards: Add sockets in CpuTopology structure 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: "Moger, Babu" , "qemu-devel@nongnu.org" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Add sockets in CpuTopology. This is required when building the CPU topology. Signed-off-by: Babu Moger --- hw/core/machine.c | 1 + hw/i386/pc.c | 1 + include/hw/boards.h | 2 ++ vl.c | 1 + 4 files changed, 5 insertions(+) diff --git a/hw/core/machine.c b/hw/core/machine.c index c58a8e594e..4034b7e903 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -795,6 +795,7 @@ static void smp_parse(MachineState *ms, QemuOpts *opts) ms->smp.cpus =3D cpus; ms->smp.cores =3D cores; ms->smp.threads =3D threads; + ms->smp.sockets =3D sockets; } =20 if (ms->smp.cpus > 1) { diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 549c437050..ef39463fd5 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1605,6 +1605,7 @@ void pc_smp_parse(MachineState *ms, QemuOpts *opts) ms->smp.cpus =3D cpus; ms->smp.cores =3D cores; ms->smp.threads =3D threads; + ms->smp.sockets =3D sockets; pcms->smp_dies =3D dies; } =20 diff --git a/include/hw/boards.h b/include/hw/boards.h index a71d1a53a5..12eb5032a5 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -245,12 +245,14 @@ typedef struct DeviceMemoryState { * @cpus: the number of present logical processors on the machine * @cores: the number of cores in one package * @threads: the number of threads in one core + * @sockets: the number of sockets on the machine * @max_cpus: the maximum number of logical processors on the machine */ typedef struct CpuTopology { unsigned int cpus; unsigned int cores; unsigned int threads; + unsigned int sockets; unsigned int max_cpus; } CpuTopology; =20 diff --git a/vl.c b/vl.c index b426b32134..d8faf5ab43 100644 --- a/vl.c +++ b/vl.c @@ -3981,6 +3981,7 @@ int main(int argc, char **argv, char **envp) current_machine->smp.max_cpus =3D machine_class->default_cpus; current_machine->smp.cores =3D 1; current_machine->smp.threads =3D 1; + current_machine->smp.sockets =3D 1; =20 machine_class->smp_parse(current_machine, qemu_opts_find(qemu_find_opts("smp-opts"), NULL)); --=20 2.20.1 From nobody Mon May 20 01:26:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=fail (Bad Signature) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564615304155631.0157991146764; Wed, 31 Jul 2019 16:21:44 -0700 (PDT) Received: from localhost ([::1]:44986 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsxug-0008WV-PG for importer@patchew.org; Wed, 31 Jul 2019 19:21:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50805) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsxts-0006rg-EF for qemu-devel@nongnu.org; Wed, 31 Jul 2019 19:20:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsxtq-0008LZ-OA for qemu-devel@nongnu.org; Wed, 31 Jul 2019 19:20:52 -0400 Received: from mail-eopbgr760058.outbound.protection.outlook.com ([40.107.76.58]:41104 helo=NAM02-CY1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hsxtq-0008JS-Il for qemu-devel@nongnu.org; Wed, 31 Jul 2019 19:20:50 -0400 Received: from DM5PR12MB2471.namprd12.prod.outlook.com (52.132.141.138) by DM5PR12MB2550.namprd12.prod.outlook.com (52.132.141.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2115.15; Wed, 31 Jul 2019 23:20:48 +0000 Received: from DM5PR12MB2471.namprd12.prod.outlook.com ([fe80::ecb0:375b:9347:fe67]) by DM5PR12MB2471.namprd12.prod.outlook.com ([fe80::ecb0:375b:9347:fe67%7]) with mapi id 15.20.2136.010; Wed, 31 Jul 2019 23:20:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BX1ByXTU4KUd2BQbgw9jN8kNgOsPs0dlpcd1zYr7YXyDzMjW5yyGirBolU8NMoY4+f6xN6lzZLisuhMcIIDCGtJ7v0RIJ2GWVicr1ow5tmOyJql2W/5m956gCPOdfW1GtvAoeuP+9gRH5R5wlqq42cYorphGc99PRbcEpCQahwLBxJB7Gy27pLksBQaaYN40zlxT0SijsZ0BUWwuk2VP/N248r7FUoIZgY2P4nEZtW6NHSsS1RbN0I1Cth3jGhavq3H9tW54fKYufkOe8JKQ/egArlq1fDHBG2d6g8k/O3ySA2ow+aNVXdqLGwxbiD+CLkejcT6yNPFMWW7hVEBBSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lFwLwbGIMSPg67QIr8CTwZREW/AKNOazu3DwwETQysM=; b=YFqaOt1pgb33QXyoc8hV4/BZmiq8QMv1WX5yqHYNh1QNs/dj3XvrrQ+V2kcZHGGlh2lWOzClR6km9Dg/LgKhdF2OCBncndSdAjxJ6/ByjgxIgy78uu/Ul1RrCkhu29y5KSJ+lTjTbrc4Jd3SmwQCXLiZWzYgg0Dbg9z+YW+tUeGUwS4J8VsHIO59l3+ZtgdzjKWFxGzBm4FB7dNLhUk4mkW3PUQ12tiDww35uzVwTTtJ5AlQQHiAPbepenv6nnLut27qeCv8pE7xKJ2MLshz6jvsaIUszEawN/3xfygMBL9lhc4qARx0HRhbPN8AhorsEScnR+jDXNa2TTlSxc16Tw== ARC-Authentication-Results: i=1; mx.microsoft.com 1;spf=pass smtp.mailfrom=amd.com;dmarc=pass action=none header.from=amd.com;dkim=pass header.d=amd.com;arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lFwLwbGIMSPg67QIr8CTwZREW/AKNOazu3DwwETQysM=; b=Hztx48zrJMYL+bKfRAUWFNcyci+lODeY9VGhZd0P1dlNtcCAIMSCr39tbh6a1fKOgzFNeWOXEiJZZjMhyrrmRiZ10rfMT+4Ov7vaWbRbPTiZmvQHNtlNYsYjIy1xHMOIzCXeWa+eOC5tDhUFXf95iezuUQaY4ko6NT6vjKFXhOQ= From: "Moger, Babu" To: "ehabkost@redhat.com" , "marcel.apfelbaum@gmail.com" , "mst@redhat.com" , "pbonzini@redhat.com" , "rth@twiddle.net" , "imammedo@redhat.com" Thread-Topic: [RFC PATCH 2/5] hw/i386: Add AMD EPYC topology encoding Thread-Index: AQHVR/aV9ViYHJWvEUuFAqiDPvghww== Date: Wed, 31 Jul 2019 23:20:48 +0000 Message-ID: <20190731232032.51786-3-babu.moger@amd.com> References: <20190731232032.51786-1-babu.moger@amd.com> In-Reply-To: <20190731232032.51786-1-babu.moger@amd.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: SN1PR12CA0050.namprd12.prod.outlook.com (2603:10b6:802:20::21) To DM5PR12MB2471.namprd12.prod.outlook.com (2603:10b6:4:b5::10) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Babu.Moger@amd.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-originating-ip: [165.204.78.2] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 272570c1-5ca8-4dcd-0619-08d7160db843 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:DM5PR12MB2550; x-ms-traffictypediagnostic: DM5PR12MB2550: x-ms-exchange-purlcount: 1 x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2000; x-forefront-prvs: 011579F31F x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(396003)(39860400002)(346002)(136003)(376002)(366004)(199004)(189003)(8936002)(7736002)(2501003)(50226002)(36756003)(1076003)(11346002)(8676002)(6436002)(81166006)(81156014)(305945005)(68736007)(54906003)(110136005)(53936002)(6486002)(66066001)(478600001)(64756008)(2906002)(316002)(5660300002)(14454004)(66556008)(102836004)(386003)(14444005)(256004)(71200400001)(6506007)(71190400001)(86362001)(486006)(26005)(99286004)(76176011)(186003)(66476007)(3846002)(66946007)(4326008)(6512007)(966005)(66446008)(6116002)(2201001)(25786009)(2616005)(476003)(52116002)(446003)(6306002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR12MB2550; H:DM5PR12MB2471.namprd12.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: pass (zoho.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: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: gNs4PldozFdfMO+ZAIGwBxvuzWsa2Id4AMolHT15wwnfBRF1DJnDXRhFCuFTpEBfGGt7I5WkDOyuYk1wAJvN1PvsFQk34XxI89guogRbwuwOiw6ALyzDoMg9xq0YYhnNzywv2xeBW3XmR6Wm68+J6QB0p0Zya0ry8Es+tPbt+JgHeDo1+u0mI3uKBiGBYu5wYz2V3fVgg6VAHJxNVvs7Ytd5I42oVi1rS7Vp0+yDgrJScRPrTrPYMZOB6qENtsNR/m09pKo6ePSTrlWpcll21/NcuhCi+KCsE4McW6URI3YBxcAgkGGoCAMXqC9jMtK0ngE85EMWDI2AOMcOT+cm8/LmTNW9aVg+riRNDfv9oisGfX7tq1Np9xIWTb/gM/qVCHf5xgzgrVyNoVjCp7yRLfhWThZQ8KUwxCfaC0ZauSQ= Content-Type: text/plain; charset="utf-8" Content-ID: <9BA5D2A2B9BAEC42ACECB7AB2341A41C@namprd12.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 272570c1-5ca8-4dcd-0619-08d7160db843 X-MS-Exchange-CrossTenant-originalarrivaltime: 31 Jul 2019 23:20:48.1448 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: bmoger@amd.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB2550 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.76.58 Subject: [Qemu-devel] [RFC PATCH 2/5] hw/i386: Add AMD EPYC topology encoding 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: "Moger, Babu" , "qemu-devel@nongnu.org" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Currently, the apicid is a sequential number in x86 cpu models. This works fine for most of the cases. But, in certain cases this will result into cpu topology inconsistency. This problem was observed in AMD EPYC cpu models. To address that we need to build apicid as per the hardware specification. We are attempting to build the topology close to the hardware as much as possible. Per Processor Programming Reference (PPR) for AMD Family 17h Models, we need to follow the following decoding. 2.1.10.2.1.3 ApicId Enumeration Requirements Operating systems are expected to use Core::X86::Cpuid::SizeId[ApicIdCoreIdSize], the number of least significant bits in the Initial APIC ID that indicate core ID within a processor, in constructing per-core CPUID masks. Core::X86::Cpuid::SizeId[ApicIdCoreIdSize] determines the maximum number of cores (MNC) that the processor could theoretically support, not the actual number of cores t= hat are actually implemented or enabled on the processor, as indicated by Core::X86::Cpuid::SizeId[NC]. Each Core::X86::Apic::ApicId[ApicId] register is preset as follows: =E2=80=A2 ApicId[6] =3D Socket ID. =E2=80=A2 ApicId[5:4] =3D Node ID. =E2=80=A2 ApicId[3] =3D Logical CCX L3 complex ID =E2=80=A2 ApicId[2:0]=3D (SMT) ? {LogicalCoreID[1:0],ThreadId} : {1'b0,LogicalCoreID[1:0]}. Add the structures and functions to decode the ApicId for AMD EPYC models. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=3D1728166 Signed-off-by: Babu Moger --- include/hw/i386/topology.h | 140 +++++++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) diff --git a/include/hw/i386/topology.h b/include/hw/i386/topology.h index 4ff5b2da6c..0b2fd46b41 100644 --- a/include/hw/i386/topology.h +++ b/include/hw/i386/topology.h @@ -50,6 +50,7 @@ typedef struct X86CPUTopoInfo { unsigned die_id; unsigned core_id; unsigned smt_id; + unsigned ccx_id; } X86CPUTopoInfo; =20 /* Return the bit width needed for 'count' IDs @@ -179,4 +180,143 @@ static inline apic_id_t x86_apicid_from_cpu_idx(unsig= ned nr_dies, return apicid_from_topo_ids(nr_dies, nr_cores, nr_threads, &topo); } =20 +/* Definitions used for building CPUID Leaf 0x8000001D and 0x8000001E + * Please refer to the AMD64 Architecture Programmer=E2=80=99s Manual Volu= me 3. + * Define the constants to build the cpu topology. Right now, TOPOEXT + * feature is enabled only on EPYC. So, these constants are based on + * EPYC supported configurations. We may need to handle the cases if + * these values change in future. + */ + +/* Maximum core complexes in a node */ +#define MAX_CCX 2 +/* Maximum cores in a core complex */ +#define MAX_CORES_IN_CCX 4 +/* Maximum cores in a node */ +#define MAX_CORES_IN_DIE 8 +#define CCX_OFFSET_EPYC 3 +#define DIE_OFFSET_EPYC 4 +#define PKG_OFFSET_EPYC 6 + +/* Figure out the number of dies required to build this config. + * Max cores in a die is 8 + */ +static inline int dies_in_socket(int numa_nodes, int smp_sockets, int smp_= cores) +{ + /* + * Create a config with user given (nr_nodes > 1) numa node config, + * else go with a standard configuration + */ + if (numa_nodes > 1) + return DIV_ROUND_UP(numa_nodes, smp_sockets); + else + return DIV_ROUND_UP(smp_cores, MAX_CORES_IN_DIE); +} + +/* Decide the number of cores in a core complex with the given nr_cores us= ing + * following set constants MAX_CCX, MAX_CORES_IN_CCX, MAX_CORES_IN_DIE and + * MAX_NODES_PER_SOCKET. Maintain symmetry as much as possible + * L3 cache is shared across all cores in a core complex. So, this will al= so + * tell us how many cores are sharing the L3 cache. + */ +static inline int cores_in_ccx(int numa_nodes, int smp_sockets, int smp_co= res) +{ + int dies; + + /* Check if we can fit all the cores in one core complex */ + if (smp_cores <=3D MAX_CORES_IN_CCX) { + return smp_cores; + } + + /* Get the number of nodes required to build this config */ + dies =3D dies_in_socket(numa_nodes, smp_sockets, smp_cores); + + /* + * Divide the cores accros all the core complexes + * Return rounded up value + */ + return DIV_ROUND_UP(smp_cores, dies * MAX_CCX); +} + +/* Calculate thread/core/package IDs for a specific topology, + * based on APIC ID + */ +static inline void x86_topo_ids_from_apicid_epyc(apic_id_t apicid, + unsigned smp_dies, + unsigned smp_cores, + unsigned smp_threads, + X86CPUTopoInfo *topo) +{ + topo->smt_id =3D apicid & + ~(0xFFFFFFFFUL << apicid_smt_width(smp_dies, smp_cores,= smp_threads)); + topo->core_id =3D (apicid >> apicid_core_offset(smp_dies, smp_cores, s= mp_threads)) & + ~(0xFFFFFFFFUL << apicid_core_width(smp_dies, smp_cores= , smp_threads)); + topo->ccx_id =3D (apicid >> CCX_OFFSET_EPYC) & 1; + topo->die_id =3D (apicid >> DIE_OFFSET_EPYC) & 3; + topo->pkg_id =3D apicid >> PKG_OFFSET_EPYC; +} + +/* Calculate thread/core/package IDs for a specific topology, + * based on (contiguous) CPU index + * Processor Programming Reference (PPR) for AMD Family 17h Model 01h, + * Revision B1 Processors + * ApicId Enumeration Requirements + =E2=80=A2 ApicId[6] =3D Socket ID. + =E2=80=A2 ApicId[5:4] =3D Node ID. + =E2=80=A2 ApicId[3] =3D Logical CCX L3 complex ID + =E2=80=A2 ApicId[2:0]=3D (SMT) ? {LogicalCoreID[1:0],ThreadId} : {1'b0,Lo= gicalCoreID[1:0]}. + */ +static inline void x86_topo_ids_from_idx_epyc(unsigned numa_nodes, + unsigned smp_sockets, + unsigned smp_cores, + unsigned smp_threads, + unsigned cpu_index, + X86CPUTopoInfo *topo) +{ + unsigned core_index =3D cpu_index / smp_threads; + unsigned core_id =3D core_index % smp_cores; /* Core id inside the soc= ket */ + unsigned ccx_cores; + + topo->smt_id =3D cpu_index % smp_threads; + + ccx_cores =3D cores_in_ccx(numa_nodes, smp_sockets, smp_cores); + + topo->core_id =3D core_id % ccx_cores; /* core id inside the ccx */ + topo->ccx_id =3D (core_id % (ccx_cores * MAX_CCX)) / ccx_cores; + topo->die_id =3D core_id / (ccx_cores * MAX_CCX); + topo->pkg_id =3D core_index / smp_cores; +} + +/* Make APIC ID for the CPU based on Pkg_ID, Core_ID, SMT_ID + * + * The caller must make sure core_id < nr_cores and smt_id < nr_threads. + */ +static inline apic_id_t apicid_from_topo_ids_epyc(unsigned smp_cores, + unsigned smp_threads, + const X86CPUTopoInfo *to= po) +{ + if (smp_threads - 1) + return ((topo->pkg_id << PKG_OFFSET_EPYC) | (topo->die_id << DIE_O= FFSET_EPYC) | + (topo->ccx_id << CCX_OFFSET_EPYC) | (topo->core_id << 1) |= (topo->smt_id)); + else + return ((topo->pkg_id << PKG_OFFSET_EPYC) | (topo->die_id << DIE_O= FFSET_EPYC) | + (topo->ccx_id << CCX_OFFSET_EPYC) | (topo->core_id)); +} + +/* Make APIC ID for the CPU 'cpu_index' + * + * 'cpu_index' is a sequential, contiguous ID for the CPU. + */ +static inline apic_id_t x86_apicid_from_cpu_idx_epyc(unsigned numa_nodes, + unsigned smp_sockets, + unsigned smp_cores, + unsigned smp_threads, + unsigned cpu_index) +{ + X86CPUTopoInfo topo; + x86_topo_ids_from_idx_epyc(numa_nodes, smp_sockets, smp_cores, smp_thr= eads, + cpu_index, &topo); + return apicid_from_topo_ids_epyc(smp_cores, smp_threads, &topo); +} + #endif /* HW_I386_TOPOLOGY_H */ --=20 2.20.1 From nobody Mon May 20 01:26:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=fail (Bad Signature) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 156461530569573.62224970159059; Wed, 31 Jul 2019 16:21:45 -0700 (PDT) Received: from localhost ([::1]:44988 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsxui-000079-F8 for importer@patchew.org; Wed, 31 Jul 2019 19:21:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50808) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsxts-0006se-Lm for qemu-devel@nongnu.org; Wed, 31 Jul 2019 19:20:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsxtr-0008M0-1p for qemu-devel@nongnu.org; Wed, 31 Jul 2019 19:20:52 -0400 Received: from mail-eopbgr760058.outbound.protection.outlook.com ([40.107.76.58]:41104 helo=NAM02-CY1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hsxtq-0008JS-Ss for qemu-devel@nongnu.org; Wed, 31 Jul 2019 19:20:51 -0400 Received: from DM5PR12MB2471.namprd12.prod.outlook.com (52.132.141.138) by DM5PR12MB2550.namprd12.prod.outlook.com (52.132.141.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2115.15; Wed, 31 Jul 2019 23:20:49 +0000 Received: from DM5PR12MB2471.namprd12.prod.outlook.com ([fe80::ecb0:375b:9347:fe67]) by DM5PR12MB2471.namprd12.prod.outlook.com ([fe80::ecb0:375b:9347:fe67%7]) with mapi id 15.20.2136.010; Wed, 31 Jul 2019 23:20:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=leiY34j72zbbc8NX8CFK6Ba2R7ZQft53ntxckw0odXjupsWFOzQrsG1OFw4+mUbMVV11g9xzihC3ka/m1AutWc2efJb79Fb4oXTOaOUJa8EtWcBpIwix/BASB+ZCHEj8RH1pgvh9vNUhkXsyOmGgxatA05R6hiL6AIMQytPLCIenCLsIEGqj/52IS8ohKcmlPpynrtWkvJgF990cae2BvX0URIF5AHVzf3Q53qQ+2knpakTUHlJyM7LJ4+03FX1vhOveXEJ/dNTXVVzlsPenl/DKcU5hWqNKganwOEafNiMhK4HZjofnWFa354g+q77KminlLvdeh4BppHeD0nVIgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Av6BCYbfU5SJ4uPC2uqYfZPaoz2uPjANkK0ldpN2Zu4=; b=NqueLdJA26AGZDB0Zp8bjtb4bqzfKCfkgLZgJUIB6MP0N9di9Om5y0ox5/6N4xlvvfSv9QeX9AF3y8AfB3yxoae4LBg9C1lxY5AnxQGo8nhqUDxfcjTJrQ1vweWcCsRQpAMGcvZLRt28Sk1VjxylwG2PJK70NPF8/P3XyCBBLbJZT/CQJKRMVGxNwoltgi+Ek0JYkmbRwKoKoC7apGSXvqS7MiHodvjBJ8F3JurYiZMMwbS10ivEVDEf2zB66oMocqCPRvf2XSIIgP3XPWTYnbQj7dNmzKs+Bv/Dpi+Ys/VE2F+nReUrEt2zZtLIbQl+4QOy+rrL+7hyZwXc+7v01g== ARC-Authentication-Results: i=1; mx.microsoft.com 1;spf=pass smtp.mailfrom=amd.com;dmarc=pass action=none header.from=amd.com;dkim=pass header.d=amd.com;arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Av6BCYbfU5SJ4uPC2uqYfZPaoz2uPjANkK0ldpN2Zu4=; b=QIMPGKyoxfKgiHD94ur8hNKoL4cnYFoNq6i0x+1qIJx4ktiIKhqXd/BXdqnrOG3FjrVrxOx8a96vjXn1RT/YdIb/JDIoaT+j2dRU2GGhtc71CKakYHqeIxWDz65RCX8tm+2QZhsuClR6ygmacni04C3qRCrHo88KAXCPUa8Z1r8= From: "Moger, Babu" To: "ehabkost@redhat.com" , "marcel.apfelbaum@gmail.com" , "mst@redhat.com" , "pbonzini@redhat.com" , "rth@twiddle.net" , "imammedo@redhat.com" Thread-Topic: [RFC PATCH 3/5] i386: Use topology functions from topology.h Thread-Index: AQHVR/aW8Ua7gUfnaUKb5pcZCkrx1A== Date: Wed, 31 Jul 2019 23:20:49 +0000 Message-ID: <20190731232032.51786-4-babu.moger@amd.com> References: <20190731232032.51786-1-babu.moger@amd.com> In-Reply-To: <20190731232032.51786-1-babu.moger@amd.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: SN1PR12CA0050.namprd12.prod.outlook.com (2603:10b6:802:20::21) To DM5PR12MB2471.namprd12.prod.outlook.com (2603:10b6:4:b5::10) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Babu.Moger@amd.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-originating-ip: [165.204.78.2] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 4092d601-e9d3-4388-ec92-08d7160db8f3 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:DM5PR12MB2550; x-ms-traffictypediagnostic: DM5PR12MB2550: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3826; x-forefront-prvs: 011579F31F x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(396003)(39860400002)(346002)(136003)(376002)(366004)(199004)(189003)(8936002)(7736002)(2501003)(50226002)(36756003)(1076003)(11346002)(8676002)(6436002)(81166006)(81156014)(305945005)(68736007)(54906003)(110136005)(53936002)(6486002)(66066001)(478600001)(64756008)(2906002)(316002)(5660300002)(14454004)(66556008)(102836004)(386003)(256004)(71200400001)(6506007)(71190400001)(86362001)(486006)(26005)(99286004)(76176011)(186003)(66476007)(3846002)(66946007)(4326008)(6512007)(66446008)(6116002)(2201001)(25786009)(2616005)(476003)(52116002)(446003); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR12MB2550; H:DM5PR12MB2471.namprd12.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: pass (zoho.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: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: thyc5x66iKW3qBcHIuwmhTiijhLI2kCqAXuB/Ud9tz0lMnOLdhx7SfkLtORw72842z4/BLkWQNL1b5hgFkYn/T8yNVOCbpVjiWKlTy5/8k9EBxVyTHuLAgPkW0QM1Y7E5x0EOYIYzjIB95EMNhU5mgG7jIepIQJee07mkRDvaYyEw6YJ7lXzuqvbw+DqCSmOHoLVGYCkxCh3o0T+aHV7u0Bo7GgyppU9UrtBK83VHHZAeGKZ8PsXfaQppqnTrZpZXSP2NBFZPnfPL5q9qOWBkhKvwVCADIrW2Ej6vKrdwn4KocB2BC6z1T0V6/R5bfWS22dhixUMzinR6v7ZXhxvJbWcp+9fC+Yv0chkmF2plXoJuj5ozXqN/nL5TZ9cfOPdZDWX9l6eBrHT/keIRIaeES1m3koDWSD6o4quNcpM2Io= Content-Type: text/plain; charset="utf-8" Content-ID: <2A245B38C2352846B0BA0A59F72C8E74@namprd12.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4092d601-e9d3-4388-ec92-08d7160db8f3 X-MS-Exchange-CrossTenant-originalarrivaltime: 31 Jul 2019 23:20:49.2312 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: bmoger@amd.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB2550 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.76.58 Subject: [Qemu-devel] [RFC PATCH 3/5] i386: Use topology functions from topology.h 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: "Moger, Babu" , "qemu-devel@nongnu.org" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Use the functions defined in topology.h and remove the old code. Signed-off-by: Babu Moger --- target/i386/cpu.c | 146 +++++++++------------------------------------- 1 file changed, 27 insertions(+), 119 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 19751e37a7..be4583068c 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -28,6 +28,7 @@ #include "sysemu/kvm.h" #include "sysemu/hvf.h" #include "sysemu/cpus.h" +#include "sysemu/numa.h" #include "kvm_i386.h" #include "sev_i386.h" =20 @@ -338,64 +339,8 @@ static void encode_cache_cpuid80000006(CPUCacheInfo *l= 2, } } =20 -/* - * Definitions used for building CPUID Leaf 0x8000001D and 0x8000001E - * Please refer to the AMD64 Architecture Programmer=E2=80=99s Manual Volu= me 3. - * Define the constants to build the cpu topology. Right now, TOPOEXT - * feature is enabled only on EPYC. So, these constants are based on - * EPYC supported configurations. We may need to handle the cases if - * these values change in future. - */ -/* Maximum core complexes in a node */ -#define MAX_CCX 2 -/* Maximum cores in a core complex */ -#define MAX_CORES_IN_CCX 4 -/* Maximum cores in a node */ -#define MAX_CORES_IN_NODE 8 -/* Maximum nodes in a socket */ -#define MAX_NODES_PER_SOCKET 4 - -/* - * Figure out the number of nodes required to build this config. - * Max cores in a node is 8 - */ -static int nodes_in_socket(int nr_cores) -{ - int nodes; - - nodes =3D DIV_ROUND_UP(nr_cores, MAX_CORES_IN_NODE); - - /* Hardware does not support config with 3 nodes, return 4 in that case= */ - return (nodes =3D=3D 3) ? 4 : nodes; -} - -/* - * Decide the number of cores in a core complex with the given nr_cores us= ing - * following set constants MAX_CCX, MAX_CORES_IN_CCX, MAX_CORES_IN_NODE and - * MAX_NODES_PER_SOCKET. Maintain symmetry as much as possible - * L3 cache is shared across all cores in a core complex. So, this will al= so - * tell us how many cores are sharing the L3 cache. - */ -static int cores_in_core_complex(int nr_cores) -{ - int nodes; - - /* Check if we can fit all the cores in one core complex */ - if (nr_cores <=3D MAX_CORES_IN_CCX) { - return nr_cores; - } - /* Get the number of nodes required to build this config */ - nodes =3D nodes_in_socket(nr_cores); - - /* - * Divide the cores accros all the core complexes - * Return rounded up value - */ - return DIV_ROUND_UP(nr_cores, nodes * MAX_CCX); -} - /* Encode cache info for CPUID[8000001D] */ -static void encode_cache_cpuid8000001d(CPUCacheInfo *cache, CPUState *cs, +static void encode_cache_cpuid8000001d(CPUCacheInfo *cache, MachineState *= ms, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) { @@ -408,10 +353,10 @@ static void encode_cache_cpuid8000001d(CPUCacheInfo *= cache, CPUState *cs, =20 /* L3 is shared among multiple cores */ if (cache->level =3D=3D 3) { - l3_cores =3D cores_in_core_complex(cs->nr_cores); - *eax |=3D ((l3_cores * cs->nr_threads) - 1) << 14; + l3_cores =3D cores_in_ccx(nb_numa_nodes, ms->smp.sockets, ms->smp.= cores); + *eax |=3D ((l3_cores * ms->smp.threads) - 1) << 14; } else { - *eax |=3D ((cs->nr_threads - 1) << 14); + *eax |=3D ((ms->smp.threads - 1) << 14); } =20 assert(cache->line_size > 0); @@ -431,55 +376,19 @@ static void encode_cache_cpuid8000001d(CPUCacheInfo *= cache, CPUState *cs, (cache->complex_indexing ? CACHE_COMPLEX_IDX : 0); } =20 -/* Data structure to hold the configuration info for a given core index */ -struct core_topology { - /* core complex id of the current core index */ - int ccx_id; - /* - * Adjusted core index for this core in the topology - * This can be 0,1,2,3 with max 4 cores in a core complex - */ - int core_id; - /* Node id for this core index */ - int node_id; - /* Number of nodes in this config */ - int num_nodes; -}; - -/* - * Build the configuration closely match the EPYC hardware. Using the EPYC - * hardware configuration values (MAX_CCX, MAX_CORES_IN_CCX, MAX_CORES_IN_= NODE) - * right now. This could change in future. - * nr_cores : Total number of cores in the config - * core_id : Core index of the current CPU - * topo : Data structure to hold all the config info for this core ind= ex - */ -static void build_core_topology(int nr_cores, int core_id, - struct core_topology *topo) -{ - int nodes, cores_in_ccx; - - /* First get the number of nodes required */ - nodes =3D nodes_in_socket(nr_cores); - - cores_in_ccx =3D cores_in_core_complex(nr_cores); - - topo->node_id =3D core_id / (cores_in_ccx * MAX_CCX); - topo->ccx_id =3D (core_id % (cores_in_ccx * MAX_CCX)) / cores_in_ccx; - topo->core_id =3D core_id % cores_in_ccx; - topo->num_nodes =3D nodes; -} - /* Encode cache info for CPUID[8000001E] */ -static void encode_topo_cpuid8000001e(CPUState *cs, X86CPU *cpu, +static void encode_topo_cpuid8000001e(MachineState *ms, X86CPU *cpu, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) { - struct core_topology topo =3D {0}; - unsigned long nodes; - int shift; + X86CPUTopoInfo topo =3D {0}; + unsigned long dies, temp_dies, shift; + CPUX86State *env =3D &cpu->env; + + dies =3D dies_in_socket(nb_numa_nodes, ms->smp.sockets, ms->smp.cores); + x86_topo_ids_from_apicid_epyc(cpu->apic_id, env->nr_dies, ms->smp.core= s, + ms->smp.threads, &topo); =20 - build_core_topology(cs->nr_cores, cpu->core_id, &topo); *eax =3D cpu->apic_id; /* * CPUID_Fn8000001E_EBX @@ -496,11 +405,11 @@ static void encode_topo_cpuid8000001e(CPUState *cs, X= 86CPU *cpu, * 3 Core complex id * 1:0 Core id */ - if (cs->nr_threads - 1) { - *ebx =3D ((cs->nr_threads - 1) << 8) | (topo.node_id << 3) | + if (ms->smp.threads - 1) { + *ebx =3D ((ms->smp.threads - 1) << 8) | (topo.die_id << 3) | (topo.ccx_id << 2) | topo.core_id; } else { - *ebx =3D (topo.node_id << 4) | (topo.ccx_id << 3) | topo.core_id; + *ebx =3D (topo.die_id << 4) | (topo.ccx_id << 3) | topo.core_id; } /* * CPUID_Fn8000001E_ECX @@ -510,9 +419,8 @@ static void encode_topo_cpuid8000001e(CPUState *cs, X86= CPU *cpu, * 2 Socket id * 1:0 Node id */ - if (topo.num_nodes <=3D 4) { - *ecx =3D ((topo.num_nodes - 1) << 8) | (cpu->socket_id << 2) | - topo.node_id; + if (dies <=3D 4) { + *ecx =3D ((dies - 1) << 8) | (topo.pkg_id << 2) | topo.die_id; } else { /* * Node id fix up. Actual hardware supports up to 4 nodes. But with @@ -527,10 +435,9 @@ static void encode_topo_cpuid8000001e(CPUState *cs, X8= 6CPU *cpu, * number of nodes. find_last_bit returns last set bit(0 based). L= eft * shift(+1) the socket id to represent all the nodes. */ - nodes =3D topo.num_nodes - 1; - shift =3D find_last_bit(&nodes, 8); - *ecx =3D ((topo.num_nodes - 1) << 8) | (cpu->socket_id << (shift += 1)) | - topo.node_id; + temp_dies =3D dies - 1; + shift =3D find_last_bit(&temp_dies, 8); + *ecx =3D ((dies - 1) << 8) | (topo.pkg_id << (shift + 1)) | topo.d= ie_id; } *edx =3D 0; } @@ -4169,6 +4076,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, = uint32_t count, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) { + MachineState *ms =3D MACHINE(qdev_get_machine()); X86CPU *cpu =3D env_archcpu(env); CPUState *cs =3D env_cpu(env); uint32_t die_offset; @@ -4584,19 +4492,19 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index= , uint32_t count, } switch (count) { case 0: /* L1 dcache info */ - encode_cache_cpuid8000001d(env->cache_info_amd.l1d_cache, cs, + encode_cache_cpuid8000001d(env->cache_info_amd.l1d_cache, ms, eax, ebx, ecx, edx); break; case 1: /* L1 icache info */ - encode_cache_cpuid8000001d(env->cache_info_amd.l1i_cache, cs, + encode_cache_cpuid8000001d(env->cache_info_amd.l1i_cache, ms, eax, ebx, ecx, edx); break; case 2: /* L2 cache info */ - encode_cache_cpuid8000001d(env->cache_info_amd.l2_cache, cs, + encode_cache_cpuid8000001d(env->cache_info_amd.l2_cache, ms, eax, ebx, ecx, edx); break; case 3: /* L3 cache info */ - encode_cache_cpuid8000001d(env->cache_info_amd.l3_cache, cs, + encode_cache_cpuid8000001d(env->cache_info_amd.l3_cache, ms, eax, ebx, ecx, edx); break; default: /* end of info */ @@ -4606,7 +4514,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, = uint32_t count, break; case 0x8000001E: assert(cpu->core_id <=3D 255); - encode_topo_cpuid8000001e(cs, cpu, + encode_topo_cpuid8000001e(ms, cpu, eax, ebx, ecx, edx); break; case 0xC0000000: --=20 2.20.1 From nobody Mon May 20 01:26:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=fail (Bad Signature) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564615310740728.8602048193839; Wed, 31 Jul 2019 16:21:50 -0700 (PDT) Received: from localhost ([::1]:44990 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsxum-0000I0-Pk for importer@patchew.org; Wed, 31 Jul 2019 19:21:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50844) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsxtv-0006zg-Lc for qemu-devel@nongnu.org; Wed, 31 Jul 2019 19:20:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsxtu-0008R6-2X for qemu-devel@nongnu.org; Wed, 31 Jul 2019 19:20:55 -0400 Received: from mail-eopbgr720053.outbound.protection.outlook.com ([40.107.72.53]:30923 helo=NAM05-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hsxtt-0008P5-PC for qemu-devel@nongnu.org; Wed, 31 Jul 2019 19:20:54 -0400 Received: from DM5PR12MB2471.namprd12.prod.outlook.com (52.132.141.138) by DM5PR12MB1657.namprd12.prod.outlook.com (10.172.38.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2115.15; Wed, 31 Jul 2019 23:20:50 +0000 Received: from DM5PR12MB2471.namprd12.prod.outlook.com ([fe80::ecb0:375b:9347:fe67]) by DM5PR12MB2471.namprd12.prod.outlook.com ([fe80::ecb0:375b:9347:fe67%7]) with mapi id 15.20.2136.010; Wed, 31 Jul 2019 23:20:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PngItcifDRi5l8sUtacs7MfSNn1tHA6Yz6sxOLyaNn9Zhq5XaTLVgB97hsjeZOyRtm0KmrsT8cdnKytwYZ2Wgvd21EO4xazQwor/2y9/jnL9zoPS5qLjOjYxOTtj5p86fcu+VVm6Cb8wGmXoD+4bgN9Z70s7XLkF91qxPo68gdlXd5Nbj1ImW21VPijZrfwx7mI91bihjqSR8/x3GI23yw+W46J09ZJK/waHIrn4L010JydJZ+dFaf/BgqTG3DKcpFtK/KGUBgEQPXxcvub5zufLb7emwIIcv9o+WEc6pYPThl1j36MMssFU41aQOISI88+7cnGfTttLzw9nYDYFpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UnDxsRvroJRPcCLozpmbXk4usK3uhc1+r25Diea4d2I=; b=c0HQJZQe8/m2pafNFqB+8V1wO34iDEtUAtp8djUt3JiTd5HbZ62q+TgBTrLYVZhSZ+hJtR25B0MflkHpgWdRWWAw1KY79f4haAO+xnsib4cLrpAoELf/5q04JdKivaItEDY2aHxHtIdOeByKAvDoyLvvM7NB0piR1UMhB7zaEiA8wkcnuItwKxD6OWdNVYpyjaJyo7WaqH4uQuJvjNZJg+nS7Vmy0JIVwi8yqSUdmODx3G+RV0Tv0p1B248cmPf9N5RcthPAVaXvLOjotF6vq1a/mWxZJ/osoZf0JXy+LtO33/OzaLLtq/wXinFUM8gbHYR+RkQcfvIe4Fz29mk7nQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1;spf=pass smtp.mailfrom=amd.com;dmarc=pass action=none header.from=amd.com;dkim=pass header.d=amd.com;arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UnDxsRvroJRPcCLozpmbXk4usK3uhc1+r25Diea4d2I=; b=SSNJMk+t/+RVggw5MFE4N8zGzt47ZotMQcwCAoL+JI2P1gw3J7N084VvZLCYZqJpojPwF2EinpYCNIHzmkp9imZ2ud2bjKU2bygd508GrINtY4h/itbQZB3C/CfqvcQm0DFfH4sHk/WXig7fAp4Fe8XMlFYJQ3cFR3HTeZKBJNM= From: "Moger, Babu" To: "ehabkost@redhat.com" , "marcel.apfelbaum@gmail.com" , "mst@redhat.com" , "pbonzini@redhat.com" , "rth@twiddle.net" , "imammedo@redhat.com" Thread-Topic: [RFC PATCH 4/5] hw/i386: Generate apicid based on cpu_type Thread-Index: AQHVR/aXbkLSW+hCAEaO8Uc/WmhXTw== Date: Wed, 31 Jul 2019 23:20:50 +0000 Message-ID: <20190731232032.51786-5-babu.moger@amd.com> References: <20190731232032.51786-1-babu.moger@amd.com> In-Reply-To: <20190731232032.51786-1-babu.moger@amd.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: SN1PR12CA0050.namprd12.prod.outlook.com (2603:10b6:802:20::21) To DM5PR12MB2471.namprd12.prod.outlook.com (2603:10b6:4:b5::10) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Babu.Moger@amd.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-originating-ip: [165.204.78.2] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: bcd9c1e5-0831-4207-afd3-08d7160db9ab x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:DM5PR12MB1657; x-ms-traffictypediagnostic: DM5PR12MB1657: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2657; x-forefront-prvs: 011579F31F x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(346002)(39860400002)(376002)(136003)(396003)(366004)(199004)(189003)(50226002)(7736002)(316002)(14444005)(256004)(102836004)(2201001)(66446008)(66556008)(6506007)(54906003)(2616005)(66476007)(76176011)(66066001)(1076003)(2906002)(8676002)(446003)(26005)(66946007)(53936002)(476003)(2501003)(305945005)(110136005)(64756008)(52116002)(4326008)(81156014)(68736007)(86362001)(14454004)(6512007)(386003)(99286004)(25786009)(11346002)(3846002)(6436002)(71200400001)(71190400001)(36756003)(6116002)(81166006)(8936002)(6486002)(478600001)(486006)(186003)(5660300002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR12MB1657; H:DM5PR12MB2471.namprd12.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: pass (zoho.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: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: daOIdJK4L8Ue4waZFU6hO0FgYUDv0xPgvbEQ8+QQcizO6FDF+5pcBrTKzX/dpcSrQ7KtRUsoVQAyP/yJsVrL9rX3ebqAXkNnfGVUJ0vPiBYwusRhDfq7k/kc/u+1QwdVzkFHYnMlpIv94qSB+aJaAmJs7XPsbX+4jR6IYUGDpTVkOEOSuW4A60H4Mn6nX4mj6i06a2hWEhE61gvNkFkwexEt3GWjGAVJ2xQ7KUCGlBaRqsSMoyJRYxZjQbGkAlP3yvo284fLLIKVOOS3+ifgBO7xk4rCiPqSO5YOKJzPhNOSEpVEwuzg2F6e8kZgPL/ZfN+Z46XLc1ZJTYfemtuNa0ITMEuiDQPzh07rhxETTi9zct1dUUlZ8Vhj6xRy9LWuKlnTpiPosZGq++6Ec9vtNjHlVeFAPGuLtlMAAZ45l+0= Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: bcd9c1e5-0831-4207-afd3-08d7160db9ab X-MS-Exchange-CrossTenant-originalarrivaltime: 31 Jul 2019 23:20:50.4315 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: bmoger@amd.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1657 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.72.53 Subject: [Qemu-devel] [RFC PATCH 4/5] hw/i386: Generate apicid based on cpu_type 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: "Moger, Babu" , "qemu-devel@nongnu.org" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Check the cpu_type before calling the apicid functions from topology.h. Signed-off-by: Babu Moger --- hw/i386/pc.c | 81 +++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 70 insertions(+), 11 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index ef39463fd5..dad55c940f 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -947,6 +947,36 @@ static uint32_t x86_cpu_apic_id_from_index(PCMachineSt= ate *pcms, } } =20 +/* Calculates initial APIC ID for a specific CPU index + * + * Currently we need to be able to calculate the APIC ID from the CPU index + * alone (without requiring a CPU object), as the QEMU<->Seabios interface= s have + * no concept of "CPU index", and the NUMA tables on fw_cfg need the APIC = ID of + * all CPUs up to max_cpus. + */ +static uint32_t x86_cpu_apic_id_from_index_epyc(PCMachineState *pcms, + unsigned int cpu_index) +{ + MachineState *ms =3D MACHINE(pcms); + PCMachineClass *pcmc =3D PC_MACHINE_GET_CLASS(pcms); + uint32_t correct_id; + static bool warned; + + correct_id =3D x86_apicid_from_cpu_idx_epyc(nb_numa_nodes, ms->smp.soc= kets, + ms->smp.cores, ms->smp.threads, + cpu_index); + if (pcmc->compat_apic_id_mode) { + if (cpu_index !=3D correct_id && !warned && !qtest_enabled()) { + error_report("APIC IDs set in compatibility mode, " + "CPU topology won't match the configuration"); + warned =3D true; + } + return cpu_index; + } else { + return correct_id; + } +} + static void pc_build_smbios(PCMachineState *pcms) { uint8_t *smbios_tables, *smbios_anchor; @@ -1619,7 +1649,7 @@ void pc_smp_parse(MachineState *ms, QemuOpts *opts) void pc_hot_add_cpu(MachineState *ms, const int64_t id, Error **errp) { PCMachineState *pcms =3D PC_MACHINE(ms); - int64_t apic_id =3D x86_cpu_apic_id_from_index(pcms, id); + int64_t apic_id; Error *local_err =3D NULL; =20 if (id < 0) { @@ -1627,6 +1657,11 @@ void pc_hot_add_cpu(MachineState *ms, const int64_t = id, Error **errp) return; } =20 + if(!strncmp(ms->cpu_type, "EPYC", 4)) + apic_id =3D x86_cpu_apic_id_from_index_epyc(pcms, id); + else + apic_id =3D x86_cpu_apic_id_from_index(pcms, id); + if (apic_id >=3D ACPI_CPU_HOTPLUG_ID_LIMIT) { error_setg(errp, "Unable to add CPU: %" PRIi64 ", resulting APIC ID (%" PRIi64 ") is too large", @@ -1658,8 +1693,13 @@ void pc_cpus_init(PCMachineState *pcms) * * This is used for FW_CFG_MAX_CPUS. See comments on bochs_bios_init(). */ - pcms->apic_id_limit =3D x86_cpu_apic_id_from_index(pcms, - ms->smp.max_cpus - 1)= + 1; + if(!strncmp(ms->cpu_type, "EPYC", 4)) + pcms->apic_id_limit =3D x86_cpu_apic_id_from_index_epyc(pcms, + ms->smp.max_= cpus - 1) + 1; + else + pcms->apic_id_limit =3D x86_cpu_apic_id_from_index(pcms, + ms->smp.max_cpus = - 1) + 1; + possible_cpus =3D mc->possible_cpu_arch_ids(ms); for (i =3D 0; i < ms->smp.cpus; i++) { pc_new_cpu(pcms, possible_cpus->cpus[i].arch_id, &error_fatal); @@ -2387,6 +2427,7 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_d= ev, PCMachineState *pcms =3D PC_MACHINE(hotplug_dev); unsigned int smp_cores =3D ms->smp.cores; unsigned int smp_threads =3D ms->smp.threads; + unsigned int smp_sockets =3D ms->smp.sockets; =20 if(!object_dynamic_cast(OBJECT(cpu), ms->cpu_type)) { error_setg(errp, "Invalid CPU type, expected cpu type: '%s'", @@ -2437,16 +2478,26 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug= _dev, topo.die_id =3D cpu->die_id; topo.core_id =3D cpu->core_id; topo.smt_id =3D cpu->thread_id; - cpu->apic_id =3D apicid_from_topo_ids(pcms->smp_dies, smp_cores, - smp_threads, &topo); + if (!strncmp(ms->cpu_type, "EPYC", 4)) { + x86_topo_ids_from_idx_epyc(nb_numa_nodes, smp_sockets, smp_cor= es, + smp_threads, idx, &topo); + cpu->apic_id =3D apicid_from_topo_ids_epyc(smp_cores, smp_thre= ads, + &topo); + } else + cpu->apic_id =3D apicid_from_topo_ids(pcms->smp_dies, smp_core= s, + smp_threads, &topo); } =20 cpu_slot =3D pc_find_cpu_slot(MACHINE(pcms), cpu->apic_id, &idx); if (!cpu_slot) { MachineState *ms =3D MACHINE(pcms); =20 - x86_topo_ids_from_apicid(cpu->apic_id, pcms->smp_dies, - smp_cores, smp_threads, &topo); + if(!strncmp(ms->cpu_type, "EPYC", 4)) + x86_topo_ids_from_apicid_epyc(cpu->apic_id, pcms->smp_dies, + smp_cores, smp_threads, &topo); + else + x86_topo_ids_from_apicid(cpu->apic_id, pcms->smp_dies, + smp_cores, smp_threads, &topo); error_setg(errp, "Invalid CPU [socket: %u, die: %u, core: %u, thread: %u] with" " APIC ID %" PRIu32 ", valid index range 0:%d", @@ -2874,10 +2925,18 @@ static const CPUArchIdList *pc_possible_cpu_arch_id= s(MachineState *ms) =20 ms->possible_cpus->cpus[i].type =3D ms->cpu_type; ms->possible_cpus->cpus[i].vcpus_count =3D 1; - ms->possible_cpus->cpus[i].arch_id =3D x86_cpu_apic_id_from_index(= pcms, i); - x86_topo_ids_from_apicid(ms->possible_cpus->cpus[i].arch_id, - pcms->smp_dies, ms->smp.cores, - ms->smp.threads, &topo); + if(!strncmp(ms->cpu_type, "EPYC", 4)) { + ms->possible_cpus->cpus[i].arch_id =3D + x86_cpu_apic_id_from_index_epyc(pcms, i); + x86_topo_ids_from_apicid_epyc(ms->possible_cpus->cpus[i].arch_= id, + pcms->smp_dies, ms->smp.cores, + ms->smp.threads, &topo); + } else { + ms->possible_cpus->cpus[i].arch_id =3D x86_cpu_apic_id_from_in= dex(pcms, i); + x86_topo_ids_from_apicid(ms->possible_cpus->cpus[i].arch_id, + pcms->smp_dies, ms->smp.cores, + ms->smp.threads, &topo); + } ms->possible_cpus->cpus[i].props.has_socket_id =3D true; ms->possible_cpus->cpus[i].props.socket_id =3D topo.pkg_id; ms->possible_cpus->cpus[i].props.has_die_id =3D true; --=20 2.20.1 From nobody Mon May 20 01:26:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=fail (Bad Signature) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 156461538351491.43107719365639; Wed, 31 Jul 2019 16:23:03 -0700 (PDT) Received: from localhost ([::1]:45008 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsxvy-0002jP-Jf for importer@patchew.org; Wed, 31 Jul 2019 19:23:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50842) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsxtv-0006z9-Gi for qemu-devel@nongnu.org; Wed, 31 Jul 2019 19:20:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsxtu-0008Rb-Hp for qemu-devel@nongnu.org; Wed, 31 Jul 2019 19:20:55 -0400 Received: from mail-eopbgr720053.outbound.protection.outlook.com ([40.107.72.53]:30923 helo=NAM05-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hsxtu-0008P5-Aj for qemu-devel@nongnu.org; Wed, 31 Jul 2019 19:20:54 -0400 Received: from DM5PR12MB2471.namprd12.prod.outlook.com (52.132.141.138) by DM5PR12MB1657.namprd12.prod.outlook.com (10.172.38.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2115.15; Wed, 31 Jul 2019 23:20:51 +0000 Received: from DM5PR12MB2471.namprd12.prod.outlook.com ([fe80::ecb0:375b:9347:fe67]) by DM5PR12MB2471.namprd12.prod.outlook.com ([fe80::ecb0:375b:9347:fe67%7]) with mapi id 15.20.2136.010; Wed, 31 Jul 2019 23:20:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y73Ck/yayK1/E+08z6qo/p7mJ0/uo/AClfROdsv+xBw4praazterN9krVBjv3P2duby1Datg47ZLTtvh75BXRpp/l0WDcyBkyxCe0Or9EpIcdGRn8rCtoSTctVH2E1c3Mpdk+37kUzOyb8e2Z8ISItvdNYLdoyRE9Atlwa2TrNAvam5nHHn6Mia8q1E9zLuNxuVcxEMgONqMRQddo2W8yP4aRxwBER7QrMaIDu7KDZvGw5iDH7NJdrhmH1mHMWU4vAjtJuMkH2n049hXwufLA3A6qxM8K8RGgdz8fuJfrg8f6m9cQcdaUOWDUHNbUUYqqSdBh4KB7wgYAIadOnh0zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0jb2oLu/YXMn8C8zTSuCIbXvWmCyUHcgsH19ILPn+fo=; b=TdJ0mDBmFyLhSWkcu5mZzWhVIkdofuAhAEKXMAlvmuYyBzmkjNhWg19p7I/WL0c8+tFhZAoODJRwZC7nCWoUziNeQmEIYJdQguojRz1DEbfFM+jet2TDuNpHf2Ikx2CmyDV1aDOwuELZdwwzxTLWxUZDHIxWp9WzH58MGMwvPeEwWNi+kLWHwmuZBdkon1Jy5EIMU2y+AZ1C9BoFXTtUmlRlAQ5voErhVx7mZ6IM/o3Nna+uzGpTZF7DQyrjhyCeUO/p57RYdOJegxK4BhSsdPW2W0F0w0/AGqCiD0y9SCG8iYO3lBLD/Fja91n0S9JRfzGg9jyyHGjUefnlK9WFeg== ARC-Authentication-Results: i=1; mx.microsoft.com 1;spf=pass smtp.mailfrom=amd.com;dmarc=pass action=none header.from=amd.com;dkim=pass header.d=amd.com;arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0jb2oLu/YXMn8C8zTSuCIbXvWmCyUHcgsH19ILPn+fo=; b=YQff77a7d844Qe9lkUJNoOVui44Xku39RPgmIkH+HrmIguWTLlaaoLA4h6v90Zv6fUYylVWm7RH+a1arAcKPz2WRchByv/Dq/kCPssIu1e5PEnnlhxP4xZGCeFkvNvXGGPa4/lKoZPVXdO/gSCK194LnBHtJ2GGTwMHrzJsVy3Y= From: "Moger, Babu" To: "ehabkost@redhat.com" , "marcel.apfelbaum@gmail.com" , "mst@redhat.com" , "pbonzini@redhat.com" , "rth@twiddle.net" , "imammedo@redhat.com" Thread-Topic: [RFC PATCH 5/5] i386: Fix pkg_id offset EPYC Thread-Index: AQHVR/aXpDsOnsB4hUqhnkMdXogqLw== Date: Wed, 31 Jul 2019 23:20:51 +0000 Message-ID: <20190731232032.51786-6-babu.moger@amd.com> References: <20190731232032.51786-1-babu.moger@amd.com> In-Reply-To: <20190731232032.51786-1-babu.moger@amd.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: SN1PR12CA0050.namprd12.prod.outlook.com (2603:10b6:802:20::21) To DM5PR12MB2471.namprd12.prod.outlook.com (2603:10b6:4:b5::10) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Babu.Moger@amd.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-originating-ip: [165.204.78.2] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 89f0f405-669a-460d-c6f3-08d7160dba4f x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:DM5PR12MB1657; x-ms-traffictypediagnostic: DM5PR12MB1657: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1824; x-forefront-prvs: 011579F31F x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(346002)(39860400002)(376002)(136003)(396003)(366004)(199004)(189003)(50226002)(7736002)(316002)(14444005)(256004)(102836004)(2201001)(66446008)(66556008)(6506007)(54906003)(2616005)(66476007)(76176011)(66066001)(1076003)(2906002)(8676002)(446003)(26005)(66946007)(53936002)(476003)(2501003)(305945005)(110136005)(64756008)(52116002)(4326008)(81156014)(68736007)(86362001)(14454004)(6512007)(386003)(99286004)(25786009)(11346002)(3846002)(6436002)(71200400001)(71190400001)(36756003)(6116002)(81166006)(8936002)(6486002)(478600001)(486006)(186003)(5660300002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR12MB1657; H:DM5PR12MB2471.namprd12.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: pass (zoho.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: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 8RFhaqRb3BPlTowAHVq0Avww/zg94SrNddEaMS9rXpL4UEUPwSNjOGOsUjHr2QTAztNMmb5TTv7CJ0UQOUxjbtQMrt3m880NxHMdMaeSby9qXIZwbriGcuEU7+W5LgMWnVLLStUcRhHeHiQ1Y+6Wlnnkmg9TEwA/14JoP5zGygFKWPwOxdyjWQPLfB69/UXMzob872AijmbLRMqPoTCN7XPnMVBzkyYhRNBF2cZPQsFVrP2sncvNTM7VqVkqbxC0eJUTk0CBxKGQuRCJM4LVnXvg/frW3NytZ0rwGbBT69Q4DuerftOU0i/LGtUsWA0kwMW+zYj5VBBDmAuELNlWuLnGJbkw+MiillGHyCHyExbZzLN5RTaA5UbBbBTKNQE7Ir/L6zR7C5lqKOpp8BYpf6ZVuyz1SJlwEqQ+gKjHj3U= Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 89f0f405-669a-460d-c6f3-08d7160dba4f X-MS-Exchange-CrossTenant-originalarrivaltime: 31 Jul 2019 23:20:51.4929 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: bmoger@amd.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1657 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.72.53 Subject: [Qemu-devel] [RFC PATCH 5/5] i386: Fix pkg_id offset EPYC 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: "Moger, Babu" , "qemu-devel@nongnu.org" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Per Processor Programming Reference (PPR) for AMD Family 17h Models, the pkg_id offset in apicid is 6. Fix the offset based on EPYC models. Signed-off-by: Babu Moger --- target/i386/cpu.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index be4583068c..235496a9c1 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -4079,7 +4079,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, = uint32_t count, MachineState *ms =3D MACHINE(qdev_get_machine()); X86CPU *cpu =3D env_archcpu(env); CPUState *cs =3D env_cpu(env); - uint32_t die_offset; + uint32_t die_offset, pkg_offset; uint32_t limit; uint32_t signature[3]; =20 @@ -4102,6 +4102,12 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index,= uint32_t count, index =3D env->cpuid_level; } =20 + if (!strncmp(ms->cpu_type, "EPYC", 4)) + pkg_offset =3D PKG_OFFSET_EPYC; + else + pkg_offset =3D apicid_pkg_offset(env->nr_dies, cs->nr_cores, + cs->nr_threads); + switch(index) { case 0: *eax =3D env->cpuid_level; @@ -4260,8 +4266,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, = uint32_t count, *ecx |=3D CPUID_TOPOLOGY_LEVEL_SMT; break; case 1: - *eax =3D apicid_pkg_offset(env->nr_dies, - cs->nr_cores, cs->nr_threads); + *eax =3D pkg_offset; *ebx =3D cs->nr_cores * cs->nr_threads; *ecx |=3D CPUID_TOPOLOGY_LEVEL_CORE; break; @@ -4297,8 +4302,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, = uint32_t count, *ecx |=3D CPUID_TOPOLOGY_LEVEL_CORE; break; case 2: - *eax =3D apicid_pkg_offset(env->nr_dies, cs->nr_cores, - cs->nr_threads); + *eax =3D pkg_offset; *ebx =3D env->nr_dies * cs->nr_cores * cs->nr_threads; *ecx |=3D CPUID_TOPOLOGY_LEVEL_DIE; break; --=20 2.20.1