From patchwork Mon Aug 31 18:42:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Moger, Babu" X-Patchwork-Id: 1354531 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=amd.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-amdcloud-onmicrosoft-com header.b=jBBsrvsj; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4BgJwj3WWFz9sTN for ; Tue, 1 Sep 2020 04:42:45 +1000 (AEST) Received: from localhost ([::1]:46408 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kColP-0005rm-Cm for incoming@patchwork.ozlabs.org; Mon, 31 Aug 2020 14:42:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40504) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCol2-0005ol-4F for qemu-devel@nongnu.org; Mon, 31 Aug 2020 14:42:20 -0400 Received: from mail-eopbgr750043.outbound.protection.outlook.com ([40.107.75.43]:51695 helo=NAM02-BL2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCokw-0007Sz-Mz for qemu-devel@nongnu.org; Mon, 31 Aug 2020 14:42:19 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L/75WMe8NNbgRBi5a8qhtlyGvgkg7Ukgd3gFvL1xTaKZOhxHfsPGK036jGDf56JrVfKr2aNRJnLejK8CB6qJVPsiPv2IHvli79LCj/lJvoJqLyZGwljbEZy7h8wSrfLQKxf+NnHbbnNYHdxxWcFtFwKX1imTgaJoGkJfcOmQ0LgZnR9ngPtQPAuxlXPsqAKdN/zHWS/Rg/HXjbBKzrZ8XjxZWl3QtlWbZj9jwWsEf7N8zIc3f5xcQUAYKA8PMmlBiVT1t7Re4z3cRA5IM1tXVfRSHcx7ubITc5ov8ynja+HNWrcju3NNWQZKKX9JTS7X6c/YAKZmtGulUNfa3TL+og== 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=KYYZTgO74ACxkoabLIb2olY7JXFiOKa11FI3TlIZwsA=; b=IbCuaCMxKoCN3zzc/XgYblczVf2oMorHLhM9T5jfEIdJ05+ePb3OqyafwfGT7qZX1b6t8pHSByNHUSpNEHNu7ljoUyt0wo0K8ehx1msPTsxBobwheiLYsbTk0v77UT3HGsjcbFs+cBOGWYw4fstfJeavPzV7lJhphegikfW2MEM4Rd0w58jbCZJNrSAja8wHJO5iFF8R2WikSr6T4166CDtZT8NXTrAUg6GNJw7z92KxrPnNwr0wYVH0yogAXfjpKcReydeVcWRK1gsK2HGGKaM3kQL+qmKuY1q7Ang0DYmM1WgvsZE0SLHIQB2OmAN+lMAwRvBkvm0H3j9KaG9svw== 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=KYYZTgO74ACxkoabLIb2olY7JXFiOKa11FI3TlIZwsA=; b=jBBsrvsjVJXHE0G4c7doBHSc824oKsECUrnj50bEtSy2gOy9JhDcNQWgOpr8NxfHq4m8fZ6FD3ashsQ0mLWZayea2/3/xFAtVTIYos/hPr+9fN0iMtw75/GO+uG/h4OUiCmf8M6hei2qrUR3es3cHVOQmsf9kvJukRLiulIjsy8= Authentication-Results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=amd.com; Received: from SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) by SN1PR12MB2559.namprd12.prod.outlook.com (2603:10b6:802:29::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.23; Mon, 31 Aug 2020 18:42:12 +0000 Received: from SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::ccd9:728:9577:200d]) by SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::ccd9:728:9577:200d%4]) with mapi id 15.20.3326.025; Mon, 31 Aug 2020 18:42:12 +0000 Subject: [PATCH v6 01/10] Revert "i386: Fix pkg_id offset for EPYC cpu models" From: Babu Moger To: pbonzini@redhat.com, rth@twiddle.net, ehabkost@redhat.com, imammedo@redhat.com Date: Mon, 31 Aug 2020 13:42:11 -0500 Message-ID: <159889933119.21294.8112825730577505757.stgit@naples-babu.amd.com> In-Reply-To: <159889924378.21294.16494070903874534542.stgit@naples-babu.amd.com> References: <159889924378.21294.16494070903874534542.stgit@naples-babu.amd.com> User-Agent: StGit/unknown-version X-ClientProxiedBy: SA9PR10CA0010.namprd10.prod.outlook.com (2603:10b6:806:a7::15) To SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from 255.255.255.255 (255.255.255.255) by SA9PR10CA0010.namprd10.prod.outlook.com (2603:10b6:806:a7::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.20 via Frontend Transport; Mon, 31 Aug 2020 18:42:12 +0000 X-Originating-IP: [165.204.78.2] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 21708d3a-ee29-4043-6ebf-08d84ddd930d X-MS-TrafficTypeDiagnostic: SN1PR12MB2559: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:247; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IJ5ugb/D2rum+EgUPW7QXRgBmtz0KBvX7ANy6fezXjX9dGr/PF66Awu2jH6VlZaYypIPI3vbex82lDZTEIE1eUTo7BrmlE7sNkJacuOwJgqjfQrLp1Y3aokpMSOIq3Oky+A1ri4t5PngQbTvlnxCmck6wK2m/oQvBLcEulgmDEUQGxS+DdjYOFfAhxiRifYE+tnc/e7uGEaPmMHsFQqHFJswkHBYmu6eIkuSQXvRfQRI6hoUtRa6TW4k4/tZw1zh2edTTuZbfNOHHGcPMXYkGictIbapJ+m7pVdig4XH0UAyee9YF1F30+OnvBipktvdx3zn6wqYfXkS3mbkZgq1eg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN1PR12MB2560.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(346002)(39860400002)(396003)(136003)(366004)(2906002)(66946007)(83380400001)(66556008)(4326008)(26005)(956004)(316002)(16576012)(5660300002)(186003)(66476007)(6486002)(8676002)(478600001)(44832011)(8936002)(86362001)(52116002)(103116003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 7aqXeXW+Uetkjkdvgag9S1ez+5H7u5Cbiub4cvZIRXWX6NW3gEuQl1aGseigwZke8gQxNHwxcuPmc6e5xfwIvB2fdq92cA6atAmsdw5+JIjmCB54Ckms2WhmlxoViKIWNGIjYMFq+PE/TlSBOOGKTPmsTOgRaFE7i62SYBp5l4Lf5RF6+Me+CqZFcpsRbxMnyKPO8c++o9k4+vz65VxO0rEsCCRs/MKPUWv5sjVVqa5ruFj7sGKo2gZRJeeTZXT9spEYDF+z9m1vo34ygdxZgbAZ5xTNy5V4jzk1PhMM0c+xiabXGWO+c6VMHoyzupN06TxTcgoGnzfc/Fj99RZUWA00IZrANdxXm1N7WagCMipo063lOTcYpI65ZsgK6A+3ndNRV1qXcRXeqKfi4YhhOPkj5hJr8SEx54vf3AwxtR8KYbhQ0Otx02AB3vZTUKaQdhL7dlRU4bUlmHjAbjcj7zFuJMP6aXFsFt+B2j5T2ZdZMrPXAr07SbNRUaMMDpDVyTWY0Yc2gKSVaS5S7X5UqvlywC/3vCpjG2xcT72YM12w1m1O9DgtIpIs6z61RmmCMloFDlNN20LCQWS9afJVBYKJaFU4NeihJ1FuUgR7/0bphYdhJel/cduT1ubwhpVlztWxVWKYy3T2bIyvf0pV2A== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 21708d3a-ee29-4043-6ebf-08d84ddd930d X-MS-Exchange-CrossTenant-AuthSource: SN1PR12MB2560.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2020 18:42:12.4016 (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: 1msdWkkKzUYljHDDv+gBx84LPVQJe7i5hMPeFKPIqGVjHLSQMPzxLaODTPkYL90q X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2559 Received-SPF: none client-ip=40.107.75.43; envelope-from=Babu.Moger@amd.com; helo=NAM02-BL2-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/31 14:42:13 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: 4 X-Spam_score: 0.4 X-Spam_bar: / X-Spam_report: (0.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FORGED_SPF_HELO=1, MSGID_FROM_MTA_HEADER=0.001, RCVD_ILLEGAL_IP=1.3, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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: babu.moger@amd.com, qemu-devel@nongnu.org, mst@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This reverts commit 7b225762c8c05fd31d4c2be116aedfbc00383f8b. Remove the EPYC specific apicid decoding and use the generic default decoding. Also fix all the references of pkg_offset. Signed-off-by: Babu Moger Reviewed-by: Igor Mammedov --- hw/i386/pc.c | 1 - target/i386/cpu.c | 9 ++++----- target/i386/cpu.h | 1 - 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 5d8d5ef8b3..6b708f4341 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1502,7 +1502,6 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev, env->nr_dies = x86ms->smp_dies; env->nr_nodes = topo_info.nodes_per_pkg; - env->pkg_offset = x86ms->apicid_pkg_offset(&topo_info); /* * If APIC ID is not set, diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 588f32e136..173e6f4a07 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -5678,7 +5678,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, *ecx |= CPUID_TOPOLOGY_LEVEL_SMT; break; case 1: - *eax = env->pkg_offset; + *eax = apicid_pkg_offset(&topo_info); *ebx = cs->nr_cores * cs->nr_threads; *ecx |= CPUID_TOPOLOGY_LEVEL_CORE; break; @@ -5712,7 +5712,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, *ecx |= CPUID_TOPOLOGY_LEVEL_CORE; break; case 2: - *eax = env->pkg_offset; + *eax = apicid_pkg_offset(&topo_info); *ebx = env->nr_dies * cs->nr_cores * cs->nr_threads; *ecx |= CPUID_TOPOLOGY_LEVEL_DIE; break; @@ -5889,11 +5889,10 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, /* * Bits 15:12 is "The number of bits in the initial * Core::X86::Apic::ApicId[ApicId] value that indicate - * thread ID within a package". This is already stored at - * CPUX86State::pkg_offset. + * thread ID within a package". * Bits 7:0 is "The number of threads in the package is NC+1" */ - *ecx = (env->pkg_offset << 12) | + *ecx = (apicid_pkg_offset(&topo_info) << 12) | ((cs->nr_cores * cs->nr_threads) - 1); } else { *ecx = 0; diff --git a/target/i386/cpu.h b/target/i386/cpu.h index e1a5c174dc..d5ad42d694 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1630,7 +1630,6 @@ typedef struct CPUX86State { unsigned nr_dies; unsigned nr_nodes; - unsigned pkg_offset; } CPUX86State; struct kvm_msrs; From patchwork Mon Aug 31 18:42:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Moger, Babu" X-Patchwork-Id: 1354538 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=amd.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-amdcloud-onmicrosoft-com header.b=TT0sRTug; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4BgK0g0BDkz9sTM for ; Tue, 1 Sep 2020 04:46:11 +1000 (AEST) Received: from localhost ([::1]:59256 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kCooi-0002g6-Uj for incoming@patchwork.ozlabs.org; Mon, 31 Aug 2020 14:46:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40520) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCol3-0005r2-Gr for qemu-devel@nongnu.org; Mon, 31 Aug 2020 14:42:21 -0400 Received: from mail-eopbgr750043.outbound.protection.outlook.com ([40.107.75.43]:51695 helo=NAM02-BL2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCol2-0007Sz-5h for qemu-devel@nongnu.org; Mon, 31 Aug 2020 14:42:21 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iLzEmllLAPZOdSfsJC56EO9zGOCCddWEv8jYQ18WuHx9zHbn7jJX8AJtt6y5FJhux92CfpduYuQrYtUEFOD9B10LtZkRccFHUryHbUREIhrd5STjZ8efz4fRZgoZDxW35HZKvIYsIj3JFkI//ScJypAHcqf/2rZakntuGhVGGHylauxWpQmKiVqPIInRkurNqEv23MsgZTD+RmLs5IbyjvpWJVLr90xakRvMWfYvfQ3NJw1J/ZgIJJ4woFIj7jQIoWkl1xmX8YCXfPAUaXFp5VQG6RpCRdC2UFUytUn1w4rakGB1SHWo0mg9pKNnwKYrzvliBGeBjhU6U+uHGoZcIA== 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=e9p0ovwqYrpmecY/lG8nSMN2vBRA6yCFMS067YaxtJY=; b=aKcRd48srridNhO9tWkNBNxBKmCvwYsv9flqZcsvt7feAkDE7vACYgnhZ+jSH5Ha4vHd10CrU4+KSxRydMJxTZKhLZXmoG/8A4aIcKhQKY217iAY9gQt4fWoERMBQ4uvJ01dnmBvjlhbN4kY8HPDeQQQ6EK6dhY88RRvdK5p3QnbnDMrevxHuDFPuyOOBQbuPUtba64VSngjSmNXhV8rSzpYiXxtU1giQ82LhtrbSJyeQ+jj5zfYiUUFL60GaNwLgIiKTjcAxE0GqD1100ciBo9djS2kCWDJXLGBBBvOFkwCJ5YPHzyj71TdgS22kAUGxPKNrzggPbKrJShX1piaJQ== 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=e9p0ovwqYrpmecY/lG8nSMN2vBRA6yCFMS067YaxtJY=; b=TT0sRTugoTuB7GNqFNmG+3+0sh9/PsTaqYz5nOPmn7m0fz5bPFsjzpudFhGymBFBbx/WQcbC6Wt0C4TFC6wOKZYjI0OzOpE/kJV3/zkM0PkkNxv1zCli9kAxRQPBB4CJS2k+y7nyQUYe25rGES6NP1+zZeqjs4C8fmpHqRqoyMQ= Authentication-Results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=amd.com; Received: from SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) by SN1PR12MB2559.namprd12.prod.outlook.com (2603:10b6:802:29::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.23; Mon, 31 Aug 2020 18:42:18 +0000 Received: from SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::ccd9:728:9577:200d]) by SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::ccd9:728:9577:200d%4]) with mapi id 15.20.3326.025; Mon, 31 Aug 2020 18:42:18 +0000 Subject: [PATCH v6 02/10] Revert "target/i386: Enable new apic id encoding for EPYC based cpus models" From: Babu Moger To: pbonzini@redhat.com, rth@twiddle.net, ehabkost@redhat.com, imammedo@redhat.com Date: Mon, 31 Aug 2020 13:42:17 -0500 Message-ID: <159889933756.21294.13999336052652073520.stgit@naples-babu.amd.com> In-Reply-To: <159889924378.21294.16494070903874534542.stgit@naples-babu.amd.com> References: <159889924378.21294.16494070903874534542.stgit@naples-babu.amd.com> User-Agent: StGit/unknown-version X-ClientProxiedBy: SN4PR0201CA0051.namprd02.prod.outlook.com (2603:10b6:803:20::13) To SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from 255.255.255.255 (255.255.255.255) by SN4PR0201CA0051.namprd02.prod.outlook.com (2603:10b6:803:20::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.19 via Frontend Transport; Mon, 31 Aug 2020 18:42:18 +0000 X-Originating-IP: [165.204.78.2] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: dbdcac55-e85f-4a6f-bf3a-08d84ddd96c2 X-MS-TrafficTypeDiagnostic: SN1PR12MB2559: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:126; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZdP9x0UGoHtVr+AjF2HGzxN8VgDPwcyP0LPTdLdTeOMrCS0ve9FF4fZuFKZH6Zg3TKRm0zj+ixau2OWbIw/a0JDyQ31Sc2huxw8zfJErhzTOFkpDFF+Iot6zdRhc7w1hS9m9RRkH5ZbEWW9ifIpIjQ5v+cJYZ+SCLBAEZpZlPJiYVTs2D18Qu62AP0buPTiI4tlesFoq+sBK++/eCtIIsc5RFWOWGOkNaereD1tkibHUem+4zeFoVBIn+MupcKuGTdlhNJ7ZKk5Ifz4Cei/SL0dWYuFg4x0anRUoW/R5w0Xz92DpU2EuHeEcd3mfCht/mopdSD3cK179CzaekWrjww== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN1PR12MB2560.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(346002)(39860400002)(396003)(136003)(366004)(2906002)(66946007)(83380400001)(66556008)(4326008)(26005)(956004)(316002)(16576012)(5660300002)(186003)(66476007)(6486002)(8676002)(478600001)(44832011)(8936002)(4744005)(86362001)(52116002)(103116003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: P/O2FsT2RWezebM45KB3SNPkgypu6rkYCC9tb0qUZ4nrd9W3bs1I5KPRYl6BhfHziv5TN5NCq2vBJeux38kyPDUiUWaVUtMSK66zRUM9NhZ4Pcra3iHIr3qn/Sfk+9DPRKXpZkDxbcTTD8fc0vCPkwCVuolPgDIi3z2Z9lY47A4kCRYbbF1tdLW3CEISUw6KK/K8ktFKvB+aIAd8kzvhX/li+c1ph2rku+pJvzqAUf0WcVCtxDQbTNPE0xnzO4fmdDqu8HwkpdcH1Pd+E8iqsubyVlSMTSDKVsZguXe0rUwZrsolFlv5fcJdXKTLb/BkSjGd6GmyiG+G4eYNoa+6Y8+9hyZzuhkTpcKGsKHPfi1Rkn4x7b4DmureMUgmWR2dnjIP7L7ODahq82gKQlKoy0qsLcNyujx2LsmcazM0xRXNzL8I8kraAnbePFAkX0hRQ2aKeZP3smGpfFNELeG92BItFL+PDgFtd8/lZl2bHsRBT8iOnXHit2RAROEABCrn4WgW/fWE7u+xlN1aiJqjDSGsGWGHwLap4ygvMVYfbf09yAAFhI8chOFrhbM/krfqq+jPI+2Vthdloh6FHL/hF6z5Ah89mAE6vTzx394CpMUj/GKjxNE3zywLvqkqZ36cAKeKHi1P49gZJ881wOJsjA== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: dbdcac55-e85f-4a6f-bf3a-08d84ddd96c2 X-MS-Exchange-CrossTenant-AuthSource: SN1PR12MB2560.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2020 18:42:18.6590 (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: BST5in+6AD/yG672+lfMZ6iy1DsuoKhGV5YhPe6ygfPVJlhSmkHTruD3NEA3C+HF X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2559 Received-SPF: none client-ip=40.107.75.43; envelope-from=Babu.Moger@amd.com; helo=NAM02-BL2-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/31 14:42:13 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: 4 X-Spam_score: 0.4 X-Spam_bar: / X-Spam_report: (0.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FORGED_SPF_HELO=1, MSGID_FROM_MTA_HEADER=0.001, RCVD_ILLEGAL_IP=1.3, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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: babu.moger@amd.com, qemu-devel@nongnu.org, mst@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This reverts commit 247b18c593ec298446645af8d5d28911daf653b1. Remove the EPYC specific apicid decoding and use the generic default decoding. Signed-off-by: Babu Moger Reviewed-by: Igor Mammedov --- target/i386/cpu.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 173e6f4a07..c9c1e681c2 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -3995,7 +3995,6 @@ static X86CPUDefinition builtin_x86_defs[] = { .xlevel = 0x8000001E, .model_id = "AMD EPYC Processor", .cache_info = &epyc_cache_info, - .use_epyc_apic_id_encoding = 1, .versions = (X86CPUVersionDefinition[]) { { .version = 1 }, { @@ -4123,7 +4122,6 @@ static X86CPUDefinition builtin_x86_defs[] = { .xlevel = 0x8000001E, .model_id = "AMD EPYC-Rome Processor", .cache_info = &epyc_rome_cache_info, - .use_epyc_apic_id_encoding = 1, }, }; From patchwork Mon Aug 31 18:42:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Moger, Babu" X-Patchwork-Id: 1354541 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=amd.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-amdcloud-onmicrosoft-com header.b=AQ+w3XbI; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4BgK3K28Vcz9sTM for ; Tue, 1 Sep 2020 04:48:29 +1000 (AEST) Received: from localhost ([::1]:39160 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kCoqx-0006EA-7P for incoming@patchwork.ozlabs.org; Mon, 31 Aug 2020 14:48:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40554) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kColB-00068e-Sf for qemu-devel@nongnu.org; Mon, 31 Aug 2020 14:42:29 -0400 Received: from mail-eopbgr750079.outbound.protection.outlook.com ([40.107.75.79]:20910 helo=NAM02-BL2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kColA-0007Uh-5N for qemu-devel@nongnu.org; Mon, 31 Aug 2020 14:42:29 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GiLBMYFJTeMoFpyxeKsHARSCWY5ymDsB1QLoTnV3oMZndCCJiQ4bPGDMx5/2MVo1W0/KKm8njCdIYUQ9eQAjlNuLyuGEnRCdxE6I8jkDoj9Nf4VxST3meBIy++HRTtaCDlD7RC+HrzTsazroCBRch6wluvaovEV5xcx4yGJVbnItzUmluTGOGY2rm5PVzY7IXnkYWO+wHbMOHQtTFFWNiGXXJvRxNwleYd3CLL2CEgBgHyEF520T1LvCgRsnvNTZe2qVCDw6mDgI6LqVcfS1OiM21rOxp+TywScFldi+v9ooEnWqyAxwIYkuXoayeap1c8SStp88MW26FysqXAXHcg== 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=6RifX0ctDpmOifbi7XCqPWHAAJNQ6Z6wtmfyU0cxe2A=; b=J6eJws5D0s6DR08sSvBmwbKy5vHscL+p+LvsH7nCoiA8vH/KmDWuroEM1yRyULeWd/TmUiwu+gWHoZxT3vUzNYNlro/DWJj1YOHWs7yOMcFxMrGDQBndJ7S5a4858RSipJMJn9jIj+vKSs7wDl12mUhk7Z/mrEJhTr6qsI7GrDYzugz9yVIuYskbunFMoDrInNgYnywiPFtbYF0792DFxmBjIp3aG1Dfx8NZqSqBGyqeEk0VoBOevV1hCOr7aQtR+ZPfDhoxfbro/5MvtvqpmBNl2bnbi0iWivnrB8KdbXsqI78hlA9CExCYwaY7IBDnC5M/DwFnnKqdrqnjrgvETQ== 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=6RifX0ctDpmOifbi7XCqPWHAAJNQ6Z6wtmfyU0cxe2A=; b=AQ+w3XbIl3TE4gQ5NLeBgvImJBRWQfTbqqD7B5dfHD3Qj0doltISoWx1qfy4HnJpBOFEcmQswyAXCJdacK48L18zVueftbAwb8QN1LFhtVTR/N4rrU92rgXW4hBeS2F8Gvs5i6EGXLpkWAmya8xvLUxDh0IezB0LXNlF5BzRCW0= Authentication-Results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=amd.com; Received: from SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) by SN1PR12MB2559.namprd12.prod.outlook.com (2603:10b6:802:29::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.23; Mon, 31 Aug 2020 18:42:24 +0000 Received: from SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::ccd9:728:9577:200d]) by SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::ccd9:728:9577:200d%4]) with mapi id 15.20.3326.025; Mon, 31 Aug 2020 18:42:24 +0000 Subject: [PATCH v6 03/10] Revert "hw/i386: Move arch_id decode inside x86_cpus_init" From: Babu Moger To: pbonzini@redhat.com, rth@twiddle.net, ehabkost@redhat.com, imammedo@redhat.com Date: Mon, 31 Aug 2020 13:42:23 -0500 Message-ID: <159889934379.21294.15323080164340490855.stgit@naples-babu.amd.com> In-Reply-To: <159889924378.21294.16494070903874534542.stgit@naples-babu.amd.com> References: <159889924378.21294.16494070903874534542.stgit@naples-babu.amd.com> User-Agent: StGit/unknown-version X-ClientProxiedBy: SA9PR11CA0028.namprd11.prod.outlook.com (2603:10b6:806:6e::33) To SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from 255.255.255.255 (255.255.255.255) by SA9PR11CA0028.namprd11.prod.outlook.com (2603:10b6:806:6e::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.19 via Frontend Transport; Mon, 31 Aug 2020 18:42:24 +0000 X-Originating-IP: [165.204.78.2] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 631f2d78-c72b-4d99-1c7d-08d84ddd9a7b X-MS-TrafficTypeDiagnostic: SN1PR12MB2559: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:162; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eVbJLgZ0LwfzLbhDF/BAZJwk0/v/qeXi1AQnAzUPiaoU4sQZKFhKnbg6slTcx2gPfrRKM0A75yIBlk7L4CWA7cQfvPCEcV6i9LpVJqz4SQJz0yTVdXarLAY6XVraFx4n0Eji1SyC3+h/0d507sDAB47EQ6R/7rLK60O70pvMIOmEYZxSicCZ+bwnANky3KoiZnGRH3+8SnQ54RWY/mW0/JwSYjvBqQ2EJuB81aVGyCJesMwfgivYeGSZAbgNB2I+d9ltGW7+eQFU8f5/rGk6iSHyLN/q6URZ871jVSrSw656EIAkMZCV2Xw0qbHPk/B9RcCT95z07rKfP7uWMlmfow== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN1PR12MB2560.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(346002)(39860400002)(396003)(136003)(366004)(2906002)(66946007)(83380400001)(66556008)(4326008)(26005)(956004)(316002)(16576012)(5660300002)(186003)(66476007)(6486002)(8676002)(478600001)(44832011)(8936002)(86362001)(52116002)(103116003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Guy8oaZenw2c91FfKHI2n3InQPyWcCTDFbz9HU81+GC11FIouu9qwWmfg7BXCnhMstOoD5hVw5MUIvHf4FZhA1T6G6WiTxf8u6QLBUUGjkt+nq1KTX8qpfN5Ew83l7W3CUjaekLPKo+syFCndZcZr2GIEaBmFZvM3fa8c8oR/0VZ9nggN/H0U3bU4MQSNvqNKMi/40WVaPrO/FNcDthwWlgwc4N644UtEwZ1IaMZs0qUJk3d7ZZhOFhp8RkL76YJW2YCIp+yCwqZhij6Ob4JNIyVnYmeqMf0EgJmfvdTYHAp1PDU6QlOUe5Pi4xn8sRvccZ9Q0H27E3pKKlbiuFRmVFXYm8lOrYtfdd/yFMP8/l3XXdEs9MRBfB6lo6SWfHHdXe7Qla4CwdAbWCicT2j+F9AAEeUwrxWKSw3BcNnNZzFNsTVmrVP2xYso8GJaUNZHt3pMGdtdk/ncd53JBleh2+mm/ho6+iKC1K+1mJMo6lpMX5vpHcSiaLxttzPTV24Y1QN9uKlfqB8VId5w/3jJxF2L9IUMLqsCWgkPiTI4V3cDmecd17RQuIZ9wOWidjvdg4BoI7iOBtynw/jt8w4e4evHdzHo8FduiIAknhCOZcgjkiuiZFSLzcmwXSFpupy5DobMs99Xsz2TWXx5c8gmg== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 631f2d78-c72b-4d99-1c7d-08d84ddd9a7b X-MS-Exchange-CrossTenant-AuthSource: SN1PR12MB2560.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2020 18:42:24.8905 (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: 15yf/z2t604LCSe1+2Mh/AeeBEpLA0kF1Svm4m1NzVXkakn1uA1zsdhn0yZhdLtt X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2559 Received-SPF: none client-ip=40.107.75.79; envelope-from=Babu.Moger@amd.com; helo=NAM02-BL2-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/31 14:42:27 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: 4 X-Spam_score: 0.4 X-Spam_bar: / X-Spam_report: (0.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FORGED_SPF_HELO=1, MSGID_FROM_MTA_HEADER=0.001, RCVD_ILLEGAL_IP=1.3, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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: babu.moger@amd.com, qemu-devel@nongnu.org, mst@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This reverts commit 2e26f4ab3bf8390a2677d3afd9b1a04f015d7721. Remove the EPYC specific apicid decoding and use the generic default decoding. Signed-off-by: Babu Moger Reviewed-by: Igor Mammedov --- hw/i386/pc.c | 6 +++--- hw/i386/x86.c | 37 +++++++------------------------------ 2 files changed, 10 insertions(+), 33 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 6b708f4341..0677d6a272 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1556,14 +1556,14 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev, topo_ids.die_id = cpu->die_id; topo_ids.core_id = cpu->core_id; topo_ids.smt_id = cpu->thread_id; - cpu->apic_id = x86ms->apicid_from_topo_ids(&topo_info, &topo_ids); + cpu->apic_id = x86_apicid_from_topo_ids(&topo_info, &topo_ids); } cpu_slot = pc_find_cpu_slot(MACHINE(pcms), cpu->apic_id, &idx); if (!cpu_slot) { MachineState *ms = MACHINE(pcms); - x86ms->topo_ids_from_apicid(cpu->apic_id, &topo_info, &topo_ids); + x86_topo_ids_from_apicid(cpu->apic_id, &topo_info, &topo_ids); error_setg(errp, "Invalid CPU [socket: %u, die: %u, core: %u, thread: %u] with" " APIC ID %" PRIu32 ", valid index range 0:%d", @@ -1584,7 +1584,7 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev, /* TODO: move socket_id/core_id/thread_id checks into x86_cpu_realizefn() * once -smp refactoring is complete and there will be CPU private * CPUState::nr_cores and CPUState::nr_threads fields instead of globals */ - x86ms->topo_ids_from_apicid(cpu->apic_id, &topo_info, &topo_ids); + x86_topo_ids_from_apicid(cpu->apic_id, &topo_info, &topo_ids); if (cpu->socket_id != -1 && cpu->socket_id != topo_ids.pkg_id) { error_setg(errp, "property socket-id: %u doesn't match set apic-id:" " 0x%x (socket-id: %u)", cpu->socket_id, cpu->apic_id, diff --git a/hw/i386/x86.c b/hw/i386/x86.c index cf384b9743..3cc2318212 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -68,22 +68,6 @@ inline void init_topo_info(X86CPUTopoInfo *topo_info, topo_info->threads_per_core = ms->smp.threads; } -/* - * Set up with the new EPYC topology handlers - * - * AMD uses different apic id encoding for EPYC based cpus. Override - * the default topo handlers with EPYC encoding handlers. - */ -static void x86_set_epyc_topo_handlers(MachineState *machine) -{ - X86MachineState *x86ms = X86_MACHINE(machine); - - x86ms->apicid_from_cpu_idx = x86_apicid_from_cpu_idx_epyc; - x86ms->topo_ids_from_apicid = x86_topo_ids_from_apicid_epyc; - x86ms->apicid_from_topo_ids = x86_apicid_from_topo_ids_epyc; - x86ms->apicid_pkg_offset = apicid_pkg_offset_epyc; -} - /* * Calculates initial APIC ID for a specific CPU index * @@ -102,7 +86,7 @@ uint32_t x86_cpu_apic_id_from_index(X86MachineState *x86ms, init_topo_info(&topo_info, x86ms); - correct_id = x86ms->apicid_from_cpu_idx(&topo_info, cpu_index); + correct_id = x86_apicid_from_cpu_idx(&topo_info, cpu_index); if (x86mc->compat_apic_id_mode) { if (cpu_index != correct_id && !warned && !qtest_enabled()) { error_report("APIC IDs set in compatibility mode, " @@ -136,11 +120,6 @@ void x86_cpus_init(X86MachineState *x86ms, int default_cpu_version) MachineState *ms = MACHINE(x86ms); MachineClass *mc = MACHINE_GET_CLASS(x86ms); - /* Check for apicid encoding */ - if (cpu_x86_use_epyc_apic_id_encoding(ms->cpu_type)) { - x86_set_epyc_topo_handlers(ms); - } - x86_cpu_set_default_version(default_cpu_version); /* @@ -154,12 +133,6 @@ void x86_cpus_init(X86MachineState *x86ms, int default_cpu_version) x86ms->apic_id_limit = x86_cpu_apic_id_from_index(x86ms, ms->smp.max_cpus - 1) + 1; possible_cpus = mc->possible_cpu_arch_ids(ms); - - for (i = 0; i < ms->possible_cpus->len; i++) { - ms->possible_cpus->cpus[i].arch_id = - x86_cpu_apic_id_from_index(x86ms, i); - } - for (i = 0; i < ms->smp.cpus; i++) { x86_cpu_new(x86ms, possible_cpus->cpus[i].arch_id, &error_fatal); } @@ -184,7 +157,8 @@ int64_t x86_get_default_cpu_node_id(const MachineState *ms, int idx) init_topo_info(&topo_info, x86ms); assert(idx < ms->possible_cpus->len); - x86_topo_ids_from_idx(&topo_info, idx, &topo_ids); + x86_topo_ids_from_apicid(ms->possible_cpus->cpus[idx].arch_id, + &topo_info, &topo_ids); return topo_ids.pkg_id % ms->numa_state->num_nodes; } @@ -215,7 +189,10 @@ const CPUArchIdList *x86_possible_cpu_arch_ids(MachineState *ms) ms->possible_cpus->cpus[i].type = ms->cpu_type; ms->possible_cpus->cpus[i].vcpus_count = 1; - x86_topo_ids_from_idx(&topo_info, i, &topo_ids); + ms->possible_cpus->cpus[i].arch_id = + x86_cpu_apic_id_from_index(x86ms, i); + x86_topo_ids_from_apicid(ms->possible_cpus->cpus[i].arch_id, + &topo_info, &topo_ids); ms->possible_cpus->cpus[i].props.has_socket_id = true; ms->possible_cpus->cpus[i].props.socket_id = topo_ids.pkg_id; if (x86ms->smp_dies > 1) { From patchwork Mon Aug 31 18:42:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Moger, Babu" X-Patchwork-Id: 1354535 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=amd.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-amdcloud-onmicrosoft-com header.b=KiOMW+Vr; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4BgJyr5J7nz9sTS for ; Tue, 1 Sep 2020 04:44:36 +1000 (AEST) Received: from localhost ([::1]:53952 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kConB-0000UT-Jh for incoming@patchwork.ozlabs.org; Mon, 31 Aug 2020 14:44:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40582) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kColG-0006JB-TT for qemu-devel@nongnu.org; Mon, 31 Aug 2020 14:42:34 -0400 Received: from mail-eopbgr750074.outbound.protection.outlook.com ([40.107.75.74]:39303 helo=NAM02-BL2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kColF-0007VD-BM for qemu-devel@nongnu.org; Mon, 31 Aug 2020 14:42:34 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a/YLprAIE/Zkgb8t8ZNAj7YG3o3ygZHILnfDIgdB2vRBNoJuNfJlnb3BvKJY+X4dJ4sktIF0bWG+em+Rsn2uyQOORD13tEwg75perwM+nF9AWMhBBctX4kIrvbPyK7UFEINtec7U89rocrnM4vVULGeCpDNGrPPs+p7BC56kKyr61NMNdvQHvlwTTB/n09D8c4XZC0mAv8RE3rdQP122z6KFgSESwcVd0TqHl6/Wy12fnhnOVSe6T6DQeNQrj9Y9qUNbpKe657c30+XAaj6htZQDhsxdP2EI9DvKExLrtY2eE93du/ejDFYnYXpbsKrlEgeE6DP1wGloM3Wfd9+Ozw== 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=J9IGypxYas902igNImmGd5TTMPeGRqNBq9ZlYS/7SwI=; b=jvjEho6E2MPxcRNQkD/Dz2C7q/bBvyW7ucoU0I5qvUL/J+iIiEly665QV5YKWTKl/Y5WdYMnBWILetRtoSiWjQKrN5gNLMZ4dQKoREsDO53lOHFc53C9kUTEvPGIko3wVQUZeugW/SE16Ly4G7In1JBmTa3hT+rY/OO3404ipZYhy1x5gEuw5+0Hn+nFvLwpI0cFXyUGdKK4cITWyYAxU2fm8AzkujgzS3qxVsjVEi20g9nAdoBuiilSNbDYZ5QMfnkJPA5wjmCE4iHtKotIRwotp2Lf8fkhzpvyssxxXyXCvq/cJu5TFAW+9fDhcOtAffJBLD2Nu/5miPq2+spmRw== 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=J9IGypxYas902igNImmGd5TTMPeGRqNBq9ZlYS/7SwI=; b=KiOMW+Vr4/H5kHe9oHuL7TjBr+Md4jjgvvmPOwlbSY1uPbjMf5TIsyaD2YvF3mJ35ScPKl+lSWzTqYrO+iKXflUQkHcxxxjTvQ90wGefNqOvrJHd7y14/YXmqjQcywreB+ZG1YpbyXjUKJ90b9bcFTfqAa1fhvTwy0yGh396rBo= Authentication-Results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=amd.com; Received: from SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) by SN1PR12MB2559.namprd12.prod.outlook.com (2603:10b6:802:29::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.23; Mon, 31 Aug 2020 18:42:31 +0000 Received: from SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::ccd9:728:9577:200d]) by SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::ccd9:728:9577:200d%4]) with mapi id 15.20.3326.025; Mon, 31 Aug 2020 18:42:31 +0000 Subject: [PATCH v6 04/10] Revert "i386: Introduce use_epyc_apic_id_encoding in X86CPUDefinition" From: Babu Moger To: pbonzini@redhat.com, rth@twiddle.net, ehabkost@redhat.com, imammedo@redhat.com Date: Mon, 31 Aug 2020 13:42:30 -0500 Message-ID: <159889935015.21294.1425332462852607813.stgit@naples-babu.amd.com> In-Reply-To: <159889924378.21294.16494070903874534542.stgit@naples-babu.amd.com> References: <159889924378.21294.16494070903874534542.stgit@naples-babu.amd.com> User-Agent: StGit/unknown-version X-ClientProxiedBy: SA9PR11CA0011.namprd11.prod.outlook.com (2603:10b6:806:6e::16) To SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from 255.255.255.255 (255.255.255.255) by SA9PR11CA0011.namprd11.prod.outlook.com (2603:10b6:806:6e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.20 via Frontend Transport; Mon, 31 Aug 2020 18:42:30 +0000 X-Originating-IP: [165.204.78.2] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 565d1c80-be9b-44b9-5d90-08d84ddd9e51 X-MS-TrafficTypeDiagnostic: SN1PR12MB2559: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:346; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: laYlAA4XYuaL10JNVMPiA6BP6XrpYYvhBLRBQb5yZjUz5l53ZZ6OWpai09wJiOIUgvurnjhMmv6VSOo1F5zSKlSODnJmRGAq2nUev2PwaZ74siiY8IKLudyJwYUMrAn/kk4e8069+PrNvNaOLQ/iei2aqau9k1uSsH2mxWKF2ndYYvXpUgh6oZfXAVFRvNfMOIO10UdqiWDMnckYqTA+zyTnsGEIlic7HyhwQYq87m5BdeZz4SUWKS6CqZ9kdpFAqSzmXi95kwrV2075SWFgWNo3qyIUaMrooXN7cGCDGWyNq0p0Fv2GJPBuIlnq7IDJAZ/WxPI2DGraN0Pw+Uhvhg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN1PR12MB2560.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(346002)(39860400002)(396003)(136003)(366004)(2906002)(66946007)(83380400001)(66556008)(4326008)(26005)(956004)(316002)(16576012)(5660300002)(186003)(66476007)(6486002)(8676002)(478600001)(44832011)(8936002)(86362001)(52116002)(103116003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: ePT2hk46raKDew5nkvsomOJkJ+0/IDbffQUOEo2dA9VRAcX6hMtofZ+c4XxzRb5Vgb10ufLNjviUi+OqdBuBJa/6NBN0WtDCIK7mJ+kZ1NvFosqFEu9DcqvbNiz+ck1SfCRBvaGc9/l24Rc4pM/RewmGh7eylZSBeaX4Ym4w9o0YqwLW09khvZWQUjNjyfQK2C+Zl/oTklrwbC5tMpzWLME1v0hB9bFx8MqPKJVe1QIwy0tBiXIggSVLMYiQj7K6wRH4dIGEKh3E/wZcDy4zggV1+8e8TxnylwMKjQMaZSYXX21gjXCuzFYP6CFmkCYqdjewYex2kXujWWIxvsS4ZGqY0dvV9LUQaQMhrVR/JuHAw6NQwijiYx3ATNUkipCs5wLKa1zFSRqpLhWqE4TsZwFeJ+GkhqfLNbgsGDJyEj8IsBU3tuYZvzURcn+5gAzEiIXyuEUxASxH+pL6Vpov5zkJahI34BO/9pQ6J9eYGS5nKasDZtg4CoLrbUt0EPiDeA7e9l0KZLZMZ9ihMEUFZbtneEBlaSDA7K5VI1wvge995CDsSA3tHn5aICdt4Gq+L65lOiBweMNukDkThAtxRR+tX2er8N1JKyxFuaU0VeoHiZQvHQtcQ/StiBcT1dimVJuN3XIf8b8TBNDYKrT/ow== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 565d1c80-be9b-44b9-5d90-08d84ddd9e51 X-MS-Exchange-CrossTenant-AuthSource: SN1PR12MB2560.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2020 18:42:31.3228 (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: ZUtWdm0WOQL2zk+J7xX36FH2RmuJHOk1kx10MgpldyPmIqgrGGox6S7kuNsByH6m X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2559 Received-SPF: none client-ip=40.107.75.74; envelope-from=Babu.Moger@amd.com; helo=NAM02-BL2-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/31 14:42:32 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: 4 X-Spam_score: 0.4 X-Spam_bar: / X-Spam_report: (0.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FORGED_SPF_HELO=1, MSGID_FROM_MTA_HEADER=0.001, RCVD_ILLEGAL_IP=1.3, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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: babu.moger@amd.com, qemu-devel@nongnu.org, mst@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This reverts commit 0c1538cb1a26287c072645f4759b9872b1596d79. Remove the EPYC specific apicid decoding and use the generic default decoding. Signed-off-by: Babu Moger Reviewed-by: Igor Mammedov --- target/i386/cpu.c | 16 ---------------- target/i386/cpu.h | 1 - 2 files changed, 17 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index c9c1e681c2..b72b4b08ac 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1638,10 +1638,6 @@ typedef struct X86CPUDefinition { FeatureWordArray features; const char *model_id; CPUCaches *cache_info; - - /* Use AMD EPYC encoding for apic id */ - bool use_epyc_apic_id_encoding; - /* * Definitions for alternative versions of CPU model. * List is terminated by item with version == 0. @@ -1683,18 +1679,6 @@ static const X86CPUVersionDefinition *x86_cpu_def_get_versions(X86CPUDefinition return def->versions ?: default_version_list; } -bool cpu_x86_use_epyc_apic_id_encoding(const char *cpu_type) -{ - X86CPUClass *xcc = X86_CPU_CLASS(object_class_by_name(cpu_type)); - - assert(xcc); - if (xcc->model && xcc->model->cpudef) { - return xcc->model->cpudef->use_epyc_apic_id_encoding; - } else { - return false; - } -} - static CPUCaches epyc_cache_info = { .l1d_cache = &(CPUCacheInfo) { .type = DATA_CACHE, diff --git a/target/i386/cpu.h b/target/i386/cpu.h index d5ad42d694..5ff8ad8427 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1918,7 +1918,6 @@ void cpu_clear_apic_feature(CPUX86State *env); void host_cpuid(uint32_t function, uint32_t count, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx); void host_vendor_fms(char *vendor, int *family, int *model, int *stepping); -bool cpu_x86_use_epyc_apic_id_encoding(const char *cpu_type); /* helper.c */ bool x86_cpu_tlb_fill(CPUState *cs, vaddr address, int size, From patchwork Mon Aug 31 18:42:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Moger, Babu" X-Patchwork-Id: 1354540 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=amd.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-amdcloud-onmicrosoft-com header.b=wN9SI7CZ; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4BgK1T4Cp2z9sTS for ; Tue, 1 Sep 2020 04:46:53 +1000 (AEST) Received: from localhost ([::1]:34144 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kCopP-00045u-ET for incoming@patchwork.ozlabs.org; Mon, 31 Aug 2020 14:46:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40612) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kColM-0006Wa-P5 for qemu-devel@nongnu.org; Mon, 31 Aug 2020 14:42:40 -0400 Received: from mail-eopbgr750073.outbound.protection.outlook.com ([40.107.75.73]:50756 helo=NAM02-BL2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kColL-0007VR-6j for qemu-devel@nongnu.org; Mon, 31 Aug 2020 14:42:40 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vyn6A9bS/HzTKizioFNWrPKqLJ2sW21+kmhySMeKeNs11DnQlrUn3a9Y5sogtoVXYx15n9LhbVPPtkgiu1dSWMMRaZj6fKRfMOGonUNwZ4ss+pqVHCq7+bPGrs2V7st5gNpjC3eEO4UWA7QDYh5yd99Fgqh39wkxwp1ENVIlgLz1Qims72WPxN8UEQ4G1SxZWWwnCCdCc3RHebBiS3/8hskcUINyiqd0G8iFSwFXIyqAXXP1cBfYiZYy150AA2Aa97IUaNwiIrHQLUiZlJCcHDzOCwmfFLndXpT0tpIUH3DeefnPOWjy6Dl6Dy0246tNyczhAH1O4uJbJT9UFCeApA== 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=oz9/vr0RtSjw+QTEjZPNKRKielVluz3EjNwJfVjl268=; b=cbfey7Un2JpxvH4hqTV/l+GZqKiY3SgXx94/WZB5EhozErBuirJtrCKV0GqMUmDMTth+2C8b0aoyK4PijKvqUMgK0qu+Z8EREc4x5Ep6GcR+i8xnDo0bZK8ZxdtrJ0qORiiq1mKb9/2n/K7bkkIt9lDanpiocd5Y2ywfcdGWrZoByrScpEvPxq4CIDMXALhJW5vZecs+0GHZUu7bBo+c/gSTuMRPXKvI+vh4IFUb+FWXWQQr5mIYKrJb5vCjWFlB17i+NBIT9FED4NjC6179KjPA0WcezW1iJbTuEk15CLN6H7rGt14JObtYkqnCcw1Bwb9fl3FnW1mHHzNLTil/yA== 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=oz9/vr0RtSjw+QTEjZPNKRKielVluz3EjNwJfVjl268=; b=wN9SI7CZ6HiDbzJYHwiaNjjDsK4s40dSe1BMspyedJtJ0uID5xXKWsVqsKKEiUZ5Sb6uZX2Ud5opGTm4KTDp0mP/zaMxCI7ELs8utLNHAutNKLPYewabxccbfUCd0kpb29CxC0sfxTzraMkLdh1ipGX58FAaNbdRsY6rmnUnr74= Authentication-Results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=amd.com; Received: from SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) by SN1PR12MB2559.namprd12.prod.outlook.com (2603:10b6:802:29::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.23; Mon, 31 Aug 2020 18:42:37 +0000 Received: from SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::ccd9:728:9577:200d]) by SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::ccd9:728:9577:200d%4]) with mapi id 15.20.3326.025; Mon, 31 Aug 2020 18:42:37 +0000 Subject: [PATCH v6 05/10] Revert "hw/i386: Introduce apicid functions inside X86MachineState" From: Babu Moger To: pbonzini@redhat.com, rth@twiddle.net, ehabkost@redhat.com, imammedo@redhat.com Date: Mon, 31 Aug 2020 13:42:36 -0500 Message-ID: <159889935648.21294.8095493980805969544.stgit@naples-babu.amd.com> In-Reply-To: <159889924378.21294.16494070903874534542.stgit@naples-babu.amd.com> References: <159889924378.21294.16494070903874534542.stgit@naples-babu.amd.com> User-Agent: StGit/unknown-version X-ClientProxiedBy: SN4PR0501CA0073.namprd05.prod.outlook.com (2603:10b6:803:22::11) To SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from 255.255.255.255 (255.255.255.255) by SN4PR0501CA0073.namprd05.prod.outlook.com (2603:10b6:803:22::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3348.5 via Frontend Transport; Mon, 31 Aug 2020 18:42:37 +0000 X-Originating-IP: [165.204.78.2] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: fcda55d4-8b29-4607-1fea-08d84ddda1f7 X-MS-TrafficTypeDiagnostic: SN1PR12MB2559: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:175; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: POQRKpm8OzwI/pc8beLIJWB0crhqCFFaXWwZ3hGSrT6Ckrb6lONF96GVqcdMOPadTJUtp6ma+eQ/jLYwGSULljesUUBoMAOek6VqwpMoots3efoHzyhphcNdmYsuV8vrfJwajCxFZ9fT4SBS+7R1b7j3ODwjswIKlpEnuPktjXo/6ed34o6dLCgB81/hoUoaakD3sRZXJ6//nvBLhpy2+qOTdjA3CbKWir9BQTCmK2HASTIG8l1w1/SSarEqZp6J8yHOn+P80+7+vWsUil4M1lrxNhAnD4fMaSNoKyVQmfnk++47pmWqqRzA1HW5ogLUW434ECzjtaMXtfBVtXBtdQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN1PR12MB2560.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(346002)(39860400002)(396003)(136003)(366004)(2906002)(66946007)(83380400001)(66556008)(4326008)(26005)(956004)(316002)(16576012)(5660300002)(186003)(66476007)(6486002)(8676002)(478600001)(44832011)(8936002)(86362001)(52116002)(103116003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: fNYtjFHMBNO4GitOcRCBcIfOxSUWcvFcuf1+c8oATmyu2fj4uWy1kAym4FCw6oaLKYApeTzs2AbgZt97ZPgeztSW9tDvn6J1nqHGtKSDIPMslMXUGd9FuYnaVVKxcz7xeGXsn4SmN27YP3dfzosMBAqT5CeEt36LCrwY4r6366RkqdXsJf5gEgWH3Zjm65RhK5PxafzDTvOOj/zM4z5NLydDhK1X/p89FSdvz4Jr9svjdL91K9U0XIrNQA4SCWS8L26QQO1uvzNOo3rTlauuXrILnAjo0UVMF5lBgU4KEXVqp37Omd3kxvciHVUjw3vJhl3e8pbg+fdFO3YspS0RWPpVJMMoSxkefuBIdB0vVraPks3DXxoBaOVttJCndislMPIswJjhqUnbTyul8DdSwuIK8fUlsofcSCZOWTn9ZIcm//CUqevhKgz7K/YRbp1acOZVaBLEqS4Q+sVyC5gwzlOHVsGIdr9lbflBUSOhV4VPJVO0tPyBaQk+jl8OZ+761oCsnk4A/vFyVdUDAzSVg1/2TBAN8DjDjEgsrd4yBNdmtqz0/d0WYesoMuH731ch/pVAla5FG987b9wKB9hnqadzBtJK9m1/x9puaae9v9E7MRaRv2CvSqqOW0P9o+VWqmS4Vuue2K+TWDsASliGYA== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: fcda55d4-8b29-4607-1fea-08d84ddda1f7 X-MS-Exchange-CrossTenant-AuthSource: SN1PR12MB2560.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2020 18:42:37.4323 (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: vIyAN25ZY6WnyTfLTcMlpWsn8XstkuGa14wQ7xOLutHYcFCgGxqlogiUUdU21voq X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2559 Received-SPF: none client-ip=40.107.75.73; envelope-from=Babu.Moger@amd.com; helo=NAM02-BL2-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/31 14:42:38 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: 4 X-Spam_score: 0.4 X-Spam_bar: / X-Spam_report: (0.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FORGED_SPF_HELO=1, MSGID_FROM_MTA_HEADER=0.001, RCVD_ILLEGAL_IP=1.3, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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: babu.moger@amd.com, qemu-devel@nongnu.org, mst@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This reverts commit 6121c7fbfd98dbc3af1b00b56ff2eef66df87828. Remove the EPYC specific apicid decoding and use the generic default decoding. Signed-off-by: Babu Moger Reviewed-by: Igor Mammedov --- hw/i386/x86.c | 5 ----- include/hw/i386/x86.h | 9 --------- 2 files changed, 14 deletions(-) diff --git a/hw/i386/x86.c b/hw/i386/x86.c index 3cc2318212..727c4a0f1d 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -896,11 +896,6 @@ static void x86_machine_initfn(Object *obj) x86ms->smm = ON_OFF_AUTO_AUTO; x86ms->acpi = ON_OFF_AUTO_AUTO; x86ms->smp_dies = 1; - - x86ms->apicid_from_cpu_idx = x86_apicid_from_cpu_idx; - x86ms->topo_ids_from_apicid = x86_topo_ids_from_apicid; - x86ms->apicid_from_topo_ids = x86_apicid_from_topo_ids; - x86ms->apicid_pkg_offset = apicid_pkg_offset; } static void x86_machine_class_init(ObjectClass *oc, void *data) diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h index b79f24e285..4d9a26326d 100644 --- a/include/hw/i386/x86.h +++ b/include/hw/i386/x86.h @@ -63,15 +63,6 @@ typedef struct { OnOffAuto smm; OnOffAuto acpi; - /* Apic id specific handlers */ - uint32_t (*apicid_from_cpu_idx)(X86CPUTopoInfo *topo_info, - unsigned cpu_index); - void (*topo_ids_from_apicid)(apic_id_t apicid, X86CPUTopoInfo *topo_info, - X86CPUTopoIDs *topo_ids); - apic_id_t (*apicid_from_topo_ids)(X86CPUTopoInfo *topo_info, - const X86CPUTopoIDs *topo_ids); - uint32_t (*apicid_pkg_offset)(X86CPUTopoInfo *topo_info); - /* * Address space used by IOAPIC device. All IOAPIC interrupts * will be translated to MSI messages in the address space. From patchwork Mon Aug 31 18:42:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Moger, Babu" X-Patchwork-Id: 1354539 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=amd.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-amdcloud-onmicrosoft-com header.b=Wr4gP9fA; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4BgK0k3zSbz9sTN for ; Tue, 1 Sep 2020 04:46:14 +1000 (AEST) Received: from localhost ([::1]:59566 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kCoom-0002oH-CF for incoming@patchwork.ozlabs.org; Mon, 31 Aug 2020 14:46:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40642) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kColT-0006mh-Pp for qemu-devel@nongnu.org; Mon, 31 Aug 2020 14:42:47 -0400 Received: from mail-dm6nam10on2072.outbound.protection.outlook.com ([40.107.93.72]:2528 helo=NAM10-DM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kColR-0007WY-MW for qemu-devel@nongnu.org; Mon, 31 Aug 2020 14:42:47 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eoSa2gQe6eklvvaGxsmp+7KyEbY5wikfwx5j3YzHajlrV2xRdgf/SxVA/nJGTPxeQsxOR7atYgVFgViz+Rdg+qLxSru94ayS/vo7cUqJLGXMjuhMl2MnMGtlHJzzPbcn+GM5g1PYHgluv7NLvA2HJbO7LqHflPwbPtJJ6QlMFLTGeUm4Yd7F0cq0XuzWfeSIeUkvq50tb1ViwIIBFLjtZ0jxrN+lg562B/GuXI84h5EXZqvxJZN6FtomwVcDBc5JZPT2SOffr+U8L4+WK2Q8ftDJWI30vNsG3ymo1NgqibRYNGIhNIfNgjBftxW5FfonY2LFOm8xOqr1p+KKx9deKg== 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=DAcDXsVNONqLK6Vw/mK3T8qrdG4uwmiHFD/Uf7PptzE=; b=VUNC6+P2BBE1K3BAh4eux0JGEEiyGRLvD/YnXzs0OPIvZSMl4aeQlz7zK+FsfCtrAJMmfKLgNVVI5F4bqq4E/zDvb6B4YYGZ5ipdQ9rMQMPIJZArA5GE9NE0HlF8oL0e735nDQleId69PDGVQNb1n85FeAnXSIOKdI2aB+xOnVRp9bu/i4xy3mBlH3W1dBaTaXrUMsFslUaVhvexijDDZY6acMuUnPmsckW0EcnQOMrwehisfiP0VBOgd93sMBmfCceMn9Jte7i1z0Xkm6ZEDH4PHWW7JRAs5IWUMtApL0JuIJImQ3zLIElxWz+1FexGbsyGgXxQBtES1iw3DfAKmA== 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=DAcDXsVNONqLK6Vw/mK3T8qrdG4uwmiHFD/Uf7PptzE=; b=Wr4gP9fAxQTonjr0SWcvz1g+267FXsLNtXdgCxfT9iT5Nvmx+nwyb3YfomgypUr7QIv0b+KCdqXk736VaSpMD9QqnR7JEzgK9B2F5x6KadDSbqJtjLbdPd6HfJLZM4Rw/7/3+nvRaNdFefJvdwtnsqisekZFwg4Lwjm84iPSGm4= Authentication-Results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=amd.com; Received: from SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) by SA0PR12MB4383.namprd12.prod.outlook.com (2603:10b6:806:94::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.21; Mon, 31 Aug 2020 18:42:43 +0000 Received: from SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::ccd9:728:9577:200d]) by SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::ccd9:728:9577:200d%4]) with mapi id 15.20.3326.025; Mon, 31 Aug 2020 18:42:43 +0000 Subject: [PATCH v6 06/10] Revert "target/i386: Cleanup and use the EPYC mode topology functions" From: Babu Moger To: pbonzini@redhat.com, rth@twiddle.net, ehabkost@redhat.com, imammedo@redhat.com Date: Mon, 31 Aug 2020 13:42:42 -0500 Message-ID: <159889936257.21294.1786224705357428082.stgit@naples-babu.amd.com> In-Reply-To: <159889924378.21294.16494070903874534542.stgit@naples-babu.amd.com> References: <159889924378.21294.16494070903874534542.stgit@naples-babu.amd.com> User-Agent: StGit/unknown-version X-ClientProxiedBy: SN4PR0501CA0026.namprd05.prod.outlook.com (2603:10b6:803:40::39) To SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from 255.255.255.255 (255.255.255.255) by SN4PR0501CA0026.namprd05.prod.outlook.com (2603:10b6:803:40::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3348.7 via Frontend Transport; Mon, 31 Aug 2020 18:42:43 +0000 X-Originating-IP: [165.204.78.2] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: e3a957ee-0b22-4180-4617-08d84ddda59c X-MS-TrafficTypeDiagnostic: SA0PR12MB4383: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:334; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pYHUnZFlaReY8ECh42kuZ0LoaPK1eeiFg+50E56ZKTnYubdIWvxfmbxgJKFFM/rws3OOdEVSikWtfls6HQpVs81gy6WWBkpGbURF6I41OKzOMdCpApXrljCLmv3tiSFIZOS4jSCWob+v3hQoxnSrlxPCxzcutDmeLvrM+DskWsabdA6nACxHu9uEyjBmDMpIzKftp9ErKluPeZWLMsF6BxdJ3x3c5JrTTAEojzkPh3PSmhMzyInnk4EpyJNSZMHt3Gg0hZcEA3JQT3paAsqB0nL1VYsXhX2uhAWfsWpNS0wJH5VWBswKEuVyp+FGcKgpGmf9fXfGEmjRUJdmqEJnLg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN1PR12MB2560.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(39860400002)(136003)(376002)(346002)(396003)(316002)(2906002)(26005)(66556008)(478600001)(6486002)(4326008)(186003)(956004)(83380400001)(8676002)(66946007)(86362001)(5660300002)(52116002)(103116003)(8936002)(66476007)(16576012)(44832011); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: kLbsr2JmcOc5RGoF/KjX8t16u19tOXs5FqJlFC6URXurfYUfawV6tjcDvxJx90Hux09t7KHXiCGt0NFp/1oQ2yxxvdDFRaGu4MAOjk4UR8g0AEluLrISHuxCrEGefDh8CkDc3Ws4iEcWhIJaO4081PsHyYb6PH1snKMf8SHIyRmD9vwa+TNNAL2P+LMSL8+vjulxYyH7JBr9/a3UP72pN6iRMJU7uB4+SFYHUayLHfDSEhvReFycrntGzrHh15cZ/VmUTwdAV8QGiU0oP853tweMXiyqyY26wbEqQSTJQEouJkW0ghFMJcDwnQtvunt24t6/otDhxlKINk+qOuxgtDsLf+h0RcLY1CNxxHsAcQOIaDeG8sNo6WLYrOOul4F5AOkLDltAnzWFvCbNnFVFLa4w+VCLWnZ704u3PYjLSzIfd/iO31zfntTUJHRLXPaoIiND84nCiG9BmSKAkdpgIvQX8xkchuA4zoqVCIRf9ELu272SiW6lVGd7BECIsUN74O2zdOJIU5BJjU+bl2cRQTcte51kx45vqJqOfpgLcA6PUQlZBzZJTY1aojWSok5cRjg5hUkPlHo23oAJb71Nv4a5ESrXay4xprXlEiTFR31Eby4ioH2Wv4hCSN3dSlZQPRpnhsVsYGRjlCxLCjTYHA== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: e3a957ee-0b22-4180-4617-08d84ddda59c X-MS-Exchange-CrossTenant-AuthSource: SN1PR12MB2560.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2020 18:42:43.5557 (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: sHH15PhT94IkcZVM9wwh10cFtq38rLutvi84Ezc6Y9PpX/A6+5qxIEUENRdYEfsl X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4383 Received-SPF: none client-ip=40.107.93.72; envelope-from=Babu.Moger@amd.com; helo=NAM10-DM6-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/31 14:42:44 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: 4 X-Spam_score: 0.4 X-Spam_bar: / X-Spam_report: (0.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FORGED_SPF_HELO=1, MSGID_FROM_MTA_HEADER=0.001, RCVD_ILLEGAL_IP=1.3, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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: babu.moger@amd.com, qemu-devel@nongnu.org, mst@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This reverts commit dd08ef0318e2b61d14bc069590d174913f7f437a. Remove the EPYC specific apicid decoding and use the generic default decoding. Signed-off-by: Babu Moger Reviewed-by: Igor Mammedov --- target/i386/cpu.c | 161 ++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 127 insertions(+), 34 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index b72b4b08ac..256bfa669f 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -338,15 +338,68 @@ static void encode_cache_cpuid80000006(CPUCacheInfo *l2, } } +/* + * Definitions used for building CPUID Leaf 0x8000001D and 0x8000001E + * Please refer to the AMD64 Architecture Programmer’s Manual Volume 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 = DIV_ROUND_UP(nr_cores, MAX_CORES_IN_NODE); + + /* Hardware does not support config with 3 nodes, return 4 in that case */ + return (nodes == 3) ? 4 : nodes; +} + +/* + * Decide the number of cores in a core complex with the given nr_cores using + * 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 also + * 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 <= MAX_CORES_IN_CCX) { + return nr_cores; + } + /* Get the number of nodes required to build this config */ + nodes = 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, - X86CPUTopoInfo *topo_info, - uint32_t *eax, uint32_t *ebx, - uint32_t *ecx, uint32_t *edx) +static void encode_cache_cpuid8000001d(CPUCacheInfo *cache, CPUState *cs, + uint32_t *eax, uint32_t *ebx, + uint32_t *ecx, uint32_t *edx) { uint32_t l3_cores; - unsigned nodes = MAX(topo_info->nodes_per_pkg, 1); - assert(cache->size == cache->line_size * cache->associativity * cache->partitions * cache->sets); @@ -355,13 +408,10 @@ static void encode_cache_cpuid8000001d(CPUCacheInfo *cache, /* L3 is shared among multiple cores */ if (cache->level == 3) { - l3_cores = DIV_ROUND_UP((topo_info->dies_per_pkg * - topo_info->cores_per_die * - topo_info->threads_per_core), - nodes); - *eax |= (l3_cores - 1) << 14; + l3_cores = cores_in_core_complex(cs->nr_cores); + *eax |= ((l3_cores * cs->nr_threads) - 1) << 14; } else { - *eax |= ((topo_info->threads_per_core - 1) << 14); + *eax |= ((cs->nr_threads - 1) << 14); } assert(cache->line_size > 0); @@ -381,17 +431,55 @@ static void encode_cache_cpuid8000001d(CPUCacheInfo *cache, (cache->complex_indexing ? CACHE_COMPLEX_IDX : 0); } +/* 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 index + */ +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 = nodes_in_socket(nr_cores); + + cores_in_ccx = cores_in_core_complex(nr_cores); + + topo->node_id = core_id / (cores_in_ccx * MAX_CCX); + topo->ccx_id = (core_id % (cores_in_ccx * MAX_CCX)) / cores_in_ccx; + topo->core_id = core_id % cores_in_ccx; + topo->num_nodes = nodes; +} + /* Encode cache info for CPUID[8000001E] */ -static void encode_topo_cpuid8000001e(X86CPUTopoInfo *topo_info, X86CPU *cpu, +static void encode_topo_cpuid8000001e(CPUState *cs, X86CPU *cpu, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) { - X86CPUTopoIDs topo_ids = {0}; - unsigned long nodes = MAX(topo_info->nodes_per_pkg, 1); + struct core_topology topo = {0}; + unsigned long nodes; int shift; - x86_topo_ids_from_apicid_epyc(cpu->apic_id, topo_info, &topo_ids); - + build_core_topology(cs->nr_cores, cpu->core_id, &topo); *eax = cpu->apic_id; /* * CPUID_Fn8000001E_EBX @@ -408,8 +496,12 @@ static void encode_topo_cpuid8000001e(X86CPUTopoInfo *topo_info, X86CPU *cpu, * 3 Core complex id * 1:0 Core id */ - *ebx = ((topo_info->threads_per_core - 1) << 8) | (topo_ids.node_id << 3) | - (topo_ids.core_id); + if (cs->nr_threads - 1) { + *ebx = ((cs->nr_threads - 1) << 8) | (topo.node_id << 3) | + (topo.ccx_id << 2) | topo.core_id; + } else { + *ebx = (topo.node_id << 4) | (topo.ccx_id << 3) | topo.core_id; + } /* * CPUID_Fn8000001E_ECX * 31:11 Reserved @@ -418,8 +510,9 @@ static void encode_topo_cpuid8000001e(X86CPUTopoInfo *topo_info, X86CPU *cpu, * 2 Socket id * 1:0 Node id */ - if (nodes <= 4) { - *ecx = ((nodes - 1) << 8) | (topo_ids.pkg_id << 2) | topo_ids.node_id; + if (topo.num_nodes <= 4) { + *ecx = ((topo.num_nodes - 1) << 8) | (cpu->socket_id << 2) | + topo.node_id; } else { /* * Node id fix up. Actual hardware supports up to 4 nodes. But with @@ -434,10 +527,10 @@ static void encode_topo_cpuid8000001e(X86CPUTopoInfo *topo_info, X86CPU *cpu, * number of nodes. find_last_bit returns last set bit(0 based). Left * shift(+1) the socket id to represent all the nodes. */ - nodes -= 1; + nodes = topo.num_nodes - 1; shift = find_last_bit(&nodes, 8); - *ecx = (nodes << 8) | (topo_ids.pkg_id << (shift + 1)) | - topo_ids.node_id; + *ecx = ((topo.num_nodes - 1) << 8) | (cpu->socket_id << (shift + 1)) | + topo.node_id; } *edx = 0; } @@ -5471,7 +5564,6 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, uint32_t signature[3]; X86CPUTopoInfo topo_info; - topo_info.nodes_per_pkg = env->nr_nodes; topo_info.dies_per_pkg = env->nr_dies; topo_info.cores_per_die = cs->nr_cores; topo_info.threads_per_core = cs->nr_threads; @@ -5902,20 +5994,20 @@ 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, - &topo_info, eax, ebx, ecx, edx); + encode_cache_cpuid8000001d(env->cache_info_amd.l1d_cache, cs, + eax, ebx, ecx, edx); break; case 1: /* L1 icache info */ - encode_cache_cpuid8000001d(env->cache_info_amd.l1i_cache, - &topo_info, eax, ebx, ecx, edx); + encode_cache_cpuid8000001d(env->cache_info_amd.l1i_cache, cs, + eax, ebx, ecx, edx); break; case 2: /* L2 cache info */ - encode_cache_cpuid8000001d(env->cache_info_amd.l2_cache, - &topo_info, eax, ebx, ecx, edx); + encode_cache_cpuid8000001d(env->cache_info_amd.l2_cache, cs, + eax, ebx, ecx, edx); break; case 3: /* L3 cache info */ - encode_cache_cpuid8000001d(env->cache_info_amd.l3_cache, - &topo_info, eax, ebx, ecx, edx); + encode_cache_cpuid8000001d(env->cache_info_amd.l3_cache, cs, + eax, ebx, ecx, edx); break; default: /* end of info */ *eax = *ebx = *ecx = *edx = 0; @@ -5924,7 +6016,8 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, break; case 0x8000001E: assert(cpu->core_id <= 255); - encode_topo_cpuid8000001e(&topo_info, cpu, eax, ebx, ecx, edx); + encode_topo_cpuid8000001e(cs, cpu, + eax, ebx, ecx, edx); break; case 0xC0000000: *eax = env->cpuid_xlevel2; From patchwork Mon Aug 31 18:42:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Moger, Babu" X-Patchwork-Id: 1354532 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=amd.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-amdcloud-onmicrosoft-com header.b=sAvJz901; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4BgJxh09FDz9sTM for ; Tue, 1 Sep 2020 04:43:36 +1000 (AEST) Received: from localhost ([::1]:49216 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kComD-0006zl-Tq for incoming@patchwork.ozlabs.org; Mon, 31 Aug 2020 14:43:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40694) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kColb-0006xO-20 for qemu-devel@nongnu.org; Mon, 31 Aug 2020 14:42:55 -0400 Received: from mail-dm6nam10on2048.outbound.protection.outlook.com ([40.107.93.48]:39137 helo=NAM10-DM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kColZ-0007X7-82 for qemu-devel@nongnu.org; Mon, 31 Aug 2020 14:42:54 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RWX6e4WhsYDHC4yLEY8/oCOzFiZbi0xKIYxaulyKgdXhpStfPDD4N5n2mf9/nCw3J6EX3zEIGuI/nmNNxyvpZqgvxsX0Vi7tZlHwr7QYSJ/l948JPbc04FcqX4+aQzXp4WFzo2cbAFsED9T+EOZkWPfiOTQd3vG4emgvzDasi04usInqgT8EkvPqHOr3GVtfh0z6ovQCCDJSa1dP/nVe1b16qUOmhAiiKzMBehAbxgQUznGPpQtQ6Fzj1feaj4mGD87B5a2lVnMzlO6X8iSkul97LZ2eY4f+PVXCj8daM+Flbl+Yr9dKCyW0ox1ZK0qJUPWiK1c7Sq6AfXvPxZ52XQ== 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=RRt2401dv7ssbjPZqebOfDuTFxwpaPHpzWq9zredbaw=; b=l8BUzFAiuWJqN4HDWICST8jnWNUJi9DqldYxax/Rl7/VuJaVljZway/uduIR7ikUlpsC6vFvluHk2V7YIGOm+P3/kKI90CfLc7eITDf5+Y8EhYxL1cQnD1tmW1wIN8yNJdQX1o65U0WXMEWZA0HBxIHP7LQwDTbM4Qz8ILPkE0rml0JIQmOmb7l0JMfyuXQEMSKVJMtEJzYlHLl8q5YcfOzdQ2rirncK+PnUS41d27FhPjr8XHGKAXGhf/SOGb0P8giCCWeBplyb8XfIa0tO1DlrJUNJLngdRkmhgtEfKridmGjhLtFImQapU5z2ASM+VdJOpDwp2Rf2IZe3ucSegg== 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=RRt2401dv7ssbjPZqebOfDuTFxwpaPHpzWq9zredbaw=; b=sAvJz901MoG4kk7EVovwp9KG5Ysp0iJA4L0l3GCk5sFjfL4Zdg4WmzQ27+WVCWCJORlTTrbFpkru/fOMkUL7DQ9cMTKp1J8x+/ACNjho+UQIsBU0GpgTcgtBsMzDyVlYb3yIT8oSPrAoZfK+L3S36t3HTUaaXGl/b1bT7j6N7xk= Authentication-Results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=amd.com; Received: from SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) by SA0PR12MB4383.namprd12.prod.outlook.com (2603:10b6:806:94::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.21; Mon, 31 Aug 2020 18:42:49 +0000 Received: from SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::ccd9:728:9577:200d]) by SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::ccd9:728:9577:200d%4]) with mapi id 15.20.3326.025; Mon, 31 Aug 2020 18:42:49 +0000 Subject: [PATCH v6 07/10] Revert "hw/386: Add EPYC mode topology decoding functions" From: Babu Moger To: pbonzini@redhat.com, rth@twiddle.net, ehabkost@redhat.com, imammedo@redhat.com Date: Mon, 31 Aug 2020 13:42:48 -0500 Message-ID: <159889936871.21294.1454526726636639780.stgit@naples-babu.amd.com> In-Reply-To: <159889924378.21294.16494070903874534542.stgit@naples-babu.amd.com> References: <159889924378.21294.16494070903874534542.stgit@naples-babu.amd.com> User-Agent: StGit/unknown-version X-ClientProxiedBy: SN4PR0701CA0031.namprd07.prod.outlook.com (2603:10b6:803:2d::34) To SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from 255.255.255.255 (255.255.255.255) by SN4PR0701CA0031.namprd07.prod.outlook.com (2603:10b6:803:2d::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.19 via Frontend Transport; Mon, 31 Aug 2020 18:42:49 +0000 X-Originating-IP: [165.204.78.2] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 72c114a4-580c-48b1-e160-08d84ddda941 X-MS-TrafficTypeDiagnostic: SA0PR12MB4383: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:265; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: y65sflPYIWgIW4JbpOL+j40qplKMngrIzp4vnhW94uZBqF9KD26PKUDSmpy7L0dW1yLYikP97prNc4o6wYgfFfXRefjjhDThbKc0hEOAKwTlSwJpS7k8l9a96RJASlu7PZEHsYRSyQiX5Ku5eCQ3JtjRXCkPnV4zn7rV3EjU0SuzBDcmrc1WoFzdP79L6zsAVUwLdrl7sn1d5mux0P3x8Xbuka2XEL1LRw5yKHjXfdGDF/GHzJWpJos5zRyDaVA/X0j5Y0C+Mnls3QUkUVBMKzcH0O4iCLtOSoMinUJLUXLo94HaBcXiGxfDWcHohdtw7Su1ERYBBUnMnaYV44o92Q== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN1PR12MB2560.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(39860400002)(136003)(376002)(346002)(396003)(316002)(2906002)(26005)(66556008)(478600001)(6486002)(4326008)(186003)(956004)(83380400001)(8676002)(66946007)(86362001)(5660300002)(52116002)(103116003)(8936002)(66476007)(16576012)(44832011); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: bw/OSFed5fQxKxO4Lm4t2Y3244ePZhqSW8G7yjrljLgSCydAozIHluET6NSvoyeRJEGt+421FN6FwBuGibvFqBoZswK09bejtr+NNFGPMjr1lrCN7SeM3ZcPm0YS1+PdcPy6Yo7I8YVblvhRPRtWt61mZmbBFTOproMdhaoxbfY8YCso2B2wrvmWn42vpERShBGUZxjJ6nrbEEMAFR5pJNChmFA6eTAC2Jc+cvjDLmw7FVKUXBdl7AR0X9d+yevhfzy33OVPpGZc6Ahuz7t2I1hBqdt81VlNdpDu31Dxz3tuvGWOn/1PjXxXB1G1wFBQQA/O2a4Q8uJsGqGTzx7UINesvh/UH34PlTfLXQDrIg1niM7CkP/7Leh8lmAb5Qh1F5YxU0L7vir/+9vPmqYPaPqu69lj4jJjqOj5AjhvO8DHDmZvYzbrS73EuEih+olxLRKtEAodJZZgMiZ1WAM8bqY4ZhffBgRd2dwRlfRy9IVJzdw2usyhI7L1QDG/PSX7Ye8Yc4Zc2T9GImjiN9N4ZTy0tR5yHHXydlX5+HjGOR535TklJ3NsLs71ltySa9avHzDu4iwTkz66+GpkO6SZwiOE2DOxI8HXjpEGIOvfoIXhcYuz/A5ruBPgCXYAwBkg71zTVqs7nhyJsduUr6hqxw== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 72c114a4-580c-48b1-e160-08d84ddda941 X-MS-Exchange-CrossTenant-AuthSource: SN1PR12MB2560.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2020 18:42:49.6522 (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: EIzK+EpdLLi34Q9HCTDfdrYGYR8VlA3aoR1cxLBEo0eEYNHZLbB8JYV/02yN8/co X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4383 Received-SPF: none client-ip=40.107.93.48; envelope-from=Babu.Moger@amd.com; helo=NAM10-DM6-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/31 14:42:50 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: 4 X-Spam_score: 0.4 X-Spam_bar: / X-Spam_report: (0.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FORGED_SPF_HELO=1, MSGID_FROM_MTA_HEADER=0.001, RCVD_ILLEGAL_IP=1.3, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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: babu.moger@amd.com, qemu-devel@nongnu.org, mst@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This reverts commit 7568b205555a6405042f62c64af3268f4330aed5. Remove the EPYC specific apicid decoding and use the generic default decoding. Signed-off-by: Babu Moger Reviewed-by: Igor Mammedov --- include/hw/i386/topology.h | 100 -------------------------------------------- 1 file changed, 100 deletions(-) diff --git a/include/hw/i386/topology.h b/include/hw/i386/topology.h index 07239f95f4..b9593b9905 100644 --- a/include/hw/i386/topology.h +++ b/include/hw/i386/topology.h @@ -47,7 +47,6 @@ typedef uint32_t apic_id_t; typedef struct X86CPUTopoIDs { unsigned pkg_id; - unsigned node_id; unsigned die_id; unsigned core_id; unsigned smt_id; @@ -89,11 +88,6 @@ static inline unsigned apicid_die_width(X86CPUTopoInfo *topo_info) return apicid_bitwidth_for_count(topo_info->dies_per_pkg); } -/* Bit width of the node_id field per socket */ -static inline unsigned apicid_node_width_epyc(X86CPUTopoInfo *topo_info) -{ - return apicid_bitwidth_for_count(MAX(topo_info->nodes_per_pkg, 1)); -} /* Bit offset of the Core_ID field */ static inline unsigned apicid_core_offset(X86CPUTopoInfo *topo_info) @@ -114,100 +108,6 @@ static inline unsigned apicid_pkg_offset(X86CPUTopoInfo *topo_info) return apicid_die_offset(topo_info) + apicid_die_width(topo_info); } -#define NODE_ID_OFFSET 3 /* Minimum node_id offset if numa configured */ - -/* - * Bit offset of the node_id field - * - * Make sure nodes_per_pkg > 0 if numa configured else zero. - */ -static inline unsigned apicid_node_offset_epyc(X86CPUTopoInfo *topo_info) -{ - unsigned offset = apicid_die_offset(topo_info) + - apicid_die_width(topo_info); - - if (topo_info->nodes_per_pkg) { - return MAX(NODE_ID_OFFSET, offset); - } else { - return offset; - } -} - -/* Bit offset of the Pkg_ID (socket ID) field */ -static inline unsigned apicid_pkg_offset_epyc(X86CPUTopoInfo *topo_info) -{ - return apicid_node_offset_epyc(topo_info) + - apicid_node_width_epyc(topo_info); -} - -/* - * 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 -x86_apicid_from_topo_ids_epyc(X86CPUTopoInfo *topo_info, - const X86CPUTopoIDs *topo_ids) -{ - return (topo_ids->pkg_id << apicid_pkg_offset_epyc(topo_info)) | - (topo_ids->node_id << apicid_node_offset_epyc(topo_info)) | - (topo_ids->die_id << apicid_die_offset(topo_info)) | - (topo_ids->core_id << apicid_core_offset(topo_info)) | - topo_ids->smt_id; -} - -static inline void x86_topo_ids_from_idx_epyc(X86CPUTopoInfo *topo_info, - unsigned cpu_index, - X86CPUTopoIDs *topo_ids) -{ - unsigned nr_nodes = MAX(topo_info->nodes_per_pkg, 1); - unsigned nr_dies = topo_info->dies_per_pkg; - unsigned nr_cores = topo_info->cores_per_die; - unsigned nr_threads = topo_info->threads_per_core; - unsigned cores_per_node = DIV_ROUND_UP((nr_dies * nr_cores * nr_threads), - nr_nodes); - - topo_ids->pkg_id = cpu_index / (nr_dies * nr_cores * nr_threads); - topo_ids->node_id = (cpu_index / cores_per_node) % nr_nodes; - topo_ids->die_id = cpu_index / (nr_cores * nr_threads) % nr_dies; - topo_ids->core_id = cpu_index / nr_threads % nr_cores; - topo_ids->smt_id = cpu_index % nr_threads; -} - -/* - * 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, - X86CPUTopoInfo *topo_info, - X86CPUTopoIDs *topo_ids) -{ - topo_ids->smt_id = apicid & - ~(0xFFFFFFFFUL << apicid_smt_width(topo_info)); - topo_ids->core_id = - (apicid >> apicid_core_offset(topo_info)) & - ~(0xFFFFFFFFUL << apicid_core_width(topo_info)); - topo_ids->die_id = - (apicid >> apicid_die_offset(topo_info)) & - ~(0xFFFFFFFFUL << apicid_die_width(topo_info)); - topo_ids->node_id = - (apicid >> apicid_node_offset_epyc(topo_info)) & - ~(0xFFFFFFFFUL << apicid_node_width_epyc(topo_info)); - topo_ids->pkg_id = apicid >> apicid_pkg_offset_epyc(topo_info); -} - -/* - * 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(X86CPUTopoInfo *topo_info, - unsigned cpu_index) -{ - X86CPUTopoIDs topo_ids; - x86_topo_ids_from_idx_epyc(topo_info, cpu_index, &topo_ids); - return x86_apicid_from_topo_ids_epyc(topo_info, &topo_ids); -} /* 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. From patchwork Mon Aug 31 18:42:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Moger, Babu" X-Patchwork-Id: 1354536 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=amd.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-amdcloud-onmicrosoft-com header.b=DLM8X40Z; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4BgK0704Rsz9sTM for ; Tue, 1 Sep 2020 04:45:43 +1000 (AEST) Received: from localhost ([::1]:57712 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kCooG-00020w-Oi for incoming@patchwork.ozlabs.org; Mon, 31 Aug 2020 14:45:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40716) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kColf-00072N-RF for qemu-devel@nongnu.org; Mon, 31 Aug 2020 14:42:59 -0400 Received: from mail-eopbgr750074.outbound.protection.outlook.com ([40.107.75.74]:33025 helo=NAM02-BL2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCold-0007Xk-Na for qemu-devel@nongnu.org; Mon, 31 Aug 2020 14:42:59 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OmzmN9HczdQ2qkG6IwC5bWHZJgAWWsd4hwy8owyBvvt8YIHTO3u4ZBEns2onUNzcqe7ZXqj+BL4sQ05LJRlGrG8N9Hq5sNfLxj91o1DwZ1VPCcphvBrhCa+CYQRXURmt+7Yxcsn4LMkOI3h2HnGzGGRcfPzrLIsa/IkXfPsiP5W+R9NFEcdo/f/uFJ4Jb+DB1aCW4KKAywS+7CYZbmVPsXTyISKkBl57ZvY4pp+oHKAeYmPQB+9CHJW0zlQ8/nLhn+loKMjkhe6VXe2BSiZyjy7uGYN6A2Frg/Q0dJIkkLT+EHhoIDi9j2l8zPZklI0iXnUnYbM1Fo+BbXSr+UxGKA== 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=Vlwyayzh/Oh2fpmwlVfYPM3lNKfFc2zhDr++mOEk8Jw=; b=PlmZ/dCTv32LJ7ibNPu3mAQt/+1SzTQY6o5n+WAGfpCtyqn07iCvlZaY3/ZCYwFGfZdIehVpa+mpmGCn4m/F/s7X4IDQn3uTLXBfRX+11iEf9O6bMhSWOepvSkVJGmbEVC5dr5ijKrZMNVYfE3450dcTLQP/2r1vr6fhIyUYLecoM4HvnYZPexrIXDV6It+WhLUTRvJZlN1wnRGdKerLKS7OrvTWWrjVYXGhCLK8uOjMNJAOaPCYNvGM5yFjGNhWsPywoqhHyBM4W9v1f5QXgDjFZqNUO2I3SW2Bny4H6AXvswUeh3/ntUYAtfWTgg4lmmtBzHTJYR/ulzN/j8yK3w== 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=Vlwyayzh/Oh2fpmwlVfYPM3lNKfFc2zhDr++mOEk8Jw=; b=DLM8X40Z6GGJOYrjVvO5gQf8VemFw0jTGLwA2hrsP9GPDBRQE2X4XxyALR6eIEtTZr8Z0gP14ZOcVoxebSCyxaYsFLT9OGn1WuFf7qmPIvKPQviDGOcbT0N37DDTrwJ0UO2dVDkpFrFWh0vElHuQPvBlNdxirplqPRU2a8ZwpWQ= Authentication-Results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=amd.com; Received: from SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) by SN1PR12MB2559.namprd12.prod.outlook.com (2603:10b6:802:29::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.23; Mon, 31 Aug 2020 18:42:55 +0000 Received: from SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::ccd9:728:9577:200d]) by SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::ccd9:728:9577:200d%4]) with mapi id 15.20.3326.025; Mon, 31 Aug 2020 18:42:55 +0000 Subject: [PATCH v6 08/10] Revert "hw/i386: Update structures to save the number of nodes per package" From: Babu Moger To: pbonzini@redhat.com, rth@twiddle.net, ehabkost@redhat.com, imammedo@redhat.com Date: Mon, 31 Aug 2020 13:42:54 -0500 Message-ID: <159889937478.21294.4192291354416942986.stgit@naples-babu.amd.com> In-Reply-To: <159889924378.21294.16494070903874534542.stgit@naples-babu.amd.com> References: <159889924378.21294.16494070903874534542.stgit@naples-babu.amd.com> User-Agent: StGit/unknown-version X-ClientProxiedBy: SN4PR0701CA0035.namprd07.prod.outlook.com (2603:10b6:803:2d::25) To SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from 255.255.255.255 (255.255.255.255) by SN4PR0701CA0035.namprd07.prod.outlook.com (2603:10b6:803:2d::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.19 via Frontend Transport; Mon, 31 Aug 2020 18:42:55 +0000 X-Originating-IP: [165.204.78.2] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: d1861f04-5db1-4824-7ca3-08d84dddace7 X-MS-TrafficTypeDiagnostic: SN1PR12MB2559: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:353; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QH4QVFfZGKxoNTKUxmI5FkjZMFmgzohEIV+qQAYyKdLwSR9IyEdncf0rFtOlcrsKi04jQw2YkzXCP9Hn0I9kHABi8Hx2f8twYDbOXCHtwT/A8juXhZtfVp7UIFiCeTt1F8+U7BIvHlv8hrO3eb1rpXuAUnjn+Nfgdqnk9FrUEl/jbj3P5OTookYLBcDvuedfxtOoima3uuUjzhDmn4qxwf6sbgXXsT2pPJnQuzeHaItsBbnoSGCZdEBZbEfr5YaY/+DG5AnLCzO9nwB2NLtkmYlMNZTKoyZ/N4V4NkB9sOtoBlm8o1pHBk/GFRQW2D92pp9GuUQDw5y20EgwWFNdcw9MkTYxYJXYhtQ5JlGeKS7gXUlIi9vwOVAOOvAu2M2H X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN1PR12MB2560.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(346002)(39860400002)(396003)(136003)(366004)(2906002)(66946007)(83380400001)(66556008)(4326008)(26005)(956004)(316002)(16576012)(5660300002)(186003)(66476007)(6486002)(8676002)(478600001)(44832011)(8936002)(86362001)(52116002)(103116003)(60793003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 786NZamkHsO2sm9PZAZ7zJqxOPC+7UhitpBnoHg6EBek0rM7IBLOS+pErMIZxfHJjNhzWxO2v5NXpz6f69M1gnGRy1IaIV8r6pcnrYIALVRHL7dVirlI3EcfZoZsZuMVcq+DJKRl42V4yZlp7bhHdoKCsuZnbUOTg7Lk3xpSbWxVvMJVVCUb80AwodlmQW8WaGvylgjYEpcNrkkOJZhgzO8yYjoLXgxONrvr9G7g6xTxi80zhj6c5rOWPDGf4g15Kt0VFFbxEaw5li7DoO1JWkhGxeY/56wC7KXgRQIMLUcUyBK9uXx7K8uoDGVz4hPvKTDDmVlJsuDkyPgopWophrlj9w+ueYSF15BODfyZUQZK40vWMWiYTVB9pfZFjRTrlGZDr1qGJPpQy0ks9QQarWeWsEmuS1VUEvf1GUbHc6Ev1zex8gGgFQPFza/Po+HvfdONvyXt7Za4XjcoojeBA52gmmhTjeW//aaCc7a1lRD7XJrbDttEyGvl5z9bc/uVN5FHv3bS0/fBCS1i4HUIQEmPaN5l5hYkFqmaVX1zM5KNge56OVi5O0vepsFxtspbBbKtx8voR5yABl3xb/aoc2R84ZSlnawWzfbvBhkxZUIaBL6DnX/bPe5Dn5F5N0rulR5CL3CweW+EfRAUo7x+EA== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: d1861f04-5db1-4824-7ca3-08d84dddace7 X-MS-Exchange-CrossTenant-AuthSource: SN1PR12MB2560.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2020 18:42:55.8257 (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: dJDQ3I7po9G2vZiHjwNRXB7i03iijyPSW5dHhvPRIiWmLhmqybsnXBA31jYQvyL5 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2559 Received-SPF: none client-ip=40.107.75.74; envelope-from=Babu.Moger@amd.com; helo=NAM02-BL2-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/31 14:42:32 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: 4 X-Spam_score: 0.4 X-Spam_bar: / X-Spam_report: (0.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FORGED_SPF_HELO=1, MSGID_FROM_MTA_HEADER=0.001, RCVD_ILLEGAL_IP=1.3, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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: babu.moger@amd.com, qemu-devel@nongnu.org, mst@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This reverts commit c24a41bb53c0854d22c96b30d57cfcaa543c409d. Remove the EPYC specific apicid decoding and use the generic default decoding. Signed-off-by: Babu Moger Reviewed-by: Igor Mammedov --- hw/i386/pc.c | 1 - hw/i386/x86.c | 1 - include/hw/i386/topology.h | 1 - target/i386/cpu.c | 1 - target/i386/cpu.h | 1 - tests/test-x86-cpuid.c | 40 ++++++++++++++++++++-------------------- 6 files changed, 20 insertions(+), 25 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 0677d6a272..d11daacc23 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1501,7 +1501,6 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev, init_topo_info(&topo_info, x86ms); env->nr_dies = x86ms->smp_dies; - env->nr_nodes = topo_info.nodes_per_pkg; /* * If APIC ID is not set, diff --git a/hw/i386/x86.c b/hw/i386/x86.c index 727c4a0f1d..c1954db152 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -62,7 +62,6 @@ inline void init_topo_info(X86CPUTopoInfo *topo_info, { MachineState *ms = MACHINE(x86ms); - topo_info->nodes_per_pkg = ms->numa_state->num_nodes / ms->smp.sockets; topo_info->dies_per_pkg = x86ms->smp_dies; topo_info->cores_per_die = ms->smp.cores; topo_info->threads_per_core = ms->smp.threads; diff --git a/include/hw/i386/topology.h b/include/hw/i386/topology.h index b9593b9905..81573f6cfd 100644 --- a/include/hw/i386/topology.h +++ b/include/hw/i386/topology.h @@ -53,7 +53,6 @@ typedef struct X86CPUTopoIDs { } X86CPUTopoIDs; typedef struct X86CPUTopoInfo { - unsigned nodes_per_pkg; unsigned dies_per_pkg; unsigned cores_per_die; unsigned threads_per_core; diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 256bfa669f..ba4667b33c 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -7023,7 +7023,6 @@ static void x86_cpu_initfn(Object *obj) FeatureWord w; env->nr_dies = 1; - env->nr_nodes = 1; cpu_set_cpustate_pointers(cpu); object_property_add(obj, "family", "int", diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 5ff8ad8427..d3097be6a5 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1629,7 +1629,6 @@ typedef struct CPUX86State { TPRAccess tpr_access_type; unsigned nr_dies; - unsigned nr_nodes; } CPUX86State; struct kvm_msrs; diff --git a/tests/test-x86-cpuid.c b/tests/test-x86-cpuid.c index 049030a50e..bfabc0403a 100644 --- a/tests/test-x86-cpuid.c +++ b/tests/test-x86-cpuid.c @@ -31,12 +31,12 @@ static void test_topo_bits(void) X86CPUTopoInfo topo_info = {0}; /* simple tests for 1 thread per core, 1 core per die, 1 die per package */ - topo_info = (X86CPUTopoInfo) {0, 1, 1, 1}; + topo_info = (X86CPUTopoInfo) {1, 1, 1}; g_assert_cmpuint(apicid_smt_width(&topo_info), ==, 0); g_assert_cmpuint(apicid_core_width(&topo_info), ==, 0); g_assert_cmpuint(apicid_die_width(&topo_info), ==, 0); - topo_info = (X86CPUTopoInfo) {0, 1, 1, 1}; + topo_info = (X86CPUTopoInfo) {1, 1, 1}; g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 0), ==, 0); g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 1), ==, 1); g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 2), ==, 2); @@ -45,39 +45,39 @@ static void test_topo_bits(void) /* Test field width calculation for multiple values */ - topo_info = (X86CPUTopoInfo) {0, 1, 1, 2}; + topo_info = (X86CPUTopoInfo) {1, 1, 2}; g_assert_cmpuint(apicid_smt_width(&topo_info), ==, 1); - topo_info = (X86CPUTopoInfo) {0, 1, 1, 3}; + topo_info = (X86CPUTopoInfo) {1, 1, 3}; g_assert_cmpuint(apicid_smt_width(&topo_info), ==, 2); - topo_info = (X86CPUTopoInfo) {0, 1, 1, 4}; + topo_info = (X86CPUTopoInfo) {1, 1, 4}; g_assert_cmpuint(apicid_smt_width(&topo_info), ==, 2); - topo_info = (X86CPUTopoInfo) {0, 1, 1, 14}; + topo_info = (X86CPUTopoInfo) {1, 1, 14}; g_assert_cmpuint(apicid_smt_width(&topo_info), ==, 4); - topo_info = (X86CPUTopoInfo) {0, 1, 1, 15}; + topo_info = (X86CPUTopoInfo) {1, 1, 15}; g_assert_cmpuint(apicid_smt_width(&topo_info), ==, 4); - topo_info = (X86CPUTopoInfo) {0, 1, 1, 16}; + topo_info = (X86CPUTopoInfo) {1, 1, 16}; g_assert_cmpuint(apicid_smt_width(&topo_info), ==, 4); - topo_info = (X86CPUTopoInfo) {0, 1, 1, 17}; + topo_info = (X86CPUTopoInfo) {1, 1, 17}; g_assert_cmpuint(apicid_smt_width(&topo_info), ==, 5); - topo_info = (X86CPUTopoInfo) {0, 1, 30, 2}; + topo_info = (X86CPUTopoInfo) {1, 30, 2}; g_assert_cmpuint(apicid_core_width(&topo_info), ==, 5); - topo_info = (X86CPUTopoInfo) {0, 1, 31, 2}; + topo_info = (X86CPUTopoInfo) {1, 31, 2}; g_assert_cmpuint(apicid_core_width(&topo_info), ==, 5); - topo_info = (X86CPUTopoInfo) {0, 1, 32, 2}; + topo_info = (X86CPUTopoInfo) {1, 32, 2}; g_assert_cmpuint(apicid_core_width(&topo_info), ==, 5); - topo_info = (X86CPUTopoInfo) {0, 1, 33, 2}; + topo_info = (X86CPUTopoInfo) {1, 33, 2}; g_assert_cmpuint(apicid_core_width(&topo_info), ==, 6); - topo_info = (X86CPUTopoInfo) {0, 1, 30, 2}; + topo_info = (X86CPUTopoInfo) {1, 30, 2}; g_assert_cmpuint(apicid_die_width(&topo_info), ==, 0); - topo_info = (X86CPUTopoInfo) {0, 2, 30, 2}; + topo_info = (X86CPUTopoInfo) {2, 30, 2}; g_assert_cmpuint(apicid_die_width(&topo_info), ==, 1); - topo_info = (X86CPUTopoInfo) {0, 3, 30, 2}; + topo_info = (X86CPUTopoInfo) {3, 30, 2}; g_assert_cmpuint(apicid_die_width(&topo_info), ==, 2); - topo_info = (X86CPUTopoInfo) {0, 4, 30, 2}; + topo_info = (X86CPUTopoInfo) {4, 30, 2}; g_assert_cmpuint(apicid_die_width(&topo_info), ==, 2); /* build a weird topology and see if IDs are calculated correctly @@ -85,18 +85,18 @@ static void test_topo_bits(void) /* This will use 2 bits for thread ID and 3 bits for core ID */ - topo_info = (X86CPUTopoInfo) {0, 1, 6, 3}; + topo_info = (X86CPUTopoInfo) {1, 6, 3}; g_assert_cmpuint(apicid_smt_width(&topo_info), ==, 2); g_assert_cmpuint(apicid_core_offset(&topo_info), ==, 2); g_assert_cmpuint(apicid_die_offset(&topo_info), ==, 5); g_assert_cmpuint(apicid_pkg_offset(&topo_info), ==, 5); - topo_info = (X86CPUTopoInfo) {0, 1, 6, 3}; + topo_info = (X86CPUTopoInfo) {1, 6, 3}; g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 0), ==, 0); g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 1), ==, 1); g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 2), ==, 2); - topo_info = (X86CPUTopoInfo) {0, 1, 6, 3}; + topo_info = (X86CPUTopoInfo) {1, 6, 3}; g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 1 * 3 + 0), ==, (1 << 2) | 0); g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 1 * 3 + 1), ==, From patchwork Mon Aug 31 18:43:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Moger, Babu" X-Patchwork-Id: 1354544 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=amd.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-amdcloud-onmicrosoft-com header.b=W2byJEKy; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4BgK696wDqz9sTM for ; Tue, 1 Sep 2020 04:50:56 +1000 (AEST) Received: from localhost ([::1]:48562 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kCotJ-0001qD-Gg for incoming@patchwork.ozlabs.org; Mon, 31 Aug 2020 14:50:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40730) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kColp-0007It-K7 for qemu-devel@nongnu.org; Mon, 31 Aug 2020 14:43:09 -0400 Received: from mail-dm6nam10on2085.outbound.protection.outlook.com ([40.107.93.85]:37504 helo=NAM10-DM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kColk-0007Y8-9J for qemu-devel@nongnu.org; Mon, 31 Aug 2020 14:43:09 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W+6XsRPsa+1K3X3/NxR8iiTpoTuFYtazsrbwO7CvlpVvCpRc6GZp+/QlSHI9z3sXjlsDJf1pVjXy2+UPD3oqdaTeOz/KCEW3H3Nu60mj1CUm9Q6LWyeXqLHu/YqTTanFhBzq3ay729VrZYF/bqTvDWuqqN2gLoURskbNM4TA+p5jLpZFplJz+3D2Nw5FvUlr/bCYm57PY6W4lfQ5mpwdiW0928USGJ02mJv/UjZJBMACF/XlwaD1G+URyDWPk8eQzaYyd9YhJpNS2Fp7kv7Ygo56swM7YysNhboEdFhIaovK/tPZpshPK317ez3eKLPCLFG0elsvvnnBiJliQYwdqQ== 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=/+8KtUav/FQdspK9sDZqTmizubAzUAiaEsaNU3DLNWk=; b=gjaUox2nLL5QpU8tqF7MbOIy2BlqybOalI7//S/aUi++gDGQb32I7dNJChLcDpq7bFpT21xPB01p0fe5uq8bhXMXosgzl6EId4gSOPjBmG2Fs0XwU4SRZN2sd/oeK4WHWHPDlFB37w3qS3WSGa91O2duXLcuDVK7D6owc2bw3dGkdLzy3io77kmQeM5vOl4BcWYG7wTIYdBgcbIDTjtFXZTNpXUngnCWCZOu8r94K/q8pJjl5xWZ9QimyFE3Pqpn+OM/GToYC65y9nhgB9LSP4RCFMozvpWYD13RaoTkG0V6gWylD0tShxwQY0gzh73TI234amYGez43O92Q6kbS8Q== 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=/+8KtUav/FQdspK9sDZqTmizubAzUAiaEsaNU3DLNWk=; b=W2byJEKyEAU8dzv/gJ40gqxm71qbUGDGzrXU5ae9hNmdgLdey8HNKQi6mEygrNQV7KmEdCW4gqgG27rFW7iKz9uk0/IJf1NSUJFl5OWwk5AhTHpfMxe3S+YCPJfOmXYqHRMGFIL7/PTSPwB7QF2PCnjVBPF+jmDZm8WqZ5yJeXU= Authentication-Results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=amd.com; Received: from SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) by SA0PR12MB4383.namprd12.prod.outlook.com (2603:10b6:806:94::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.21; Mon, 31 Aug 2020 18:43:02 +0000 Received: from SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::ccd9:728:9577:200d]) by SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::ccd9:728:9577:200d%4]) with mapi id 15.20.3326.025; Mon, 31 Aug 2020 18:43:02 +0000 Subject: [PATCH v6 09/10] i386: Simplify CPUID_8000_001E for AMD From: Babu Moger To: pbonzini@redhat.com, rth@twiddle.net, ehabkost@redhat.com, imammedo@redhat.com Date: Mon, 31 Aug 2020 13:43:01 -0500 Message-ID: <159889938099.21294.9493474163204060713.stgit@naples-babu.amd.com> In-Reply-To: <159889924378.21294.16494070903874534542.stgit@naples-babu.amd.com> References: <159889924378.21294.16494070903874534542.stgit@naples-babu.amd.com> User-Agent: StGit/unknown-version X-ClientProxiedBy: SN4PR0401CA0041.namprd04.prod.outlook.com (2603:10b6:803:2a::27) To SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from 255.255.255.255 (255.255.255.255) by SN4PR0401CA0041.namprd04.prod.outlook.com (2603:10b6:803:2a::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.19 via Frontend Transport; Mon, 31 Aug 2020 18:43:01 +0000 X-Originating-IP: [165.204.78.2] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: e4be18f2-5db2-4cdc-6dad-08d84dddb09b X-MS-TrafficTypeDiagnostic: SA0PR12MB4383: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1388; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: z+AxekWJJO+4s9PFclE3GP26VPX5n1hKHbBfb4erO/rcwLDFuDYNYtRvTQYP7MZxus5fEX3fogu1C5dSbtvcqmMzy8jpp7K+ZKIUkscKB+2QPvDxLDDGgu1DQNb4oWtI940Vw2cUQxLBqTv80etMFvRG7wtdI7H+FpLPo+0s4L+sD8L2mhVbK7wk36uJ68HbCwTMkF1wDYA6/rB6gDFKmgLUHYeXZobjv7r889hYScuX6fyiK94uzRfAgCyg70LGCBN7PnKeb3mZ+2n9ALKZdu4tWhyeyWEWAvyKbsVTxmKORwzRvHz8SukY+UtqpyiUHJAdrcJ+4m3TaJ8PQwaZ+w== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN1PR12MB2560.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(39860400002)(136003)(376002)(346002)(396003)(316002)(2906002)(26005)(66556008)(478600001)(6486002)(4326008)(186003)(956004)(83380400001)(8676002)(66946007)(86362001)(5660300002)(52116002)(103116003)(8936002)(66476007)(16576012)(44832011); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: ntNommQdT7tsdh6GkKKaGZp63sD5ybjHSVdVwPgWokEILAt9JBdHS4etdXJTN/sq48Bqa1SRkJF/1+XUYKBjkeLv2UJvFlERaoECDZmK0vA8VlZtfsnVBgBwf/asIqH8ZuAPMwnI04BUDqdp1Y+Fz8u++wJrqPE/sYwvn8eFqqH9RN600tfiQRIy5O8zjGR7SKxkkEgJGw6P7XS4uEN5dDtlRFdZ0E5vA4RBdI/hiLzQz55iFthZiZesn3TzOOvYDr4ULcvVWfePpdCX30Wl1Xri81YTljYDaXs2eWQCe4VQR9gu0LwRohylN4/8zQyPJvNfOlaV1LZADsGdY2nMAvPxmYiGT4pZWAI9uenCPHURABvWIt89/YKfDplpF9vDV7fmBGWH+LeD/DdAn/4kbo5WEpM0wDvFO/eeqK7Bqz54HlY4Vz1lHPEQMDrc74Z/KYRND4Pnq5ytAHx/yJE+FSszG4eUJXSqocb2bHJoJCnTaRHXcfwGTy7MblYzYLzrP4mOLJXPFqByfULD12mc4A+XDyCf6zpF8c+A0W+9El9MkInTWky4FiT7vyGS07WMW9FjRNMkcr/dMwem6wOVE46+XCq75CRwZS6Mwfn0wowCo30ciB5xg6CR66NEguVMc4bA2B1bcpTUB4HQURYNKg== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: e4be18f2-5db2-4cdc-6dad-08d84dddb09b X-MS-Exchange-CrossTenant-AuthSource: SN1PR12MB2560.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2020 18:43:02.0721 (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: sOMEzK6KMsf58mjIUOYMcjfIr19sAjUqea2lyhXYwmuWltdzx6OhldzhsHZWygGp X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4383 Received-SPF: none client-ip=40.107.93.85; envelope-from=Babu.Moger@amd.com; helo=NAM10-DM6-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/31 14:43:02 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: 4 X-Spam_score: 0.4 X-Spam_bar: / X-Spam_report: (0.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FORGED_SPF_HELO=1, MSGID_FROM_MTA_HEADER=0.001, RCVD_ILLEGAL_IP=1.3, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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: babu.moger@amd.com, qemu-devel@nongnu.org, mst@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Remove all the hardcoded values and replace with generalized fields. Signed-off-by: Babu Moger --- target/i386/cpu.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index ba4667b33c..d434c8545a 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -395,9 +395,10 @@ static int cores_in_core_complex(int nr_cores) } /* Encode cache info for CPUID[8000001D] */ -static void encode_cache_cpuid8000001d(CPUCacheInfo *cache, CPUState *cs, - uint32_t *eax, uint32_t *ebx, - uint32_t *ecx, uint32_t *edx) +static void encode_cache_cpuid8000001d(CPUCacheInfo *cache, + X86CPUTopoInfo *topo_info, + uint32_t *eax, uint32_t *ebx, + uint32_t *ecx, uint32_t *edx) { uint32_t l3_cores; assert(cache->size == cache->line_size * cache->associativity * @@ -408,10 +409,12 @@ static void encode_cache_cpuid8000001d(CPUCacheInfo *cache, CPUState *cs, /* L3 is shared among multiple cores */ if (cache->level == 3) { - l3_cores = cores_in_core_complex(cs->nr_cores); - *eax |= ((l3_cores * cs->nr_threads) - 1) << 14; + l3_cores = DIV_ROUND_UP((topo_info->cores_per_die * + topo_info->threads_per_core), + topo_info->dies_per_pkg); + *eax |= (l3_cores - 1) << 14; } else { - *eax |= ((cs->nr_threads - 1) << 14); + *eax |= ((topo_info->threads_per_core - 1) << 14); } assert(cache->line_size > 0); @@ -5994,20 +5997,20 @@ 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, - eax, ebx, ecx, edx); + encode_cache_cpuid8000001d(env->cache_info_amd.l1d_cache, + &topo_info, eax, ebx, ecx, edx); break; case 1: /* L1 icache info */ - encode_cache_cpuid8000001d(env->cache_info_amd.l1i_cache, cs, - eax, ebx, ecx, edx); + encode_cache_cpuid8000001d(env->cache_info_amd.l1i_cache, + &topo_info, eax, ebx, ecx, edx); break; case 2: /* L2 cache info */ - encode_cache_cpuid8000001d(env->cache_info_amd.l2_cache, cs, - eax, ebx, ecx, edx); + encode_cache_cpuid8000001d(env->cache_info_amd.l2_cache, + &topo_info, eax, ebx, ecx, edx); break; case 3: /* L3 cache info */ - encode_cache_cpuid8000001d(env->cache_info_amd.l3_cache, cs, - eax, ebx, ecx, edx); + encode_cache_cpuid8000001d(env->cache_info_amd.l3_cache, + &topo_info, eax, ebx, ecx, edx); break; default: /* end of info */ *eax = *ebx = *ecx = *edx = 0; From patchwork Mon Aug 31 18:43:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Moger, Babu" X-Patchwork-Id: 1354542 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=amd.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-amdcloud-onmicrosoft-com header.b=UZU32BF8; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4BgK3t2srsz9sTM for ; Tue, 1 Sep 2020 04:48:58 +1000 (AEST) Received: from localhost ([::1]:41798 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kCorQ-0007LA-9n for incoming@patchwork.ozlabs.org; Mon, 31 Aug 2020 14:48:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40756) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kColt-0007MJ-DK for qemu-devel@nongnu.org; Mon, 31 Aug 2020 14:43:13 -0400 Received: from mail-dm6nam10on2073.outbound.protection.outlook.com ([40.107.93.73]:31936 helo=NAM10-DM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kColr-0007YO-Fa for qemu-devel@nongnu.org; Mon, 31 Aug 2020 14:43:13 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=emhLceN4EniX7MxCcMx9QfsIa75mGSAuPTgIuNxLQOQqumELM8pAAIULuj25sMLyY1e2q/56c3bB8Yo3w2H5VPIPAo1zrVSDH+kz/vyxU0zFN9IIeTrXc+oyyTJ9rgrSBf8SifG853zkyTj/w03yGwYJd7zkyjk7WQMWOna+3C6nfU7ZxgNixgDDOJMK96aHl73pR5S0/nYdxmEhQUSUl8Fg5fsnrOL1pSjVxrdxP2GZvU3As5VB0/sz5Vcg+uA2lMDuGKchmvn4N8SbeVQcp+fHZr8Ef7t436nMuOmno/Uw5UWq4Jvi2Tmxm81mIL95e6/ZT1R0WyTz6x2LnXkY4A== 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=lDB+aFGQhxsTmPbYoNcSTI+2GoyqdGwkphCHHSzqwms=; b=UpgTuW4bLfimZOK7wQoqq5ofw5TOyyC1lruCEsMEyyuXMTqXwaXO/pt7gSDMz60j43ZbwB5i81H+x/n9ptGRSZVRqdtftiEeEBgyMguVgq7ZNHmtjANRbvQdb0jxrf87x20BQ80gQIYQqZ6jPcBCvDADLW85XkRf/nf89BWkfzfH1fqqS4Qc6m1GobXNVn8x80uvBUmH1uQnKz1YEkAI+niyYtpnQbDpWEylhVjrs3U4Ftvtlfp6WUGkpwHO1bBUZc0eHiVmidBfi+Yc00DrPIVz5d10bwrfvszEMmPndP7YRMesf1UC7BSUYKIHZbRlgKODI2Oc5tk/D9v2aGhvYg== 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=lDB+aFGQhxsTmPbYoNcSTI+2GoyqdGwkphCHHSzqwms=; b=UZU32BF8upIwOfF/mhxc7cBsVrdiGcVxfzsryku9t7lBJxzyIOa2hr8ylHAwYW1PgPa9mB6qVMxcHKyrxf0FeO46hPE7aBujONBBWOQ9jFjbx1IOojKKAG6pGiXbm1UYCDcDb2mFZkie4Yw3qk9KZKiMrTopY8zdMQgqj1oAZ3o= Authentication-Results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=amd.com; Received: from SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) by SA0PR12MB4383.namprd12.prod.outlook.com (2603:10b6:806:94::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.21; Mon, 31 Aug 2020 18:43:09 +0000 Received: from SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::ccd9:728:9577:200d]) by SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::ccd9:728:9577:200d%4]) with mapi id 15.20.3326.025; Mon, 31 Aug 2020 18:43:09 +0000 Subject: [PATCH v6 10/10] i386: Simplify CPUID_8000_001E for AMD From: Babu Moger To: pbonzini@redhat.com, rth@twiddle.net, ehabkost@redhat.com, imammedo@redhat.com Date: Mon, 31 Aug 2020 13:43:07 -0500 Message-ID: <159889938728.21294.12746724309255308236.stgit@naples-babu.amd.com> In-Reply-To: <159889924378.21294.16494070903874534542.stgit@naples-babu.amd.com> References: <159889924378.21294.16494070903874534542.stgit@naples-babu.amd.com> User-Agent: StGit/unknown-version X-ClientProxiedBy: DM6PR07CA0055.namprd07.prod.outlook.com (2603:10b6:5:74::32) To SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from 255.255.255.255 (255.255.255.255) by DM6PR07CA0055.namprd07.prod.outlook.com (2603:10b6:5:74::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.19 via Frontend Transport; Mon, 31 Aug 2020 18:43:08 +0000 X-Originating-IP: [165.204.78.2] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 7aff72f6-1e80-43f4-dae5-08d84dddb4e0 X-MS-TrafficTypeDiagnostic: SA0PR12MB4383: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: S109gnlkGiCg0FcRHmnbntX6gygULxuo95B/qgXJHtGog+JgoynEXBqQsonGAwt4gQhZOmgszPgA+H9h1lAvN3qpbM2uph+f5Z/JkG6vkDQzc0WHQrF1cQq83WN8AVljb/VMj063SHu2JOKJeiy+ktJfiQ2i0w45h3xdAgn5WiNKIH9U2Be7gQiGQK/IFLsZQFO5SmTrvsqYCKu+25yeAvOTsicvSCV6jvYM49CgdxRCwZ88REK7WmyvWQ1VANwCzfvjwNugHFbjkioEBJfpjMUzXRKiHGdmiAVVHaj5VGrS4mETpXQWfF+PxgiS+i8ZqtYNQKCdw5o/qD8B247bwHMXjWbqNFweoVT6+DfpaSoOLcwyTZ73Kg3Ek1DOmAOC8yA86LgEA0EJbPvIW5rF9A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN1PR12MB2560.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(39860400002)(136003)(376002)(346002)(396003)(316002)(2906002)(26005)(66556008)(478600001)(6486002)(4326008)(186003)(956004)(83380400001)(8676002)(66946007)(86362001)(5660300002)(52116002)(103116003)(8936002)(66476007)(966005)(16576012)(44832011); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Ey5SG05uCzn4M479Sdd/rdyzDi2WC9bS2kM1pWfaM+7c/bmTe9Xrr4GK0v5mNdsxzfQTeQ7Q+N+Mc0eXcxGu+k3ygdfthDCOUW8nsXOoB6JNTuWStvCXuhz5EdOZYSZ3nl4lTfAIN8EHV7DwTFeBqwAvZucsWEXMSlRAjm4r2eH9ZFZvbWjBbizjADD1jfqTEVfJuI8r8QlSVyCQK54EgAKSH2vJ99Eo8NTOiJX3OL7+aADngTb4G/jhxUFSwbvvddKMI9iRZDxlI4kjFe2a2CsqcwNRmL9HRg62DF5h63bZweVf1K+mqVkBt07PXjcgJ/rAH0UZ7+Z4GQ1UtK8d2Byj2q16zzChvhLH5Zziuc8/Q+GJS9GOqNdI8U/xX7X4t59LzjoTQHQhJZMrQIBL/PQR79ULc+Y+3JMw0CHMSXDA3v8hJsEbhA4LyTMuqNKShO28IbKCQVjrIDAiKgRHwfFUONBadq68IaspCEfpXB7Uy2aMT+islyWdI82ze9jRNRbzaOrJYuTlso3dpMt+Kiuvqa1qkBiwn6zTTLViGuCDCrib+bU1+IK4uGNdonFcJqIQDhjY6B4wzGuGMLI7UbyrcPgKi258b4ivtQOnAOgK2I31I4A2OQyK1BVfuAvBbewYBcniKZxHNiIqtD/Mzw== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7aff72f6-1e80-43f4-dae5-08d84dddb4e0 X-MS-Exchange-CrossTenant-AuthSource: SN1PR12MB2560.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2020 18:43:09.2920 (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: M7VnlOYsiuP6PXochLnt6uMBpQAkgQIxEy63uGGs/2tmUd2/You6/5OYvHvx+/kN X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4383 Received-SPF: none client-ip=40.107.93.73; envelope-from=Babu.Moger@amd.com; helo=NAM10-DM6-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/31 14:43:10 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: 4 X-Spam_score: 0.4 X-Spam_bar: / X-Spam_report: (0.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FORGED_SPF_HELO=1, MSGID_FROM_MTA_HEADER=0.001, RCVD_ILLEGAL_IP=1.3, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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: babu.moger@amd.com, qemu-devel@nongnu.org, mst@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" apic_id contains all the information required to build CPUID_8000_001E. core_id and node_id is already part of apic_id generated by x86_topo_ids_from_apicid. Also remove the restriction on number bits on core_id and node_id. Remove all the hardcoded values and replace with generalized fields. Refer the Processor Programming Reference (PPR) documentation available from the bugzilla Link below. Link: https://bugzilla.kernel.org/show_bug.cgi?id=206537 Signed-off-by: Babu Moger Reviewed-by: Igor Mammedov --- target/i386/cpu.c | 195 ++++++++++++----------------------------------------- 1 file changed, 45 insertions(+), 150 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index d434c8545a..ada9ec8f3a 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -338,62 +338,6 @@ static void encode_cache_cpuid80000006(CPUCacheInfo *l2, } } -/* - * Definitions used for building CPUID Leaf 0x8000001D and 0x8000001E - * Please refer to the AMD64 Architecture Programmer’s Manual Volume 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 = DIV_ROUND_UP(nr_cores, MAX_CORES_IN_NODE); - - /* Hardware does not support config with 3 nodes, return 4 in that case */ - return (nodes == 3) ? 4 : nodes; -} - -/* - * Decide the number of cores in a core complex with the given nr_cores using - * 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 also - * 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 <= MAX_CORES_IN_CCX) { - return nr_cores; - } - /* Get the number of nodes required to build this config */ - nodes = 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, X86CPUTopoInfo *topo_info, @@ -434,107 +378,58 @@ static void encode_cache_cpuid8000001d(CPUCacheInfo *cache, (cache->complex_indexing ? CACHE_COMPLEX_IDX : 0); } -/* 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 index - */ -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 = nodes_in_socket(nr_cores); - - cores_in_ccx = cores_in_core_complex(nr_cores); - - topo->node_id = core_id / (cores_in_ccx * MAX_CCX); - topo->ccx_id = (core_id % (cores_in_ccx * MAX_CCX)) / cores_in_ccx; - topo->core_id = core_id % cores_in_ccx; - topo->num_nodes = nodes; -} - /* Encode cache info for CPUID[8000001E] */ -static void encode_topo_cpuid8000001e(CPUState *cs, X86CPU *cpu, - uint32_t *eax, uint32_t *ebx, - uint32_t *ecx, uint32_t *edx) +static void encode_topo_cpuid8000001e(X86CPU *cpu, X86CPUTopoInfo *topo_info, + uint32_t *eax, uint32_t *ebx, + uint32_t *ecx, uint32_t *edx) { - struct core_topology topo = {0}; - unsigned long nodes; - int shift; + X86CPUTopoIDs topo_ids; + + x86_topo_ids_from_apicid(cpu->apic_id, topo_info, &topo_ids); - build_core_topology(cs->nr_cores, cpu->core_id, &topo); *eax = cpu->apic_id; + /* - * CPUID_Fn8000001E_EBX - * 31:16 Reserved - * 15:8 Threads per core (The number of threads per core is - * Threads per core + 1) - * 7:0 Core id (see bit decoding below) - * SMT: - * 4:3 node id - * 2 Core complex id - * 1:0 Core id - * Non SMT: - * 5:4 node id - * 3 Core complex id - * 1:0 Core id + * CPUID_Fn8000001E_EBX [Core Identifiers] (CoreId) + * Read-only. Reset: 0000_XXXXh. + * See Core::X86::Cpuid::ExtApicId. + * Core::X86::Cpuid::CoreId_lthree[1:0]_core[3:0]_thread[1:0]; + * Bits Description + * 31:16 Reserved. + * 15:8 ThreadsPerCore: threads per core. Read-only. Reset: XXh. + * The number of threads per core is ThreadsPerCore+1. + * 7:0 CoreId: core ID. Read-only. Reset: XXh. + * + * NOTE: CoreId is already part of apic_id. Just use it. We can + * use all the 8 bits to represent the core_id here. */ - if (cs->nr_threads - 1) { - *ebx = ((cs->nr_threads - 1) << 8) | (topo.node_id << 3) | - (topo.ccx_id << 2) | topo.core_id; - } else { - *ebx = (topo.node_id << 4) | (topo.ccx_id << 3) | topo.core_id; - } + *ebx = ((topo_info->threads_per_core - 1) << 8) | (topo_ids.core_id & 0xFF); + /* - * CPUID_Fn8000001E_ECX - * 31:11 Reserved - * 10:8 Nodes per processor (Nodes per processor is number of nodes + 1) - * 7:0 Node id (see bit decoding below) - * 2 Socket id - * 1:0 Node id + * CPUID_Fn8000001E_ECX [Node Identifiers] (NodeId) + * Read-only. Reset: 0000_0XXXh. + * Core::X86::Cpuid::NodeId_lthree[1:0]_core[3:0]_thread[1:0]; + * Bits Description + * 31:11 Reserved. + * 10:8 NodesPerProcessor: Node per processor. Read-only. Reset: XXXb. + * ValidValues: + * Value Description + * 000b 1 node per processor. + * 001b 2 nodes per processor. + * 010b Reserved. + * 011b 4 nodes per processor. + * 111b-100b Reserved. + * 7:0 NodeId: Node ID. Read-only. Reset: XXh. + * + * NOTE: Hardware reserves 3 bits for number of nodes per processor. + * But users can create more nodes than the actual hardware can + * support. To genaralize we can use all the upper 8 bits for nodes. + * NodeId is combination of node and socket_id which is already decoded + * in apic_id. Just use it by shifting. */ - if (topo.num_nodes <= 4) { - *ecx = ((topo.num_nodes - 1) << 8) | (cpu->socket_id << 2) | - topo.node_id; - } else { - /* - * Node id fix up. Actual hardware supports up to 4 nodes. But with - * more than 32 cores, we may end up with more than 4 nodes. - * Node id is a combination of socket id and node id. Only requirement - * here is that this number should be unique accross the system. - * Shift the socket id to accommodate more nodes. We dont expect both - * socket id and node id to be big number at the same time. This is not - * an ideal config but we need to to support it. Max nodes we can have - * is 32 (255/8) with 8 cores per node and 255 max cores. We only need - * 5 bits for nodes. Find the left most set bit to represent the total - * number of nodes. find_last_bit returns last set bit(0 based). Left - * shift(+1) the socket id to represent all the nodes. - */ - nodes = topo.num_nodes - 1; - shift = find_last_bit(&nodes, 8); - *ecx = ((topo.num_nodes - 1) << 8) | (cpu->socket_id << (shift + 1)) | - topo.node_id; - } + *ecx = ((topo_info->dies_per_pkg - 1) << 8) | + ((cpu->apic_id >> apicid_die_offset(topo_info)) & 0xFF); + *edx = 0; } @@ -6019,7 +5914,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, break; case 0x8000001E: assert(cpu->core_id <= 255); - encode_topo_cpuid8000001e(cs, cpu, + encode_topo_cpuid8000001e(cpu, &topo_info, eax, ebx, ecx, edx); break; case 0xC0000000: