Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp2984557ybn; Thu, 26 Sep 2019 22:20:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqzXb4GDv/0dcZMl8Vq0gdsGIdjg/z1lN1MsGMktS1wIRwBw1mbZozbQErdbxyuSwwtEy5GU X-Received: by 2002:aa7:c4d0:: with SMTP id p16mr2524929edr.266.1569561640469; Thu, 26 Sep 2019 22:20:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569561640; cv=none; d=google.com; s=arc-20160816; b=nn3ufR83IIw4kkEbbespwlQlaig+ckdcVxBb1O14wL+M+2oQn9g8RLnXyEzj521HV2 JBHZ2Kg0IBOKOVkvB2XUM1XLUvLQnIX7w9xpne1EKUAf/T4FqrbSpLY1zfS8aiKn2cBF LLoY38i7XevipyFsdMy7Ny8enx/E68/f0/LpWzQhZaKaYSDmpmWqT5EUFnWeESuAmMfi gPwmcu4MabT4rWjeusblgX+AKCcKZo0K4WFkAxM8xilttYf/FEOM4Iumrtgk2dISV0rt lgZ4B069qjJheaqbHTUN3w03yo8xAUUFQhdvqDBlNgmKPK0Z+/jR55o6H6XG6trzq8FJ 2kFQ== 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; bh=ZQu2Y30ZTsC2v+o8mTpCxUDk2H1AKUnBO71GjbOeyS0=; b=GrSZUTL16iSa426ucl2u6POHsCZP1W6rkKkJnyv0umBUMxFF/5wCM7JOzUyMA3LLgr T4KGIs1A7Has7nYvVEQUaA9TSgedwnic261G3Nt/vioXNxSmD/1krqQwIhQcG+XXb4Do aBsuggG9Th0Rt8sF+GoAWiRhI6owpKd/bPPxg4qBpEl+Z2IMzSyrSLFrGF8U7PMRM26j 7+brOR6CcPhgEt3fw1nO1ol9Jq4aYtgYwGlZczjmkk4lWAUo1qRbyLz9D9GVaQGpOE7E DADc91xJE9y09mzf/L1kj1zQRo/EI3AAe3DhZdFfy7KATDOMuVPxabG5qSLl4r2K8k8B DFMw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d19si808109edv.287.2019.09.26.22.20.15; Thu, 26 Sep 2019 22:20:40 -0700 (PDT) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725819AbfI0FP3 (ORCPT + 99 others); Fri, 27 Sep 2019 01:15:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59922 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725268AbfI0FP3 (ORCPT ); Fri, 27 Sep 2019 01:15:29 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4D9CF300894D; Fri, 27 Sep 2019 05:15:28 +0000 (UTC) Received: from dhcp-128-65.nay.redhat.com (ovpn-12-78.pek2.redhat.com [10.72.12.78]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AF89C60C44; Fri, 27 Sep 2019 05:15:22 +0000 (UTC) Date: Fri, 27 Sep 2019 13:15:18 +0800 From: Dave Young To: Lianbo Jiang Cc: linux-kernel@vger.kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, x86@kernel.org, bhe@redhat.com, jgross@suse.com, dhowells@redhat.com, Thomas.Lendacky@amd.com, kexec@lists.infradead.org, Vivek Goyal , Eric Biederman Subject: Re: [PATCH] x86/kdump: Fix 'kmem -s' reported an invalid freepointer when SME was active Message-ID: <20190927051518.GA13023@dhcp-128-65.nay.redhat.com> References: <20190920035326.27212-1-lijiang@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190920035326.27212-1-lijiang@redhat.com> User-Agent: Mutt/1.12.1 (2019-06-15) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Fri, 27 Sep 2019 05:15:28 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Lianbo, For kexec/kdump patches, please remember to cc kexec list next time. Also it is definitely kdump specific issue, I added Vivek and Eric in cc. On 09/20/19 at 11:53am, Lianbo Jiang wrote: > Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=204793 > > Kdump kernel will reuse the first 640k region because of some reasons, > for example: the trampline and conventional PC system BIOS region may > require to allocate memory in this area. Obviously, kdump kernel will > also overwrite the first 640k region, therefore, kernel has to copy > the contents of the first 640k area to a backup area, which is done in > purgatory(), because vmcore may need the old memory. When vmcore is > dumped, kdump kernel will read the old memory from the backup area of > the first 640k area. > > Basically, the main reason should be clear, kernel does not correctly > handle the first 640k region when SME is active, which causes that > kernel does not properly copy these old memory to the backup area in > purgatory(). Therefore, kdump kernel reads out the incorrect contents > from the backup area when dumping vmcore. Finally, the phenomenon is > as follow: > > [root linux]$ crash vmlinux /var/crash/127.0.0.1-2019-09-19-08\:31\:27/vmcore > WARNING: kernel relocated [240MB]: patching 97110 gdb minimal_symbol values > > KERNEL: /var/crash/127.0.0.1-2019-09-19-08:31:27/vmlinux > DUMPFILE: /var/crash/127.0.0.1-2019-09-19-08:31:27/vmcore [PARTIAL DUMP] > CPUS: 128 > DATE: Thu Sep 19 08:31:18 2019 > UPTIME: 00:01:21 > LOAD AVERAGE: 0.16, 0.07, 0.02 > TASKS: 1343 > NODENAME: amd-ethanol > RELEASE: 5.3.0-rc7+ > VERSION: #4 SMP Thu Sep 19 08:14:00 EDT 2019 > MACHINE: x86_64 (2195 Mhz) > MEMORY: 127.9 GB > PANIC: "Kernel panic - not syncing: sysrq triggered crash" > PID: 9789 > COMMAND: "bash" > TASK: "ffff89711894ae80 [THREAD_INFO: ffff89711894ae80]" > CPU: 83 > STATE: TASK_RUNNING (PANIC) > > crash> kmem -s|grep -i invalid > kmem: dma-kmalloc-512: slab:ffffd77680001c00 invalid freepointer:a6086ac099f0c5a4 > kmem: dma-kmalloc-512: slab:ffffd77680001c00 invalid freepointer:a6086ac099f0c5a4 > crash> > > In order to avoid such problem, lets occupy the first 640k region when > SME is active, which will ensure that the allocated memory does not fall > into the first 640k area. So, no need to worry about whether kernel can > correctly copy the contents of the first 640K area to a backup region in > purgatory(). The log is too simple, I know you did some other tries to fix this, but the patch log does not show why you can not correctly copy the 640k in current kdump code, in purgatory here. Also this patch seems works in your test, but still to see if other people can comment and see if it is safe or not, if any other risks other than waste the small chunk of memory. If it is safe then kdump can just drop the backup logic and use this in common code instead of only do it for SME. > > Signed-off-by: Lianbo Jiang > --- > arch/x86/kernel/setup.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c > index 77ea96b794bd..5bfb2c83bb6c 100644 > --- a/arch/x86/kernel/setup.c > +++ b/arch/x86/kernel/setup.c > @@ -1148,6 +1148,9 @@ void __init setup_arch(char **cmdline_p) > > reserve_real_mode(); > > + if (sme_active()) > + memblock_reserve(0, 640*1024); > + > trim_platform_memory_ranges(); > trim_low_memory_range(); > > -- > 2.17.1 > Thanks Dave