From patchwork Tue Apr 10 23:16:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 10334507 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 54AE26053C for ; Tue, 10 Apr 2018 23:16:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 502FA28565 for ; Tue, 10 Apr 2018 23:16:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 44CC72856A; Tue, 10 Apr 2018 23:16:39 +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 D084828565 for ; Tue, 10 Apr 2018 23:16:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755348AbeDJXQg (ORCPT ); Tue, 10 Apr 2018 19:16:36 -0400 Received: from mail-by2nam01on0081.outbound.protection.outlook.com ([104.47.34.81]:40576 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753091AbeDJXQd (ORCPT ); Tue, 10 Apr 2018 19:16:33 -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=ZqszMJ1gxujV5Tk9Kjw3C8SjojU+gU17BBy/dBq7PGA=; b=kpfG39jeUWGafj/2jVNVYcIZp2F4S/NyyRvFqLbGxIX17mOsG37IWiA9J0HoebezGobGl100CCRN+RQsd+dx3hB2khlt7qxgp3aA9+7D5vB7V1emstz++QQETy9I/bO7BjcCbYZkiUhyjrG9lk/9tGqbjeVIFoAk90uuUHxbQus= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Babu.Moger@amd.com; Received: from linux-pyp0.amd.com (165.204.77.1) by CY4PR12MB1767.namprd12.prod.outlook.com (2603:10b6:903:122::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.653.12; Tue, 10 Apr 2018 23:16:27 +0000 From: Babu Moger To: mst@redhat.com, marcel@redhat.com, pbonzini@redhat.com, rth@twiddle.net, ehabkost@redhat.com, mtosatti@redhat.com Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, kash@tripleback.net, geoff@hostfission.com, babu.moger@amd.com Subject: [PATCH v6 7/9] i386: Add support for CPUID_8000_001E for AMD Date: Tue, 10 Apr 2018 19:16:07 -0400 Message-Id: <1523402169-113351-8-git-send-email-babu.moger@amd.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1523402169-113351-1-git-send-email-babu.moger@amd.com> References: <1523402169-113351-1-git-send-email-babu.moger@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: MWHPR2201CA0048.namprd22.prod.outlook.com (2603:10b6:301:16::22) To CY4PR12MB1767.namprd12.prod.outlook.com (2603:10b6:903:122::9) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(2017052603328)(7153060)(7193020); SRVR:CY4PR12MB1767; X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1767; 3:Opt7rpiBt0SwvFoNlhU9VD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Dz1BAnA2imENIhW9U52KPgo0aJiFwJ/0weHqKmVtFzBWxpgyR/NW+1tmlgbmvzzg90JuV6QonbT/4ev9pbL1e564o5foY4dJyJxeFHSg6+L5Cb8kUzt60qJRJv2jI9+K5y2TjYhu/BUjAtROnXE2QqWpR2xfyJ+54TbaETUQIXEfpn15QbanugkistLx1p7LinenH4RuLxg+fCRLWNtxrkSf9YYjD3RcvRquuzRlmTfssSjoEBn1q/dkhHXWpCiEv3w3qa0kqEyRys6e4XFs9OnrVknzvmv6S5on1biC2qdfOj/H55AOF0tcCts7Pa; 4:jvlpyvWwxb1JQwL/lSWoOQFAnc07F0LdVIHhy+Oe98KBOFyl+fZXGtfePgf8QII5pwioXODE27X0lhb3vftrpOkK772xWZgAuJ07ACEP2/8P65TOS0cETCxNQ4ygkqKCTJ/XXAbPVLDD4Ye6Xu77C+tJGKIqVMk35zQUmmevXk5VRDgTpWcmvaDkMv0xCbvZLO6WJEzq9YMmOYpqCft97mYleFlZmg0QfwqJT3d2IVSLmdqMqx6gY06NuS4MFn3sbgVtTw6SYeS5wZjByj2ZbKYW/gIRvn+STQ6xT2gOA4TYzoX8kui6CHku4cYuhSy2 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231221)(944501327)(52105095)(3002001)(10201501046)(6055026)(6041310)(20161123560045)(20161123564045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:CY4PR12MB1767; BCL:0; PCL:0; RULEID:; SRVR:CY4PR12MB1767; X-Forefront-PRVS: 0638FD5066 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(376002)(366004)(39860400002)(39380400002)(396003)(199004)(189003)(476003)(2906002)(52116002)(26005)(86362001)(50466002)(50226002)(305945005)(5660300001)(186003)(48376002)(7736002)(16526019)(6666003)(25786009)(6116002)(446003)(11346002)(105586002)(4720700003)(2616005)(6486002)(4326008)(956004)(3846002)(66066001)(53416004)(8936002)(386003)(72206003)(478600001)(316002)(16586007)(8676002)(81156014)(81166006)(97736004)(36756003)(47776003)(76176011)(106356001)(7416002)(7696005)(51416003)(68736007)(53936002)(486006); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR12MB1767; H:linux-pyp0.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY4PR12MB1767; 23:vPhoGLGA1H/Hi27alJGADnnSxhJoCUzrPNmWJ0ylp?= =?us-ascii?Q?XT7Q00u9SDOVvl9E4tP5D376pJPrUqUqhmntyAxRlW5443rB+EvauIlIp3fi?= =?us-ascii?Q?40n4lQErd9gShwjG864GyS4WF27Avt7gtmTdaPQX0dPHNMsbYKQXfVwHfyRz?= =?us-ascii?Q?P6ZpsTjdKa5vqV3K8v/snJyse+Xog6O6Z+kEUo2l/wGNkZYnShrDk9FiCcoH?= =?us-ascii?Q?igz4fYl77SjKitT4HsvCgHrad3Nieh19fUqxIrji4Ze4Z6F5KJOc2MWFEEo2?= =?us-ascii?Q?L1ysQ2JuhA6+p29cTh8+1u8VjOQ9AZLfBdEC132Oc/5B78AZ6wDuddK+IWkh?= =?us-ascii?Q?/c6aPJ/yQYkamXFGJ6Jbve9FcOr7LzrNSkOyiWcar5qwkC6b7Um3BrSCWzM6?= =?us-ascii?Q?Bq/QilsZ2zp0n7SLzKSzeOXIGG2f8ncgrat33fuSDFllDP/YJVmOXHGsCOe3?= =?us-ascii?Q?V3+8P/VtUCsJSq8Hkh1Y2VR7xdttelr5wZTjRNocK+K+tAP6oZ3m9tfkTuL2?= =?us-ascii?Q?GQpopzokEvGQNfGAMEIGsdTOdLBxOfIC84nr4FfXqXxBD0K8JIA6JOct7moe?= =?us-ascii?Q?vtfoRJRgenfq3BcHMLgJFeO40edqAoN/O+tBv4/SBfPpHyfQNcXxhaQ/ya+I?= =?us-ascii?Q?Cj5F8/l1pFMwML4vrJ3FggWAG4F75rusENm2VYcUOkAH7/pkzG/NPV8/As9e?= =?us-ascii?Q?7C/0/q3npU33xLPd+ewuYzIRthirGBCoVp/yREpaXBtGp54HFQBk+7uw5Geq?= =?us-ascii?Q?YGaCQeQZPgjFI2QRuRNkSTmVshwgo1S6uwubHYqMgom6WlbcVpp8WTy4Wnym?= =?us-ascii?Q?6Qd3mBuvV1OGtIdF14vacrcOF0SVAATR2I41ew86NXAVoVUrzBvZo+LqKqXB?= =?us-ascii?Q?WhkHXDSnOYHpCqVDK+RkQMOSMO1Fqvh/+q9ikD9hYspKUDFaHwMEcVNBF/k4?= =?us-ascii?Q?q90MRDKGCtiW4TB4zfp+mbrMhXcKHFN86boB5goA6WJbQJd0l8QlRzgPg5Y1?= =?us-ascii?Q?rpcaPptil3Xj0HB+yZnrIzTRMggbFzmKbXonyKCRYBeSW64houuIGmWrYjnA?= =?us-ascii?Q?S77F3deyAQKCbZzUHR0mVm/rc0xuGPwABQ4mg02zs9DY+/q81C+iDYkmRoPk?= =?us-ascii?Q?gn+3eizs/+BQgllxHON5Y54AMKUpKnMJgD7FbiyxuhUpkZyyLxwIIuIVq5/0?= =?us-ascii?Q?OmB8DTCd9mCXcbwpDTrdl+oU+vHfaU2LGL6RHt9SR+t4RTr5wSOOUd8hw=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Antispam-Message-Info: mkWcZglQWk4MXPKv/bcHVXShXev8QMTyoPCeJtGOaXnx3YZsnlhgcuRqi5tfRMGiqFm2ml4/vZcRcbksUM+Sd2YhTBpFIDK8aXkvEv98PhALOEvE6hPcX9pZT20frHS3kBJ1Hgd27Ykba0if4JBdZcUKiibB53864KTbrmdzbo/vGwJK0JaxVbmJ+8YvSL6C X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1767; 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+VOyARg; 20:5zly1JrnOaGCXr7IDaM9Dc/nua3gOFxVv7L4AvSMaFWuOCYpjOl9ewbBPdGQbWKrcySLHwhN8cG+2o4FJVljcguB896AZRUR+d/RO8qPAbmrG85nzzQN+oa4pPDOAT5hIZVUc5srou2p2nsUqLrVvMvvsAFShe12686uWHfccfMa0EIJzSYm3A2noshxXsruEbnui/Pw9BgB95pDJPOnAeSJagNefMGhPx/1tmv2iO1IL7+rWIZmvEkxdZU9IQyh X-MS-Office365-Filtering-Correlation-Id: ec5853f1-bf36-4fba-831b-08d59f3916b3 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Apr 2018 23:16:27.5296 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ec5853f1-bf36-4fba-831b-08d59f3916b3 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1767 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 --- target/i386/cpu.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 63f2d31..24b39c6 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -315,6 +315,12 @@ static uint32_t encode_cache_cpuid80000005(CPUCacheInfo *cache) (((CORES_IN_CMPLX - 1) * 2) + 1) : \ (CORES_IN_CMPLX - 1)) +/* 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)) + /* * Encode cache info for CPUID[0x80000006].ECX and CPUID[0x80000006].EDX * @l3 can be NULL. @@ -4098,6 +4104,14 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, break; } break; + case 0x8000001E: + assert(cpu->core_id <= 255); + *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;