From patchwork Thu Apr 26 16:26:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 10366333 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 B272E6032C for ; Thu, 26 Apr 2018 16:27:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A46961FF29 for ; Thu, 26 Apr 2018 16:27:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9902D28A14; Thu, 26 Apr 2018 16:27:41 +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 2A0E91FF29 for ; Thu, 26 Apr 2018 16:27:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932206AbeDZQ1d (ORCPT ); Thu, 26 Apr 2018 12:27:33 -0400 Received: from mail-sn1nam01on0075.outbound.protection.outlook.com ([104.47.32.75]:11117 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932270AbeDZQ1V (ORCPT ); Thu, 26 Apr 2018 12:27:21 -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=oy0vgeJE8cb1bY9BJdg0LUABnwkTTo1XoszxVpxIuUw=; b=sn5bpMy8HgpbVhJT04kA1ZkY6vA0aTnANM4fCkQpziBpkd9XHRuMpQWz97kmcw/9HuNqEi1x0+1qIANagHV1BW16yqTREHXJ367Xg7vMAHk/UGkNqgNXuuEPf0zM+t2Cf64fFAwSfhc12m9CJSY3ZIHoWyfb1npim96B5amO/cc= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Babu.Moger@amd.com; Received: from bmoger-ubuntu.amd.com (165.204.78.1) by SN1PR12MB2479.namprd12.prod.outlook.com (2603:10b6:802:29::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.696.13; Thu, 26 Apr 2018 16:27:06 +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 v7 7/9] i386: Add support for CPUID_8000_001E for AMD Date: Thu, 26 Apr 2018 11:26:47 -0500 Message-Id: <1524760009-24710-8-git-send-email-babu.moger@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1524760009-24710-1-git-send-email-babu.moger@amd.com> References: <1524760009-24710-1-git-send-email-babu.moger@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: CY4PR1801CA0020.namprd18.prod.outlook.com (2603:10b6:910:74::33) To SN1PR12MB2479.namprd12.prod.outlook.com (2603:10b6:802:29::18) 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:SN1PR12MB2479; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB2479; 3:0/m5xlVvc/JasU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hzPjgG5R9eRGyy6F296v8Wo08x0JEKhRditRuK1XWijVcgbioNyqKHQybMm8hjz+oVJni+rZxs2Axq6bibrYq/87+QBqgyxlUFs8Bc0rbI+nXXbjldHIYO1Dp8KM2f8xZR33Wlt/NyxqL6IXWmOOVMk0Z2QThNpBZdphpd9muWiUqYRh8yn9Vcj6DgrpNXKWUsLfcC23f+CCPxR9o+VrhwJ3QQsqyTb2rwq4m0WpDEp3vebgQnW+XJNh7VUQgF3ddQhJWO+9gq2gYgcPQLy93c4Fov4bva6a0oCYdAt9XXv1BEWmDoNbltAxaYvSDf+jyFR/r; 4:GkCDb/lVMkB94nlzVeJ8IEtW1lFV64SvY6A5bKhGX5eEbqPe5cc7BaB+ty7dbJjAmSfCYrweJddNdNAB2p3V5KUeUUZPlXWDAAyIDuxnc5/ujhMdeSx0l/gJa0xet/CI5texoSmdf2q7pdk87aueqkhybbjPgwOnMx6H2pp8tbfc0rXSKI5ON/8eGFoAc5pc2VjLTDWkaqeqBnGj8wVlAlvovul2GKON/p5sFTbrAtELd4tESXIYmb3ydTVQyy0LJESxrr8oRjGUBzf1fpPz8ADrY8sLLvnaOeOgFGeKKJJlUXJR0ntjg5bpbOS1TRAt 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)(10201501046)(3002001)(3231232)(944501410)(52105095)(6055026)(6041310)(20161123560045)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(6072148)(201708071742011); SRVR:SN1PR12MB2479; BCL:0; PCL:0; RULEID:; SRVR:SN1PR12MB2479; X-Forefront-PRVS: 0654257CF5 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39380400002)(366004)(376002)(396003)(39860400002)(346002)(189003)(199004)(68736007)(8676002)(2906002)(6116002)(76176011)(8936002)(5660300001)(316002)(3846002)(4326008)(81156014)(50226002)(81166006)(386003)(956004)(16526019)(7416002)(52116002)(476003)(97736004)(186003)(25786009)(86362001)(446003)(7696005)(11346002)(51416003)(26005)(48376002)(36756003)(16586007)(47776003)(53416004)(486006)(44832011)(106356001)(7736002)(6666003)(72206003)(2616005)(6486002)(105586002)(66066001)(478600001)(305945005)(53936002)(50466002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB2479; 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; SN1PR12MB2479; 23:EBFzLsFnAkD7N3wX0CQXAEBqS/H9NFyQBlyq76G9O?= =?us-ascii?Q?W0oSn14pYz1R5aRKtci6IqbJmMzdBTIee0zjdLhByjWI1T6UTAg/J78Jea5h?= =?us-ascii?Q?NhoNIOgi5YAdTgWOJ2EwocumBx3OOHRIdByw4nzRqCrQdGT4u2oV+2OsGDhw?= =?us-ascii?Q?Cr71gdDcO9GEqZUqviOXb8330ZytukOKWzAR55b9hxHphMFenenHxVY8xQsr?= =?us-ascii?Q?GXZyUKkcoOh0Z4Wb5+tSJNBdfVEntTpl0hhvPRgX749sGGw9JMpxXsAWcAge?= =?us-ascii?Q?7N2nOtl95KQIbcoOJHZXKVIm0+Gbx/meyyQ9x5fAswe4ajT+gPCZvsxmOTWX?= =?us-ascii?Q?DwcFeYZ86sqfaZhixrdgpnLhTMYXEAFRxA4Qh8+T4vUKd3YC+OfeyH9zQk5r?= =?us-ascii?Q?L18RoYNwCWRY/U5j0v3paegnI90xuV2+Fg2utjVaynXr48CBjqsbTxJO0KrK?= =?us-ascii?Q?d+hfWZM/l8EGSXGXfaHUnASjYz/FHTZgA9yVghaH+61ajjWAncTGvcakGPTy?= =?us-ascii?Q?8/gYm+c08a3LvfBxSYMsabfbzs2H+n2RrHYQ7U8EyLZSUQDliXDzoohx9GsP?= =?us-ascii?Q?iHgopE86q8NMBqkmp975q9A0JweZXcMi69jjVXacPs9NBwg8OoNMHnFpQn4a?= =?us-ascii?Q?EzrLZhDeqFQfeYR8otHEQKB8BHZKCZvkOzFBHp/ZRyv4XzYNJekNCtXrWl02?= =?us-ascii?Q?HNnV36R9yHUp7OmKbsPxfquLeKqO6udK7ziZOGvvilGFoJDaDFK7R/gNwGA/?= =?us-ascii?Q?G4NiL579mNlSm/TPrNbs2T1+EDCHTBXvRB64HlgyLvEna56wO/MYWwbwCFBQ?= =?us-ascii?Q?BFT6W97QPlwhFI1aBv0Skg5XnmIA2hnNTOWvpI1n1vdA4NEJWNU0HNMu8bQc?= =?us-ascii?Q?ryuInYkZCN6nwbrMPiV8MOf/+FzxMJlOoVVOgyLNqsiVr2ZsBeHzX6pAdRz7?= =?us-ascii?Q?phPxwo8qqfybm6xWXo7shF8YmuEYYDPtjGYU7FZ4k8jr2JWgJZ9alj89TwEQ?= =?us-ascii?Q?Cw01VAyLfWJfHqGss46YXDLIk9cl5uUz2Yphz+FeD1ifJQ0I2VtLyAF6BARK?= =?us-ascii?Q?ingAEnW5I7pbYI37KAe21d1icF/vc5v2Ez5kAMC7LcMoXX5F4Fas8HBSiXQ/?= =?us-ascii?Q?6lYHNiwuLNPIU9yczrmCs0+1PFV+6fvlxlApufjUUfiZccC944jtd+4GxuNl?= =?us-ascii?Q?SmWnNjSiDqX7jM2ESufn0xjSNV2+hwZafTYB14ino4pwev3MkpW28zpjw=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Antispam-Message-Info: NW3JbpzDAgn5FG5irWcjjVVphGpuy523tvCDj2Hg/iOSiVZ15eFvoayQYd1H/6B5eGXC3lUsAPbo+xztVoEcH5ggX11bl5pVBK7/4jes5ujnXUpqtWtmUW7obvwqRW5n3EfksKHLMEzjRdg96agYT4/7m1Ko+uskgFrZ3MVPyMt1Tw96ow+qdgbl/x7tjNCh X-Microsoft-Exchange-Diagnostics: 1; S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aw5IomgF7lWVHrDVd7NpbcHKk+rLwxiZXBl55kFNzNoRydkNKnk; 20:qkriysDkOzQmsVTrWo8U8Cf7wwwgXbxtYHBxqe3LiQlFzNC1kZRK5KXx5b5/ibdFfy2D6C+PdH0/KFWyLzTiUxxMCgU4BunNPoF+2VrkQOp6826PaE/ONlHYjvK5T9GYmOSWUzPBLwqVUVclETnyTG+rLBaoVxi3s7seVvSKy0hDkhftwVkuo1Bcb5TElgGZt8F3C+K4idjEj+VRjrxlcFRpE1TKsfaX7+3axTRLQf9RPEileuKU0XM27e61dmiO X-MS-Office365-Filtering-Correlation-Id: b7f6e437-c394-42b1-5660-08d5ab928db4 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2018 16:27:06.4399 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b7f6e437-c394-42b1-5660-08d5ab928db4 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2479 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 1024b09..1b15023 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. @@ -4105,6 +4111,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;