Received: by 10.223.176.46 with SMTP id f43csp771373wra; Sat, 20 Jan 2018 04:34:55 -0800 (PST) X-Google-Smtp-Source: AH8x2250OJSMuaXUkf7Lsi1XpKzrB8lDxrexhd/YZqTvxsaMr5vVWrHlPd1/HjMo2WDeaQODAtTj X-Received: by 10.98.217.135 with SMTP id b7mr2123288pfl.239.1516451695004; Sat, 20 Jan 2018 04:34:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516451694; cv=none; d=google.com; s=arc-20160816; b=d4BonIIsuKbhMEsPSkDH2PC6rCxAmLZviLR2Px3xxTr1HgSGa8nUy+S/ltb1E2Q6rB eqYQYLowARUnLf3JodJVRIISsI8YvOJdaW2i/UKn0fvmKbQiSeHLd8sdsH8nWXB0qDIs 59lutHC8NwGSDVeiSDyZoyhWPKht54vBJOoeKg779jMufK2yE3oTpB3A7JyPqB2YB+WX gSCFqNEwkX03N9jcWvp9tsZenoAtjffM8nFP0qyTQFC7VtG1Nos2EqN+vClhc5qFD51y FdasNHGAJgz2HP/1kT9NzYgBm/r8ImfPDCI02gRkJLr3aD320U7y5zuBUzUOqyCYMpiY uFHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=GnYjm4Ttj03oRW8hsshpD0NcHyNrtIkcgewzVYIKejk=; b=0cM/dkovq3ks15TXPNOhDoVa3Cd4zk3Pw57VoZ7nWlvtmx8QbdCiezy7tt3tRhJJWO XnLQvoc++LZB/lF0NxcvM1noJX0uXpWuZbb8W0qxTYLRZxbg3XZVdjckKRCJPWLU81i+ Z0FJVdsjQ35za8lZbUYwCvXiSCaTiL+6idmjEOQteKBW+Hf8Qxm6E1lNkVBlPvcq73vR 7gvZe3QWfknPwJLBRmiNd99TnoanUGEvzdvyh9xP0KRlpejlYbb6RgqsgTsg4J2K5jPr lYL8zlzevVhIyvLhPDS2MA6SRszjy2tnCfV+gqkUUVLZbiNbDV2uxkFHgXD3h7i1ce2Q FzEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=gjRyuAC4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i9si9751401pgq.0.2018.01.20.04.34.41; Sat, 20 Jan 2018 04:34:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=gjRyuAC4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756037AbeATMdx (ORCPT + 99 others); Sat, 20 Jan 2018 07:33:53 -0500 Received: from mail-wr0-f195.google.com ([209.85.128.195]:35655 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755212AbeATMdp (ORCPT ); Sat, 20 Jan 2018 07:33:45 -0500 Received: by mail-wr0-f195.google.com with SMTP id g38so3918487wrd.2 for ; Sat, 20 Jan 2018 04:33:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=GnYjm4Ttj03oRW8hsshpD0NcHyNrtIkcgewzVYIKejk=; b=gjRyuAC4vg/0KU7JSbFqp3wXbCpKrKtoIADSztWpNLf6fDoiSHsMfl4xJkHwD0pnJs EpjqFam8VxlVn77z4ieXmueqdRJ8nn6SKNzrv67JqaMQX8xHwMhKbEhZGkmIbPYIBCe4 v4GLVTp0sggWGyjczRyR+ObSMdD20yAIUudNUpNSSbY7gCP8DRHa0qsIBhht8Zsjr17x qRxzW79fzsIzYOPLEVdK/t++Z2w9876BNCpjoJMcbO2aR0Ir8x59zCKNnswpTXXaYkym 1t7MPhTD2gDIYu4Ol6fTt9kkvoy++OZQda5TqeV9xVEpjUqflVDhqp4hyUEm2ENUCkrs pL+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=GnYjm4Ttj03oRW8hsshpD0NcHyNrtIkcgewzVYIKejk=; b=M29Fslen/K0OUlc8lzY8UTlDcXAuEGlMTo7Xc1DTlY0VoeOzRmGL5tCExY9zyBXAEJ RTQb07R89pmwS4DPNziGd5BRYPUoEphi7++szf098GuvOt6JTc69NMhBdPH54f5vqXNj K9L/q9ZAYXc/Htbdadoh5PLEW3TgSrudVyz9tf+GD3ksPnhsYtjM7jbWrdjcEMoYUczh LdOdtt/HDiJMpN/gi90hZ3QdCsPFxWxRoUk4M4sUCHQJIpmmrdxi2Hu09d/RQOQm6EPl zvCfFcnn5wYu2B3AYkQ0+ChkQWmbuVg/IpneJaWRtEqvXORm4y1AUMc4ZUhFzu60Y0d7 CZ/A== X-Gm-Message-State: AKwxytdhlmcKOh0nr5WW3HUaq8VlM2o04N5oxZmEs7IXIHfmgJmP8ofr gGDp/T/kzrevBZXHf5/MJKs= X-Received: by 10.223.175.217 with SMTP id y25mr1353421wrd.172.1516451624479; Sat, 20 Jan 2018 04:33:44 -0800 (PST) Received: from gmail.com (2E8B0CD5.catv.pool.telekom.hu. [46.139.12.213]) by smtp.gmail.com with ESMTPSA id l142sm2368139wmb.43.2018.01.20.04.33.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 20 Jan 2018 04:33:40 -0800 (PST) Date: Sat, 20 Jan 2018 13:33:38 +0100 From: Ingo Molnar To: Laura Abbott Cc: Tom Lendacky , Gabriel C , Borislav Petkov , Linus Torvalds , Peter Zijlstra , Thomas Gleixner , Brijesh Singh , X86 ML , Linux Kernel Mailing List Subject: Re: Boot regression with bacf6b499e11 ("x86/mm: Use a struct to reduce parameters for SME PGD mapping") on top of -rc8 Message-ID: <20180120123338.buixvrhlxqo3ev5p@gmail.com> References: <9fdddcb1-d122-7d52-9204-7066ada5ccba@redhat.com> <44505ab1-237b-88ea-1fb1-f80de9b3025a@redhat.com> <6277b77a-d4a0-5669-e5aa-7a850436227c@amd.com> <6b616ebc-1a8f-0bd7-68be-3674ff99500b@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6b616ebc-1a8f-0bd7-68be-3674ff99500b@redhat.com> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Laura Abbott wrote: > The machines I have are a Lenovo X1 Carbon and a Lenovo T470s. > A Lenovo X220 ThinkPad also reported the problem. > > If I comment out sme_encrypt_kernel it boots: > > diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c > index 7ba5d819ebe3..443ef5d3f1fa 100644 > --- a/arch/x86/kernel/head64.c > +++ b/arch/x86/kernel/head64.c > @@ -158,7 +158,7 @@ unsigned long __head __startup_64(unsigned long > physaddr, > *p += load_delta - sme_get_me_mask(); > > /* Encrypt the kernel and related (if SME is active) */ > - sme_encrypt_kernel(bp); > + //sme_encrypt_kernel(bp); > > /* > * Return the SME encryption mask (if SME is active) to be used as a > > > Interestingly, I tried to print the values in sme_active > (sme_me_mask , sev_enabled) followed by a return at the > very start of sme_encrypt_kernel and that rebooted as well, > vs booting if I just kept the return. sme_me_mask and > sev_enabled are explicitly marked as being in .data, > is it possible they are ending up in a section that isn't > yet mapped or did I hit print too early? So all this is in awfully early code. I think you should only be able to use early_printk here - is that what you are using? As like Linus I don't see anything explicitly wrong in the patch, it obviously made a difference to you and others, and the commenting out experiment verifies the bisection result I think. Here's a brute-force list of historic problems in early code, and an attempt to check whether those aspects are fine: 1) stack troubles The bisected-to patch adds one more C function call parameter, and one of the (low probability) possibilities would be for the initial stack to be overflowing. But stack setup in setup_64() looks fine to me: /* Set up the stack for verify_cpu(), similar to initial_stack below */ leaq (__end_init_task - SIZEOF_PTREGS)(%rip), %rsp /* Sanitize CPU configuration */ call verify_cpu __end_init_task is defined as: #define INIT_TASK_DATA(align) \ . = ALIGN(align); \ VMLINUX_SYMBOL(__start_init_task) = .; \ *(.data..init_task) \ VMLINUX_SYMBOL(__end_init_task) = .; and we set up space for the init task in arch/x86/kernel/vmlinux.lds.S via: /* Data */ .data : AT(ADDR(.data) - LOAD_OFFSET) { /* Start of data section */ _sdata = .; /* init_task */ INIT_TASK_DATA(THREAD_SIZE) where THREAD_SIZE is at least 16K of space, more on KASAN. So we put the initial stack PT_REGS below the end of &init_task - which should all be good and there should be plenty of space. 2) using global variables, which is unsafe in early code if the kernel is relocatable. The bisected to commit uses a new sme_populate_pgd_data to collect variables that were already on the stack, which should be position independent and safe. But the other commits use sme_active(), which does: bool sme_active(void) { return sme_me_mask && !sev_enabled; } EXPORT_SYMBOL(sme_active); And that looks PIC-unsafe to me, as both are globals: u64 sme_me_mask __section(.data) = 0; EXPORT_SYMBOL(sme_me_mask); Does the code start working if you force sme_active() to 0 while keeping the function call, i.e. something like the hack below? Thanks, Ingo arch/x86/mm/mem_encrypt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/mm/mem_encrypt.c b/arch/x86/mm/mem_encrypt.c index 3ef362f598e3..52f7db4d08d6 100644 --- a/arch/x86/mm/mem_encrypt.c +++ b/arch/x86/mm/mem_encrypt.c @@ -403,7 +403,7 @@ int __init early_set_memory_encrypted(unsigned long vaddr, unsigned long size) */ bool sme_active(void) { - return sme_me_mask && !sev_enabled; + return 0; } EXPORT_SYMBOL(sme_active);