From patchwork Thu May 10 20:41:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 10392443 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 4777C60540 for ; Thu, 10 May 2018 20:42:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 33EC428CF8 for ; Thu, 10 May 2018 20:42:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2837028CFA; Thu, 10 May 2018 20:42:26 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B7F8A28CFB for ; Thu, 10 May 2018 20:42:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752322AbeEJUmX (ORCPT ); Thu, 10 May 2018 16:42:23 -0400 Received: from mail-sn1nam01on0080.outbound.protection.outlook.com ([104.47.32.80]:43264 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751937AbeEJUmM (ORCPT ); Thu, 10 May 2018 16:42:12 -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; bh=ieyGtXCfWvldyN9VB1OL/tBT73RRigqgp3cnxWk84Y8=; b=ps2wWnu3j/SZFZUrymhAIa2ojOteuEbX/dBtx4bDDbynovB9eIn2ux+mwpBqeaeRgqsXsqmvl/iNSskLxw5m5Rl7nLsb4aR/wXIhb2JsCp/S7fUwcmz3RmfW8jCKwoqD58+ALFljiheFGsGGZTj49NdN0oDXXxMRj+4tTDUwlPM= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Babu.Moger@amd.com; Received: from bmoger-ubuntu.amd.com (165.204.78.1) by SN1PR12MB2478.namprd12.prod.outlook.com (2603:10b6:802:29::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.755.16; Thu, 10 May 2018 20:42:06 +0000 From: Babu Moger To: mst@redhat.com, marcel.apfelbaum@gmail.com, pbonzini@redhat.com, rth@twiddle.net, ehabkost@redhat.com, mtosatti@redhat.com Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, geoff@hostfission.com, kash@tripleback.net, babu.moger@amd.com Subject: [PATCH v8 6/8] i386: Add support for CPUID_8000_001E for AMD Date: Thu, 10 May 2018 15:41:46 -0500 Message-Id: <20180510204148.11687-7-babu.moger@amd.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180510204148.11687-1-babu.moger@amd.com> References: <20180510204148.11687-1-babu.moger@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: SN4PR0801CA0024.namprd08.prod.outlook.com (2603:10b6:803:29::34) To SN1PR12MB2478.namprd12.prod.outlook.com (2603:10b6:802:29::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(48565401081)(2017052603328)(7153060)(7193020); SRVR:SN1PR12MB2478; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB2478; 3:8VgauVQQQlGsTkLNiQZ8g4zfxUjcy00xNqxX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KSX5YZoCAaYukSH2Fc6FVDAKQ5esZtaMOKys5zzFzbJ14XUW+Ugmw6nc2WFO/3qG5zMpml7O2OpsBsVIUoZzC0En1aLV74tyJ0KzQtcKn7FkZqOSWGr1FUDwVKE2xMEcEji7X/ql1JwSBi3iRHd86DGTmmauskKi5VZE5TBeOn2YgV5fwdDUPioxHqz1SUJ37Oa+GC/mu1IJQIFWJfLLraumt3vriq6ZYFisiJAqUjL/MCkCqQd5CuxpOs9q4SpkE9bxIbgDjVNUS6/6g9inWZHH6KaEYRTKJwFZLkqmTf+WLZt; 4:tVYz4v0ajKdMeT1arZbjUejNDtm3afxhDHyR9yIDW/lkHeKZtYg8dbl1bmya9Eb6pC3vO8h0TY+G0E6bu9qD5obN4rLh+0BQTxG7wZvLd+8Fs4PtvtiDkW+03KWFYzdyMbA5S68O5xrtHnCvxm2a6E2JJtps9RZhCu1PPL3ttqjwLt2bxylIiZclQOj89/udOr/Wji2Of2JzP0iARnMXM9E2WgduUvrgkLXVpiyrnaKMjViYBIIpMJTGIL74knhcikRcU3JNQaUaId/pvgtmK9K3ZDIC47BVtvjLtMEHJqKGdvKw/gRAFV0UXy5IvApb 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)(5005006)(8121501046)(10201501046)(3002001)(93006095)(93001095)(3231254)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(20161123558120)(20161123562045)(20161123560045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:SN1PR12MB2478; BCL:0; PCL:0; RULEID:; SRVR:SN1PR12MB2478; X-Forefront-PRVS: 066898046A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(366004)(376002)(396003)(39860400002)(39380400002)(189003)(199004)(476003)(446003)(48376002)(50466002)(50226002)(2616005)(53936002)(76176011)(97736004)(4326008)(11346002)(16526019)(8676002)(86362001)(186003)(7736002)(956004)(44832011)(305945005)(6486002)(81156014)(2906002)(575784001)(8936002)(52116002)(7696005)(486006)(81166006)(386003)(3846002)(26005)(25786009)(68736007)(51416003)(106356001)(5660300001)(316002)(36756003)(16586007)(105586002)(53416004)(7416002)(6666003)(6116002)(39060400002)(72206003)(66066001)(478600001)(47776003)(1076002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB2478; H:bmoger-ubuntu.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; SN1PR12MB2478; 23:QdWMCqMpbIhzXJtKjLypaENBYmMoFXsQWhi1WKRqh?= =?us-ascii?Q?NhF7BHGyowDFGMFZyNA3Jyccz6H0JHI4HKXpyy3nMgr3ubbuNXe9W4fhM7gp?= =?us-ascii?Q?RKdHUgwkCL1bj0iVvo9oCXx2UPEhqNTLsNihNxSVaHCcEkKrDPfucgeEFMcu?= =?us-ascii?Q?dmZK3GZ1yIlFFbqboQ92bFutpIAT7pSsSdVRqzH5oQP4rpJpMyBXFCFLSbhi?= =?us-ascii?Q?qKiS5v/MnuXA//wzFHsn/2/CicWq0kbSlsSXOCLsTPeC6At+O1GmUBsYlmT7?= =?us-ascii?Q?4weblNEbnYU6n3MiCqQFD59LErYagQa1otBt5S4SjhgsFhKuNsnrcDNkoNXu?= =?us-ascii?Q?yx6DyTgnmlXTnNNAJmWMGsDJ29RHTU8z+7RfGaakrR5m0bLRBlL9AfpBlkLl?= =?us-ascii?Q?1xLAzl6XDNGTR72fUg1AJX7vUTnrRGoXpeFbY11280mQIp/IPo7YO58lP9s+?= =?us-ascii?Q?qPt1cOSYM9Qvf5+c0TPXAHjzhNZH0VhcEFEyzoilGx30RA7BRo8clZWj+b0T?= =?us-ascii?Q?VBbqVdVm3MdvyO8FwRmROx4hQOUidYdzTzBTBpVomNdHdd4owpnlboGZuNmE?= =?us-ascii?Q?HohbUrD17dzIAfcpFgokcFEKILhxvJYff+Zw+ONWb4hBAq7fse/Hy5nqANax?= =?us-ascii?Q?kfc5O19JXjwAcCuyuk4UZ6qw7urulzHKS6fWzDVpPkj9rpcuF4v/gYyaKZpV?= =?us-ascii?Q?QBChjPztZGgmdkTlVlCV7wrYl2OS09z7kaXT6G+D+XFxbncM62CikejhTfX6?= =?us-ascii?Q?e57Krvl0wW82vuxXRIpyxu+K9cCgXwfbOwcsFKXNLZzDhcvNldWLHVlA9WIl?= =?us-ascii?Q?1zNlchIgT9YXRtXkJpi8BbGGaIkJsxMNTV+T2KAuZ+HFXiFxPfrbtFlQK/JN?= =?us-ascii?Q?vOWnRt+TwxacfOxckuqBjA0G+Rt9dOdblYrOpscgAj1Q+V5n8ShZzkp4eqYx?= =?us-ascii?Q?sy3OtlyHABIAtiwMp9uHj5WaxEAGAn1hKu1m40v91og0mRS8INaSR3bHtYnT?= =?us-ascii?Q?icMFYwWR6FZ0mjeGAPRzyLQ/QYfShUv0AL6IWJ0Ei96WgfQ8vCPcEdri3pWl?= =?us-ascii?Q?WJH/Kmt86CfmzdiSotnlG3P+1G68hMwHE1S0umcjJFBFhd310U6Av6rKcUp/?= =?us-ascii?Q?o74zlB/lvN8h15MBOEfWeKUvm+amyc/+ycgFhfoXdsPN5jveXjpoba3AGtZm?= =?us-ascii?Q?JSIWJ0XRbj0cWZdIW8X/AOC9i2q1vrekV8BzhTGT1zpl1gJh/OAApX6rgMOG?= =?us-ascii?Q?IlS++la62twfxenFqAv6DfpJn02xNKHghCchzXtRpxJ7eXjFDya1MiX3yUEA?= =?us-ascii?B?UT09?= X-Microsoft-Antispam-Message-Info: 23ntv3ux/Bf9Py0iRLWSjHserF6XAh6RUaOF5/tPYTs45Qq9Tet2GRI3l/H85xndovRTfH13z4FUc0X6Jr5eZox3vOrGGzDfQNM+KGYCp8QkAX9jLtOenqDh3Cnv635ALPXWpu6t+tm5IUmN93b9UFRob+xQjvp68u7yNYQbF6nKTI+nS7k+NxwPjQvyEyYP X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB2478; 6:jvgzB+2M3qVZrIfpGTkmm8uvnzkLRYn0KZR7IkSAVpfx67mU7kwFW7+VUGcekVw+unohm2KfRrXJ4PCLAcJ6ST5NlcAoH38U3iMWpcadz51taLasMvV7dAXu6s1XJiQTyEiJuMFtcZYRMFtO3tDay+UXn01t75WFNCQsNs71Li+q+c7JMiXqapS6vIR/Ox2dNnCmA9bLT7N52W1BPFy5D0A6iolXJG/Twb8f+xKgF96SQPvf6XXuLQJ6psuatBwFctcLbK19EFNx3x7OOKilO0fghit72jbFb4EdBr7hbLXZchzK+VJWR46fUl2U1fXWD9Ht7bZvNKfS3rWmlQoY071OKoNCl8q6FnOcgY5phtXt2ZhNBH24BjWjARmAKT1QExf927uTEmlVMNHiszKhTw7Q/wff0vh/bv8GfT0FClMfksk0RiXWaYjG8FBEOIaebsem/z2mIQEV73SxINGu2g==; 5:8xWgR1l77lJu0jXeNE7uhz9Mo1sRBoSwmNsLmzse5HiQbtIaQZpBFr1mCk5yPRSIhNAplCRII9MxFmooub8qDSOg+dGMDtU8LUNppkarh9vuZksFarkA5yeON7MD9jUlapJhIBrApeWnNlQTLgQPf2WLjD5BzOmZV5gr7Mr12GI=; 24:jYaJa7PKUSNmrPosOZljzlVulNfDC61ORs+c9zO7yU4kDzGzK6zE50wxAbUMwR4mtNKEoKUxl1w2iVP0vb0WNgWvh67xSRRXcAW6PXW7//I= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB2478; 7:++HNBVrb/kQguNM34ogUIBuDUDU9k5jS9vXPE61FX35PfF97FWX2NC7tISHZHL3JNobHSFwGuAryvbOVKxEF0gBsJ6jzMOYBMJt+a6eXisp5+ZbZMtEf/GDWBfKux/sz4wRNuWppjmzoRZGfU1onmfavM78xB/a4dTfEwLeWqR+X7bk04WfQmHgc1UyWgEntHQG2Z/ubGTMHs9Nsy6X1BLIp0hwdqPli2kYrYwVwBysd4/ybmVZGtSZRucgjnPKf; 20:6zBZxhtklhCRFC12VlRhNzbMk6jbVjUEH1g2nDmchQScSkKlqu21mk8A7QCPWAmVjvdIFbFG8cfnJWe/G6xGNswHI7FtYytHhq4xoNwnRdj1cZJhpHQzCXKmdRkXiP4naWa+ts555qPOeEKZ7apmmNtGBGecSar3+ag0pAEF81qmP0W/Sg3FhblfkbWE44bt61zwEpBy1onJogd02oAxnF/RyW+2JqnDLxRJuZcs56VSbOp9PvJ6Gb9MFQS7N594 X-MS-Office365-Filtering-Correlation-Id: 58be9097-c4ee-47d6-4174-08d5b6b67eb9 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 May 2018 20:42:06.6197 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 58be9097-c4ee-47d6-4174-08d5b6b67eb9 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2478 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Populate threads/core_id/apic_ids/socket_id when CPUID_EXT3_TOPOEXT feature is supported. This is required to support hyperthreading feature on AMD CPUs. This is supported via CPUID_8000_001E extended functions. Signed-off-by: Babu Moger Tested-by: Geoffrey McRae --- include/hw/i386/topology.h | 6 ++++++ target/i386/cpu.c | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/include/hw/i386/topology.h b/include/hw/i386/topology.h index 1ebaee0f76..4af746e50c 100644 --- a/include/hw/i386/topology.h +++ b/include/hw/i386/topology.h @@ -145,4 +145,10 @@ static inline apic_id_t x86_apicid_from_cpu_idx(unsigned nr_cores, return apicid_from_topo_ids(nr_cores, nr_threads, &topo); } +/* Definitions used on CPUID Leaf 0x8000001E */ +#define EXTENDED_APIC_ID(threads, socket_id, core_id, thread_id) \ + ((threads) ? \ + ((socket_id << 6) | (core_id << 1) | thread_id) : \ + ((socket_id << 6) | core_id)) + #endif /* HW_I386_TOPOLOGY_H */ diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 6898042787..5cfc7bb0e1 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -4072,6 +4072,13 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, break; } break; + case 0x8000001E: + *eax = EXTENDED_APIC_ID((cs->nr_threads - 1), + cpu->socket_id, cpu->core_id, cpu->thread_id); + *ebx = (cs->nr_threads - 1) << 8 | cpu->core_id; + *ecx = cpu->socket_id; + *edx = 0; + break; case 0xC0000000: *eax = env->cpuid_xlevel2; *ebx = 0;