From patchwork Mon Mar 12 21:00: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: 10277483 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 DB27560211 for ; Mon, 12 Mar 2018 21:01:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8C73286EE for ; Mon, 12 Mar 2018 21:01:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC42428E20; Mon, 12 Mar 2018 21:01:33 +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=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 EBF2C286EE for ; Mon, 12 Mar 2018 21:01:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932405AbeCLVBb (ORCPT ); Mon, 12 Mar 2018 17:01:31 -0400 Received: from mail-co1nam03on0047.outbound.protection.outlook.com ([104.47.40.47]:37717 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932501AbeCLVBJ (ORCPT ); Mon, 12 Mar 2018 17:01:09 -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=D+JSIhs6/OIIA7S/beIsBjG0Ic+RhGZQBwI8Q9Lfs10=; b=uc3t3BpbpRQkLZH7wm01Th7DKtE8LeKAHfrbAkrI5Dws20bMDzQbErMKFTDEw3dtMiKGUNgQv5pBF8IcrQPf91F+7Xy9d52xAlKpPS1yhZzhf1BDV1Gc9WdGjEkxRBhVp63R+PG6uy/42eQKYJy6FYOI0sjhJNamj77lkXpk85Y= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Babu.Moger@amd.com; Received: from linux-pyp0.amd.com (165.204.77.1) by MWHPR12MB1774.namprd12.prod.outlook.com (2603:10b6:300:112::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.567.14; Mon, 12 Mar 2018 21:01:06 +0000 From: Babu Moger To: pbonzini@redhat.com, rth@twiddle.net, ehabkost@redhat.com, rkrcmar@redhat.com Cc: mtosatti@redhat.com, qemu-devel@nongnu.org, kvm@vger.kernel.org, Gary.Hook@amd.com, Thomas.Lendacky@amd.com, brijesh.singh@amd.com, babu.moger@amd.com, kash@tripleback.net Subject: [PATCH v4 3/5] target/i386: Add support for CPUID_8000_001E for AMD Date: Mon, 12 Mar 2018 17:00:47 -0400 Message-Id: <1520888449-4352-4-git-send-email-babu.moger@amd.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1520888449-4352-1-git-send-email-babu.moger@amd.com> References: <1520888449-4352-1-git-send-email-babu.moger@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: BN6PR1201CA0019.namprd12.prod.outlook.com (2603:10b6:405:4c::29) To MWHPR12MB1774.namprd12.prod.outlook.com (2603:10b6:300:112::21) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 22406f69-81b1-4cb0-12cb-08d5885c6085 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7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PUQ1JJogskFABHW46snHg21qVSVYvYROZLtn1bOaD6Cm1KHSOKZYevdHdp/J8vM1s/nssT4+IMeFjGKOhPbQY/rvU20WV91/oM85TQuE1cfL/eMpRznuNDUSNO43q0TuYeF9K85iLKBzx/B47rvqwCb7iJw3iVV9pn1QvgPAHItJHoCCvdjfsmyoyR+izUITXSAgVS7jH3T7hy0BVGS/PvPRC8f7505z6VaaYgLdiz+EQmkDfm0smcWK8hMfhU4PhBuOMq4v9VB062o/WEFPTQ8EHh+h9m+qL/hOhHppvFnRN+vlDqU9aJwBv/0GwMuqlGBOwA2q8KLXnrPfyvjnS2QDKf7hZOlRo02l4bc9wqnLRQND2tH4L1OvcT6rCdivVhCxxg0Mgn0WLXYONcZq3aI67pRBzPLI; 4:IXHOuo4C77C2OCSZLV4vMv5+v5Ynazr+8gnQW4Caf5cx6zSF+MJF4K6h5hs8+nEilnL2cRyBS8fAXZesL3gdKFRAAwV5TQ/WjEV39EkL1sPSKLQMgf94GSa3DjzU0VcVUmGcKpPrx4PeNKJS5OqxuwnDP2LXnHnnPvyWR6AZ8sUkPusRjtc0O1RAfxYu/2q/MGivoKEvpMV+lTyg00Ky7XCSzAMsbhbOcuyLvnKhTwku4kGB5+OjkARxV6bc4o91KHnJ8YuzJLsw1R/PnCUwBUNOuy4UTUNrYhipxoez5TR3cySf8ZCmG5Ya/ojtb0Mu 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)(5005006)(8121501046)(3231221)(944501244)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(6041310)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(6072148)(201708071742011); SRVR:MWHPR12MB1774; BCL:0; PCL:0; RULEID:; SRVR:MWHPR12MB1774; X-Forefront-PRVS: 06098A2863 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(376002)(366004)(39860400002)(39380400002)(346002)(199004)(189003)(6486002)(66066001)(8676002)(81156014)(76176011)(50466002)(316002)(47776003)(4720700003)(6666003)(50226002)(6116002)(8936002)(106356001)(2906002)(2950100002)(3846002)(48376002)(16586007)(25786009)(53936002)(81166006)(7696005)(4326008)(386003)(51416003)(52116002)(478600001)(72206003)(186003)(97736004)(5660300001)(68736007)(26005)(7736002)(305945005)(105586002)(575784001)(16526019)(36756003)(86362001)(53416004); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR12MB1774; H:linux-pyp0.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR12MB1774; 23:VFLP6ZsC5pw0RkVwlyXYKtQ+N2nUaYPhUSbFYteEG?= =?us-ascii?Q?yQ4tkog0tjhFk+o4s4amVdyEufDFptIQposahKOJ8i1Y+y4eI5Q+6JNqegD6?= =?us-ascii?Q?Zeu0SwDIdsHfgqTNY9hHvpgogMrDhazT6zntM1+vlhHDw8i5d6zs3jZNc1PX?= =?us-ascii?Q?9/YxFWcV/vYSt7TcycT7fznMRp+Xlw3HDnS2oo08c1bwSyMJWwQzdDonlE5B?= =?us-ascii?Q?tIu8Jwnbh7nm7nJB/TlDACY4c5zl5FEHut4fvR/yAXMiXPi69ipWIYUHN//y?= =?us-ascii?Q?rA8leqFIa+2ohcVGEesuTPHdNd1d/r/ZnJ6V/OGk0bgYhZV14gynK4dc/Mz0?= =?us-ascii?Q?C1CoMQKjidfDGjkE4Kj2FiPVUgQsz+TrDaz0chx0vCpGzOg7g4G6cMyhvB79?= =?us-ascii?Q?BClQ0Sx1+0zVlJKaO6MIhtdfaldtTQmr49NHqkZ3QwuMuyHATCr78Vj8L8kD?= =?us-ascii?Q?gspKZtT9f5LiorqyO8OoYnpeRlVW5RsrvcPhFRQpUCFDe/uejPsXYAp19ieM?= =?us-ascii?Q?xs0hR7qPhYiRovOjegromfpqodA8k00GEhQ38d65+TXZBSlzb/MbLiydDRaQ?= =?us-ascii?Q?EDmKqTw1NBNVc7puZo/lLXCpliebgaRVtaWRDpSt5pMyOq3TF5HZpo184Hzl?= =?us-ascii?Q?XkRhl290bau5DhFG0fk+1OQp9C7LNbPbz1G92HQBnbk2nfSvROkCqQ28SpeY?= =?us-ascii?Q?x323yNcYvVvyIatIFwpugGyhebedtrh58kppOAGWKVbVZfm+l494iV286Htr?= =?us-ascii?Q?zYD9RnoXoxD5PdUAoRcIwgnWO8qQmPKUQ8IDN9HFrax1F5WNKs8oThkaWE7r?= =?us-ascii?Q?LJQfMLOmj1pXKojMAokSZvsiFyihiaoqz/IPHTa3rLMG51xq7UBuYNEOvEop?= =?us-ascii?Q?m2FWQAWRyIBoFHPwHbcWHzLJCdmFc4gAXRHiwL2K+3LrVemRDnYjOeK+/4aX?= =?us-ascii?Q?PBXJXUXl8OYn2nJvqMXFyuhFz3RLdWcYPxtTGWLGpQ6hg2lJdhzKjxt/GMh8?= =?us-ascii?Q?3Vd7BXYG9SDe3rVG9EaautFfLEvswnW2ddBXbCMGYaNwFQJIKEFKFOKFMmH8?= =?us-ascii?Q?TcnrF4gawKM3ZBy82ywX+HihgsqlTYbw0m9xs6heGTV5MsudfWANIGLKMWKu?= =?us-ascii?Q?Z5kxi0orTvzAqZhsfpogQtz4FWbKzRcRmc5kTSyTj6UyAgiCnnrug=3D=3D?= X-Microsoft-Antispam-Message-Info: 0ojXFo7wly/jcROW2bZIjx00NU0BkC1KxqKp/g1E5Q1qirG53dvkrXhMzio/YJ+2DQFHSPZ9FgFHnjktU0lAHcJK+wIZtwbuuJ3SOtiM4FuE5vgatuhVAHxnVecpH2P4yNZAEeUGYo6NcMN6TwsJ7cW8GgKNMCOvZ6wojQWpo6qEeDHl5lzypRzB4GI1c/ml X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1774; 6: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x9vBV2sOBxv6ESLgKkug1o6u4k9lOJXS4vVlIVd5P/jQBHgMwZeGchQ3JegK7DGvny/Kq2fJLxyygidfPzujROyTXPVrMQ0Pdva72Va3bsQPNh9TbD7c1Sw5+8EtlUGOIq3LX8INTltBacDIvKxfE/tqrpSwxpUs6fuOcWvdFo X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Mar 2018 21:01:06.3464 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 22406f69-81b1-4cb0-12cb-08d5885c6085 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1774 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Stanislav Lanci 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: Stanislav Lanci Signed-off-by: Babu Moger --- target/i386/cpu.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 5fdbedd..ba63d0c 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -3655,6 +3655,13 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, break; } break; + case 0x8000001E: + assert(cpu->core_id <= 255); + *eax = cpu->apic_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;