Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755327AbcKOOdR (ORCPT ); Tue, 15 Nov 2016 09:33:17 -0500 Received: from mail-bl2nam02on0042.outbound.protection.outlook.com ([104.47.38.42]:54432 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751633AbcKOOdN (ORCPT ); Tue, 15 Nov 2016 09:33:13 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; Subject: Re: [RFC PATCH v3 04/20] x86: Handle reduction in physical address size with SME To: Joerg Roedel References: <20161110003426.3280.2999.stgit@tlendack-t1.amdoffice.net> <20161110003513.3280.12104.stgit@tlendack-t1.amdoffice.net> <20161115121035.GD24857@8bytes.org> CC: , , , , , , , , , Rik van Riel , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Arnd Bergmann , Jonathan Corbet , Matt Fleming , Konrad Rzeszutek Wilk , Paolo Bonzini , Larry Woodman , Ingo Molnar , Borislav Petkov , Andy Lutomirski , "H. Peter Anvin" , Andrey Ryabinin , Alexander Potapenko , Thomas Gleixner , Dmitry Vyukov From: Tom Lendacky Message-ID: Date: Tue, 15 Nov 2016 08:32:50 -0600 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20161115121035.GD24857@8bytes.org> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: BN6PR17CA0011.namprd17.prod.outlook.com (10.173.147.21) To MWHPR12MB1149.namprd12.prod.outlook.com (10.169.204.13) X-Microsoft-Exchange-Diagnostics: 1;MWHPR12MB1149;2:6hPu6SLsFQb2GqAMrc+3JlIOq076YwAaiJWJyGbdX1SAV0/1hupGgPWJQS77/gkljxWmPz6N1MIBFNjpB7cUYFcksqJ5kQuz82nYIWM7BIwgzQ+U/UgpUfdeVOfRjieDPqoVl07ZIg6DQhZBe2knLBkCGHQj3uZe9InrkhWNLwA=;3:1aJ45FVY974VEnBhnir7vZNW2yyKbOO3MsmE5AqDmxn443vCdpGiTi4DxDYvmuimph0/klWwlH2ES9oP9r41q5vTDrRaov9pBIMbZJVwfcGM0BJVzDtZ0xQ8Of/lXlYlEHvr/b1YUuf7so4LqZq4QDsIGa9376lJLQLzCtmXe9Y= X-MS-Office365-Filtering-Correlation-Id: fda4a991-537a-41f6-a1a9-08d40d644f9a X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:MWHPR12MB1149; X-Microsoft-Exchange-Diagnostics: 1;MWHPR12MB1149;25:nqDghynP1wCCR2ZNv+LnCWHY+qdcQ60Hr7BeCOp4YD+rRGvg13W3uWkCBdQYSkovBJDp0yV43B6WwPe/Art5oDSOfNkbIVUJBVJEcHSeIIg2ngyavWs4X1LzOtpvjYdxWpAdBfyym83ZENTZ6kk/bowsE0rXKsGneR+nk1aUr/qWLU3LkcEiQf5jXoQ47+oC2KXd14IlT38TNtpnLXLSF2io5yOwhnuVD4ZvySyveqTM47WHlgOPicGMrAogSP09kczPR0g8Jabh9LSL/+fbMkH9tH2ZITQ2vbtkbbMy4Dx3Le37wXDehD7W/SRiOPs6ULJqQ3hEGAeMuSkDLX19tvxpBZzWq9Q6ISkK/Rb6tZTwwi4y76aS1qDwwLaBOmbNWcSofmT28sAL0jJuaF6VpNzUBPMsCva6UhxGSToV0VGIlMV4JpZLtSYHkcuiS9ttKozEyDPL9cak0xLO3uuiILIqgPF8pzfIfsB3lhUr0O96AhYyU3s6JfaNy12T9pEUAmNQ/X9o1YPUbdw22wSSEncyMJTq2yBhGU3+c/OMeZLi9snAhuzMrmg/skX7/dST7jAElV9F/LFjM5/rcte4n+ddoLk/yFt5xfNwuW3anQvSFzuRIuehsKjZgJkG2mS3w5J2aTaiGPPuclEggIXMLZ0S0xns9Z+cM/bj5hCvxjqolMRyDQPwyPFe8U4Z8g8GLaSRo475hXmRItV2MblftLVbSY1X9t2jdY8pC9t6fR3O+MHxFVur7ZiTaN2h2prdSXKknJKvZULX1XesYJqDjqBaURF2SA0jCI6nJbrHWZg= X-Microsoft-Exchange-Diagnostics: 1;MWHPR12MB1149;31:aufLgDVhTbHtVgNSqV3CgdEXvTxkgZKl8ns5oyeLuZXaef5B5juhHpMpdPMv59uet9rB1rMANRLlECa4TKF2TrWVrl8C4XufsEszgVwdiDk7d7DsH8V8J1v63sbtyayCY7yPVYTmXDlW1qtb5dobwlfNtboafHVOiO10TQGKojz+6cm8cu6R0KnyZcffQ76aeMskpYR+nFIHMjCC7ee9RZvwy+FJI9GT/QA0sTrcUpzT146qGlbAWAEUmvclvU6CPHWPVR1gNy9qVV9Nptj4tE2Q+KWPJao9L6co7ITznYE=;20:DlDPQFZTZNbDq5j8qshxDsxNf/AkICw1+G7NKmOetMXi7ffmFeUyfQ0rSjKOdORrf/ag8WO+JRA+IeAnGMWEsfijxgxw7cjRhWBYEoIe76+8HnE2zUISWz8vZEk5sfqYyxrlSgNCM1qKdZGHGLnrtDjhAo70bSQSJEoLlLRJQgbBIH2w+rc1N18lD8x6EcYfXOmuiTuQfkKWNHOqpj43RgFNQsaI7xVW4C+YY8JigQQ2tjbamWmHSRldgpnFPFvuhCub0sfm1TeWBj6TmAOcLAvqC39AnWvUgZI+qnvKjbQW/mzcX2Q/o2jo7fOZGEjzGZuCUi+jQrVP4h5Og1Tdi3URwPSYFzadfsieuYUoorRhvnNl79gU4MYul6D39Wm2iyf7fuzY/Q3IRmU7HbkCUHJOzcBt/J/yTrvvpG5seR0QRzKutaNoZ0Tk/UD9O2WioY18QP5g+TvXClrhy0B22tFq+1KbSUkAv8tPoexVFva499arkKSOiPzaXBvNn4S3 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6060326)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026)(6061324);SRVR:MWHPR12MB1149;BCL:0;PCL:0;RULEID:;SRVR:MWHPR12MB1149; X-Microsoft-Exchange-Diagnostics: 1;MWHPR12MB1149;4:UhA3HNIGQQ0RkaBRaqy20++9v79bzLawb5BqK1VjMkFo9C8vzaYJv3w9hH58ao8Qia9DJAuG3/nqnrvVUY6oniULRE9LDtG/gEMLvikW6w5EL9DL0dqEqyMXr/oIide3a1HRS4Y1EtbCPPgTCChXkTL/bQ1HUq6muH30cgpsd2B4DV8KOAexgqzKEYS8hu2vVwhFf1Z2RT54G+1fhEKczWKieV6XG79r0Xvl0lMb3dhcM45NXBgiV32+OxwFtXcBVWrzrxkTMoVXdOiSncC37Aj3W3/hjov90NDt/oUe5BHGQ4xqLSUoZ3Gslwtti9gySkVEw6sv3XSNDJo0XuAHecN5156hdW9nDMxl4g6z2a+Hn2vWnyjnhC50dHNyvb+r+A5X+SjbBMW1vojq62AtcZF+Xi6oZMM6QpsCWOiO6/zGsaWOWaw3PIuqITMfMIxM X-Forefront-PRVS: 012792EC17 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6049001)(6009001)(7916002)(377454003)(189002)(199003)(24454002)(5660300001)(86362001)(50466002)(42186005)(7416002)(65826007)(7846002)(105586002)(47776003)(31696002)(106356001)(31686004)(66066001)(54356999)(101416001)(50986999)(7736002)(4001350100001)(65806001)(305945005)(76176999)(97736004)(230700001)(65956001)(83506001)(8676002)(4326007)(68736007)(6666003)(81166006)(2906002)(3846002)(92566002)(229853002)(64126003)(36756003)(6116002)(81156014)(23746002)(33646002)(110136003)(189998001)(2950100002)(77096005)(6916009)(217873001);DIR:OUT;SFP:1101;SCL:1;SRVR:MWHPR12MB1149;H:[10.236.64.222];FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;MWHPR12MB1149;23:UIuSAyR5oVR6v/pUnvh5h8kVCPQf9VUgZ3+1+?= =?Windows-1252?Q?0k7qwwIEskjb5JBc/w/rXSiYj5IjnW1Xia+kp+6N8IzXtpO1w/MVTg6u?= =?Windows-1252?Q?nmhg5nNZQiQAfg3YKJWIcaTxyvoehPARwlIC51h5njfBkXuGfzIm5lW9?= =?Windows-1252?Q?kgYxGSmJegwcTQBzY+Vm+aMBJuAxKhWVaYNZ3De8rEoZrQnXaNqNUflY?= =?Windows-1252?Q?2IkKgkou1F7GmGN9I2CiFncPESvLjnld9qYlYcnwoOe0a1wpapgMosxg?= =?Windows-1252?Q?1Si8XRH9DdvVsweYyqsag1noAopYt+PT9y/tcHLaBA3uzS2LNYNsg5nu?= =?Windows-1252?Q?aQrFdnfbpVAw/k7Oea3iSC0AdomwQObQVlhKhIcGTxMDjLJ9jntfXoz8?= =?Windows-1252?Q?mX69FDYb7KwJY3QAucVJk8qo4SjCclFRMVBv6s3WHvmxI8CFzgVf5uUc?= =?Windows-1252?Q?FX4mBM4NoFaBoewC+GTWFxjh3LIiLc5u6xheHtPCesgSN1gSAZgOHfL8?= =?Windows-1252?Q?IfyDjrtZTiEpBDEpfRLN1RjSylLFMsUsjie5Mu8kMxMa2QG2uc+LfFzu?= =?Windows-1252?Q?TbEsKJ2MnNIa2jiAyz/KcfbO9oQH/W9M14of6EujgveB5fjEAoJP+Jy5?= =?Windows-1252?Q?sxJArSb19UKO2gdI9gD/ZykLyUA5+BEMA9FxRyJqevIabhBcbay9s4XW?= =?Windows-1252?Q?jmkAwLkZl6gJYv1X6Qcq6krx5jXG9j5G3SeZ49k/boNOin3MmLCJKshn?= =?Windows-1252?Q?Upqj0B/XrfLsofeCBvZh21Zh3Vvnza4p/IBcWmpRbrMg2fnctdh0Sao4?= =?Windows-1252?Q?QPHNhSDWj8AqCUOU3aOZIf0gkG9tFUMJBesCxEvCm7STxcUmqiNUID4w?= =?Windows-1252?Q?5IfDZXWBqm6ttlf4XYLbhyU88P2twAZ3yLZFmgMBFnlyA+4WL0EEUlDC?= =?Windows-1252?Q?76V7pbaZLTGTp6yPOB3K0eRq3rYN8np+/tlcot1nskvRfYTK2f2TaDqE?= =?Windows-1252?Q?NPijfvx724IiLk2oJXIVFXZSV7qx9EusB1NAV1klU78SV5LtN5ixBJO4?= =?Windows-1252?Q?OfgkJTnGhp+0pSMJMYDYc99eghJR6hNyCr3ZX//pxgnnHwbeUwNFh/IQ?= =?Windows-1252?Q?L2c5We8kT81qZdKwaa/otMI5Xn8f6JE33oAEqihIDV3gQyR9RNA8ICNT?= =?Windows-1252?Q?++twxKMgl8Kii0K2pC9yrAmsl299xyZRadEdZ82m3dwuEjhQ5fBJHDbv?= =?Windows-1252?Q?8Oyva3brCk49dA53AeiLaV/IjLCxHC4FMlTzC9ZtvDRmT2ZMBtiIMhDv?= =?Windows-1252?Q?grfQXwiHgMyJuKN81pFf/pKKgrxHEM89GTXYoLCwYdQ9mqDl7q6J2cMg?= =?Windows-1252?Q?IgwQCEbMxd8I6AbscPmjzzzBFIGpT4vSlVuOC4YfDOT3AHDkqsdZJk?= =?Windows-1252?Q?=3D?= X-Microsoft-Exchange-Diagnostics: 1;MWHPR12MB1149;6:HxOTj1DYIn948PFIfB3Av/We4/BMR32LyjyHn87HydH/T5cAqL6dL8+4BhVUpM7O0fJVJqz5UFx5fLLwypvKJYRM55UIhxJVZkX6MKMdYdeA79M4TsmFlE5+jPCgQxrTSALJzvBFKQ8hP27VHe4eCehq8lCUOjo2arX4Kwn4uzYf6kCDyDywWM7W7dDsRN9EfZgVGj67UOE8BraxXjWQbvFnFXuHSSUg0W+QtHDNq7u03SuWZ8PbwFa/GCyNHrxcAdL6C86COTvTYzgzWY2D/lECcmn6afYdFZNINL06njhdu853lmj3CPjBxRiIkdWSoQIj+EYW+vtu6mr1JXA1Zx5O0y+yq0eL7B8l+bJxPsDJIMG1wEiYIQ5b4TVIfblS;5:5PG2SdQZoXpFIsgc7VGssTOHn9PqZHm4ERMq2tQabCkwa5gLKKABkY1OEp+ZKqczcM3a1SQGd9IRCuMowxDCYLQwbaDGkugBlUEdonLw8agcrh8j9Uk7yg+YZiFWkWHI3MzrUXUvLbdJHRYIlQWijQ==;24:4+E66BBekqtfsJRYk/svyZmU6pDfhB6+0JnFXwaEFIW/CUbXE24abeA1EPjNTB+jOH10M2tFksiz9qAiX5iDbx++TcO0d040qOMvyhzSv5M= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;MWHPR12MB1149;7:o6hZKNP3OYPzmm8FWFhxmxcvdLqx0DNbwnd6y/sXmrLY6n+z4Hq+2dCgi1cI+40v95Z1YXEHnOHywsVWXjsMaMmUjIpkelVIWOaNOYgUvicVTybhkdcV9gW5ucv4pow6YVQ3cUurNFktvUL8j2jhB9+0jLGFc2ZH8M4g3qZ74B82TQaxnazvz8Nk/gHQezFEQOz6zF5+9IaBNbaimQrpaVXq7ZFKw59mvLJrW+nSkpvsXw/6HY4Ibq/1sTXL+YYuGuVDgJnvkSKQIcUnvkjL/o6F72KNZ4I4NqBSQ13djSUrUIGL3h1Xo8HL0lsi7gyRSkBQfyLkf+A35YWf4tPdAUz6YLPNPtmmsRkrxOvvBd8=;20:aw1e8ghUAidVo71q3Ok8gxoH3tDjquSVdEv10sMxaAK6Ch2YfHnj8LHfVYjigWb5OxRzBEhSvk4ohB0wXP1WrE5Zo+memUnZE6V/XkrEW2dnX8Q5T3l9O1Np56jIh606qukl9T2gLeP0k3sEtEzuu/Ch3mSuIAHSih9alZvjGxOXZ2TvXV2Ho2aleADDxIFaQthjo4qsI3QOjZ3CysxJMUNMc4Rq+F/63RWLlOV8fX+ytV2/7s/Glcwcyq3UZnzI X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2016 14:33:01.4548 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1149 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 927 Lines: 37 On 11/15/2016 6:10 AM, Joerg Roedel wrote: > On Wed, Nov 09, 2016 at 06:35:13PM -0600, Tom Lendacky wrote: >> +/* >> + * AMD Secure Memory Encryption (SME) can reduce the size of the physical >> + * address space if it is enabled, even if memory encryption is not active. >> + * Adjust x86_phys_bits if SME is enabled. >> + */ >> +static void phys_bits_adjust(struct cpuinfo_x86 *c) >> +{ > > Better call this function amd_sme_phys_bits_adjust(). This name makes it > clear at the call-site why it is there and what it does. Will do. > >> + u32 eax, ebx, ecx, edx; >> + u64 msr; >> + >> + if (c->x86_vendor != X86_VENDOR_AMD) >> + return; >> + >> + if (c->extended_cpuid_level < 0x8000001f) >> + return; >> + >> + /* Check for SME feature */ >> + cpuid(0x8000001f, &eax, &ebx, &ecx, &edx); >> + if (!(eax & 0x01)) >> + return; > > Maybe add a comment here why you can't use cpu_has (yet). > Ok, will do. Thanks, Tom