From patchwork Tue Mar 27 21:31:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 891815 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=amd.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="49OCPBhr"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 409kkR3nbpz9s19 for ; Wed, 28 Mar 2018 08:32:31 +1100 (AEDT) Received: from localhost ([::1]:36199 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f0wCi-0002Nr-Kb for incoming@patchwork.ozlabs.org; Tue, 27 Mar 2018 17:32:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44961) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f0wBi-0002MH-FO for qemu-devel@nongnu.org; Tue, 27 Mar 2018 17:31:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f0wBf-0003pY-8H for qemu-devel@nongnu.org; Tue, 27 Mar 2018 17:31:26 -0400 Received: from mail-bn3nam01on0064.outbound.protection.outlook.com ([104.47.33.64]:43315 helo=NAM01-BN3-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 1f0wBe-0003oR-Pp for qemu-devel@nongnu.org; Tue, 27 Mar 2018 17:31:23 -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=SSBF3pYJAIJt2bTT6fm9m8gfh+v8ZLftmcb97qAdvpE=; b=49OCPBhr0DDSZJXTMN+NkkyV3ykBH1b3ZpCsdGAk+sgPeQOks1eZv+K6W2W560kVZbj8KsuiE9mvGWpRmmejee/jIijHXPA74hrrVdS0zlNfbAgZQ54xjxMvsqR4iX5gT19nA5G1GbnxLsqfqhJqhHBgPI5JsA7qIIR3jz2cnls= Received: from linux-pyp0.amd.com (165.204.77.1) by DM5PR12MB1771.namprd12.prod.outlook.com (2603:10b6:3:113::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.609.10; Tue, 27 Mar 2018 21:31:19 +0000 From: Babu Moger To: mst@redhat.com, marcel@redhat.com, pbonzini@redhat.com, rth@twiddle.net, ehabkost@redhat.com, mtosatti@redhat.com Date: Tue, 27 Mar 2018 17:31:02 -0400 Message-ID: <1522186271-27743-1-git-send-email-babu.moger@amd.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: CY4PR04CA0039.namprd04.prod.outlook.com (2603:10b6:903:c6::25) To DM5PR12MB1771.namprd12.prod.outlook.com (2603:10b6:3:113::8) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 61d38e52-c867-4ec6-350a-08d5942a1494 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:DM5PR12MB1771; X-Microsoft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ZRhfBnUaokoL5+XfpjPbI2lWS/Lcg0vldlsCVD9mtJytluXEectgE+6cETullJAVr2SJ2uh9rnp4/OhJsiNZ03Ju3B5mEfbcoN1bF6TagYg/0pzhNrmJvFcI90sUQe4kMhgpk/nHZIiEDCjyuG/PX1T51Fza0iinOFqpM+GUJEhhruBaVXdJp5oY2BVaPSSKECVMWomur+lZEX/1kI1TkoDK3TO/s4OK/2jpLvnFvG9X2QfetiQ4rH6EOAS7QEuq16fbKEt167wd3RaAJq3+5b+WbGP6iY1KB6MyEWL6VNe3HfTIHXmWt2B/2zDkxqWyVIniTe//f8kRHYhP0jrs0uW40YKLMHG/o5xUeGTbuStl80V+w9NNgIMjaXz; 4:1kkKhI6VEUWCSZHsot2TlHrLKnUHUSYbNVSB/xVe7etF8aP6tV89MbbSBtJY7jSmGz71zO0fIYRoCzLS/Be80q1cpdiAm63G0GSlN8dV035ZN5O1qNi3P91VBr/6a9C1LJwo+87MZXEEIDHyT3X0ECyeSh620J3SecPqzADM9UXYZCZ4xv23Efvb9LYb83LfCgr7O/IedeQmiKMlJzbhWp+kAqL997JkfSxdgBr1FUtCopEsw1OyEgnG2IpLi5HUG706OjRbSl5Svd53NOb1IlVv7uP6Y3zgnJBr4zlFzMFpQ2VU2zkoUHk3crIPt9b3t3+d7+W7vzg4Ko2vpl7edOjUI++EYNJOruglNkrjz8rcC0HlNPgsFdixY9LzBTMC X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(211254476889703)(83566789882024)(24339691489775); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231221)(944501327)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123558120)(20161123560045)(6072148)(201708071742011); SRVR:DM5PR12MB1771; BCL:0; PCL:0; RULEID:; SRVR:DM5PR12MB1771; X-Forefront-PRVS: 0624A2429E X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(366004)(346002)(39380400002)(376002)(39860400002)(199004)(189003)(36756003)(6666003)(105586002)(47776003)(25786009)(66066001)(53416004)(966005)(97736004)(7696005)(386003)(486005)(486005)(2906002)(72206003)(4720700003)(6486002)(52116002)(4326008)(2870700001)(5660300001)(7736002)(305945005)(53936002)(81156014)(50466002)(6306002)(8676002)(6346003)(81166006)(16526019)(106356001)(68736007)(50226002)(8936002)(3846002)(476003)(478600001)(26005)(2616005)(186003)(316002)(6116002)(956004)(86362001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR12MB1771; 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) Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Babu.Moger@amd.com; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR12MB1771; 23:3AWPD7CDW0q6rvUUm463SY4CbCghPZaSaT9+0tOhZ?= ysJ906YnirOF8lzehVhbxfFTiVC62pjqKoEyrdjbLNVZNIjNU648IN4tJpk9p2QC4GkzK1KYZWT6tT+x4mdx73c+CX7kkA/fSjrFY6aITGXNiW0Pediw0m0pHZAU7FumDZedDMdujI3DSg0wMhbLFZrdfwEw/9Kw8LF2pwO9lP7KKS7PxODLFX5hrtjLohibx7z+4f6n0sRt67IZolDHSGqeM4a+iESgPPlJmF0460i9gTBN7lp8vhkJsIMfZEtskp2QyVuXZ/KF44qVrKm+HZurZGL19Q3Fvu9an4khEzUoesLAkswXjk8iPdQzb+lDsOfbWjgUTHtIKOYpi6tUyvPdMPFmdXgz5nB3AyoBY7SfbNu75EFWqLGhq3act34wq0a3Kh7ijhYtzp5uc+y5ylqWeYrCvoEI9w6CiMQOZ+AFih2sK/l7IZN6KPoZ8IykfYfNWrw5fKS/TewGGbIB+bBdu8cno52sfi7/38LXjULzUcqo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nMm3vRJUdNbCSl0+hrgXXxhhXWjtEVba4KiI0jnGoppluRyMXlmOhcxGpxkWIbhRjuWVwAiBZw8pM5lyRixBWfk9S/e1vooiNL0J X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Mar 2018 21:31:19.1806 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 61d38e52-c867-4ec6-350a-08d5942a1494 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1771 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.33.64 Subject: [Qemu-devel] [PATCH v5 0/9] i386: Enable TOPOEXT to support hyperthreading on AMD CPU 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: babu.moger@amd.com, kash@tripleback.net, qemu-devel@nongnu.org, kvm@vger.kernel.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This series enables the TOPOEXT feature for AMD CPUs. This is required to support hyperthreading on kvm guests. This addresses the issues reported in these bugs: https://bugzilla.redhat.com/show_bug.cgi?id=1481253 https://bugs.launchpad.net/qemu/+bug/1703506 v5: In this series I tried to address the feedback from Eduardo Habkost. The discussion thread is here. https://patchwork.kernel.org/patch/10299745/ The previous thread is here. http://patchwork.ozlabs.org/cover/884885/ Reason for these changes The cache properties for AMD family of processors have changed from previous releases. We don't want to display the new information on the old family of processors as this might cause compatibility issues. Changes: 1. Based the patches on top of Eduardo's(patch#1) patch. Changed few things. Moved the Cache definitions to cpu.h file. Changed the CPUID_4 names to generic names. 2. Added a new propery "legacy-cache" in cpu object(patch#2). This can be used to display the old property even if the host supports the new cache properties. 3. Added cache information in X86CPUDefinition and CPUX86State 4. Patch 6-7 changed quite a bit from previous version does to new approach. 5. Addressed few issues with CPUID_8000_001d and CPUID_8000_001E. v4: 1.Removed the checks under cpuid 0x8000001D leaf(patch #2). These check are not necessary. Found this during internal review. 2.Added CPUID_EXT3_TOPOEXT feature for all the 17 family(patch #4). This was found by Kash Pande during his testing. 3.Removed th hardcoded cpuid xlevel and dynamically extended if CPUID_EXT3_TOPOEXT is supported(Suggested by Brijesh Singh). v3: 1.Removed the patch #1. Radim mentioned that original typo problem is in linux kernel header. qemu is just copying those files. 2.In previous version, I used the cpuid 4 definitions for AMDs cpuid leaf 0x8000001D. CPUID 4 is very intel specific and we dont want to expose those details under AMD. I have renamed some of these definitions as generic. These changes are in patch#1. Radim, let me know if this is what you intended. 3.Added assert to for core_id(Suggested by Radim Krčmář). 4.Changed the if condition under "L3 cache info"(Suggested by Gary Hook). 5.Addressed few more text correction and code cleanup(Suggested by Thomas Lendacky). v2: Fixed few more minor issues per Gary Hook's comments. Thank you Gary. Removed the patch#1. We need to handle the instruction cache associativity seperately. It varies based on the cpu family. I will comeback to that later. Added two more typo corrections in patch#1 and patch#5. v1: Stanislav Lanci posted few patches earlier. https://patchwork.kernel.org/patch/10040903/ Rebased his patches with few changes. 1.Spit the patches into two, separating cpuid functions 0x8000001D and 0x8000001E (Patch 2 and 3). 2.Removed the generic non-intel check and made a separate patch with some changes(Patch 5). 3.Fixed L3_N_SETS_AMD(from 4096 to 8192) based on CPUID_Fn8000001D_ECX_x03. Added 2 more patches. Patch 1. Fixes cache associativity. Patch 4. Adds TOPOEXT feature on AMD EPYC CPU. Babu Moger (8): i386: Add cache information in X86CPUDefinition i386: Initialize cache information for EPYC family processors i386: Add new property to control cache info i386: Use the statically loaded cache definitions i386: Populate AMD Processor Cache Information for cpuid 0x8000001D i386: Add support for CPUID_8000_001E for AMD i386: Enable TOPOEXT feature on AMD EPYC CPU i386: Remove generic SMT thread check Eduardo Habkost (1): i386: Helpers to encode cache information consistently include/hw/i386/pc.h | 6 +- target/i386/cpu.c | 735 ++++++++++++++++++++++++++++++++++++++++++--------- target/i386/cpu.h | 66 +++++ target/i386/kvm.c | 29 +- 4 files changed, 702 insertions(+), 134 deletions(-)