From patchwork Mon May 14 16:41:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 10398893 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 C278D60536 for ; Mon, 14 May 2018 16:42:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B40DF28390 for ; Mon, 14 May 2018 16:42:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A8677283AD; Mon, 14 May 2018 16:42:30 +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 DE83528390 for ; Mon, 14 May 2018 16:42:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932296AbeENQm1 (ORCPT ); Mon, 14 May 2018 12:42:27 -0400 Received: from mail-cys01nam02on0080.outbound.protection.outlook.com ([104.47.37.80]:44837 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932262AbeENQmX (ORCPT ); Mon, 14 May 2018 12:42: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=8/7sqGkhbQQTDHGPGYEiNo1pCSE/hXRWhi6i7h625Tw=; b=lnRrQ7kVLLK4Cf85NJzgL36ZoRzmpJ/F+URYAjYWrXMbrEIcnDHIBI3OBY5WkezJuZhu/hkI6TfhkdnjCk4SfgMVcBuKK8ViGP9M3jxGQAkXsFCcyS9XxLz3xLqxVVQw/jwmmgVL9OzALoOyqGlYlVbFqcDQaebqZKeEDUaw2lk= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Babu.Moger@amd.com; Received: from bmoger-ubuntu.amd.com (165.204.78.1) by MW2PR12MB2476.namprd12.prod.outlook.com (2603:10b6:907:9::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.755.16; Mon, 14 May 2018 16:42:20 +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 v9 6/7] i386: Enable TOPOEXT feature on AMD EPYC CPU Date: Mon, 14 May 2018 11:41:55 -0500 Message-Id: <20180514164156.27034-7-babu.moger@amd.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514164156.27034-1-babu.moger@amd.com> References: <20180514164156.27034-1-babu.moger@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: SN4PR0701CA0008.namprd07.prod.outlook.com (2603:10b6:803:28::18) To MW2PR12MB2476.namprd12.prod.outlook.com (2603:10b6:907:9::15) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:MW2PR12MB2476; X-Microsoft-Exchange-Diagnostics: 1; MW2PR12MB2476; 3:/wl4+iXO3Dw6T2ubsc+Km5tN7ZtnPnt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13eHh30ixoV4D/sw6ZDD7vYSMvXa+7xgcGY/Izh/zc3WN6TIkLiJ1r4K9AnNKhlxRd5ZYoHxRBmQdUp/c9GYk7kgcbtox5HPpeRFjm+nZSUrV3PjNrq58+UnCNHEI1e2g6oIs/YpKG+xlVMPVwg7lr3JUmvr6e1GSm27lXND6pr8tkaB9t3Q44PP2CsIQDGQ3IfOsyYPlQtKHOGzIcEKnnpyIYJ+Zai3NZjEufUh2qiMd426973x65FIOqs89hmWuIbfL8euVnTypBrYy5JBQizTg4VP25uL6zKa0GZHe8kOZ8YV; 4:pYgx4Y0mEfPXBd4Cj/nc9KVfeId6NGA4Aggr4pZVoN7KOj7DHW0cMfSa7WaYQZ4HK+yMUD72UJpjhJD66OmqJFuQFUkESUL98MYsLAaNeb97cxH62qg5e6+VMCupMV7aqQcOx8I3fen2b3Id+oh+Hr8Ft0dOZmIt+D+S2G11LSOUzdGzKuPmCtUV7fsKVxBnjDt5v0Xu/ea8fk36v08I4b6UoRQfIn6rPlT7wHk9NWAR42IULsRz1DBJxAfn8QEQ9JmByr6uY+mct++2fHtW/Bks/0we/4z0n2FvcwEpD/ylDTt+lQwmN5QHxkJoP205 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)(3231254)(944501410)(52105095)(93006095)(93001095)(3002001)(10201501046)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(6072148)(201708071742011); SRVR:MW2PR12MB2476; BCL:0; PCL:0; RULEID:; SRVR:MW2PR12MB2476; X-Forefront-PRVS: 067270ECAF X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39380400002)(39860400002)(396003)(346002)(376002)(366004)(199004)(189003)(50226002)(53936002)(50466002)(8936002)(8676002)(39060400002)(48376002)(2616005)(486006)(476003)(305945005)(25786009)(7736002)(6666003)(446003)(11346002)(956004)(59450400001)(5660300001)(76176011)(186003)(36756003)(86362001)(16526019)(81166006)(26005)(4326008)(386003)(81156014)(7416002)(106356001)(53416004)(72206003)(97736004)(316002)(47776003)(478600001)(105586002)(51416003)(68736007)(6116002)(3846002)(16586007)(2906002)(6486002)(1076002)(44832011)(7696005)(66066001)(52116002)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:MW2PR12MB2476; H:bmoger-ubuntu.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; MW2PR12MB2476; 23:CSz7GgSn0PaQPhOEuK9ggCpB3eQUAz5bFkuuHFLLw?= =?us-ascii?Q?fXsN3F97IsM5z90qul/mkcHf60O1MOdhOpz9n1qY1CBYJAhV5Jr9QjR/1LNG?= =?us-ascii?Q?qU3bGa4cKWA9tQGmlAPRFh4QBHTkcn/JoH2AssHxyBSvWz75C0I3aL4Up1Tx?= =?us-ascii?Q?bxerfkiCjpjbbRpy83Sud0uppYYx7/QXSGkfqfuaXyedJrQL/g1y0BGWryOj?= =?us-ascii?Q?9q6MGVawY7Pt9ICgQ0+72PfjMjzDuT9cj0cobUQYNiCCFydibN+3hE7ncv8z?= =?us-ascii?Q?/tG8H6p/tJq3LTT1WY3IqVFr41sZslFBAe5iAtXmWbjJfmVAbrjiMligMWHP?= =?us-ascii?Q?JTWvuuTJ38Bv4tXSIO+IL7j72N/XzOQ+4zN9+voqvgRwrnzv9F5pcqYT7yXF?= =?us-ascii?Q?F9LHi3u+FxJjMDroATEQSU9FncwBmaE4sJdMFwJvVkb/uFRRmjNaTAX+k/6Y?= =?us-ascii?Q?1+rELOQLmgo4qDGrP/nSytOqzD+G/7H3byNaAR2Nxx0ccjuxRcRklGSwOMaL?= =?us-ascii?Q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HRxYx5mDnAGvyaUCF2TnJQd4tVCjRK+2RUGtl9SuJM8Exz6h/VFJw1WidhgTQ12kMDqAG6ieAB1litsP+oZOeazMbB3HIyAskWaiLRSaMvkZ3EuxAQsGGe5rq+ytt7TX X-Microsoft-Exchange-Diagnostics: 1; MW2PR12MB2476; 6:JcrdGybphUCS/2RFZMHkpUMynQghwhbVGUowkbtfJ/hjbvhs8EpkXG6G0NQA3pfz0jnb7etyf4zAY5+Lp6x3uGxBdy4nJaRp/FJEs+oWHHI/Pbm6BUN9aUGOZ8LNFX1h932etMi70VRTyBylxHJH8izwHGV/ixB1b+lDY1qFbuT2Zo2+0qU+MHUT1zYmqM5xfzAltHzqRE5vVwAShoepYojdatoYB46JkR1zXa0kJpQ2ng9ts9lOkdZ7bcdgpFPnUYYZRmi4hi5WfBUCXNj/9kIKFPGEk9np9Ahb9Vbw92J9uyRbyah3eEdUZxsb6S/T9bngmbVtSUi3ttVeHaZBpEE21Q7AdmhSQGssVskaecb1V9n7XPMtSDhrJEq7d9cwqDzdjAKQs6o6cMBczdUHHotmM0H+6RWMWgJ+wGsgdue2e70HAzTcvM49Ekjp63BY87cziQ0XTaLqvmDHf6+BtA==; 5:MiDIe/E9DgOT/yL84co/jgX4d98RhqkC/rSYLOwA5/7Ms/90s7LdIn7nJ4thehaKAqoXNmhzp2Wh8BGm1e5EcjlBkm7um8qLls9I4P2KSDxzi8S2GdmJ6k1ZVynF7evEvFcD8nCaUjeJruxYao4dtB8e9Ae+a85JEAm08BgmAic=; 24:iSvA31lWZ+9ELOy2hgiRLThM/6376LhbABVh+S4+oEqYRMVgTlAml3l5qotBA8nNTJUiZ60tUSe4yVDyDF1AHWHnZCXwONwGwOyPhcx9w74= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; MW2PR12MB2476; 7:UaCg6RSx0817/gvWx5uHJsbuwhY6N9LMu6UZLxjggo3SRd79plweCjvghWjlKEQqDaMbLkeNS6/0BG6/p9bKxNynGBQu55XeY6cmeN4KEAR4cCkA9RuuphUFI0M39icrgNmBj4fE2I5G0NwIO67IX+9pT/QU0U39UrTYVFfephQVVpck89Sm9zrYLvNGqxvXC73aM4BIcKaF1NsAzmDcQeUX/vyyT6a7S7qBWoSHnrOW6v2gLFkByrOY7K4n4ROc; 20:jaek0BKC8R5v3Y2Eb/LhtV7EvhgqH0Mq8ftj2BprnlL4E7LeJYEbsPKCQdvmYWrm3Pwv1xfG8gAqW4yJfykEDjHNItduBbV1fJEzo5zZShUVwKT4APpdTEFYvds0U1UhVlcoxbtIF1vI5EazAf4s5X9qFHX4xDx/GjvBafnwbV1Nr7HkT6AC3VWczD6Y2P8jSrA61KIkmm3hPbo96VzY0CqhDwUZ1iL+Of1G071vkppe2IhESEin+pMZ4AMe8NEB X-MS-Office365-Filtering-Correlation-Id: f04f89a2-6006-4058-fda1-08d5b9b9a9ce X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 May 2018 16:42:20.2733 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f04f89a2-6006-4058-fda1-08d5b9b9a9ce X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR12MB2476 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Enable TOPOEXT feature on EPYC CPU. This is required to support hyperthreading on VM guests. Also extend xlevel to 0x8000001E. Disable TOPOEXT feature for legacy (2.12 or older) machine types. Signed-off-by: Babu Moger Tested-by: Geoffrey McRae Reviewed-by: Eduardo Habkost --- include/hw/i386/pc.h | 4 ++++ target/i386/cpu.c | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index df15deefca..c01adc92ba 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -310,6 +310,10 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *); .driver = TYPE_X86_CPU,\ .property = "legacy-cache",\ .value = "on",\ + },{\ + .driver = "EPYC-" TYPE_X86_CPU,\ + .property = "topoext",\ + .value = "off",\ }, #define PC_COMPAT_2_11 \ diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 18a7872b7d..de2749ae81 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -2424,7 +2424,8 @@ static X86CPUDefinition builtin_x86_defs[] = { .features[FEAT_8000_0001_ECX] = CPUID_EXT3_OSVW | CPUID_EXT3_3DNOWPREFETCH | CPUID_EXT3_MISALIGNSSE | CPUID_EXT3_SSE4A | CPUID_EXT3_ABM | - CPUID_EXT3_CR8LEG | CPUID_EXT3_SVM | CPUID_EXT3_LAHF_LM, + CPUID_EXT3_CR8LEG | CPUID_EXT3_SVM | CPUID_EXT3_LAHF_LM | + CPUID_EXT3_TOPOEXT, .features[FEAT_7_0_EBX] = CPUID_7_0_EBX_FSGSBASE | CPUID_7_0_EBX_BMI1 | CPUID_7_0_EBX_AVX2 | CPUID_7_0_EBX_SMEP | CPUID_7_0_EBX_BMI2 | CPUID_7_0_EBX_RDSEED | @@ -2469,7 +2470,8 @@ static X86CPUDefinition builtin_x86_defs[] = { .features[FEAT_8000_0001_ECX] = CPUID_EXT3_OSVW | CPUID_EXT3_3DNOWPREFETCH | CPUID_EXT3_MISALIGNSSE | CPUID_EXT3_SSE4A | CPUID_EXT3_ABM | - CPUID_EXT3_CR8LEG | CPUID_EXT3_SVM | CPUID_EXT3_LAHF_LM, + CPUID_EXT3_CR8LEG | CPUID_EXT3_SVM | CPUID_EXT3_LAHF_LM | + CPUID_EXT3_TOPOEXT, .features[FEAT_8000_0008_EBX] = CPUID_8000_0008_EBX_IBPB, .features[FEAT_7_0_EBX] = @@ -4540,6 +4542,11 @@ static void x86_cpu_expand_features(X86CPU *cpu, Error **errp) x86_cpu_adjust_level(cpu, &env->cpuid_min_xlevel, 0x8000000A); } + /* TOPOEXT feature requires 0x8000001E */ + if (env->features[FEAT_8000_0001_ECX] & CPUID_EXT3_TOPOEXT) { + x86_cpu_adjust_level(cpu, &env->cpuid_min_xlevel, 0x8000001E); + } + /* SEV requires CPUID[0x8000001F] */ if (sev_enabled()) { x86_cpu_adjust_level(cpu, &env->cpuid_min_xlevel, 0x8000001F);