From patchwork Tue Apr 18 21:17:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Lendacky X-Patchwork-Id: 9686449 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 646CF602C2 for ; Tue, 18 Apr 2017 21:27:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 552892094F for ; Tue, 18 Apr 2017 21:27:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 496CC252D5; Tue, 18 Apr 2017 21:27:13 +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=unavailable 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 EDE6E2094F for ; Tue, 18 Apr 2017 21:27:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757955AbdDRVRv (ORCPT ); Tue, 18 Apr 2017 17:17:51 -0400 Received: from mail-bn3nam01on0085.outbound.protection.outlook.com ([104.47.33.85]:4220 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1757888AbdDRVRh (ORCPT ); Tue, 18 Apr 2017 17:17:37 -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=DKD8ZkqrUMZx+QORkroEIHjARQfbyNbG1PW8gEIJHP0=; b=E0aK7T6Ww5k9ULFnX3unXp2XOCoOJMWsDWHHtrHGoLqjcACqhmxkuYHfGvPshtKY6qfiDZmVKpglnVqdOpIZM4avv12kTK2Tq80lzm3QtOBIUdyFtECt0FjfDsQ08SR8CSYniGJOGUKGD7YZInHzZ0wVbeOjxEUxjZKdzNaopE0= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from tlendack-t1.amdoffice.net (165.204.77.1) by BN6PR12MB1137.namprd12.prod.outlook.com (10.168.226.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1034.10; Tue, 18 Apr 2017 21:17:16 +0000 From: Tom Lendacky Subject: [PATCH v5 05/32] x86/CPU/AMD: Handle SME reduction in physical address size To: , , , , , , , , , CC: Rik van Riel , Radim =?utf-8?b?S3LEjW3DocWZ?= , Toshimitsu Kani , Arnd Bergmann , Jonathan Corbet , Matt Fleming , "Michael S. Tsirkin" , Joerg Roedel , Konrad Rzeszutek Wilk , Paolo Bonzini , Larry Woodman , Brijesh Singh , Ingo Molnar , Borislav Petkov , Andy Lutomirski , "H. Peter Anvin" , Andrey Ryabinin , Alexander Potapenko , Dave Young , Thomas Gleixner , Dmitry Vyukov Date: Tue, 18 Apr 2017 16:17:11 -0500 Message-ID: <20170418211711.10190.30861.stgit@tlendack-t1.amdoffice.net> In-Reply-To: <20170418211612.10190.82788.stgit@tlendack-t1.amdoffice.net> References: <20170418211612.10190.82788.stgit@tlendack-t1.amdoffice.net> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: MWHPR1701CA0010.namprd17.prod.outlook.com (10.172.58.20) To BN6PR12MB1137.namprd12.prod.outlook.com (10.168.226.139) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 981cf094-032c-4b9b-2f46-08d486a04d96 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(201703131423075)(201703031133081); SRVR:BN6PR12MB1137; X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1137; 3:3wVLFO3l64uC9pLJe6jHVfsBxfEv+/PH6nXF7SNVeA+kZB9YlsEbEnVk9x3gEnYStzG2lriIVwyMOYvf/dnuAkvUN3Z6sScjR4oItOI6qJpCrpC8cNhiM59JTzxdhl6gZJIYeK/36Vxp16iu8kk7jwxgJ46arYy9ZYhE7VM9UMjieBs9124S19Ml/ZoSabMZhGlDhW4HPKZolQDIxjg9tj/AA0DNbciWxjrqyMQGDFYqswLckZ8yit1bcaiyKEM5YKBgH3lBaoWxGz5kyQEnAYQhkJrC+w4OyraFdv9eTarVfx34KqWf6fxlVTCbXBa+EPjipZiY951JzjNtSPuMRm6hTBnJv21m0jfZUMdaBMg=; 25:vzba8J1Gcysu0oS16/8GAYdqsrlIoT/wBd+ylNE8z1qfs6QNumO1xJ798SnwumIPo2XCoMJMaUas0WNeN+mObOzHKPli/LXMS1XB7MQXd1iww7R8VCPB1QTueu51tCRLx4cQtDLTqc3bPdQsg1fQIkXsjjqFTgQQe7eLhamDlJZmOzVAXQVJKFAbk5yT3zY9v9QZCfSp4WO6MeNLzdaktsG27C3u/t8d+9nmpu+gsG2UACEnF1powa9kJGdJ/0fDXqKISIZJ6grP2Km91Hcl+L2hQE0aI8k3a0pvnh/bjuHN5+sOfR9Gkq44R9F6YMVEP5K7DSVhPz+6fW2M0EEA75XrLGjpfAFsJBZ0asr0LaMKWq5RLCPD9gjfnwUby5BLMEk5m6mMCo16xBCJUCLv8U0SKJzSxQ04uU6Ajuoh3RwP4nHh1rhVHnyiyBnvPS8EaerJNKjJPpjDsa8uzLGjFA== X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1137; 31:MQK0ceEJjjClEq6n35ihsZlC/A4LIWkGet4CFbjEDJ6wfpGGdFfK6wNpSAB3Ac/lyIcknfhmM1cTCr/JUiCphdkzzU4Fom/OsOpD1m6vCqNGkdUT6ZmFLBf2G8fXNNwhWhYN8adP7eZnOgbOAAvDcLtFGePzNrbdYQ984Y0wD+XngAIWffOeD4Cm6X8i9PGtGrwVUpCX2AR+Y4h6wLAnislbbxerQsqDO86AY4CRDUg=; 20:0/fCzz+nc9f4LC6r4u3ctg0ktGA2vhqh+qbYYmyOC0WjnjqhN8g1RUH4G4SSq4fMolQ6btEh+jd5uLKitZ0qV5Sfbhw1HVi3tLYECw8lWHAgsSYV7ijQzmi1dZjGOlnZQY6i5pT1ocWsdpqtt5H7EAmhiJ6njOs65w2k+WFbMtyqtAQu2Rll03REtHUSHREUWoK5bpCw3upaF5Y6VmKcJx9ctuwQR6VsXF/Yx1Y9i9s6vyqt8otNX/2hVXnNJr74Vx+QSuozaVOgNuEGhv8m8PqxxeiSWQrlZIWRdE8ivkBpMhcfO2EA5ZacRA3KtGfTx+AuNNmxmdH69o/QYqR407S5jLsJ1rUnTcqLXYL7hEu4rTej3G1WC+d6HmU0Ccp3tIsNn5X2+uR9ImT1HeBXd6HdyRqtHY0pnxh8byTLTXq2oHykEPz0fj7hxDfZ9z0iZaLvxK6za3kWiGFJ9+S3gLN4R9GMX1EU6ediinGfmtGWwxxw663rBR+Jr8ODN8Md X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93001095)(6055026)(6041248)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(20161123560025)(20161123555025)(20161123564025)(6072148); SRVR:BN6PR12MB1137; BCL:0; PCL:0; RULEID:; SRVR:BN6PR12MB1137; X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1137; 4:8V0IPnvkAIFmiyt5yaOopMSqkFR0xcLDGt5194tcrXlzeFF9fpTObTklEWfP0Zg2WuGL9f+Uue1sFUVBl3HutXhcTMpO8LrY92sqOd+AA0qR67NRVx8J+EvONbyWgjOJgz/A/11CQU+YJY3XqHWZQHoLz3bGJDKX9Kyre9Mg0BMQQ/9NJHLO59lMICU9+3CterEPpx/eKOQj3+SE+JZtj7duebc49VfGAmuJIFWOH/atn1PoS/nZ4/9OycibErNsJygBYGi5BSn4UkStQyHNfXNWJY23wYjduYrk+rjkiGnuyLF8W0eZMK6yb37tVLQDsWWHFOrBAW6hKELIwqL4r/aiFBW61r/BkrYdrzMbUVrZFKYs9mW90L3qD9usQXsKgymEIwErZ4m/s7+SGJlw3JksWyP7ERu64yJ3o+c+tpIZOwGuuHDHU/wmfQFPsyjhBkeeAvjGYzM+uGiRsNZqA1a/mbTtvTXJscyWk+cR/wKUhT+3h7vUCEQ88VtJoSmpkFYI8sPs6h4qE2DGWf/JwU61Vee3FCatle+A0dhyigIF/GtwwrCkZfnNMkmR6KYDF6BmAQXmIZy2N4bgTz3e2Vm5PIi0XrjUbCUp+G596p9cE4tDIRUzoJK9buIr2sIhO/SKawOeBhDRwyhLFbPjJnAlm/7WGuv9Eo8JKXDFgIUjD1IjTm6ygKKC5U4SOir/JFJ4ugzG+JQ7xloipPVTpyiUEeDXAFKkjDZAVcWxQ0uvvhpDQKIhMNM4061jv/D1q7og4pdeOuJUVztyCkbzgg== X-Forefront-PRVS: 028166BF91 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(39840400002)(39850400002)(39400400002)(39410400002)(39860400002)(39450400003)(7736002)(7406005)(2201001)(6506006)(7416002)(23676002)(53936002)(86362001)(54906002)(5660300001)(9686003)(83506001)(305945005)(81166006)(8676002)(55016002)(42186005)(2950100002)(53416004)(230700001)(50986999)(6666003)(1076002)(76176999)(103116003)(6116002)(33646002)(97746001)(3846002)(25786009)(47776003)(4001350100001)(50466002)(38730400002)(66066001)(54356999)(2906002)(189998001)(4326008)(921003)(71626007)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6P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PR12MB1137; 6:zgSB1yjuSgjGp4ilcDPd037vX/m+twolO7Vkxy28edGSFJG9wzD0QK9pJpP+iXcE85wVxFy5woKCkNYTxNywM7XoLPBcm1uWDLrkgn1VXeIOSYYlqZTpC8N2g3pJi8stcho/lA0Y+2+pOfKt70LNl+LOErWfF5Jjq0u2EHHJ8St4DzZjBBY33seJKdHyvfOimapX5A40QKmlqf6osBbJ/JKFGDo6+a+xe1a+agyjKloDd+Q7buT99HduSvdeKBmeAmcMWtjStL94Vg/xOsfGpQpnwIhVm3o3j57fodELWhf6pVcINCOdz2uDYHwCriUn3v/1/Yfn4hLc4URUP0baVBEfv0GfvitNMzqb3QY+kGhtEm8OjB5aSTjHuw6YMWL5RWwwHi5+4R2Bswe/WYEvUThFAYGwiS2568K6TAjV/WnX1hD9RAr33hzTGBSG9vXIp4nLlQ/wclCqDgnUD2dqBijUinv98Nu9sRTbl5scWeQ=; 5:bdt1VXCysAh+lxfnyRJNAM/OdPQ84FX10MstIxunky3AaLjmwHATOJITlWJITbJvJckAqpllmshKA4fIZOUVega6Xnlw9XP86PvkSSa0mexAPkDBOMfYwVwvoMowDo4LvYVTQpjcobRvOkrlDWqkHg==; 24:lywyyw/lJAtfm9mZ2ngbxvL8nWhB97ipSZvqlhJbdngvnr3I7IegxpW0DWflf/aHF5MkawRBJI/6cLwFmhHhTQn8a7xF7qE1fUSrm/Z9Fos= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1137; 7:YbF5s0WKlCsdpaxPOJW0TnIavXyGYyqjat9Taam1Uyrjlmgr07sIxm/0R8gcRHZWP4LjgblH0iNXIhhL6ksnRbYOF4jbcJ/mwvF4bnAV86/vcvRFqMMTuwd/G9BKsFlmb29A1r8jN6z6+BbAVTncNZWGL2cNrHifxuhjaduqKc2PK8bd0SHLNYck2wgVffO7X6brhXP2NIB276WMzwisRSaDIClimqjs51JsbKTvnDNe4DT5jnDQhNDifpB7Qjv5rJsZU8ywWZGXjG4g3RT2tvlzvbQ1FM7/pnHRVyK8TzXCKWNUlcKCZcQa75AIkvbr2ycKM3EZtoBuLcgB4NL87w==; 20:Q39WY9Mawmt3xwJcnfFzQ8LUk5aUKH27VFoTRSDtQpzgZU7rN/Je4axjA15vhXt86BcI4L2Mv43P2gWjqCx63wg7TzUM1QKxSK4aUR5tztKSt+46kOiHkiRn7XCtF2397Hewc7Z+B6Pu57fMAGQ0qGMsYtRUF6vnC0DNVOdSvs03Fornn44MlrCDa6QWqQodQum1xnOg26KgSOJaxIucUzk0K8vG5qMh8lOkE4xb3M710uZM/+pthnsvqTz0qEky X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Apr 2017 21:17:16.4162 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1137 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When System Memory Encryption (SME) is enabled, the physical address space is reduced. Adjust the x86_phys_bits value to reflect this reduction. Signed-off-by: Tom Lendacky --- arch/x86/kernel/cpu/amd.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c index 5fc5232..35eeeb1 100644 --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c @@ -613,8 +613,10 @@ static void early_init_amd(struct cpuinfo_x86 *c) set_cpu_bug(c, X86_BUG_AMD_E400); /* - * BIOS support is required for SME. If BIOS has not enabled SME - * then don't advertise the feature (set in scattered.c) + * BIOS support is required for SME. If BIOS has enabld SME then + * adjust x86_phys_bits by the SME physical address space reduction + * value. If BIOS has not enabled SME then don't advertise the + * feature (set in scattered.c). */ if (c->extended_cpuid_level >= 0x8000001f) { if (cpu_has(c, X86_FEATURE_SME)) { @@ -622,8 +624,14 @@ static void early_init_amd(struct cpuinfo_x86 *c) /* Check if SME is enabled */ rdmsrl(MSR_K8_SYSCFG, msr); - if (!(msr & MSR_K8_SYSCFG_MEM_ENCRYPT)) + if (msr & MSR_K8_SYSCFG_MEM_ENCRYPT) { + unsigned int ebx; + + ebx = cpuid_ebx(0x8000001f); + c->x86_phys_bits -= (ebx >> 6) & 0x3f; + } else { clear_cpu_cap(c, X86_FEATURE_SME); + } } } }