Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752967AbdFOO77 (ORCPT ); Thu, 15 Jun 2017 10:59:59 -0400 Received: from mail-bl2nam02on0059.outbound.protection.outlook.com ([104.47.38.59]:4477 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752409AbdFOO7z (ORCPT ); Thu, 15 Jun 2017 10:59:55 -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: [PATCH v6 26/34] iommu/amd: Allow the AMD IOMMU to work with memory encryption To: Borislav Petkov Cc: 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, linux-mm@kvack.org, iommu@lists.linux-foundation.org, Rik van Riel , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Toshimitsu Kani , Arnd Bergmann , Jonathan Corbet , Matt Fleming , "Michael S. Tsirkin" , Joerg Roedel , Konrad Rzeszutek Wilk , Paolo Bonzini , Larry Woodman , Brijesh Singh , Ingo Molnar , Andy Lutomirski , "H. Peter Anvin" , Andrey Ryabinin , Alexander Potapenko , Dave Young , Thomas Gleixner , Dmitry Vyukov References: <20170607191309.28645.15241.stgit@tlendack-t1.amdoffice.net> <20170607191745.28645.81756.stgit@tlendack-t1.amdoffice.net> <20170614174208.p2yr5exs4b6pjxhf@pd.tnic> <0611d01a-19f8-d6ae-2682-932789855518@amd.com> <20170615094111.wga334kg2bhxqib3@pd.tnic> From: Tom Lendacky Message-ID: <921153f5-1528-31d8-b815-f0419e819aeb@amd.com> Date: Thu, 15 Jun 2017 09:59:45 -0500 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: <20170615094111.wga334kg2bhxqib3@pd.tnic> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: DM5PR16CA0044.namprd16.prod.outlook.com (10.172.42.158) To CY4PR12MB1141.namprd12.prod.outlook.com (10.168.163.149) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PR12MB1141: X-MS-Office365-Filtering-Correlation-Id: f7ad5915-1d95-4f33-074e-08d4b3ff2c20 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(48565401081)(201703131423075)(201703031133081);SRVR:CY4PR12MB1141; X-Microsoft-Exchange-Diagnostics: 1;CY4PR12MB1141;3:CCA82nfspNYGYI7QB626bZD2nUq2D0aD7WqXSRoBJ7m4qgl9bPsJlDl8oeXbkD0WgMEk54o5jsxa1thjCjUnCePR8S7PZPzK6y4o3+x/mLFT6wCAoHVIpnkUhHHcqAOXeWpoX/OBMv8mIjzSlbYXGqxvoO8G3io/nG3BHvZSwx5NspVYnhn2I24vf4kswy3HRayrPMcx+DnYZ846AhkCnuAnxEV+Ax4CGLPsDwjWy4wdK/U2QoJWs/Zf5AAqyb83aoWWtyyD0+8bqvqm75jgV7Z1wZt+MduJuunGodKaD3ypkgsJiq/INu93TBx9Nrs/gHJXHdrsdsJWSkWLhx6e02bEtlTWLic7BvWWxWa4+po=;25:gWVHPF2xlrLacoMLTFs+kW21VGAHmO362hvhv1BqpKejQoix+l3jSl/DluiZPO5tb4L0cY/goKkGJsbyiLmebfbO2SN4WvLFCGUPN2DfLbsDcBwIfaPLV8UkciPbzjBMfMFdKj9Qi/K4QBPgT+iddu3I0Rn+HRZljcgyqreNDmWIPGDsOsmRln9NPEggrtX7GmCyUls7/YbxyUa/A+a9JTtyFlkQJDXQDOoEZrocrTw0Fdv2LQTv3toxA/lDNVLIj1EggTdvBYooeb8GlXrEyJUJZwVftLO3aA9V1I1mWIBUoCEPBkvlR2SlXitPkODSEgOGfbG6vNqIkDvo5Y03sgssSdOcvaGtS3k/CGjpuE4Uci8flpHKrIRufEv8szL7pqt4reLE0mHUsdMjP4P4Gi0wQ9iPatDwmiApENdnyPn9gYqzBmUr16PqYqKppbOr2EtjwBGzmFTTBFAIOY4vHrH/bd1HCVgsdCbsPFaMnjQ= X-Microsoft-Exchange-Diagnostics: 1;CY4PR12MB1141;31:ks1TdEVPqmHKYZgWYjordNaKAeIbNstVxaRmhkyKUm0WwELGI0B40vbCtavcY5wHRpgO1joTrqRt9MRznfs+3qLzMbqtKwKw35a3p5l5ovfMry+WzqBXQvxHmcw5C9s5F8YQlrPitIPMDVXSd8zcqh9ilHl6XuDIculy/B0gIwKtbib2E8rW+gGGaLHu3Hs5v4rxapOA2Qrrt8V5Mj5Gj6WR80HUEXmRh97PFLRpvDA=;20:TrL6gw78zsCuyqeMu5BDmOAZY2swBhu4eABoiRtbm+IXv0G4g2ZJUL5foewTNVRtVev71efi6vnqm0rA6emH4FouIqLCaXskm03YLf0hXAdmT5Da3iJbuiKELxEnaH8fohqKvYoQ3xSz4ekYMHLrYOkyk8O+xrz2u4lKDPbUmFCW4JhLSV6y25CKwTcLdDcM+aEM+sqp/U3Gfn1VZKJA7JOqYf+wORYU8pmNNPOVL9kPxHIfnIkqEHIUKAu+cILbyw2VDsHxnGZ7ntcKqmkB0s+uC8EWlOSre7w2+ZwU3VHTzumcgy23sVixGSNlAj1UFI+Gx6rCND/Kx9c//DxwZwDBSArLEGvg3DpTKynVt0TCWat/EbpMfR3KHZJYF+TtweqH8FIymRqy9Ny2nkEKacHGCWUZJOEs7bgeO95BI3mCEsqtOLMOP5zDDlMx0S4/K2ouT+uqYuh9mJ75qF7UB50KuALEopDZp3gZShnKn95RAtNqIeWLGxNMuHnbG71Z X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(93001095)(100000703101)(100105400095)(10201501046)(3002001)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123564025)(20161123555025)(20161123562025)(20161123560025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:CY4PR12MB1141;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:CY4PR12MB1141; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtDWTRQUjEyTUIxMTQxOzQ6RGxIcVdsb2ordFRwcTFnWDVmTnEvMUxPeTg5?= =?utf-8?B?eXE1ZUUvbkNBV2g1RmR4UVlPaVNqWU42VEJpa1lMS1RIOWZHQ2pxbWo0dnF6?= =?utf-8?B?Y1Urd01MTnhyZGJHaks2Z3dRNzVqc0V0YWV6UXN4dTdOaVBoaVpVdlFteU9W?= =?utf-8?B?eklRVi9wZnZBdHU1L3I5YXNOSmxKS0FxNWw4ekNTRjJCdHBXcW9iSXVSNnpC?= =?utf-8?B?MjJTeUxWckxkL2lad0dudEdEL01ybVd6bHJCenIxcjNjbnE0M0o2eTZqeklk?= =?utf-8?B?M2F3SW1zZXdWckVmRlF3N2tNMTM2UzZLOUdBcHZEMUpldE55YU05R0hJUnNO?= =?utf-8?B?eDN5K0d1eVp5TWZzQ25GRko3UnNZY3lJTEowb2xPaEdCSnI1YzBTckFoUWND?= =?utf-8?B?OUFnWGRIdEk4endsVytyZVFDbFE3MXZaZThiR25peW9DVCtmd05IOW5pYld0?= =?utf-8?B?OEF3V1MzTXB2Ym9BTkcyTE5KVDlVb0lyZTcwU2xDMHVlTUZveVY3OEN4RUZm?= =?utf-8?B?UTI3Smt5K0h1cTVLK21WM0YzanhrT2FHbllHdnJHdGF5M01aMHJ6VlVsSnBp?= =?utf-8?B?V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ZGNWclk5cHU4MHZD?= =?utf-8?B?UzE2eGZWR0s5c2V2VFQ3NEtROURRV0RlK3R0QjZWN0lzejRZNEVnamo3K3JT?= =?utf-8?B?Q3owWlNodWE3L0FkSlN4OWdvYVRqUT09?= X-Forefront-PRVS: 0339F89554 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6049001)(6009001)(39400400002)(39850400002)(39840400002)(39860400002)(39450400003)(39410400002)(24454002)(377454003)(189998001)(77096006)(6486002)(23676002)(83506001)(90366009)(4001350100001)(53936002)(2906002)(7406005)(50466002)(53546009)(305945005)(54906002)(7736002)(36756003)(3260700006)(25786009)(50986999)(42186005)(54356999)(31686004)(76176999)(31696002)(93886004)(86362001)(66066001)(33646002)(4326008)(8676002)(72206003)(81166006)(478600001)(3846002)(229853002)(6116002)(2950100002)(6916009)(6666003)(47776003)(5660300001)(110136004)(6246003)(230700001)(38730400002)(217873001);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR12MB1141;H:[10.236.64.250];FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtDWTRQUjEyTUIxMTQxOzIzOndUWURwbWQzSjZpNy8wOEpudVJCOTRIeCtC?= =?utf-8?B?czN6bVltV3p1U2VmbUxhR05YeDZBUnlJM1dsSXYveFRwaDJtaTZkb3laUU1y?= =?utf-8?B?eDlMWjB3Y2hoZTYzWHA1b2JPR2RNY0hUdnh1aGp6V08wS3ZENEZRSnUzQVRx?= =?utf-8?B?RlRzdDdHVkNwTVp5blRLK1VQWDFtbW50eDkrV2pzZU1NeGNFbkpFVzJEd3NX?= =?utf-8?B?WnlVWHpHUmNHYktNZnh0RG55TksyMnZSTzVLSVYxZjg2bXYzT084QVlwZHFN?= =?utf-8?B?L1NYSHdaUnV3TGx5aXdvVGdyWVpWemJtbjZ1N2NVNFdBM0dLcUxKYStmVEN2?= =?utf-8?B?OThHd0kyUEh2dHFHR0ltaWFFUU5HYkV2ODhYM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UbswF3YCnspJPaAK3j1RCGS2065LRRuZhvaiO9wv+Mivd4Md+2xTPuB5FhLOrLIkRz9+Z1XExmF0UzdF7TQzeekPc3A0enAVwEUww+nnlRwR3B97KEXdSJT4tOvmQCS0vU8ksHg9cn0ua+fJcaPAYLgzRvvRpJb7L8qxM4hMbVk5ANQL+7R1xiN6/6ilnei+Wu/YfIYGDcaOxVRZJlTp0pYQu+UD9tNcccCQ8/BB/S1zgyMZ0CMdCXlPdFnmkc9JIyQ==;20:lHA/N7Ky+AnPbDd+l6oTxrFpeJrSTOS1ixIUKDyU+4P2OVyTBmNOenXNb6hOZwjJBOWFlJRIiLY7pXPr/zQ/rK89M2zGF8d43NAvUTPfTlToabguLIGg3AvtlzoNYd9NibeXvr3rq+Ixb6O/r1KdOLiXmDYPsOG2HokEa0kamDy626q36goiCz5EPKBeYEYcrI0Law2GIve4ah6aFb73mzDiw26JdSS+LKgoM29X13qW4csChELkaZ6NvrUUzVG3 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jun 2017 14:59:48.8942 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1141 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2632 Lines: 78 On 6/15/2017 4:41 AM, Borislav Petkov wrote: > On Wed, Jun 14, 2017 at 03:40:28PM -0500, Tom Lendacky wrote: >> I was trying to keep all the logic for it here in the SME related files >> rather than put it in the iommu code itself. But it is easy enough to >> move if you think it's worth it. > > Yes please - the less needlessly global symbols, the better. Ok. > >>> Also, you said in another mail on this subthread that c->microcode >>> is not yet set. Are you saying, that the iommu init gunk runs before >>> init_amd(), where we do set c->microcode? >>> >>> If so, we can move the setting to early_init_amd() or so. >> >> I'll look into that. > > And I don't think c->microcode is not set by the time we init the iommu > because, AFAICT, we do the latter in pci_iommu_init() and that's a > rootfs_initcall() which happens later then the CPU init stuff. Actually the detection routine, amd_iommu_detect(), is part of the IOMMU_INIT_FINISH macro support which is called early through mm_init() from start_kernel() and that routine is called before init_amd(). > >> I'll look into simplifying the checks. > > Something like this maybe? > > if (rev >= 0x1205) > return true; > > if (rev <= 0x11ff && rev >= 0x1126) > return true; > > return false; Yup, something like that. > >>> WARNING: Use of volatile is usually wrong: see Documentation/process/volatile-considered-harmful.rst >>> #134: FILE: drivers/iommu/amd_iommu.c:866: >>> +static void build_completion_wait(struct iommu_cmd *cmd, volatile u64 *sem) >>> >> >> The semaphore area is written to by the device so the use of volatile is >> appropriate in this case. > > Do you mean this is like the last exception case in that document above: > > " > - Pointers to data structures in coherent memory which might be modified > by I/O devices can, sometimes, legitimately be volatile. A ring buffer > used by a network adapter, where that adapter changes pointers to > indicate which descriptors have been processed, is an example of this > type of situation." > > ? > > If so, it did work fine until now, without the volatile. Why is it > needed now, all of a sudden? If you run checkpatch against the whole amd_iommu.c file you'll see that same warning for the wait_on_sem() function. The checkpatch warning shows up now because I modified the build_completion_wait() function as part of the support to use iommu_virt_to_phys(). Since I'm casting the arg to iommu_virt_to_phys() no matter what I can avoid the signature change to the build_completion_wait() function and avoid this confusion in the future. Thanks, Tom >