Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751773AbdFHO05 (ORCPT ); Thu, 8 Jun 2017 10:26:57 -0400 Received: from mail-dm3nam03on0081.outbound.protection.outlook.com ([104.47.41.81]:2368 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751344AbdFHO0v (ORCPT ); Thu, 8 Jun 2017 10:26:51 -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: Nick Sarnie 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, Thomas Gleixner , Rik van Riel , Brijesh Singh , Toshimitsu Kani , Arnd Bergmann , Jonathan Corbet , Matt Fleming , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Andrey Ryabinin , Ingo Molnar , "Michael S. Tsirkin" , Andy Lutomirski , "H. Peter Anvin" , Borislav Petkov , Paolo Bonzini , Alexander Potapenko , Dave Young , Larry Woodman , Dmitry Vyukov References: <20170607191309.28645.15241.stgit@tlendack-t1.amdoffice.net> <20170607191745.28645.81756.stgit@tlendack-t1.amdoffice.net> From: Tom Lendacky Message-ID: <9ca73103-f202-b5b0-b449-79a4b8a8fd72@amd.com> Date: Thu, 8 Jun 2017 09:26:38 -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: 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: BN6PR03CA0044.namprd03.prod.outlook.com (10.175.124.30) To MWHPR12MB1152.namprd12.prod.outlook.com (10.169.204.16) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWHPR12MB1152: X-MS-Office365-Filtering-Correlation-Id: 4b271c94-6f4b-4b1b-67b7-08d4ae7a6517 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(48565401081)(201703131423075)(201703031133081);SRVR:MWHPR12MB1152; X-Microsoft-Exchange-Diagnostics: 1;MWHPR12MB1152;3:oYQMdEBdcSaDjQ9RVez+AabWWGllvijken87SNdDqKJb8XsMEZ1R4XNF5F/nXKWM5+nENFFF/NWzpP4bbjrYU69Bo1zXoN7VT6qL2beWkgUSAVBx2cGNXkcvPIwLa5jeJD5lZfKhADthVtj8FESRZQyzqJMfZcANFfhHE8tmpBpEz/KqCgaEG4Tw0RIB2wBchXTLxeOTx4Ov7V4ZFU5dyLsM0vg6kebzHbhGBLc3eDKHkb+JXKLJCQB2C9ieipNs7uOmP9xtD2pG52DabklRiseF0JS7SnD1LC9FaWlV9qXkwsiei+W1caOZILati1J/taXTXj6QvTi13CasM6RKDb7QXVla7rCg7mIlT/YzhIQ=;25:URzFw/1BUnpTZvqClQutMM656+dvyFtmfsR9hPUWrPcXmetgehymEruUeJfxIySXPfpB0/SzKx/hXsdzKkG/w2VonzziCmyXONhToA6/q90Rdq5d6sWPL9n0PEAoyQh/J0pA28QqtUQCMSQYPl8iqwK7UO9sBa9jR5eWlSMrhfjt4fZkNTBF9j90slUrGk3o8KkByutSuJTwqjm6WUNlpvfsl/HyhMcvoTzPT9lNxsrkEknei6XcpICllmAIQIbc/IMlFIqEXM0KcKxIvb2koLSbik1Ededbu6aOWyZ1T6xe27TU/65UsQFki+IHEVdwTVGmMoGZfVYfOQPS4KQaXwuRKoLhcPSeP3FMErNRA6ydJFMJ5kqYEiaZjOfx6P0bDVYJ/gtZAiXDQAZa7ZLIhqBsc7uZHNnUDSK8fcG8Nm9XroBX8Xgl8yBqLdbttZ33YbyQlcHqNesQ2tAMHvlaHIgO5Xku4wO2PU6M7b+zc4E= X-Microsoft-Exchange-Diagnostics: 1;MWHPR12MB1152;31:UlEOIDvNWP9+QiqgNTjt6diGWKRapzjUnTSA101yqbSf9vMgyotBw6SPQbfnbMPa9fMjUiTiaRMAe0dBvacRNBWw7V9HZuvzaw4PV5SjVdoOUBVxlR76KPu8ez3HIcR+ge+jenxnD4izXZTujZlNexYaqsULdf8BGJeCUCtzpaVuRvvOgMR1c94vmxzsCvgPqDmvOixdjqtzeT2g+6Pmd/s0dIpmEi4DJVvhI1aWWj4=;20:12KJU5hmEa19ipulzzE2VRv+VINQyD0OaTwWB1NCb+ewwuNLfCAPq3/i5nOrj2bgms0msImyvo3riKvXMeC9H212If+tYa0xeIHr7vPtisjNakNCs9J73CkUjJAhZhGOX0bdosVxzFSEiCVmd8ud56lz7Zb/HhuyZUUh5iUIGSZgNx/enJTFMls7BiT+UARgHjVAbihxtJw6HLSQwBo7vnLLZCBkxSXwKw3Mmm/3kZbja7AIqGCJPzrses5ZJT7j5Y2sg8/gFPwujaM0QinqK14h9XiBk7B1QwzgNkCwCbn7/iLG+SRWm1pE03KdydsNELgkLuvFpftfpP0wtSFKqsfiT33Nkol08z/Yw4I6/6VOoapFDYvsspqm7+t3Bo6MNNXtn7mRsIdur24rB/rusA0+qeZXhIXyO8OaTAG6d7SVa6QjrWJQWGWwQ9h/unGhxH/4g8Q3IF9JLz/vicNvCWcSPDuISY344fXvGJe/DheW1Cbl4xN9bDgB08u1iTSp X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(100000703101)(100105400095)(10201501046)(6055026)(6041248)(20161123562025)(20161123558100)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123564025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:MWHPR12MB1152;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:MWHPR12MB1152; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtNV0hQUjEyTUIxMTUyOzQ6MGlEcGkwMnp6WWcrbEtUY3FTa00yUnB6d2NY?= =?utf-8?B?UklRbWV2cGQ5WHRJQmZzVC9Fb3VqYnY5alUxYmFmaFpJdzkzcGNGUXZzRUcz?= =?utf-8?B?d2N6WXRLbGt6aUVEOUlTUWZxMjBVWDE0L1o4ZFN5QnJ0Nmx4V0lCS1daOThK?= =?utf-8?B?SDNLU3gvM2xCZU9vY2NlNXAxeHBrQm9DK2lNM2RTZmZmS0hGdHRwSDU4SHhD?= =?utf-8?B?cis1R1hCQ0ZpY0E4MCt1OGxCVjF5a3gyRDZzb21KOWRVc1ZwZWl3cVB5WE9l?= =?utf-8?B?ZVowcVNuc2hBMkREODVNQ0RUNzY5Mm1rNXIyT0lkWUZPZ21idytHYnl5SVVm?= =?utf-8?B?T2FjbnlsL09MNkpudDRSUmNCUklYaU9hUDRYZjM5UnBkYjBqTlFPWXp2V2gw?= =?utf-8?B?WXBIeEMwVnBFNThtdXpXaVdJMjFhUFJnYjR6QU1vclpINDRZMVJFb1dEdGZF?= =?utf-8?B?WUwzN3lDTnZNc3QyL1FISVI2eHVsSWRoRGdYR3lZSkhueTBHUWphOFg0YUxa?= =?utf-8?B?MVhLelVyazlVNlI1WEd0aEhXZ0xQWTk4RzJ0YnAvNnVLN0ROeDJ5ellsZUc2?= =?utf-8?B?VTlGdGtiUWl6ZzVxVGd0M21Tam5JMU9DZ21QaDlPcVhLWnNiTDdmVXdkSlZU?= =?utf-8?B?ZSttMzJJNldSTDlnSkZhQ2l4Q0poTG00c3B0NTNjYUNU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1JONW9mR09JQ2Qxenk4TTdI?= =?utf-8?Q?bKhjsN4COqjLgOf+X+K?= X-Forefront-PRVS: 0332AACBC3 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6049001)(6009001)(39450400003)(39860400002)(39840400002)(39850400002)(39410400002)(39400400002)(377454003)(24454002)(54356999)(53546009)(305945005)(8676002)(76176999)(65956001)(47776003)(66066001)(65826007)(81166006)(50986999)(65806001)(1411001)(5660300001)(36756003)(42186005)(64126003)(23676002)(7736002)(33646002)(7416002)(2906002)(31686004)(53936002)(54906002)(575784001)(86362001)(478600001)(2950100002)(6916009)(77096006)(6486002)(72206003)(90366009)(25786009)(230700001)(189998001)(3260700006)(3846002)(6666003)(4326008)(6246003)(229853002)(38730400002)(110136004)(31696002)(217873001);DIR:OUT;SFP:1101;SCL:1;SRVR:MWHPR12MB1152;H:[10.236.64.250];FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtNV0hQUjEyTUIxMTUyOzIzOlJBSlU4UEt0UXMwRVVPczZsNld6d1R0cy9o?= =?utf-8?B?VHBIRmw3alYxZUhTNjVtSmZNanNzajMybW5WZjAveTJIeW5BY0xwQVdjKzJu?= =?utf-8?B?SUxWaHY4Z2NLcEVodUtKUW8rVFhEb1Vxbndsb3g4N0VRUHU0M0ZIbmlncFFj?= =?utf-8?B?dDVDRmhkbllvZGFJS2ROWDRuVzRORm5iNVdEY210b1NidnU4M3FYL1JtUlNU?= =?utf-8?B?V3oxdjRwREZQc0k5MWFFWGdWdWdyT25YQ1huSFJyYU9COXVDdXhURVpibEEw?= =?utf-8?B?OXBRWTg3ZS9ZTmdrZmZQVEV5UDNFZ1pTZExuYnFCREcvTFJlSWVWU3pFbUtO?= =?utf-8?B?WDlCc1JJWTdET09ySVhaRVVyU2VCdjRVRVR6ZHBDWWdMSTlpSTA5UnJjanBq?= =?utf-8?B?R3RJQUljV2FlNFE0bkV0RmVGQjA1NVJ5WH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nyX7KuuFurGdKVzPX2+ZTNyKe2CwyMRZURXJW+4v/fARgNI6omA6G15DjlecYudrhrat7hxbndW/arWN1wjVpOZL6DpJf9qoXbHOGTVXkoIhzcE6xZwhGl149hRJTPiFo50e+/L2wSIoUfcGGY5a+stGQ4kqW7mtZMn+E5hwBK15l2/N14Lom1HmXpf3Tr2nJ/srbLXNyzO5SksqM+y5olJ0l0KwtNdZum/8JOpKtcpcaM3a4SB/ct83GxaoTA+lw==;20:CCNrGSow9cCKJ7/WrXJjo9thwpbzvxMpfai7iAk9RYy2K9ogUcgDzcJrCc0WW7hh3Ylrch8lomHLN6z3yWQes4B9xyJ3ayQh7RJozfBGYYwly3AwNH7OqdKmqdfZa4AcNuWRXmrxTnBA6ry6zCnLACKGpsRqfQNwlFLIWq7eG/TPvb4hZ0QuvE4p8aNgrSSMFMW9Uyrfc46e4ijlNSEd8qrg2vUONoOgaP3qQDSDRoZ8PMJfw2i7VQl4dmapxKc+ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jun 2017 14:26:43.4014 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1152 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3937 Lines: 113 On 6/7/2017 9:38 PM, Nick Sarnie wrote: > On Wed, Jun 7, 2017 at 3:17 PM, Tom Lendacky wrote: >> The IOMMU is programmed with physical addresses for the various tables >> and buffers that are used to communicate between the device and the >> driver. When the driver allocates this memory it is encrypted. In order >> for the IOMMU to access the memory as encrypted the encryption mask needs >> to be included in these physical addresses during configuration. >> >> The PTE entries created by the IOMMU should also include the encryption >> mask so that when the device behind the IOMMU performs a DMA, the DMA >> will be performed to encrypted memory. >> >> Signed-off-by: Tom Lendacky >> --- >> arch/x86/include/asm/mem_encrypt.h | 7 +++++++ >> arch/x86/mm/mem_encrypt.c | 30 ++++++++++++++++++++++++++++++ >> drivers/iommu/amd_iommu.c | 36 +++++++++++++++++++----------------- >> drivers/iommu/amd_iommu_init.c | 18 ++++++++++++------ >> drivers/iommu/amd_iommu_proto.h | 10 ++++++++++ >> drivers/iommu/amd_iommu_types.h | 2 +- >> include/asm-generic/mem_encrypt.h | 5 +++++ >> 7 files changed, 84 insertions(+), 24 deletions(-) >> >> diff --git a/arch/x86/include/asm/mem_encrypt.h b/arch/x86/include/asm/mem_encrypt.h >> index c7a2525..d86e544 100644 >> --- a/arch/x86/include/asm/mem_encrypt.h >> +++ b/arch/x86/include/asm/mem_encrypt.h >> @@ -31,6 +31,8 @@ void __init sme_early_decrypt(resource_size_t paddr, >> >> void __init sme_early_init(void); >> >> +bool sme_iommu_supported(void); >> + >> /* Architecture __weak replacement functions */ >> void __init mem_encrypt_init(void); >> >> @@ -62,6 +64,11 @@ static inline void __init sme_early_init(void) >> { >> } >> >> +static inline bool sme_iommu_supported(void) >> +{ >> + return true; >> +} >> + >> #endif /* CONFIG_AMD_MEM_ENCRYPT */ >> >> static inline bool sme_active(void) >> diff --git a/arch/x86/mm/mem_encrypt.c b/arch/x86/mm/mem_encrypt.c >> index 5d7c51d..018b58a 100644 >> --- a/arch/x86/mm/mem_encrypt.c >> +++ b/arch/x86/mm/mem_encrypt.c >> @@ -197,6 +197,36 @@ void __init sme_early_init(void) >> protection_map[i] = pgprot_encrypted(protection_map[i]); >> } >> >> +bool sme_iommu_supported(void) >> +{ >> + struct cpuinfo_x86 *c = &boot_cpu_data; >> + >> + if (!sme_me_mask || (c->x86 != 0x17)) >> + return true; >> + >> + /* For Fam17h, a specific level of support is required */ >> + switch (c->microcode & 0xf000) { >> + case 0x0000: >> + return false; >> + case 0x1000: >> + switch (c->microcode & 0x0f00) { >> + case 0x0000: >> + return false; >> + case 0x0100: >> + if ((c->microcode & 0xff) < 0x26) >> + return false; >> + break; >> + case 0x0200: >> + if ((c->microcode & 0xff) < 0x05) >> + return false; >> + break; >> + } >> + break; >> + } >> + >> + return true; >> +} >> + >> /* Architecture __weak replacement functions */ >> void __init mem_encrypt_init(void) >> { > ... > > Hi Tom, > > This sounds like a cool feature. I'm trying to test it on my Ryzen > system, but c->microcode & 0xf000 is evaluating as 0, so IOMMU is not > being enabled on my system. I'm using the latest microcode for AGESA > 1.0.0.6, 0x08001126. Is this work reliant on a future microcode > update, or is there some other issue? This is my mistake. I moved the check and didn't re-test. At this point the c->microcode field hasn't been filled in so I'll need to read MSR_AMD64_PATCH_LEVEL directly in the sme_iommu_supported() function. Thanks, Tom > > Thanks, > Sarnex >