From patchwork Fri Aug 7 16:32:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 11705941 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D0D41913 for ; Fri, 7 Aug 2020 16:33:25 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 568A920748 for ; Fri, 7 Aug 2020 16:33:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="nZbtE4cK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 568A920748 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:55068 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k45J6-0007Ow-6t for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Aug 2020 12:33:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38542) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k45IZ-0006kn-EN for qemu-devel@nongnu.org; Fri, 07 Aug 2020 12:32:51 -0400 Received: from mail-bn7nam10on2064.outbound.protection.outlook.com ([40.107.92.64]:44064 helo=NAM10-BN7-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 1k45IW-0002VT-NA for qemu-devel@nongnu.org; Fri, 07 Aug 2020 12:32:51 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IsmDTV2ca7ecd457E3Tw9f3r0KF1ArCuSp/ndJAPmP8PP1j2AOiexnlJfua5wb+Ta+5XhJ4juGU3kFFh8BVvkqxugERHJA5HqqnRlyS5ApcSsDjGAMMazM+LY/IXvq0NC9EnMAJdirhVddvxmdz92OnG6XaBDBB//GWOm9fzE1RgDWkL7Zm92TIX/W2QcmDq7w94vYG7Qyg1A+MrkVlLdOVTeGx61ppCKaKiz98BqehtsNP1mfyewexxfTWYU9tK+PKUHMnXQNuSqn8LK4CtFaj61r58Tl7g0qIfJ0l1nARP8oRSMdDpZa7BxSfEcWvgQJRj28+qgQ9OkldAHjID0A== 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=k3Bcud70015EEBHv9exnpqLDea/RqX1ukkWulpKXHYM=; b=GfG1GGLCIaJ40KnLPx6tkVMn5nlOlIBR9o2/LAWaz8StAhZS6bO2UNBiJMQZXJ2N/Raxh8K6bQ8HriFSwJLrQr8AcdEeYiOPvg8hLHTSqtSik+/BugJqgTNMdPFZqYfSb1gVqv2trwRhoaXP7PsVMJEcdxgqWmJ5Fb3fCCtXEQi7Mtvz9BXwgzq3GjM5+ZRMTDJfj+hHg0ts5qQPsR7aysegDx7eEpl6uiHvJTwTWbh9EuFa2woSAHgy3L5youj3eKoii0xgIAz5esPkQ5tg9CPgTXP73LKdH7+3qJ1qrxHZOUV/tQozXrKQlgrI6kK1Ybm+zF6AIEjFRXV3aZehyw== 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=k3Bcud70015EEBHv9exnpqLDea/RqX1ukkWulpKXHYM=; b=nZbtE4cKWtY3ltXZZ5VGw/3IcK8LIlr2vrJ5yoTpRgGGipJVOGgjIgEcwrJtF1R7Vjn3RWOoRmWoHBITO/2PDekK/9L+PtkzEM4svSq5wctQLIvdkHL4EfbPivLhLEpniJTtSl4xaxX7cvDdkq4GALDJxGp74cgoelIR9FRgi/M= 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 SN1PR12MB2429.namprd12.prod.outlook.com (2603:10b6:802:26::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.19; Fri, 7 Aug 2020 16:32:46 +0000 Received: from SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::691c:c75:7cc2:7f2c]) by SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::691c:c75:7cc2:7f2c%6]) with mapi id 15.20.3239.024; Fri, 7 Aug 2020 16:32:46 +0000 Subject: [PATCH v3 1/3] i386: Simplify CPUID_8000_001E for AMD From: Babu Moger To: pbonzini@redhat.com, rth@twiddle.net, ehabkost@redhat.com, imammedo@redhat.com Date: Fri, 07 Aug 2020 11:32:45 -0500 Message-ID: <159681796533.9679.8403552849052625336.stgit@naples-babu.amd.com> In-Reply-To: <159681772267.9679.1334429994189974662.stgit@naples-babu.amd.com> References: <159681772267.9679.1334429994189974662.stgit@naples-babu.amd.com> User-Agent: StGit/unknown-version X-ClientProxiedBy: SN4PR0201CA0070.namprd02.prod.outlook.com (2603:10b6:803:20::32) To SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from naples-babu.amd.com (165.204.78.2) by SN4PR0201CA0070.namprd02.prod.outlook.com (2603:10b6:803:20::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.20 via Frontend Transport; Fri, 7 Aug 2020 16:32:46 +0000 X-Originating-IP: [165.204.78.2] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 6f5b9451-2f28-4c30-2b09-08d83aef8443 X-MS-TrafficTypeDiagnostic: SN1PR12MB2429: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yUTXmbZCQEbMtruFPwgJAlzM9o3URVgohc7lvQfc11aveK5OUsdcpcd5odouVHiW0/LB1vB1dGuS0xcNn6Hh7D0J3GlOZS91o1gfe0//h3qJb6VPDEjXC1UsVJvc12D66p436Y/YGcmt+HdgKl7sJlR1bu+qqTjHFTNQgKz+SkCp0fIslhZB91BmRiy1znYLMvj1lLF/HmZ2ZBwVAJbWfpTSg/okUJZ2LgqF2dBR7FVbfI1StbxQaSskblJar55QVpdnQ6TQjxDVzLaWv82kJrqJv98CbhShOAcn5ndDWJpV8gDr+2jKFIHvcOzaOEkl 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; SFTY:; SFS:(4636009)(396003)(366004)(346002)(136003)(376002)(39860400002)(2906002)(52116002)(7696005)(66946007)(478600001)(316002)(55016002)(16526019)(26005)(186003)(86362001)(44832011)(956004)(103116003)(66556008)(66476007)(4326008)(8676002)(8936002)(5660300002)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 1WU2dFa+xsy7r350uiFmS4NCboPDkfZfX+Qi5QxCwRDqdZ83ZmHqcZV3A+QBfN26/l1WXEtgwfj3r1/rPs/dpZ9xZSW8aD2vkqj8tX7t9BfWhac8pIjvQqEG/5kenomyCSJaS8D9Xfo0z3QL0u7egPFsH7MD2HqXoYqpFHlY2+k5f0i3F9UOqY28u5LDAVy1hLgKdkjy40ryX+GzRhQBB3WVUfwzdc4Z9hQnuosVulPt+I6kVbIQvqbtq5v7ATMbI/wT5owfhNuFK2mAz0T8+LAINYExOOeo1b9t7NOnby+ANaALuF4uX40XbfKnCxL5VXN4msTjNxaLuhKWa04+XzGRZh9nX7Ja6VBQkjcjEL8Wt0aVnBgq8n55vsiUkTdIkoY9oycTXeXNJA/s86xXfGyvGO4tWHcuEkJneVXloIq3sl0xQunWPh316JLj80RlzgHJJQKnPR15NWBmw7Q6j6WQ3vP+iaLOZSs2t7Gr03f8r9Ux9GKNcarmMyW2n9WMIf9KNvUag76bEqxhp/B4YMZQ+SNUIOSMGD2NPSQMYyvFw5UoOeFF4gwveQFo7YVgwad3bDILEjTxSE97UmnNsSMbHnF/few+imn7Kdjf3vJDliESwUFqfO75QtzOlrprIr/1R8i1PMPJw0uaoOSpNw== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6f5b9451-2f28-4c30-2b09-08d83aef8443 X-MS-Exchange-CrossTenant-AuthSource: SN1PR12MB2560.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2020 16:32:46.4483 (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: ywRcCx2WYo0C+MYsIiEIyy4pEC0UAF3igwKBpaQ3QUkfKcWcL24bnl1ru4fXVMSH X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2429 Received-SPF: none client-ip=40.107.92.64; envelope-from=Babu.Moger@amd.com; helo=NAM10-BN7-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/07 12:32:47 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=ham 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: qemu-devel@nongnu.org, mst@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" apic_id contains all the information required to build CPUID_8000_001E. 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. Signed-off-by: Babu Moger Reviewed-by: Igor Mammedov --- target/i386/cpu.c | 77 +++++++++++++++++++++++++---------------------------- 1 file changed, 36 insertions(+), 41 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 588f32e136..c892432cae 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -388,57 +388,52 @@ static void encode_topo_cpuid8000001e(X86CPUTopoInfo *topo_info, X86CPU *cpu, { X86CPUTopoIDs topo_ids = {0}; unsigned long nodes = MAX(topo_info->nodes_per_pkg, 1); - int shift; x86_topo_ids_from_apicid_epyc(cpu->apic_id, topo_info, &topo_ids); *eax = cpu->apic_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]; * 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 + * 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. */ - *ebx = ((topo_info->threads_per_core - 1) << 8) | (topo_ids.node_id << 3) | - (topo_ids.core_id); + *ebx = ((topo_info->threads_per_core - 1) << 8) | (topo_ids.core_id & 0xFF); + /* + * CPUID_Fn8000001E_ECX [Node Identifiers] (NodeId) + * Read-only. Reset: 0000_0XXXh. + * Core::X86::Cpuid::NodeId_lthree[1:0]_core[3:0]_thread[1:0]; * 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 + * 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 (nodes <= 4) { - *ecx = ((nodes - 1) << 8) | (topo_ids.pkg_id << 2) | topo_ids.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 -= 1; - shift = find_last_bit(&nodes, 8); - *ecx = (nodes << 8) | (topo_ids.pkg_id << (shift + 1)) | - topo_ids.node_id; - } + *ecx = ((nodes - 1) << 8) | cpu->node_id; *edx = 0; } From patchwork Fri Aug 7 16:32:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 11705945 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 66144913 for ; Fri, 7 Aug 2020 16:34:14 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3D44420866 for ; Fri, 7 Aug 2020 16:34:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="Jnkgs+ry" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3D44420866 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:58398 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k45Jt-0000TO-Ia for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Aug 2020 12:34:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38640) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k45JB-0007Y9-Fc for qemu-devel@nongnu.org; Fri, 07 Aug 2020 12:33:29 -0400 Received: from mail-dm6nam11on2082.outbound.protection.outlook.com ([40.107.223.82]:39489 helo=NAM11-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 1k45J9-0002Ws-Le for qemu-devel@nongnu.org; Fri, 07 Aug 2020 12:33:29 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kSnM9Sc4T7Okl/9GzsXhUsheKAEZJXQX8nV1ejEhmZVuW8InpZMkHoMdciV6c9oXuZ/S2gxEx4htad9Y6i3SMvCD9fs8euQNLy8yf+36nycKFLw8S4wQofD+Ynl1QqxyczFUCG1pK+53eYOTcVjBcOjYoBP68IaNXuzsfSUJJFrFelIcqLwhn+Nv4yokvbF7vYE4/1bJO7d/tl5E0cTwh4srvX5IWUO4BEDcv0zZeR/D5bJ2piFQOw8SS8FuAsv3tnQcZI7FioYvzraXim4MnJq0aTXW2e5bRBqP7bEvhQ6DB2VWfhwKaH7HFpRecnG3pNU45gglkBn36MyPiBSRlw== 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=rkLmVVs3L0O/fLjJqOAg8Ywgwxf5Pcz1jgHg94mTQJw=; b=gZAYztpgho6zZ7JJyKYcKrwLVDfj9WE18IAME38L5RCUSWKE2ORVzb2X133X+q+zTEJPQbNlLKKIVyhM327Ymz6KTC2kBo1I0Jn2HOwCVtD/M8NuBDnE0B3bgUzCksBcLsRmoQOso5r/0q4Etur6KIx5tP4gHAzgeygihajoRLReemiBJ8CJ/ix5RVv48K9gfi/+PZ6tEtN6tBjc/xCXTnnP6abfzxltb8sd/j0X5jQOMajpAmxWMkwcLmp5Y7P+5u8cP224tbwgltto/7AH9dCwrn1Q/02M0qPPa1VLukxpWPUlppvgqBAIRYY8y14MuIvB2qPasTJ/8iFFILixOQ== 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=rkLmVVs3L0O/fLjJqOAg8Ywgwxf5Pcz1jgHg94mTQJw=; b=Jnkgs+ryHHE3o0CThpasjUrJZPMThLNlz08cJr6DuiSC4WNgFtjDhtlX6NVaA/gz9/nM5vWonNeCQtYhSHHZeON6cyd5qd1ikwo24mEq0Nhg3s1Drqv15fsnB9kv6WYyYckJ0djS10WVy4QI4c/N40SrKOtirQ05uR3ktrCsx+0= 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 SA0PR12MB4414.namprd12.prod.outlook.com (2603:10b6:806:9a::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.19; Fri, 7 Aug 2020 16:32:52 +0000 Received: from SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::691c:c75:7cc2:7f2c]) by SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::691c:c75:7cc2:7f2c%6]) with mapi id 15.20.3239.024; Fri, 7 Aug 2020 16:32:52 +0000 Subject: [PATCH v3 2/3] hw/i386: Add a new check to configure smp dies for EPYC From: Babu Moger To: pbonzini@redhat.com, rth@twiddle.net, ehabkost@redhat.com, imammedo@redhat.com Date: Fri, 07 Aug 2020 11:32:51 -0500 Message-ID: <159681797161.9679.5653247810916709875.stgit@naples-babu.amd.com> In-Reply-To: <159681772267.9679.1334429994189974662.stgit@naples-babu.amd.com> References: <159681772267.9679.1334429994189974662.stgit@naples-babu.amd.com> User-Agent: StGit/unknown-version X-ClientProxiedBy: SN4PR0601CA0019.namprd06.prod.outlook.com (2603:10b6:803:2f::29) To SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from naples-babu.amd.com (165.204.78.2) by SN4PR0601CA0019.namprd06.prod.outlook.com (2603:10b6:803:2f::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.19 via Frontend Transport; Fri, 7 Aug 2020 16:32:52 +0000 X-Originating-IP: [165.204.78.2] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 4cc0b257-3114-41bf-c351-08d83aef87f1 X-MS-TrafficTypeDiagnostic: SA0PR12MB4414: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4941; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3qHvooYr8Ma48FaZN0D5GvxIu2KKb3ux0XZ49k16dIT2NuGcGhzwszhpSJaQc40WYp5tqxY70TAGRnaG3sE/f4pvAE5fWr9H3GEFGXCcMzCWe8dML/B3Nitik8DfCS0URJh1dEynk3ZcYlTwsIY4JJjALJQ+ojdgFDTZSPCQk2MYkw5xy7UfSiGQ97LVvd5ECGRYxNAfIx3TB4j7XXe9B3Jdv4MWk+wTvG+SuRvKf7S0X4DBQ05k16miEeM30Tz/hTVe8ogxHdVk2PgrR44kGefTOlqrdtJSqG7pHmerqlnUNtKLpaactdMr9uPP9WfVgyU2FhiHrwfuiFWY6FJCuQ== 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; SFTY:; SFS:(4636009)(366004)(136003)(376002)(396003)(39860400002)(346002)(66476007)(66556008)(103116003)(66946007)(8936002)(4744005)(316002)(8676002)(186003)(478600001)(16526019)(86362001)(956004)(7696005)(52116002)(2906002)(5660300002)(44832011)(26005)(4326008)(55016002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: rTAGx/hYhEbA4YJpL/4dBTd+JxSl4zb4cVYxy0PeDADrzHwSvcQzDm7bdfd8R41TZo9vTvW3na7Anj4Eepr9KNjs8dECd6CX03zRda5Vm7WqFY/SfHI6JBpN7oxneEbCM8dQy/bFln5YqE24LIf1Uz1BC/RTYbgsgqlTevMXC+s3YQvu++k8SG9B3SC2xLw2NMwmJJP9BCPgePToW7tADZDHigpON8EOVPMlaOj4V5isyApesGOlHfJN1wvB3J/r+VgzVMsH7ZWWA8vpO7Epfg4Dh6gAp78mAAFM0b4NgnPb1P+pOuaOth1Y3zeRfmCf4XDj0OM16iMSiImzhb7+XZnToJxCD9t9R8N3pXe9NoamB9T/WK2v8lre4eZhmHN/Ti6BpB3VM3fWYMc2uh8vprs4HYJqy1a/3ShZXGB7WiCyEfErmkYE6FTWeiScSodcP/k1MvcR+42WOB6ISTgFacIrfOBebXC52axc3r79U1mv2h9giIW3fTPrHVcyAxWDai8Zj4d+ZJE4v1XUL4n6CpHnmfb/3wocKCpVyXkuF4SzCQvaRjC8GUeJ63pbNoi6u7sv0GHs8Q1Bspqx+n2YycPE4posxWnYUHy2Xa0r+JIHuZJuDh0V5oxKUHgrmVEmwZ2VyjKjmt9T02QeBDeqIg== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4cc0b257-3114-41bf-c351-08d83aef87f1 X-MS-Exchange-CrossTenant-AuthSource: SN1PR12MB2560.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2020 16:32:52.6407 (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: gzKxIStCOML1JkIiLwT9tTFrraIhHWlzGM/dTLRwkMaBJBpqsN1Q0iTvJKOXHmoP X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4414 Received-SPF: none client-ip=40.107.223.82; envelope-from=Babu.Moger@amd.com; helo=NAM11-DM6-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/07 12:33:26 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=ham 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: qemu-devel@nongnu.org, mst@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Adding a new check to warn the users to configure 'dies' when topology is numa configured. It makes it easy to build the topology for EPYC models. Signed-off-by: Babu Moger --- hw/i386/x86.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/i386/x86.c b/hw/i386/x86.c index 67bee1bcb8..2a6ce56ef1 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -138,6 +138,13 @@ void x86_cpus_init(X86MachineState *x86ms, int default_cpu_version) /* Check for apicid encoding */ if (cpu_x86_use_epyc_apic_id_encoding(ms->cpu_type)) { + if ((ms->numa_state->num_nodes > 0) && + ms->numa_state->num_nodes != (ms->smp.sockets * x86ms->smp_dies)) { + error_setg(&error_fatal, "Numa configuration requires smp 'dies' " + "parameter. Configure the cpu topology properly with " + "max_cpus = sockets * dies * cores * threads"); + return; + } x86_set_epyc_topo_handlers(ms); } From patchwork Fri Aug 7 16:32:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 11705943 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1D7C4913 for ; Fri, 7 Aug 2020 16:33:41 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D877720748 for ; Fri, 7 Aug 2020 16:33:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="we2WWaXD" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D877720748 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:56186 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k45JM-0007qk-2i for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Aug 2020 12:33:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38596) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k45Ik-0006uG-Gs for qemu-devel@nongnu.org; Fri, 07 Aug 2020 12:33:02 -0400 Received: from mail-bn7nam10on2074.outbound.protection.outlook.com ([40.107.92.74]:60938 helo=NAM10-BN7-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 1k45Ii-0002WB-KE for qemu-devel@nongnu.org; Fri, 07 Aug 2020 12:33:02 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m7PPSVi3sSnKT2dsd2HZxtRxJA8l/5wf9Swt9j5TRYqT7GC5EJpuGGBzHOKeFIhA0SfRIlQZUUXzQBTIKB8fvt4Fm3MAIzDysXYiMbPjnrUyCWzDx6RpD4zv2ODmmqhAHWmmggoyTqi18o30kViQmJwF5qUN9Yuqz4v09XTlH3BGPoFOFCme71FqrQJEMuyR8T1nUelZvUMU80qCLf3LUtGFYKI11DGwsJeaKwZEZtFM8kFmwhr4mUtpNji3gVaH/qBA7AI0sdzsL6Z0BChDd+jjYPzhl2IAY5+nxjsa6KStECjitvX+pJ47GQOtCYcMH0adtBPCbEWdJ7YylGEzKA== 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=UOETgrYAYM2orICWPNZ+UfikKBv7UJQ7NmE/ajZzujY=; b=Q7AjIPSYMJnvU0rC+7ZrxC/JY9ncRLnIoCFmP1jGrzNlIwWhCjmrIxBcts+Fdy2Lss1WnJeDtwdefxIwmQbnMQFrkCE2voiNExcbqZFf8qMhjckzpPiHrmLc+BQGA4Hf/i/7CMZFGzpgWadX1sdtavZeQ9DXEIPeXW8kLqAA80kmUXqLccNjdJJuoqCVo/MXw6CF0Q2HiFpog9j0D0LoFUU/iDGamRcnVDz2fSWqdHc0o6eIe9JyQkT4/RJ0eemhCax/FfedrVwcOKzOrQjUSXpPzWAap82ed7GbpJRJ2O3D5Riv8zx6eVDYr3wPrNMTYSBh10nMkPRZsMDHEupYEA== 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=UOETgrYAYM2orICWPNZ+UfikKBv7UJQ7NmE/ajZzujY=; b=we2WWaXD1X39rJTrqbo3IpTPrPB2sD1AEYsTE5RXRpHvfZM2wEH0mKrNzqqYok+DJ3GOWoyKSNkD0Y7MHza/FiXgIzyvPF5kspXTcuBm2FuV6EyFesKMg2bWsLQC66JtwXnqS8h0ODYtxcFf2u+qdpOgEATjezq/K08TxWI+JZQ= 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 SN1PR12MB2429.namprd12.prod.outlook.com (2603:10b6:802:26::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.19; Fri, 7 Aug 2020 16:32:59 +0000 Received: from SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::691c:c75:7cc2:7f2c]) by SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::691c:c75:7cc2:7f2c%6]) with mapi id 15.20.3239.024; Fri, 7 Aug 2020 16:32:59 +0000 Subject: [PATCH v3 3/3] hw/i386: Remove node_id, nr_nodes and nodes_per_pkg from topology From: Babu Moger To: pbonzini@redhat.com, rth@twiddle.net, ehabkost@redhat.com, imammedo@redhat.com Date: Fri, 07 Aug 2020 11:32:57 -0500 Message-ID: <159681797783.9679.18340388367001883091.stgit@naples-babu.amd.com> In-Reply-To: <159681772267.9679.1334429994189974662.stgit@naples-babu.amd.com> References: <159681772267.9679.1334429994189974662.stgit@naples-babu.amd.com> User-Agent: StGit/unknown-version X-ClientProxiedBy: SN6PR2101CA0017.namprd21.prod.outlook.com (2603:10b6:805:106::27) To SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from naples-babu.amd.com (165.204.78.2) by SN6PR2101CA0017.namprd21.prod.outlook.com (2603:10b6:805:106::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.1 via Frontend Transport; Fri, 7 Aug 2020 16:32:58 +0000 X-Originating-IP: [165.204.78.2] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: b67245e4-a233-4b91-1a5f-08d83aef8ba3 X-MS-TrafficTypeDiagnostic: SN1PR12MB2429: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:758; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HQmFMZntp49L0HW2sheNKQrYd36wPZxmQ+CwEJv77KxIXJqRW9trZmpUx0Br7YE7br2BE64ko4rRQFZ8OLOcr/Aky6W9ewtYlz0AYiVRpwn2gN8QQS4nYb4Qufc7YDX0sSUi/MeDAEXUBxyz1yQRzCo38SSBUxZkotoiudHdk/x6iT0Ct1X2V91p92E7jHS4KeshPmpTAaauqWsbPpNRT0n1zb7Nk1bpEn/r6vTZedI5Bqn53L/0MNfGVr13Y/TOJqfdhWY4vO753wQI0feGm7JhguezDo7rcqH7ObU2NkImphH1xiSbiD7ew1e1QSkB 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; SFTY:; SFS:(4636009)(396003)(366004)(346002)(136003)(376002)(39860400002)(2906002)(52116002)(7696005)(66946007)(478600001)(316002)(55016002)(16526019)(26005)(186003)(86362001)(44832011)(956004)(103116003)(66556008)(66476007)(4326008)(8676002)(8936002)(5660300002)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: HxBAjWTUgVlUZ6K698hjMOe8CuzDMVNj9wOFx6PWSJgMa1UHxjAOWNP/DLLaFNkXkpVJg1X7APYZJGAsMPtykVZxA+WBIBYBFdLX6e13E16+prfJ6tCvx1+3eDvmxKlTNGxRBTWuKZ4EnODcL6RLNbOWtYJDSLzt88GSnN4dD42iVMLgGEx5waX//jK+Xq9XMm2wJAgUy0RbbCsqlta73tWbTHpr5k7uHB69ssmf1ZP9FJKyRi3+vvscOvFEPdj5qqdU6jctTYNgjin+gCIm6hq43mQ8Ir0Vy8C0y25nw07tCwrKdaONmeHTVNes+bVeYpCNL0/7zybb8S6xa7DZF5ngvAOu/ABCRvDHY/hLzsrPsPRVAk6trNU3i7ihjEpcnH8wikEN7My/jRwIlLDa1jQsdq3osbgUlwIUNwfXad8nWuUV6kSEPkuZT+0MA6NRXkDhKmg40nwy9EiSOw17RCe1z7LiOWT2GdOCC3R2HjQ4P+YHBU5H1jwsh3NCnT8Yre9en7T1FJ16NzJUCDX/1udPccf3ULxo0y96XDr9iNjXVH1kb9Z4Hj+Tkl1gpfU0btUtY8AKrP0JMh9mOCtYc37VHAQl2M+j0MHaiT0xeUvasQ0JaJAgOvs+X31IVlyTS4KRSKL+tChGkKvzkV6OfQ== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: b67245e4-a233-4b91-1a5f-08d83aef8ba3 X-MS-Exchange-CrossTenant-AuthSource: SN1PR12MB2560.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2020 16:32:58.8531 (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: fAvXRY5LAhCBY70iiFsrGR0wEH770Kf4oNXoSONGZRooWidfR/Xw2ptgPoZJ+79U X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2429 Received-SPF: none client-ip=40.107.92.74; envelope-from=Babu.Moger@amd.com; helo=NAM10-BN7-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/07 12:32:59 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=ham 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: qemu-devel@nongnu.org, mst@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Remove node_id, nr_nodes and nodes_per_pkg from topology. Use die_id, nr_dies and dies_per_pkg which is already available. Removes the confusion over two variables. Signed-off-by: Babu Moger --- hw/i386/pc.c | 1 - hw/i386/x86.c | 1 - include/hw/i386/topology.h | 40 +++++++++------------------------------- target/i386/cpu.c | 11 +++-------- target/i386/cpu.h | 1 - 5 files changed, 12 insertions(+), 42 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 47c5ca3e34..0ae5cb3af4 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1498,7 +1498,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; env->pkg_offset = x86ms->apicid_pkg_offset(&topo_info); /* diff --git a/hw/i386/x86.c b/hw/i386/x86.c index 2a6ce56ef1..3ac46960db 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 07239f95f4..05ddde7ba0 100644 --- a/include/hw/i386/topology.h +++ b/include/hw/i386/topology.h @@ -47,14 +47,12 @@ typedef uint32_t apic_id_t; typedef struct X86CPUTopoIDs { unsigned pkg_id; - unsigned node_id; unsigned die_id; unsigned core_id; unsigned smt_id; } X86CPUTopoIDs; typedef struct X86CPUTopoInfo { - unsigned nodes_per_pkg; unsigned dies_per_pkg; unsigned cores_per_die; unsigned threads_per_core; @@ -89,11 +87,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,30 +107,23 @@ 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 */ +#define EPYC_DIE_OFFSET 3 /* Minimum die_id offset if numa configured */ /* - * Bit offset of the node_id field - * - * Make sure nodes_per_pkg > 0 if numa configured else zero. + * Bit offset of the die_id field */ -static inline unsigned apicid_node_offset_epyc(X86CPUTopoInfo *topo_info) +static inline unsigned apicid_die_offset_epyc(X86CPUTopoInfo *topo_info) { - unsigned offset = apicid_die_offset(topo_info) + - apicid_die_width(topo_info); + unsigned offset = apicid_core_offset(topo_info) + + apicid_core_width(topo_info); - if (topo_info->nodes_per_pkg) { - return MAX(NODE_ID_OFFSET, offset); - } else { - return offset; - } + return MAX(EPYC_DIE_OFFSET, 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); + return apicid_die_offset_epyc(topo_info) + apicid_die_width(topo_info); } /* @@ -150,8 +136,7 @@ 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->die_id << apicid_die_offset_epyc(topo_info)) | (topo_ids->core_id << apicid_core_offset(topo_info)) | topo_ids->smt_id; } @@ -160,15 +145,11 @@ 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; @@ -188,11 +169,8 @@ static inline void x86_topo_ids_from_apicid_epyc(apic_id_t apicid, (apicid >> apicid_core_offset(topo_info)) & ~(0xFFFFFFFFUL << apicid_core_width(topo_info)); topo_ids->die_id = - (apicid >> apicid_die_offset(topo_info)) & + (apicid >> apicid_die_offset_epyc(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); } diff --git a/target/i386/cpu.c b/target/i386/cpu.c index c892432cae..ba0a24f6b8 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -345,7 +345,6 @@ static void encode_cache_cpuid8000001d(CPUCacheInfo *cache, 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,10 +354,9 @@ 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 * + l3_cores = DIV_ROUND_UP((topo_info->cores_per_die * topo_info->threads_per_core), - nodes); + topo_info->dies_per_pkg); *eax |= (l3_cores - 1) << 14; } else { *eax |= ((topo_info->threads_per_core - 1) << 14); @@ -387,7 +385,6 @@ static void encode_topo_cpuid8000001e(X86CPUTopoInfo *topo_info, X86CPU *cpu, uint32_t *ecx, uint32_t *edx) { X86CPUTopoIDs topo_ids = {0}; - unsigned long nodes = MAX(topo_info->nodes_per_pkg, 1); x86_topo_ids_from_apicid_epyc(cpu->apic_id, topo_info, &topo_ids); @@ -433,7 +430,7 @@ static void encode_topo_cpuid8000001e(X86CPUTopoInfo *topo_info, X86CPU *cpu, * NodeId is combination of node and socket_id which is already decoded * in apic_id. Just use it by shifting. */ - *ecx = ((nodes - 1) << 8) | cpu->node_id; + *ecx = ((topo_info->dies_per_pkg - 1) << 8) | cpu->node_id; *edx = 0; } @@ -5484,7 +5481,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; @@ -6944,7 +6940,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 e1a5c174dc..4c89bee8d1 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; unsigned pkg_offset; } CPUX86State;