From patchwork Fri Sep 6 19:11:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 11135847 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E70B513BD for ; Fri, 6 Sep 2019 19:13:09 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BC0A32070C for ; Fri, 6 Sep 2019 19:13:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="qApVvP+T" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BC0A32070C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:59518 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6JfQ-00037b-Ha for patchwork-qemu-devel@patchwork.kernel.org; Fri, 06 Sep 2019 15:13:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42129) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6Je1-0001a4-5i for qemu-devel@nongnu.org; Fri, 06 Sep 2019 15:11:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i6Jdz-0003yS-Ko for qemu-devel@nongnu.org; Fri, 06 Sep 2019 15:11:41 -0400 Received: from mail-eopbgr750071.outbound.protection.outlook.com ([40.107.75.71]:61423 helo=NAM02-BL2-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 1i6Jdz-0003xj-Bs for qemu-devel@nongnu.org; Fri, 06 Sep 2019 15:11:39 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QmyjpesRpTs7wV7gcLcLAj1/+JA2h3WoqcmeLEywiI1057FU++NW8sl3zq6bKv4T46ukMm1xfssfuBpIlpL66yEovCEyLRFjzexMLD5ZRyaRolonxpoMd3NboqZcUEBZDLPbjYxhB/1PoVIG3qRcfn9I6BDNH8s19HvzyNei1zKbqRtb5ljMfFfH6trO3y4sMTDY2d0btYA95RCs7pPZ1IXUDrho1QRA2UC2lzTvO7FzF489BQQaUTLfCXxN3sd7T8dXd2bdXgs+qHkYbsNreM3cPsZleX/1PJl0bgXkcSDxDkwGd2IaJnyqj05pedpISEgfQUUbtXJHf5q0G05lqA== 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=GtWlPkIPxhaA4R4G91XG69+uWHqGq4aQLGExq/4Grhs=; b=XK6OkZWdffcQ3isIvOq+slA7F0RJUKSpehLhKFaeZ8Yli8h0mUdPpFwvTIpwQ6bF4dfzSaZ+Yt15tq8hGb72clvbYThiuv7j6v2pLtIpZzhdZgEyJIme7YGr1pMpjDkL3bsmJ0lUXfO2HpWFX9HURw6PtZdSphvR7wM1c06Tnaj+blkJttzF7q6X5jQiowdc4ZpvekzCQCINl94w9WmQ2HZPepSlA698z5jS435aB1b9BzzcsH0WwCfdiMJQUPAp1bkuc1roQnjGy/9zZJVuv8Gb1rmIZUd1m2jaBgZ68f1krJ25au6n3nwl+BEXpymg0gFdx25ETHhxLv7+rsKCSA== 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=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GtWlPkIPxhaA4R4G91XG69+uWHqGq4aQLGExq/4Grhs=; b=qApVvP+T6OTBoHNzuiJ9fu5x1/fo3VqgKfhGEZKa1WHpmHE9RmQwWitzDyUzSTZ089YMPDET7wa8XUSUby9yRi7sXq4cQ+xtWL/uOdyMMSR7bEpiwlGQnVANPBXHdSPYvLOAoYuyOZBxMRcD6LBv/nN5fcKDBKr3j2vRt2Rjhgg= Received: from DM5PR12MB2471.namprd12.prod.outlook.com (52.132.141.138) by DM5PR12MB1145.namprd12.prod.outlook.com (10.168.238.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2241.14; Fri, 6 Sep 2019 19:11:36 +0000 Received: from DM5PR12MB2471.namprd12.prod.outlook.com ([fe80::6c7c:4b6d:f136:1bf8]) by DM5PR12MB2471.namprd12.prod.outlook.com ([fe80::6c7c:4b6d:f136:1bf8%3]) with mapi id 15.20.2220.022; Fri, 6 Sep 2019 19:11:36 +0000 From: "Moger, Babu" To: ssg.sos.staff , "ehabkost@redhat.com" , "marcel.apfelbaum@gmail.com" , "mst@redhat.com" , "pbonzini@redhat.com" , "rth@twiddle.net" , "eblake@redhat.com" , "armbru@redhat.com" , "imammedo@redhat.com" Thread-Topic: [RFC 2 PATCH 00/16] APIC ID fixes for AMD EPYC CPU models Thread-Index: AQHVZObn5GxgbST9YEezYs2SnJ7woQ== Date: Fri, 6 Sep 2019 19:11:36 +0000 Message-ID: <156779689013.21957.1631551572950676212.stgit@localhost.localdomain> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: SN6PR06CA0012.namprd06.prod.outlook.com (2603:10b6:805:8e::25) 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-originating-ip: [165.204.78.1] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: a21d559f-38d1-42cc-eefa-08d732fe0998 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600166)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:DM5PR12MB1145; x-ms-traffictypediagnostic: DM5PR12MB1145: x-ms-exchange-purlcount: 3 x-ld-processed: 3dd8961f-e488-4e60-8e11-a82d994e183d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-forefront-prvs: 0152EBA40F x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(376002)(396003)(366004)(39860400002)(136003)(346002)(199004)(189003)(2201001)(71190400001)(305945005)(7736002)(9686003)(52116002)(86362001)(71200400001)(6116002)(8936002)(6512007)(3846002)(6436002)(103116003)(99286004)(6506007)(6486002)(26005)(4326008)(14454004)(5660300002)(386003)(476003)(102836004)(2906002)(25786009)(6306002)(2501003)(53936002)(8676002)(66446008)(186003)(66556008)(486006)(66946007)(66476007)(64756008)(110136005)(81166006)(81156014)(478600001)(14444005)(66066001)(966005)(256004)(316002)(170073001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR12MB1145; H:DM5PR12MB2471.namprd12.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: iVBi9dxYZXQKpkBUeULptzgd8iKLHGSmlUZH1rozYisyzk9DjFITxUy8OeGgi+CTULe9aK8Noq4DQI3rqZf7TILmZnt4hkSLUVdApWaMk6EOofFzN9+bPETOR0a75m1PICwD5hNL9x7OdofUwmX4UCvF3eBJACJr0SUzdOUeXPiaKGZSwC5pEViEODFoST8J2tWfdlM+pZeAPQJXeSo/QBtxWsW+EPGp3G+qJ1sO2nVdfoEEe8pZavR85Paq0XP1SZ7JwvxeQZr+unPJXojwWHFk5S7OuwD+SIX6QdAc79uR8K5l/WOyuaC7ns6e9inAVs5Zcvl3nC7rFLuf4VWoxIbQ4gti9Y/Xo9FsL5nUHsfWF0jrR0BiacNHTy0D+h+lF2RMPrdSWsjnN9JDxGleeRMC8eLck/rq0vbsVpLEdgw= Content-ID: <26DA203A4F075B4487B6627DD2021ED7@namprd12.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: a21d559f-38d1-42cc-eefa-08d732fe0998 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Sep 2019 19:11:36.3212 (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: YrAHoWUJKmM41WzI1TjvEBFeEHMRIhsEz0Oz4mo74HTwvbMf4IkTpvsmB6YcqKYz X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1145 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.75.71 Subject: [Qemu-devel] [RFC 2 PATCH 00/16] APIC ID fixes for AMD EPYC CPU models 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" These series fixes the problems encoding APIC ID for AMD EPYC cpu models. https://bugzilla.redhat.com/show_bug.cgi?id=1728166 This is the second pass to give an idea of the changes required to address the issue. First pass is availabe at https://patchwork.kernel.org/cover/11069785/ Currently, apic id is decoded based on sockets/dies/cores/threads. This appears to work for most standard configurations for AMD and other vendors. But this decoding does not follow AMD's APIC ID enumeration. In some cases this causes CPU topology inconstancy. While booting guest Kernel is trying to validate topology. It finds the topology not aligning to EPYC models. To fix the problem we need to build the topology as per the Processor Programming Reference (PPR) for AMD Family 17h Model 01h, Revision B1 Processors. It is available at https://www.amd.com/en/support/tech-docs Here is the text from the PPR. 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 that 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: • ApicId[6] = Socket ID. • ApicId[5:4] = Node ID. • ApicId[3] = Logical CCX L3 complex ID • ApicId[2:0]= (SMT) ? {LogicalCoreID[1:0],ThreadId} : {1'b0,LogicalCoreID[1:0]}. """ v2: 1. Introduced the new property epyc to enable new epyc mode. 2. Separated the epyc mode and non epyc mode function. 3. Introduced function pointers in PCMachineState to handle the differences. 4. Mildly tested different combinations to make things are working as expected. 5. TODO : Setting the epyc feature bit needs to be worked out. This feature is supported only on AMD EPYC models. I may need some guidance on that. v1: https://patchwork.kernel.org/cover/11069785/ --- Babu Moger (16): numa: Split the numa functionality hw/i386: Rename X86CPUTopoInfo structure to X86CPUTopoIDs hw/i386: Introduce X86CPUTopoInfo to contain topology info machine: Add SMP Sockets in CpuTopology hw/i386: Simplify topology Offset/width Calculation hw/core: Add core complex id in X86CPU topology hw/386: Add new epyc mode topology decoding functions i386: Cleanup and use the new epyc mode topology functions hw/i386: Introduce initialize_topo_info function hw/i386: Introduce apicid_from_cpu_idx in PCMachineState Introduce-topo_ids_from_apicid-handler hw/i386: Introduce apic_id_from_topo_ids handler in PCMachineState machine: Add new epyc property in PCMachineState hw/i386: Introduce epyc mode function handlers i386: Fix pkg_id offset for epyc mode hw/core: Fix up the machine_set_cpu_numa_node for epyc hw/core/machine-hmp-cmds.c | 3 hw/core/machine.c | 38 ++++++ hw/core/numa.c | 110 ++++++++++++---- hw/i386/pc.c | 143 +++++++++++++++------ include/hw/boards.h | 8 + include/hw/i386/pc.h | 9 + include/hw/i386/topology.h | 294 +++++++++++++++++++++++++++++++++++--------- include/sysemu/numa.h | 2 qapi/machine.json | 4 - target/i386/cpu.c | 209 +++++++++++-------------------- target/i386/cpu.h | 1 vl.c | 3 12 files changed, 560 insertions(+), 264 deletions(-) -- Signature