From patchwork Tue Jun 27 14:58:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Lendacky X-Patchwork-Id: 9812177 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 80C8E60351 for ; Tue, 27 Jun 2017 15:00:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 73C71286AE for ; Tue, 27 Jun 2017 15:00:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 67F78286C7; Tue, 27 Jun 2017 15:00:53 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 29DD1286AE for ; Tue, 27 Jun 2017 15:00:52 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dPrwV-0003EP-VW; Tue, 27 Jun 2017 14:58:15 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dPrwU-0003Dm-VU for xen-devel@lists.xen.org; Tue, 27 Jun 2017 14:58:15 +0000 Received: from [85.158.139.211] by server-10.bemta-5.messagelabs.com id C5/10-01734-68272595; Tue, 27 Jun 2017 14:58:14 +0000 X-Brightmail-Tracker: H4sIAAAAA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elabs.com!1498575490!102431589!1 X-Originating-IP: [104.47.40.75] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 56928 invoked from network); 27 Jun 2017 14:58:12 -0000 Received: from mail-co1nam03on0075.outbound.protection.outlook.com (HELO NAM03-CO1-obe.outbound.protection.outlook.com) (104.47.40.75) by server-7.tower-206.messagelabs.com with AES256-SHA256 encrypted SMTP; 27 Jun 2017 14:58:12 -0000 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=ftqMCvmg+ce+XxC1oJ9rgy4fNJdKfySZlvBr6/zkVoY=; b=aEYpqWxnqoCO8VE9s37ofcQcquo9ytxZ9OtCDSKztwlTWjx3baZWNlXja2e0R7eWj3Lay1Ur+FlRtw24M/7wHCEkcveDGpjorxgtKZKUtm/SpaUxz7sGwa9ioDTsvkeVVxIUcxOht5Qp4kGPbYNNUS0Zgw5OSynFIPRcFMz53gg= Received: from tlendack-t1.amdoffice.net (165.204.77.1) by MWHPR12MB1149.namprd12.prod.outlook.com (10.169.204.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1220.11; Tue, 27 Jun 2017 14:58:04 +0000 From: Tom Lendacky To: linux-arch@vger.kernel.org, linux-efi@vger.kernel.org, kvm@vger.kernel.org, linux-doc@vger.kernel.org, x86@kernel.org, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, xen-devel@lists.xen.org, linux-mm@kvack.org, iommu@lists.linux-foundation.org Date: Tue, 27 Jun 2017 09:58:01 -0500 Message-ID: <20170627145801.15908.37399.stgit@tlendack-t1.amdoffice.net> In-Reply-To: <20170627145607.15908.26571.stgit@tlendack-t1.amdoffice.net> References: <20170627145607.15908.26571.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: MWHPR2201CA0056.namprd22.prod.outlook.com (10.172.59.30) To MWHPR12MB1149.namprd12.prod.outlook.com (10.169.204.13) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 836a7512-f226-40ad-98ea-08d4bd6ceb35 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(300000504095)(300135200095)(300000505095)(300135600095)(300000506067)(300135500095); SRVR:MWHPR12MB1149; X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1149; 3:t/WBSbg0N5/3l0/dWsusDFsP4eF/HcVJhPcHdRF4Q9DfD+pRIdJaSJP1bxXurgthxx+1OAkTEIJWDJto1dElPEfRGCU/tuMuEhlCGqS574voV8TNsKXKCr01ZFFofm5/y60ketv7jIehKRKVtqVxJefNBa9A2nBe/ebe2CSAAI+a88wx85+S4NY6JWaPaBZXfDxCu8MZ8+joRQkOLUdpsL03pJUhvq9HVbAywlbx4FJ2oXK0F08tXg0sr8jLbRiOrAONBM/5aeJRsd9+noPTdz35SgE89uJN/ICxnFGuz52m/RQzLR9NpNFNIqc3CwYBEwTE0ow4qk+kViBycLJS0RPrnlrxYuVA5XI5NGpTFajR5BWWrAKB4fv48MKf3K1nIc2yZGVsk28XAwvLPe6dfuxooFgprGqDrbJ/cJWYzgUKwJ2pRKhNBuE/Tq4MMVoet36HLDe2Q3tGYGJM1mkex6FZcQl4EKznligsEaoU+lC0dY4QIV+w1goYEftsyST4tEgNQ3ZUggzECku8v+nrHlcqobH6ITpf/t2EcOjW2SFOhdir2r6hCDqiZ7swIY+pAb+z5i60PxZSdghu4j8i5Z3nWdfvgjEwOo0XwOhUFGoFn9NEBrKSldjo3z/VshnxLCWSLShrkiwqons1ebHbBHYYUuzkiQh/Z9fJd90fCkoGKDgVFVhrVn6bipPwZdUgGWjoqyMiyEp18rQGO9AV3MrCgBk6o2a1qwY/PxnN3d3r3gLmGb/sWULI0LXUji72Xbk5sSjAj4tBNkoeICmNMg== X-MS-TrafficTypeDiagnostic: MWHPR12MB1149: X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1149; 25:jM750BQU68p8elm6HXpdQ8HXssK1KefJYud0UpZcKrmjPGKQK0dETCr6Wg1mjLBxOjXmVDepc/86rvIyRjg12oodvfC03bUh/fydkpZzWsIrBsw4yczOd8qIFcF1tFdMT8v3D2ylD15ObT2t0vXba0vN4VWUNN5KpMxMyxJahDcoDWqDvbp1opfUSXUScC21q6SZgLxPyc0OwdgAlR4uKnfHZpPcnKdL9SMOrucibnRUftLqSRIkGl3s7kBh4ymaqFEgOvmMlC1w24RDsJ3dxfbb325RozWQc+zpAl/HE6HJKhcG9aw9LFSqss2YpXruELf0QeC/jkUqhJJg+5xGCb/bw9/M9afaJ8Arig4tyzQcNlxhovPYjmY3dyGqC2Co4js3teLpeugm/bW3pT8K15dKEREOBsuovKiHBOcFS/xsCdo019sjqwBICL3MNXYLK5cbzK9X87HNVF8q8Gf19OEgXA6ZOZ8qxRIff/mKfhLQe85r3Chn5PI3rLQb1se3ERQA8qR+Dzt3G2FLXD6d4pNDnbCq+9JPbFvyqw6ywojH77rvoD0GeJzOikPh2/asl+ZSulMdYnRz1asGJ3G3Y2YI8AOULDRSSF5ARbFa2loiB6JHzBjOb2Ji9PEQhWNyq6bGDkWustQ0VhfFH9XB8pVGAQJ6gRdsYlC1owKev9qwMjc/sD2dxBVJxvlwkYX2RUggjM1oxkt2UaA6550AwyVqYIk8mg41g9BYPsAAUi30/AflejSrWw82e89LEV3UwaTfBJxpxKwsgcNliwLyPi9F/vn1Q0BXzW46azUkXT4w0nzc7XcRO3PMIMW+46bZVhhv3wdJbiDjzmZ8D8B78UAwihFke3BPlof5T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02XdY00MNjt5lrtZJ6oeP+bz7qCdXu/5gPYo/3Dt/xVNvpvNXk+rtsJd7UoxoBqXfwi9sYJGOx63C+gf4neIe/a+MZ5BWl5PQ4yRUNBTI7kbqss1Apl0GKdJZsherxed7rqCCBlG8vmO7wuMr8/5E3+nBesUVfwg2a/Px20BawO6Ckr1EFgjpTOACPRD3Ro80jwUPOWfjostGJL8y0yWMBB2MJIx1tqOuHRU39H6NWSMb7WfNywxhC9fggksKyqo/w X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(133145235818549)(236129657087228)(767451399110)(148574349560750)(167848164394848); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(3002001)(93006095)(93001095)(100000703101)(100105400095)(10201501046)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123564025)(20161123555025)(20161123558100)(20161123560025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:MWHPR12MB1149; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:MWHPR12MB1149; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtNV0hQUjEyTUIxMTQ5OzQ6bXRZWElYRk1sQThxd1l3NERYeERDTjhzOGZ6?= =?utf-8?B?a3RqOXU0NnNVTDdBTFl3aUlCWk9VOXljMHAvbHJhckJLZ3pXZkQrU3VsVUdH?= =?utf-8?B?Sm9GTTBBMlg0THpHUytNVUtSMk5hSk1TbzZwNmRaVEVqZXBNYk5RKzZGdTlu?= =?utf-8?B?VnlDRTRNL09BclNJSnY0Z1lrMWFZUUZuclYxbFg3MnNEZklacWlKYnYwN0x4?= =?utf-8?B?aUNzc2FFTkFQcVR1VG5oeGNJSCtVSGJEMk4zR3ozMz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ZVI4OVAzSU1jYllRL3c4b0ZUaGxjNTJNQjFD?= =?utf-8?B?V1dqNWpqV29CdHNJWWwwRU1nZ3hZTmwzQjFaZU9aakJJbndWM3ZQcWw3cU9H?= =?utf-8?B?azZDQXN5WjVnTE9mTzUxWnBvaU9jMnJjUGhKQjA3QldCSTlRcVhlZk55cXBT?= =?utf-8?B?ekx1dXhGQjdvNmJGVmlLSUc5STVKaXJlN0FacHp3TFFHYXBoUXI5WGFEVWcx?= =?utf-8?B?aXZLT0luM0JiczluUGNndGxzREdNbXdjOU5Vd2FXc0JzT1BnSXo5akxHZmFP?= =?utf-8?B?RnE5d3FMN213bEY2NitwbDkwV3RET1dpd3hvYnZIQmRtM0dEb1J2UHRTb3VP?= =?utf-8?B?Titvblk1VGVtOS93a1RJWmtkdkIwejVCajhWQUhEQS9xNjZXWDhGbFhUNzFR?= =?utf-8?B?UWRyOTVPSVJydSs3Y1dwempvUHJMMlRMbktIRnIxNFhwQjBvOUIyVjdXZVUz?= =?utf-8?B?cnNPRVBvZ281SXlxU1NUbjhMd3ZCVnl1SCtmNXdUSWptUTl5eDZjSC94RzB0?= =?utf-8?B?UDdKaVFUMFVkWGY4YnJTKzhaaUlnckxNQmw0ekhpeGY1YXhuN2tuWlkzS3lB?= =?utf-8?B?ZktFQ1g0MnhsYmo1dHA0VW5OdzdPeWdES3BMcytRalgrMFp6UG1WQjU4TTZF?= =?utf-8?Q?F5mRaNhtincp?= X-Forefront-PRVS: 0351D213B3 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(979002)(6009001)(39450400003)(39410400002)(39840400002)(39850400002)(39400400002)(39860400002)(42186005)(7416002)(7406005)(6506006)(50466002)(47776003)(2950100002)(305945005)(33646002)(54906002)(66066001)(55016002)(6666003)(2906002)(4326008)(9686003)(5660300001)(72206003)(53416004)(23676002)(478600001)(83506001)(97746001)(7736002)(103116003)(1076002)(230700001)(25786009)(54356999)(76176999)(189998001)(50986999)(6116002)(3846002)(4001350100001)(38730400002)(8676002)(81166006)(53936002)(86362001)(575784001)(110136004)(11771545001)(921003)(1121003)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR12MB1149; H:tlendack-t1.amdoffice.net; FPR:; SPF:None; MLV:ovrnspm; PTR:InfoNoRecords; LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtNV0hQUjEyTUIxMTQ5OzIzOm9WR1dtT3VDd1JYNGhFdHdqQmRXb256MnVB?= =?utf-8?B?STgzczg3RGx4eVdhSVJMS1gwUW9uSDZHem1uWm1ab1lUak9zT0d3RFR4c3I5?= =?utf-8?B?eDdyR3R0Y1djaTBTQjlXVW9CUXBrVmh1Yi9JbVpxN1NQN0pmWEVWOURyRzZZ?= =?utf-8?B?ZEFRZ2xzTTBqb2gvVkdldGlpc3I3SEpuTWxWd1BlL2dPd2txZ0RzM3ZiRUV6?= =?utf-8?B?Q3BqUWl1T0hnK2ZxakNXbnVLRGRrOE9ZcmtxbGM5QkE4dGFnOHM2VHgyUDQ0?= =?utf-8?B?TmdmZlBBVmdPa21rSzA1SXlvbnlMdVlwcHpGR080V2FOb3JyVVZHNExvZkc4?= =?utf-8?B?a0hCcTNReTNJelAzYVJZZ1VYMXVxQUdtZURKcTJ3WjErSCtlZ0FWVGloTkV3?= =?utf-8?B?VDFKYUFVOXZ5TW8vNDdZc3FVMGpidUZ0UDRHTE9TbmRQWVl1RERaTVY2bWtF?= =?utf-8?B?VmlxcmI2NjZWZ3FmOWR4ZnVuQ0k0Y1piR1pQK24zSXlGMFZlbHpTNklsMnVY?= =?utf-8?B?TU9vczA0VW9Od1U4QmprNkxHVDc3WE5jWEk2RW9CS2JJMG9lR2d1QkxubGFt?= =?utf-8?B?Z1I2d2tXb3dCWWptYlpzem9jcnVXZWhoNW1OTktXZDdtMFR1S3VsTkd6SVJH?= =?utf-8?B?b1NndERzQktoTEZQU082YlpzUzgvdVVEYk4xWU8yVi9ibmJ0YWFMY2lqU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vMBxRZAZEPBqKTTcoW1lHXpRklHllutkdCCvoGW7Js9UKImaRlUWfIr+JyLRhe962eeGCUzH5waSy4nCUJGZELxQYbgjEhX1DWcUI15MHPGLXAAiff5b+D+1ASEFK0XD7ot1+OpPLymnbGLs2hrxOBYqcNcrKU/2JrYIz316axBANr/l4oNchlGQ2ieLhnZ/lOdiWEVkmVn1vyyA2avcsDEp19xU8GBmLKhI5Dfkga0Fz+C7cHWTBjkBnfiQ+h7mhIhFEmnGuWi2/LeggfbmxMrVpnqz7cvkt3il78FvaNjk030blwTSmBXT+TTA9tljY8asl5884efFy0e77h2zV+Ljl5QqQhsY9hboIgUuHGvkmTwZ0W30Izt0WekQwvdD+o/sr+drn5RU7PegWmJ1ezk5YWYaQ8RwFsE8IgN8ZJMr/icCv8j7uJXmiFzaFw1XsNy4lxTlxvaJglz4l; 24:xcGKEHLCB28shVVYwiTEOqxf3if0h6FfTYXGLVC51jwT6nYRjg6376245Fhpc9kbCMAx0AQkbWzJ2CPyljZ0Uaj16TKZVLRgtyffk3N55KM= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1149; 7:h56MG3CtMcujzZAClz1IAUrLctKK5euIeGDJW5XNCZsclapiVdDJNJayRmt5WAaFPQo41U+Sbr0ds/GAZcgaxQFSyefk3htVceehMBd8zbw7mOtWWVey3olO1PGZJJXE57zylL67hXF8as1Ek7vL48/g3VgjW2j9ZZQQtmLNZXaq2MQpX2a9PFOgJfZq2IhkyN/Bm85sLATzi7aoYT4fpY/TAoTdzuu84X2IYBB8XzWmzMPFqFWRvfuTj1oy+ES946WmmOP4BpNafdbXmd7qwFAmpwqBYQZF+riLRPiJTM3zSNxdlQoEUqKLJd7gVLskrDy6p47liB1nmHjGLLSGbp8Umm+RSh0YrBJxX/0Y0sMU4hnWPI6paHFSv/qIYMoCniY0XvLBePugfvV7qmLjPLD/Xbr4Ei4qEBoQBBQw4NLF5E3un0fmBpa9POAewskI5Ivcs5kAysenahxC52jwNgG02KjW8Jur/kbSnxTkctZuYiyKiwPVqTjV8K8F2/E/sK38giE3NhaCWGejuV3c60bmK7zjTwzEVX2vlt7jNpG7jHgdZzRT9OYqmAst0JUpU3mm3RLnMv8fIyIGsRMIUyZK12hGuUX6OJuA15nNDHYkx1Qy7SoiWA6dK3KbtlPZN4ije0peZORvlIj2puRP8J7pEO777YHWVfpLlG3kK/IxYJ8s7oHp8Cguuyz/5uvKC6cYFWGD8LDNkvp25gqQ91hMwbqaRCX8+9mYrCVEbjA47pk2ay7ntMuY+GFx2POOGXkDwT4e0wU8VTwvIPSXGLbYImUEH2c9FD4wgQ8pm1Q= X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1149; 20:Xkuzg8ckplWxfBmHo80UwahSo/QCmbXuNK8IOg2PFWFQi4fkO08rc7huEmLkpC4qbGmNlJLVNydzqnM8RVwSUZwQ+Dr7w64+QIIVY02Bouh7EXDh7Mg5DxzrygB+3kecGTbgsQVW2knv9JQpIs4ostYInYh4HEGDgSCtBX+RFxjOhnruA0P8uYiAtGhkQYDdrdin1DWUmuv9XNMhFZDyB/OZV0qdw8JydUSyprA/vsaqYZG56I43XVaB0EaPIDPR X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jun 2017 14:58:04.5981 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1149 Cc: Brijesh Singh , Toshimitsu Kani , "Michael S. Tsirkin" , Matt Fleming , Alexander Potapenko , "H. Peter Anvin" , Boris Ostrovsky , Jonathan Corbet , Joerg Roedel , Radim =?utf-8?b?S3LEjW3DocWZ?= , Larry Woodman , Ingo Molnar , Andrey Ryabinin , Dave Young , Rik van Riel , Arnd Bergmann , Borislav Petkov , Andy Lutomirski , Thomas Gleixner , Dmitry Vyukov , Juergen Gross , Paolo Bonzini Subject: [Xen-devel] [PATCH v8 10/38] x86/mm: Provide general kernel support for memory encryption X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Changes to the existing page table macros will allow the SME support to be enabled in a simple fashion with minimal changes to files that use these macros. Since the memory encryption mask will now be part of the regular pagetable macros, we introduce two new macros (_PAGE_TABLE_NOENC and _KERNPG_TABLE_NOENC) to allow for early pagetable creation/initialization without the encryption mask before SME becomes active. Two new pgprot() macros are defined to allow setting or clearing the page encryption mask. The FIXMAP_PAGE_NOCACHE define is introduced for use with MMIO. SME does not support encryption for MMIO areas so this define removes the encryption mask from the page attribute. Two new macros are introduced (__sme_pa() / __sme_pa_nodebug()) to allow creating a physical address with the encryption mask. These are used when working with the cr3 register so that the PGD can be encrypted. The current __va() macro is updated so that the virtual address is generated based off of the physical address without the encryption mask thus allowing the same virtual address to be generated regardless of whether encryption is enabled for that physical location or not. Also, an early initialization function is added for SME. If SME is active, this function: - Updates the early_pmd_flags so that early page faults create mappings with the encryption mask. - Updates the __supported_pte_mask to include the encryption mask. - Updates the protection_map entries to include the encryption mask so that user-space allocations will automatically have the encryption mask applied. Reviewed-by: Borislav Petkov Signed-off-by: Tom Lendacky --- arch/x86/boot/compressed/pagetable.c | 7 +++++ arch/x86/include/asm/fixmap.h | 7 +++++ arch/x86/include/asm/mem_encrypt.h | 13 ++++++++++ arch/x86/include/asm/page_types.h | 3 ++ arch/x86/include/asm/pgtable.h | 9 +++++++ arch/x86/include/asm/pgtable_types.h | 45 ++++++++++++++++++++++------------ arch/x86/include/asm/processor.h | 3 ++ arch/x86/kernel/espfix_64.c | 2 +- arch/x86/kernel/head64.c | 11 +++++++- arch/x86/kernel/head_64.S | 20 ++++++++------- arch/x86/mm/kasan_init_64.c | 4 ++- arch/x86/mm/mem_encrypt.c | 17 +++++++++++++ arch/x86/mm/pageattr.c | 3 ++ include/asm-generic/pgtable.h | 12 +++++++++ include/linux/mem_encrypt.h | 8 ++++++ 15 files changed, 131 insertions(+), 33 deletions(-) diff --git a/arch/x86/boot/compressed/pagetable.c b/arch/x86/boot/compressed/pagetable.c index 8e69df9..246bf29 100644 --- a/arch/x86/boot/compressed/pagetable.c +++ b/arch/x86/boot/compressed/pagetable.c @@ -15,6 +15,13 @@ #define __pa(x) ((unsigned long)(x)) #define __va(x) ((void *)((unsigned long)(x))) +/* + * The pgtable.h and mm/ident_map.c includes make use of the SME related + * information which is not used in the compressed image support. Un-define + * the SME support to avoid any compile and link errors. + */ +#undef CONFIG_AMD_MEM_ENCRYPT + #include "misc.h" /* These actually do the work of building the kernel identity maps. */ diff --git a/arch/x86/include/asm/fixmap.h b/arch/x86/include/asm/fixmap.h index b65155c..d9ff226 100644 --- a/arch/x86/include/asm/fixmap.h +++ b/arch/x86/include/asm/fixmap.h @@ -157,6 +157,13 @@ static inline void __set_fixmap(enum fixed_addresses idx, } #endif +/* + * FIXMAP_PAGE_NOCACHE is used for MMIO. Memory encryption is not + * supported for MMIO addresses, so make sure that the memory encryption + * mask is not part of the page attributes. + */ +#define FIXMAP_PAGE_NOCACHE PAGE_KERNEL_IO_NOCACHE + #include #define __late_set_fixmap(idx, phys, flags) __set_fixmap(idx, phys, flags) diff --git a/arch/x86/include/asm/mem_encrypt.h b/arch/x86/include/asm/mem_encrypt.h index 475e34f..dbae7a5 100644 --- a/arch/x86/include/asm/mem_encrypt.h +++ b/arch/x86/include/asm/mem_encrypt.h @@ -21,6 +21,8 @@ extern unsigned long sme_me_mask; +void __init sme_early_init(void); + void __init sme_encrypt_kernel(void); void __init sme_enable(void); @@ -28,11 +30,22 @@ #define sme_me_mask 0UL +static inline void __init sme_early_init(void) { } + static inline void __init sme_encrypt_kernel(void) { } static inline void __init sme_enable(void) { } #endif /* CONFIG_AMD_MEM_ENCRYPT */ +/* + * The __sme_pa() and __sme_pa_nodebug() macros are meant for use when + * writing to or comparing values from the cr3 register. Having the + * encryption mask set in cr3 enables the PGD entry to be encrypted and + * avoid special case handling of PGD allocations. + */ +#define __sme_pa(x) (__pa(x) | sme_me_mask) +#define __sme_pa_nodebug(x) (__pa_nodebug(x) | sme_me_mask) + #endif /* __ASSEMBLY__ */ #endif /* __X86_MEM_ENCRYPT_H__ */ diff --git a/arch/x86/include/asm/page_types.h b/arch/x86/include/asm/page_types.h index 7bd0099..b98ed9d 100644 --- a/arch/x86/include/asm/page_types.h +++ b/arch/x86/include/asm/page_types.h @@ -3,6 +3,7 @@ #include #include +#include /* PAGE_SHIFT determines the page size */ #define PAGE_SHIFT 12 @@ -15,7 +16,7 @@ #define PUD_PAGE_SIZE (_AC(1, UL) << PUD_SHIFT) #define PUD_PAGE_MASK (~(PUD_PAGE_SIZE-1)) -#define __PHYSICAL_MASK ((phys_addr_t)((1ULL << __PHYSICAL_MASK_SHIFT) - 1)) +#define __PHYSICAL_MASK ((phys_addr_t)(__sme_clr((1ULL << __PHYSICAL_MASK_SHIFT) - 1))) #define __VIRTUAL_MASK ((1UL << __VIRTUAL_MASK_SHIFT) - 1) /* Cast *PAGE_MASK to a signed type so that it is sign-extended if diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index b64ea52..c6452cb 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -1,6 +1,7 @@ #ifndef _ASM_X86_PGTABLE_H #define _ASM_X86_PGTABLE_H +#include #include #include @@ -13,6 +14,12 @@ cachemode2protval(_PAGE_CACHE_MODE_UC_MINUS))) \ : (prot)) +/* + * Macros to add or remove encryption attribute + */ +#define pgprot_encrypted(prot) __pgprot(__sme_set(pgprot_val(prot))) +#define pgprot_decrypted(prot) __pgprot(__sme_clr(pgprot_val(prot))) + #ifndef __ASSEMBLY__ #include @@ -38,6 +45,8 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page); +extern pmdval_t early_pmd_flags; + #ifdef CONFIG_PARAVIRT #include #else /* !CONFIG_PARAVIRT */ diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h index bf9638e..de32ca3 100644 --- a/arch/x86/include/asm/pgtable_types.h +++ b/arch/x86/include/asm/pgtable_types.h @@ -2,6 +2,8 @@ #define _ASM_X86_PGTABLE_DEFS_H #include +#include + #include #define FIRST_USER_ADDRESS 0UL @@ -121,10 +123,10 @@ #define _PAGE_PROTNONE (_AT(pteval_t, 1) << _PAGE_BIT_PROTNONE) -#define _PAGE_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | \ - _PAGE_ACCESSED | _PAGE_DIRTY) -#define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | \ - _PAGE_DIRTY) +#define _PAGE_TABLE_NOENC (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER |\ + _PAGE_ACCESSED | _PAGE_DIRTY) +#define _KERNPG_TABLE_NOENC (_PAGE_PRESENT | _PAGE_RW | \ + _PAGE_ACCESSED | _PAGE_DIRTY) /* * Set of bits not changed in pte_modify. The pte's @@ -191,18 +193,29 @@ enum page_cache_mode { #define __PAGE_KERNEL_IO (__PAGE_KERNEL) #define __PAGE_KERNEL_IO_NOCACHE (__PAGE_KERNEL_NOCACHE) -#define PAGE_KERNEL __pgprot(__PAGE_KERNEL) -#define PAGE_KERNEL_RO __pgprot(__PAGE_KERNEL_RO) -#define PAGE_KERNEL_EXEC __pgprot(__PAGE_KERNEL_EXEC) -#define PAGE_KERNEL_RX __pgprot(__PAGE_KERNEL_RX) -#define PAGE_KERNEL_NOCACHE __pgprot(__PAGE_KERNEL_NOCACHE) -#define PAGE_KERNEL_LARGE __pgprot(__PAGE_KERNEL_LARGE) -#define PAGE_KERNEL_LARGE_EXEC __pgprot(__PAGE_KERNEL_LARGE_EXEC) -#define PAGE_KERNEL_VSYSCALL __pgprot(__PAGE_KERNEL_VSYSCALL) -#define PAGE_KERNEL_VVAR __pgprot(__PAGE_KERNEL_VVAR) - -#define PAGE_KERNEL_IO __pgprot(__PAGE_KERNEL_IO) -#define PAGE_KERNEL_IO_NOCACHE __pgprot(__PAGE_KERNEL_IO_NOCACHE) +#ifndef __ASSEMBLY__ + +#define _PAGE_ENC (_AT(pteval_t, sme_me_mask)) + +#define _PAGE_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | \ + _PAGE_ACCESSED | _PAGE_DIRTY | _PAGE_ENC) +#define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | \ + _PAGE_DIRTY | _PAGE_ENC) + +#define PAGE_KERNEL __pgprot(__PAGE_KERNEL | _PAGE_ENC) +#define PAGE_KERNEL_RO __pgprot(__PAGE_KERNEL_RO | _PAGE_ENC) +#define PAGE_KERNEL_EXEC __pgprot(__PAGE_KERNEL_EXEC | _PAGE_ENC) +#define PAGE_KERNEL_RX __pgprot(__PAGE_KERNEL_RX | _PAGE_ENC) +#define PAGE_KERNEL_NOCACHE __pgprot(__PAGE_KERNEL_NOCACHE | _PAGE_ENC) +#define PAGE_KERNEL_LARGE __pgprot(__PAGE_KERNEL_LARGE | _PAGE_ENC) +#define PAGE_KERNEL_LARGE_EXEC __pgprot(__PAGE_KERNEL_LARGE_EXEC | _PAGE_ENC) +#define PAGE_KERNEL_VSYSCALL __pgprot(__PAGE_KERNEL_VSYSCALL | _PAGE_ENC) +#define PAGE_KERNEL_VVAR __pgprot(__PAGE_KERNEL_VVAR | _PAGE_ENC) + +#define PAGE_KERNEL_IO __pgprot(__PAGE_KERNEL_IO) +#define PAGE_KERNEL_IO_NOCACHE __pgprot(__PAGE_KERNEL_IO_NOCACHE) + +#endif /* __ASSEMBLY__ */ /* xwr */ #define __P000 PAGE_NONE diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index f3b1b27..8010c97 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -29,6 +29,7 @@ #include #include #include +#include /* * We handle most unaligned accesses in hardware. On the other hand @@ -241,7 +242,7 @@ static inline unsigned long read_cr3_pa(void) static inline void load_cr3(pgd_t *pgdir) { - write_cr3(__pa(pgdir)); + write_cr3(__sme_pa(pgdir)); } #ifdef CONFIG_X86_32 diff --git a/arch/x86/kernel/espfix_64.c b/arch/x86/kernel/espfix_64.c index 6b91e2e..9c4e7ba 100644 --- a/arch/x86/kernel/espfix_64.c +++ b/arch/x86/kernel/espfix_64.c @@ -195,7 +195,7 @@ void init_espfix_ap(int cpu) pte_p = pte_offset_kernel(&pmd, addr); stack_page = page_address(alloc_pages_node(node, GFP_KERNEL, 0)); - pte = __pte(__pa(stack_page) | (__PAGE_KERNEL_RO & ptemask)); + pte = __pte(__pa(stack_page) | ((__PAGE_KERNEL_RO | _PAGE_ENC) & ptemask)); for (n = 0; n < ESPFIX_PTE_CLONES; n++) set_pte(&pte_p[n*PTE_STRIDE], pte); diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c index 1f0ddcc..5cd0b72 100644 --- a/arch/x86/kernel/head64.c +++ b/arch/x86/kernel/head64.c @@ -102,7 +102,7 @@ unsigned long __head __startup_64(unsigned long physaddr) pud = fixup_pointer(early_dynamic_pgts[next_early_pgt++], physaddr); pmd = fixup_pointer(early_dynamic_pgts[next_early_pgt++], physaddr); - pgtable_flags = _KERNPG_TABLE + sme_get_me_mask(); + pgtable_flags = _KERNPG_TABLE_NOENC + sme_get_me_mask(); if (IS_ENABLED(CONFIG_X86_5LEVEL)) { p4d = fixup_pointer(early_dynamic_pgts[next_early_pgt++], physaddr); @@ -177,7 +177,7 @@ static void __init reset_early_page_tables(void) { memset(early_top_pgt, 0, sizeof(pgd_t)*(PTRS_PER_PGD-1)); next_early_pgt = 0; - write_cr3(__pa_nodebug(early_top_pgt)); + write_cr3(__sme_pa_nodebug(early_top_pgt)); } /* Create a new PMD entry */ @@ -310,6 +310,13 @@ asmlinkage __visible void __init x86_64_start_kernel(char * real_mode_data) clear_page(init_top_pgt); + /* + * SME support may update early_pmd_flags to include the memory + * encryption mask, so it needs to be called before anything + * that may generate a page fault. + */ + sme_early_init(); + kasan_early_init(); for (i = 0; i < NUM_EXCEPTION_VECTORS; i++) diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S index ec5d5e9..513cbb0 100644 --- a/arch/x86/kernel/head_64.S +++ b/arch/x86/kernel/head_64.S @@ -351,9 +351,9 @@ GLOBAL(name) NEXT_PAGE(early_top_pgt) .fill 511,8,0 #ifdef CONFIG_X86_5LEVEL - .quad level4_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE + .quad level4_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE_NOENC #else - .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE + .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE_NOENC #endif NEXT_PAGE(early_dynamic_pgts) @@ -366,15 +366,15 @@ NEXT_PAGE(init_top_pgt) .fill 512,8,0 #else NEXT_PAGE(init_top_pgt) - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE + .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE_NOENC .org init_top_pgt + PGD_PAGE_OFFSET*8, 0 - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE + .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE_NOENC .org init_top_pgt + PGD_START_KERNEL*8, 0 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */ - .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE + .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE_NOENC NEXT_PAGE(level3_ident_pgt) - .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE + .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE_NOENC .fill 511, 8, 0 NEXT_PAGE(level2_ident_pgt) /* Since I easily can, map the first 1G. @@ -386,14 +386,14 @@ NEXT_PAGE(level2_ident_pgt) #ifdef CONFIG_X86_5LEVEL NEXT_PAGE(level4_kernel_pgt) .fill 511,8,0 - .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE + .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE_NOENC #endif NEXT_PAGE(level3_kernel_pgt) .fill L3_START_KERNEL,8,0 /* (2^48-(2*1024*1024*1024)-((2^39)*511))/(2^30) = 510 */ - .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE - .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE + .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE_NOENC + .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE_NOENC NEXT_PAGE(level2_kernel_pgt) /* @@ -411,7 +411,7 @@ NEXT_PAGE(level2_kernel_pgt) NEXT_PAGE(level2_fixmap_pgt) .fill 506,8,0 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE + .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE_NOENC /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */ .fill 5,8,0 diff --git a/arch/x86/mm/kasan_init_64.c b/arch/x86/mm/kasan_init_64.c index 88215ac..d7cc830 100644 --- a/arch/x86/mm/kasan_init_64.c +++ b/arch/x86/mm/kasan_init_64.c @@ -92,7 +92,7 @@ static int kasan_die_handler(struct notifier_block *self, void __init kasan_early_init(void) { int i; - pteval_t pte_val = __pa_nodebug(kasan_zero_page) | __PAGE_KERNEL; + pteval_t pte_val = __pa_nodebug(kasan_zero_page) | __PAGE_KERNEL | _PAGE_ENC; pmdval_t pmd_val = __pa_nodebug(kasan_zero_pte) | _KERNPG_TABLE; pudval_t pud_val = __pa_nodebug(kasan_zero_pmd) | _KERNPG_TABLE; p4dval_t p4d_val = __pa_nodebug(kasan_zero_pud) | _KERNPG_TABLE; @@ -158,7 +158,7 @@ void __init kasan_init(void) */ memset(kasan_zero_page, 0, PAGE_SIZE); for (i = 0; i < PTRS_PER_PTE; i++) { - pte_t pte = __pte(__pa(kasan_zero_page) | __PAGE_KERNEL_RO); + pte_t pte = __pte(__pa(kasan_zero_page) | __PAGE_KERNEL_RO | _PAGE_ENC); set_pte(&kasan_zero_pte[i], pte); } /* Flush TLBs again to be sure that write protection applied. */ diff --git a/arch/x86/mm/mem_encrypt.c b/arch/x86/mm/mem_encrypt.c index 3ac6f99..f973d3d 100644 --- a/arch/x86/mm/mem_encrypt.c +++ b/arch/x86/mm/mem_encrypt.c @@ -12,6 +12,7 @@ #include #include +#include /* * Since SME related variables are set early in the boot process they must @@ -21,6 +22,22 @@ unsigned long sme_me_mask __section(.data) = 0; EXPORT_SYMBOL_GPL(sme_me_mask); +void __init sme_early_init(void) +{ + unsigned int i; + + if (!sme_me_mask) + return; + + early_pmd_flags = __sme_set(early_pmd_flags); + + __supported_pte_mask = __sme_set(__supported_pte_mask); + + /* Update the protection map with memory encryption mask */ + for (i = 0; i < ARRAY_SIZE(protection_map); i++) + protection_map[i] = pgprot_encrypted(protection_map[i]); +} + void __init sme_encrypt_kernel(void) { } diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c index c8520b2..e7d3866 100644 --- a/arch/x86/mm/pageattr.c +++ b/arch/x86/mm/pageattr.c @@ -2014,6 +2014,9 @@ int kernel_map_pages_in_pgd(pgd_t *pgd, u64 pfn, unsigned long address, if (!(page_flags & _PAGE_RW)) cpa.mask_clr = __pgprot(_PAGE_RW); + if (!(page_flags & _PAGE_ENC)) + cpa.mask_clr = pgprot_encrypted(cpa.mask_clr); + cpa.mask_set = __pgprot(_PAGE_PRESENT | page_flags); retval = __change_page_attr_set_clr(&cpa, 0); diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h index 7dfa767..4d7bb98 100644 --- a/include/asm-generic/pgtable.h +++ b/include/asm-generic/pgtable.h @@ -583,6 +583,18 @@ static inline void ptep_modify_prot_commit(struct mm_struct *mm, #endif /* CONFIG_MMU */ /* + * No-op macros that just return the current protection value. Defined here + * because these macros can be used used even if CONFIG_MMU is not defined. + */ +#ifndef pgprot_encrypted +#define pgprot_encrypted(prot) (prot) +#endif + +#ifndef pgprot_decrypted +#define pgprot_decrypted(prot) (prot) +#endif + +/* * A facility to provide lazy MMU batching. This allows PTE updates and * page invalidations to be delayed until a call to leave lazy MMU mode * is issued. Some architectures may benefit from doing this, and it is diff --git a/include/linux/mem_encrypt.h b/include/linux/mem_encrypt.h index 570f4fc..1255f09 100644 --- a/include/linux/mem_encrypt.h +++ b/include/linux/mem_encrypt.h @@ -35,6 +35,14 @@ static inline unsigned long sme_get_me_mask(void) return sme_me_mask; } +/* + * The __sme_set() and __sme_clr() macros are useful for adding or removing + * the encryption mask from a value (e.g. when dealing with pagetable + * entries). + */ +#define __sme_set(x) ((unsigned long)(x) | sme_me_mask) +#define __sme_clr(x) ((unsigned long)(x) & ~sme_me_mask) + #endif /* __ASSEMBLY__ */ #endif /* __MEM_ENCRYPT_H__ */