Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753327AbcD0QVM (ORCPT ); Wed, 27 Apr 2016 12:21:12 -0400 Received: from mail-bn1bon0074.outbound.protection.outlook.com ([157.56.111.74]:48784 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752666AbcD0QVI (ORCPT ); Wed, 27 Apr 2016 12:21:08 -0400 Authentication-Results: google.com; dkim=none (message not signed) header.d=none;google.com; dmarc=none action=none header.from=amd.com; Subject: Re: [RFC PATCH v1 03/18] x86: Secure Memory Encryption (SME) support To: Pavel Machek References: <20160426225553.13567.19459.stgit@tlendack-t1.amdoffice.net> <20160426225626.13567.72425.stgit@tlendack-t1.amdoffice.net> <20160322130354.GC16528@xo-6d-61-c0.localdomain> CC: , , , , , , , , , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Arnd Bergmann , Jonathan Corbet , Matt Fleming , Joerg Roedel , Konrad Rzeszutek Wilk , Paolo Bonzini , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Andrey Ryabinin , Alexander Potapenko , Thomas Gleixner , Dmitry Vyukov From: Tom Lendacky Message-ID: <5720E6E9.30900@amd.com> Date: Wed, 27 Apr 2016 11:20:57 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <20160322130354.GC16528@xo-6d-61-c0.localdomain> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: SN1PR15CA0014.namprd15.prod.outlook.com (10.163.200.24) To DM3PR1201MB1120.namprd12.prod.outlook.com (10.164.198.20) X-MS-Office365-Filtering-Correlation-Id: 472cc50a-4be6-499b-be6c-08d36eb7ed38 X-Microsoft-Exchange-Diagnostics: 1;DM3PR1201MB1120;2:0A65uysqfs1yGaMjHd+GrRCxV5P3tLoV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SgA/vMyzVU9I1TBdqioNNZlThIv0Ben6dbqpOBpz6Lu9h+wjR2mZg0CvgndB1cAO09uEu2OvVMQE45XIwmNUHudP3W3CLVs/gYRmQGlWKGDxLpaoJsFYF9ezTlb8I5I8pWLK8U9krsl3e89l5zhWq8FD2D7TNi;4:ZEfQD34+o8sVZfr0BPmsO6YQ9Yu1XKgQ+NVExmhdZkYkN1bOGnEyNHDnc4BD51Wsd2I+KLGVFheu+YYx4Znm18Qgmgu5tB/vDUh+DuZJEfl+s7ipFxwPF7lne+gvZOxzIeHc7qgLkyG2nvUZRC1TmSOIYeW5xXOmWghg4sLipNAoGHlESN9vsZmpyl2iHUH3DYkMig7w5iNcHRJP+ivqy3j80Z/nRPDlHlraFdTiJM8mkEBgW1jqJLKwXbcMfFxd23Av3osVJOchZMs524beYguTkZoFJh71+zxf8d1zMMGKB4JChaYVbliJrl3JzOBW0bWoktDGKeEb5UvveOTfZ820JIwnST7zYM3ETmRE4dmqD2Hh0aKHtLjzAURPRZJB5lzHE3/GD+BqNpvcHx3vYorpga/4DKG4hX7sJgViJrQ= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(9101521072)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026);SRVR:DM3PR1201MB1120;BCL:0;PCL:0;RULEID:;SRVR:DM3PR1201MB1120; X-Forefront-PRVS: 0925081676 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6049001)(6009001)(24454002)(377424004)(377454003)(230700001)(23746002)(36756003)(4326007)(3846002)(1096002)(6116002)(189998001)(4001350100001)(2906002)(54356999)(586003)(77096005)(76176999)(50986999)(42186005)(65806001)(110136002)(5004730100002)(5008740100001)(81166005)(19580405001)(33656002)(64126003)(19580395003)(50466002)(65956001)(2950100001)(47776003)(66066001)(83506001)(92566002)(217873001);DIR:OUT;SFP:1101;SCL:1;SRVR:DM3PR1201MB1120;H:[10.236.18.82];FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;DM3PR1201MB1120;23:lgLKcvywguRDz5NOlT1YcZr4ZjB2gqeXMPs?= =?Windows-1252?Q?cpPFihqp9XuxoKPG42Awi/50koxq1rshn1YNLR7KmamMlUN2PMLz8hid?= =?Windows-1252?Q?fxNga4tNpElXmdPGv3sDkddsHJd0CXP/BiOeF/1t6Nyo/KZfuxyPXUxw?= =?Windows-1252?Q?sy9Y70yBQReilEAFq9Glov3/+kS7QywUFuzmXBcFSUB9u0IJuhe0abz8?= =?Windows-1252?Q?SusnY6ca2G8y5xeeBLVZi5LmMud7w/Fq44OUwwzT5PAu9cEpVvI5WFmw?= =?Windows-1252?Q?Svzy8YKRF8JuuoRKSjqV1TIsqbWN3dH3lUdkKZHATuF1eBUxa1EICY2b?= =?Windows-1252?Q?Jkj4Ar3txdN7Hoqn2Z7O4RS4YRoq12czyk3ehoT92i1N0xgBqiScVKuh?= =?Windows-1252?Q?yFIp3gIKUg7Gk9gkLyqAo9rT+lwV271J3F1Jrvzg0JdLJT6kwSzgw8UX?= =?Windows-1252?Q?wYrA4Lva1UAnmAcpaUImu60qqIC1h6h++5BPqBy1qYjVAUKbAiIEDr9k?= =?Windows-1252?Q?t8kM1iOr1gXPLVKUMSdF52ItKrOCP0jvFgA/Z3xVF0ChqyxNrf92adRl?= =?Windows-1252?Q?tODK6AktRZkfETALVqNn6CHl/hWfADc/sl20Iuf/vf1v3Q42RqkDJYLy?= =?Windows-1252?Q?oHgEwg4uYF+fKbFYt/dVntCp5mAy2IaUmKS7N/Jgf/oWI8603PnRF0q8?= =?Windows-1252?Q?zbV7bpqo03zTLixp7TRoFVy1BMdYXM3mFZ22DlM67SfGbvwM0QvUNvJH?= =?Windows-1252?Q?e8S79DjMT1GR9IeEFx1z2stQ1Z8lk84mseQwboBshmPIpfckmaHanqWm?= =?Windows-1252?Q?v7zeqtcjIJpem3DuUzW8NCDbr9d2chPD8KY/RmPcZvzmGmMRbx40GybQ?= =?Windows-1252?Q?+9CUFrJs76xDx9W0/yB4vDYqaRm37pKEkp/qPTImYBIjF08yteYlNhki?= =?Windows-1252?Q?lMohJIVs1txzwbf9tOnRp8UAhx+eDd3kdfd6LMJieZItNarB4Qbg32xZ?= =?Windows-1252?Q?p5wpDByotZcEwG9VSmaxBJQ5WeFiyrvHJe3YtPp0ydIRa2XBxJa6KSlG?= =?Windows-1252?Q?ZvIenHydnRECcYTKSpaz1zOCEj9H4mNKoZhxRkGOIdOtY7BQsGeB+KvO?= =?Windows-1252?Q?vtvf72dc+X0nMdwSUDsdzHwE=3D?= X-Microsoft-Exchange-Diagnostics: 1;DM3PR1201MB1120;5:esn7YYxVs9oP6KRLqEogawmGw6AVmOmBxbkRNlYSRha6woip5qGQPQ3lC6b3B+0q46EgXdOQNd/niKrJ0NP5a5EaROAdbcUo89MAgT3D7HAMFATBrtOqqIV5uKAP+YTgBCafYosVLN1tFhdC/BwRIw==;24:8z+qLiIulAUb3FMciE9dNKXl+M+hxXVMcaM+LnS5x25d6cPqGKxwaBfbRaZkm5g9vxFbLBGKJSP1CjSyTYheEMgmuZq6hlR9ytYE7H7ZV9Y=;7:abtnXYuChNR7YmOhIIV5JPctyVIR6mMzI9iEO/XL/u6jD5xYooWipMHW0/c5tsNn9kyF3Ap0Wp1ra6agv4W0LcfoNwt072t9PA7uQdMsV1uMduCa+8C4WjGgeFmVqm7T+i2NzxSKRVatEoMaBCup1ZwlnhzmXd5ovE/9WAv+lcfvW/PRXYLGUGm9FK7cKsU1;20:aPnTEipEL9foOo92IMDOp7SA5wKHAwywc9ICNXfTLwJ+O7adndgDsKluWfe9jtUmBNflcwGjgcVkdX+koqsmHVbI4kVzN4VD8SqdDwtipyqWdwN5h/cMyyMw6yZT0S+qS60+D9WrTMKWHEltGdn33YxWuzX61lMzLL+aD5UlqaczKDlZa8zqTfI2a8fg9HEOKXG2L3gCB3JndtCAUJ19+GwWfA9hf2+zDox2Hjw4ci+4o+u6nzz7KJBa7Ap3Ooli SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Apr 2016 16:21:01.6579 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR1201MB1120 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1735 Lines: 54 On 03/22/2016 08:03 AM, Pavel Machek wrote: > On Tue 2016-04-26 17:56:26, Tom Lendacky wrote: >> Provide support for Secure Memory Encryption (SME). This initial support >> defines the memory encryption mask as a variable for quick access and an >> accessor for retrieving the number of physical addressing bits lost if >> SME is enabled. >> >> Signed-off-by: Tom Lendacky >> --- >> arch/x86/include/asm/mem_encrypt.h | 37 ++++++++++++++++++++++++++++++++++++ >> arch/x86/kernel/Makefile | 2 ++ >> arch/x86/kernel/mem_encrypt.S | 29 ++++++++++++++++++++++++++++ >> arch/x86/kernel/x8664_ksyms_64.c | 6 ++++++ >> 4 files changed, 74 insertions(+) >> create mode 100644 arch/x86/include/asm/mem_encrypt.h >> create mode 100644 arch/x86/kernel/mem_encrypt.S >> >> index 0000000..ef7f325 >> --- /dev/null >> +++ b/arch/x86/kernel/mem_encrypt.S >> @@ -0,0 +1,29 @@ >> +/* >> + * AMD Memory Encryption Support >> + * >> + * Copyright (C) 2016 Advanced Micro Devices, Inc. >> + * >> + * Author: Tom Lendacky >> + * >> + * This program is free software; you can redistribute it and/or modify >> + * it under the terms of the GNU General Public License version 2 as >> + * published by the Free Software Foundation. >> + */ >> + >> +#include >> + >> + .text >> + .code64 >> +ENTRY(sme_get_me_loss) >> + xor %rax, %rax >> + mov sme_me_loss(%rip), %al >> + ret >> +ENDPROC(sme_get_me_loss) > > Does this really need to be implemented in assembly? That particular routine probably doesn't need to be in assembly. But since it was such a simple routine I put it there because a later patch derives the value in this file. Thanks, Tom > >