From patchwork Fri Jun 15 17:15:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 10467145 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0A9756020F for ; Fri, 15 Jun 2018 17:17:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF22428E14 for ; Fri, 15 Jun 2018 17:17:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E1AC728E16; Fri, 15 Jun 2018 17:17:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 68B0728E14 for ; Fri, 15 Jun 2018 17:17:43 +0000 (UTC) Received: from localhost ([::1]:48475 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTsM2-0007QT-N5 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 15 Jun 2018 13:17:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53294) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTsKV-0006Hi-2f for qemu-devel@nongnu.org; Fri, 15 Jun 2018 13:16:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTsKP-0007SU-2J for qemu-devel@nongnu.org; Fri, 15 Jun 2018 13:16:07 -0400 Received: from mail-eopbgr730053.outbound.protection.outlook.com ([40.107.73.53]:16992 helo=NAM05-DM3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fTsKO-0007R7-SU for qemu-devel@nongnu.org; Fri, 15 Jun 2018 13:16:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jmr3pEmNFqH1zeWrkQsaojO/Zvbbx5yFwLB8iYeefS4=; b=CWB4MF4YVN+Zt6s9fnewRJOxW3Fk/u6sVciVmc4QPX+VsKahRK34/yQB2nNJJRQYwrqhhJTsi8snmFviACzQk0PffKOhmqdJ8iulwvDb8Y+ayzs+ZNPhrc7wh/UzdxFEgmFgURxvysBoKvvPHRuNAKTq9/0PG1BBMb7fVAhBd0g= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Babu.Moger@amd.com; Received: from linux-h3ml.amd.com (165.204.77.1) by DM5PR12MB2471.namprd12.prod.outlook.com (2603:10b6:4:b5::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.863.14; Fri, 15 Jun 2018 17:15:57 +0000 From: Babu Moger To: mst@redhat.com, marcel.apfelbaum@gmail.com, pbonzini@redhat.com, rth@twiddle.net, ehabkost@redhat.com Date: Fri, 15 Jun 2018 13:15:45 -0400 Message-Id: <1529082947-60001-2-git-send-email-babu.moger@amd.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1529082947-60001-1-git-send-email-babu.moger@amd.com> References: <1529082947-60001-1-git-send-email-babu.moger@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: SN4PR0201CA0010.namprd02.prod.outlook.com (2603:10b6:803:2b::20) To DM5PR12MB2471.namprd12.prod.outlook.com (2603:10b6:4:b5::10) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4213841f-944a-432c-9104-08d5d2e3a965 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(711020)(48565401081)(2017052603328)(7153060)(7193020); SRVR:DM5PR12MB2471; X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB2471; 3:le9WYQa2om6dkvn+wLVJnttiLlEWO4bH8lAGyjNbD+l4s5F12mvwG8VdlaXMbSpxKOPUQD1sTM28BE5RM/ZtQ3mcnvaHHhL/tfHFA8EIu+eyxXbTGUOpxxJ8JmOCE5r2BDrV8QRRvnhAR/1+h7AIDdzpqKaoDwvwbFgia6SYKxb9wLVZCHp58oV/gHHNlx1+ZKCo9uARdhyjMHOS7+xwFZY711kUytXuy47HhANDSGnX96Ra12J8eqjERPf7O+jo; 25:/dYgaSxuzPP4sRA4PDkrZ+tO4JzGzctK8XGTKeol3fRtPGP/7fi9ncqhb5tPNj6H1phc8n1Ji9rXNQdVvj1wDifd1Ame6+qvYymqcyLJ4Qmuv8pMo28SnJDIMfeciNoUTqQVROLs/sVEzwBhDaBuNlWPlwnKWAQn/9Y3/aC2t42QEspqPvbyUdIyLGjepVLzqGqZm9tFbot1qBFR0ICQnxJivPFgP9T7l/3/rBXx6e5ru+yU0FNJuZ2CR9fMsKp4mGJ7p90faP9rcnBG8hA4NTVyIbs218XAtxtRI0hnhFXn5Hwcw0njjtCvr98/ck27tKfNi4T/O32TDaELvftjpQ==; 31:SEJwJvW23r3pziOaIOzCzBGPkVg79E4pzBi2J4P55BCGSXTJViZHh0jdn5yqDEWoHasDzGeWzgMDcCI6JifMcw0qcPXzR9fy6K1Mgqp5VcrL7weAD7V0pZ5Pp8bVXpuk2QYpiVYJcW6c8AzJPh8BLYGr0vEbW1vBs0IPTP57zIFHaw0jRz3edtF1vklgg/AKyQsuPL3mdE0KQD2/j1zRhYpDFSz2kSFCIn5Ybn/4EcU= X-MS-TrafficTypeDiagnostic: DM5PR12MB2471: X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB2471; 20:38//eZbO54L+mjEie+8TGY4yl6pZBBbhkkeF7F1YFTqrJ69Ym4RT0pQe8lmpIV9qcLSuHzkEYpnhrJWUuLA1oab9UOzJOFNwKgZJSfMLY9E3f3bnIdH/20YPGpJVNAW0gkjUtwA085rjT32fYe+7mxFELlIRoGfDIKBFmpVQjRCOCUnVGArldqjSnL0L9nOP+YGpUKVgH7ZYvfOLj/PECBW/EQ85SU7CtaAagmjg606a+tSefhKJJj6giX4DEw0KIc4vx4Yq3j68M1hHltg1bQb5s17q1p0X8NBusTkqbr3Ztz0rPnQJAjKsOBpN6+7Wv5Ui3XmirBRY0OO2coopiMBWe8B1SY7HvEq9tbZfTieGqg08NDWZ5TcTgV+vKbDIcrqi/rNRxwDr6CfANwWaNMRYqD3uYRCJQ/e8vu3SjWsjhDQQrL843/6eq+zdOxOBVdFCwK9fQ0Ec5P3iF5nSjuz8GMZtv2Ej6LKueOTELGT3vyaKgjnC0Q6BDwxgqvSl; 4:fXSJzDObo9S+lZjQXNTDn7cAX5O4VYNR3oa43G460KHTdruz9955GNuOsofuKUWnKF/5YzZXusa12TwOD1km1bN8PrORWGOSgwv3iTxenrhc6PiAPkpqmNwcbGwCs9GeQT2WpHFPJy644lGTazaswzAOHbV12A1G+cQLQy49snJHkyv3gWgsUep/NgMXhEyA6J0jqSEkOovZANnsBpmVZ6HGJivExWaWPfL1GS44jZXi+A5IXviaTKuRm5fxXtLoNFdVPooZzZsIrO2fWv1pMJL9xc23/nHuKlW5xRec4OBlIhnDsPJ7gouw2J7RFxf2 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(10201501046)(93006095)(93001095)(3231254)(944501410)(52105095)(3002001)(6055026)(149027)(150027)(6041310)(20161123562045)(20161123564045)(20161123560045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:DM5PR12MB2471; BCL:0; PCL:0; RULEID:; SRVR:DM5PR12MB2471; X-Forefront-PRVS: 0704670F76 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(376002)(39860400002)(346002)(366004)(39380400002)(396003)(189003)(199004)(186003)(66066001)(6666003)(86362001)(5660300001)(8676002)(68736007)(47776003)(36756003)(478600001)(7416002)(81166006)(26005)(50226002)(48376002)(59450400001)(386003)(6486002)(16526019)(50466002)(81156014)(4720700003)(72206003)(25786009)(76176011)(51416003)(316002)(446003)(52116002)(8936002)(7696005)(4326008)(53936002)(3846002)(11346002)(305945005)(6116002)(7736002)(956004)(476003)(2616005)(97736004)(2906002)(486006)(53416004)(106356001)(44832011)(39060400002)(105586002)(16586007); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR12MB2471; H:linux-h3ml.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR12MB2471; 23:HPocQu70C8E+y9elSYzKWTarykAZdIftyeUwPksX+?= =?us-ascii?Q?ALxJfvYjZR1SYycF7O5ZAj0gemdxml500jPGYALJ2CwYRPVI4rDkPXxrP0K7?= =?us-ascii?Q?h8tUu08lfrGx/UdP1RjvlVVSAir/vH+gaEH2Omxo9UtBYziL+HjJF8zdmsMZ?= =?us-ascii?Q?R3/4eits+onTtMjfCxldzDX5FoBpiecXWv77yKEbFAMSzKcPaWchfr65Reie?= =?us-ascii?Q?QzWDpAqsfxFwB7IDDPfBASCeZ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RkvDFgFgX15bt0bQVAfQn69j+RL49GvyKwTeDtGYqQc5gs4pPaANRH0mwUrYqYmV+UXpFJMgMjBstv3rJkb1kU130=; 24:CD8lAfFHLC5SFsttoAwlluxV2tqb4O07rxCoLbv2LJS44e1Or094oB/h4+8yIMT9j7MWia+KWVL/ozhjvqiEGx9wKGB5u/kzcr6NIyz6POY= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB2471; 7:zzTupXiWG+Me0KUgc4/oQVz/0s+K8l+NyY48bpr65iyqBM5Si0nzOCEla4iVIOdT+9BJf+3W4OzyTAiUN3p9I4ox7EARIQFXcPlUAFwsTEo55uWl/OiQew7hX4pyr1N69Bb/nr8BKJs7Knjsh4ugCkRIzGTRJR4957Wd8rSpOskRTnB8WrTWBJnmIyvy4b4sbQMuy/5+cG25JtnkdsmN0okdDV1rLtG7cMZ3jIEeagecYCIvP55fpF5Dxuuhg7JS; 20:vIlv8osplv8OcyIA5123rEdcqzyT0nU/0xjLqICgLlyyJZ55tpFvz5hewzbTDqyak15f6DtjdZEAbSS9oKVSWnvHR9Zb2AXwPXUR4+RKazqM0VI1ix5sALTM/nqMa23W1kzDOzZq08XuEbYdSAHeFGRwQoRY+ieRD3fMaBC9ho12SKD7cPlZk0+L3HFTKLfE8jM+zoEvgXPEuPxnV+JDaTe/1XPRyRNm6MdLzvzGcpZLtV6cPelWlIeyTsCNqLWj X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jun 2018 17:15:57.7713 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4213841f-944a-432c-9104-08d5d2e3a965 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB2471 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.73.53 Subject: [Qemu-devel] [PATCH v15 1/3] i386: Fix up the Node id for CPUID_8000_001E X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: geoff@hostfission.com, kvm@vger.kernel.org, kash@tripleback.net, mtosatti@redhat.com, qemu-devel@nongnu.org, babu.moger@amd.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This is part of topoext support. To keep the compatibility, we need to support all the combination of nr_cores and nr_threads currently supported. With this combination, we might end up with more nodes than we can support with real hardware. We need to fix up the node id to accommodate more nodes here. We can achieve this by shifting the bits. Signed-off-by: Babu Moger --- target/i386/cpu.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 7a4484b..5246be4 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -19,6 +19,7 @@ #include "qemu/osdep.h" #include "qemu/cutils.h" +#include "qemu/bitops.h" #include "cpu.h" #include "exec/exec-all.h" @@ -472,6 +473,8 @@ static void encode_topo_cpuid8000001e(CPUState *cs, X86CPU *cpu, uint32_t *ecx, uint32_t *edx) { struct core_topology topo = {0}; + unsigned long nodes; + int shift; build_core_topology(cs->nr_cores, cpu->core_id, &topo); *eax = cpu->apic_id; @@ -504,7 +507,25 @@ static void encode_topo_cpuid8000001e(CPUState *cs, X86CPU *cpu, * 2 Socket id * 1:0 Node id */ - *ecx = ((topo.num_nodes - 1) << 8) | (cpu->socket_id << 2) | topo.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 + * 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 bit we can have + * here is 8. + */ + nodes = topo.num_nodes - 1; + shift = find_last_bit(&nodes, 8); + *ecx = ((topo.num_nodes - 1) << 8) | (cpu->socket_id << shift) | + topo.node_id; + } *edx = 0; }