Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751366AbdIOOtJ (ORCPT ); Fri, 15 Sep 2017 10:49:09 -0400 Received: from mail-by2nam01on0088.outbound.protection.outlook.com ([104.47.34.88]:11613 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751111AbdIOOtF (ORCPT ); Fri, 15 Sep 2017 10:49:05 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Cc: brijesh.singh@amd.com, Tom Lendacky , "H. Peter Anvin" , Arnd Bergmann , David Laight , "linux-kernel@vger.kernel.org" , "x86@kernel.org" , "linux-efi@vger.kernel.org" , "linuxppc-dev@lists.ozlabs.org" , "kvm@vger.kernel.org" , Fenghua Yu , Matt Fleming , David Howells , Paul Mackerras , Christoph Lameter , Jonathan Corbet , =?UTF-8?Q?Radim_Krcm=c3=a1r?= , Piotr Luc , Ingo Molnar , Dave Airlie , Kees Cook , Konrad Rzeszutek Wilk , Reza Arbab , Andy Lutomirski , Thomas Gleixner , Laura Abbott , Tony Luck , Ard.Biesheuvel@zytor.com Subject: Re: [RFC Part1 PATCH v3 13/17] x86/io: Unroll string I/O when SEV is active To: Borislav Petkov References: <20170724190757.11278-1-brijesh.singh@amd.com> <20170724190757.11278-14-brijesh.singh@amd.com> <063D6719AE5E284EB5DD2968C1650D6DD003FB85@AcuExch.aculab.com> <201707261927.v6QJR228008075@mail.zytor.com> <589d65a4-eb09-bae9-e8b4-a2d78ca6b509@amd.com> <20170822165248.rkbluikdgduu7ucy@pd.tnic> <20170915122430.pnroy6vsg53warel@pd.tnic> <95314c89-2620-8bb7-cbe8-cd9bc3adabb0@amd.com> <20170915143935.6vtfp5rtj5h324fi@pd.tnic> From: Brijesh Singh Message-ID: Date: Fri, 15 Sep 2017 09:48:53 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170915143935.6vtfp5rtj5h324fi@pd.tnic> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR10CA0003.namprd10.prod.outlook.com (10.172.33.13) To CY1PR12MB0152.namprd12.prod.outlook.com (10.161.173.22) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 83ba82f8-a8bd-42ca-5967-08d4fc48e614 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:CY1PR12MB0152; X-Microsoft-Exchange-Diagnostics: 1;CY1PR12MB0152;3:FTHofcChdJU/5V9l/XEIwwIb6XClqFxeW+i5G6CjvJ5pq1Mnf+WvVCyRAK7v/OHt8jkdzY6M7glazSgIqvIKJkgX3tFzoVPv1eI89kSJX90wbsP7XHRsee2CvY7hbenkolTCcZbJcZHjY4AOByobOAHrXr4zsp4foxl1JTpBdik4fg8umGWm1bbfI8VnBHLsz5MxZukztp75YzYngUFfGqXdK5cj5ljn0N2PCqjAEghKte3yhPsB4l5yRvYb6FDp;25:HMBko8dnlJvSB+SNQ+kme2gOIIz3Qa9N2taa8NsVP5lKKDsigUDuVyJ6T/YP9h/71MSMLCpicdgI39R4XqyY8mxc/tIGrvqy1UtaOVot1o5pPxBMMfdDZkbmrjy9TAa2bpWKvAwfrqjEpUOjARX73lRQwTzRbQO+A6UtEwHkmtHerYwjdl8+QDzyqo0+085T4Ovbtw7xJhjsGFz8r0aTDZcMT+H0JgSRWmkyZiHd3/OUHkRFGFjAmK9V/ohdYCNFAK2xoxZqRtsMEqHiRlbtx4L1IO+jaQ9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Nut+S6jKZ3WEaHixLmWBvIRXwYVSepokHtuD5/WolCU0lrojijQhkuwBbzl4c X-Exchange-Antispam-Report-Test: UriScan:; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(10201501046)(100000703101)(100105400095)(6055026)(6041248)(20161123555025)(20161123564025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:CY1PR12MB0152;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:CY1PR12MB0152; X-Forefront-PRVS: 0431F981D8 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6009001)(6049001)(376002)(39860400002)(346002)(24454002)(377454003)(199003)(189002)(23676002)(50986999)(105586002)(6246003)(33646002)(25786009)(106356001)(6116002)(3846002)(68736007)(110136004)(54356999)(4326008)(189998001)(76176999)(53546010)(65806001)(36756003)(8936002)(66066001)(2950100002)(47776003)(101416001)(6916009)(50466002)(8676002)(58126008)(7416002)(81166006)(81156014)(65826007)(6666003)(90366009)(229853002)(6486002)(65956001)(97736004)(77096006)(5660300001)(83506001)(2906002)(305945005)(7736002)(230700001)(86362001)(478600001)(93886005)(54906002)(31696002)(64126003)(31686004)(316002)(16576012)(16526017)(53936002);DIR:OUT;SFP:1101;SCL:1;SRVR:CY1PR12MB0152;H:[10.236.136.62];FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtDWTFQUjEyTUIwMTUyOzIzOlYwdVJKZlNCaDU5UnRMa1p0SEl0L0JjbFds?= =?utf-8?B?TEpxK1UxMV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yM= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;CY1PR12MB0152;20:4VkJJmcrdtXepbWOABWtoenhifU+6PrVmkxhPcEQx5H9TKIqh9Ycn/6slkliXA6WiQj5zhIX3arZQBDE1pvaCN2iCCFAKYXHQy/sQf5duxgWt0IY1VrHMIjAZUBvC5EDtGtOsoCmhS0Ut0NRm2KwFEcjeFCUQc5gDBJ7KSCVlzXS0wQL25MU9hpRtKUzeMciXjpHuACaTdfa0LvhcaPCZ2hV22yPJqR+xdxJ4EEpGNPbA6DZNXI/XVHjFU8AyPgh X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2017 14:48:57.6676 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR12MB0152 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1284 Lines: 36 On 09/15/2017 09:40 AM, Borislav Petkov wrote: > I need to figure out the include hell first. I am working with slightly newer patch sets -- in that patch Tom has moved the sev_active() definition in arch/x86/mm/mem_encrypt.c and I have no issue using your recommended (since I no longer need the include path changes). But in my quick run I did found a runtime issue, it seems enabling the static key in sme_enable is too early. Guest reboots as soon as it tries to enable the key. I see the similar issue with non SEV guest with my simple patch below. Guest will reboot as soon as it tries to enable the key. --- a/arch/x86/kernel/head64.c +++ b/arch/x86/kernel/head64.c @@ -40,6 +40,8 @@ pmdval_t early_pmd_flags = __PAGE_KERNEL_LARGE & ~(_PAGE_GLOBAL | _PAGE_NX); #define __head __section(.head.text) +DEFINE_STATIC_KEY_FALSE(__testme); + static void __head *fixup_pointer(void *ptr, unsigned long physaddr) { return ptr - (void *)_text + (void *)physaddr; @@ -71,6 +73,8 @@ unsigned long __head __startup_64(unsigned long physaddr, if (load_delta & ~PMD_PAGE_MASK) for (;;); + static_branch_enable(&__testme); + /* Activate Secure Memory Encryption (SME) if supported and enabled */ sme_enable(bp);