Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp327303lqp; Thu, 21 Mar 2024 02:23:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVwZy03eYAOqOPWsB2J5bqdkWefNRz7zKbiHVWUF3uHBkwFrxbzaCCUj8mIst0xILS/SFDYUIMlTN3iXrjpjOjPJ7LvqTT0N/5PvmmcMw== X-Google-Smtp-Source: AGHT+IE4XicMe4UBdwdrKCyTy2Qy06MZnmnVfB8MtyAoVojMMbRs/40wr3DsPy0AzOX4dBybUjkT X-Received: by 2002:a05:6870:5253:b0:220:de16:412b with SMTP id o19-20020a056870525300b00220de16412bmr25125678oai.44.1711013004616; Thu, 21 Mar 2024 02:23:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711013004; cv=pass; d=google.com; s=arc-20160816; b=cSs6V+Z+AWp23ku95Spgywvf1Th6vOJB7zU0s9wRu12DaNZ89F4H1k4XPjNhUMNYVx GphpcdeySNlK9Cr0NmEZicdYF6fQkJoHp900+fK4f4LAV2wr0RikJW5WfGVTy4ye4aRN Uu1/J/O3oe58aF3l4jpw+Iw4jeNDNMdMoyQDE4VckJbru7suD27tEH/cdlaHrmiGXDN8 NWzatJ6ezHNKGrI0PK7vU7+S5xpmNpPG8zEltuYb3PNtb8IyfaCdhHfVIuSP7wUUXnQn eknn3XucjwcpeWdR0P7dw+PcfnZLOz8UgZQAU26KtN1PBLwlJDdlqTmJWeBRGl65UutD Ursg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:message-id:subject:cc:to:from:date :dkim-signature; bh=zxkwrp3mdbNU5mo25cZdyKhgtO4FahVvi8Wm46GQNE4=; fh=1d5kgJRyOm93v/jKZYrVubM82/CN86US+empHnL9ni0=; b=upxaSBZMEhGxzewDG2RwN+9iFg5zee4lhllwnRXIt/q0lOHyia9w4LG8vXxq802fYM neL6Ydyt50gyA6S+7nt9t9Jmhaj9tmyeCVo1gCwPzpcpCt3vWcHxST9ffMLwXTeXtQc3 4rlIELu9HoTm51P6aZQj4+bvDW9ogeKwhis6FRm6d5KbWdStKTncsSH43E6UzxWQ6L45 yxWerZ07Xws+M0TfgXfVPD/SVUOLqpLs/WNRpmkm4TcooiSRMtnqi/GKQT7tmRkT3pUF c7gPh6tN6xsoZPxM20G0aMi/St2NRUarmGMTrDanlpZ3ZkNToCKZZgjghMo9RYgh0ZyD CVyA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=J+UN1ZbX; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-109842-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109842-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id fb14-20020a056a002d8e00b006ea6f77a1cdsi1221970pfb.45.2024.03.21.02.23.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 02:23:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-109842-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=J+UN1ZbX; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-109842-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109842-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 4B0EC282221 for ; Thu, 21 Mar 2024 09:23:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C98E741C73; Thu, 21 Mar 2024 09:23:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="J+UN1ZbX" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F246228DCB for ; Thu, 21 Mar 2024 09:23:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711012999; cv=none; b=RuGiVtJ99+vRkgKu2/LkBtboyEp57qu0YPdtKZ+rnkM58eyiqr4FTY4NGHQmfXePDVBcqVmCrjltSwBI8F2SwkZW/lp+1TVcA1gWYlsG5uK7Aq0Bl7tC0MZQge1IVA+G+eUO0TjDfeU7l4AKJ7LX2GbR5jBJ5WAgFHl8aoFzjGE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711012999; c=relaxed/simple; bh=Q43tX5IqNhiO7UwIWFH9LqtYREscYgG7OABwqbffrkc=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=MbabeuUdem6l7J4JtoBlwf118DQnlQ+6qrOrbRwTTrx50RogHc14TXMCfAu1YudjE7RERV6GpNChIznSiFTXKyu7tynZ/HTEY5RGSNHychNcJk2185I9Agv9PCcvexfDcW5CdF0qrT2uJb6+zOCIOvKt82Urc/3oEk+vuqrb498= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=J+UN1ZbX; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711012995; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=zxkwrp3mdbNU5mo25cZdyKhgtO4FahVvi8Wm46GQNE4=; b=J+UN1ZbX2FngOUzObxHPgNvrc/dr7c0vTx+Sql1fLPCOScfUSUEXtk6KaT+GZMLJ32x/Ju 6xa8h0jJlukISd5WDPoaQ0CXAZzraYt1+K9mlDrcz+JegcOVNsckwGE8Ql6te6aKXu1+qd yTtfngDhmsS+gZHg65ThQhie/iltQJw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-587-Ii_wWUY7PnmwFdksqGhh0Q-1; Thu, 21 Mar 2024 05:23:12 -0400 X-MC-Unique: Ii_wWUY7PnmwFdksqGhh0Q-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 360A2101D223; Thu, 21 Mar 2024 09:23:11 +0000 (UTC) Received: from darkstar.users.ipa.redhat.com (unknown [10.72.116.143]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 03B87C04122; Thu, 21 Mar 2024 09:23:05 +0000 (UTC) Date: Thu, 21 Mar 2024 17:23:20 +0800 From: Dave Young To: x86@kernel.org Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , linux-kernel@vger.kernel.org, kexec@lists.infradead.org, Baoquan He , Eric Biederman , "Huang, Kai" Subject: [PATCH V2] x86/kexec: do not update E820 kexec table for setup_data Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 crashkernel reservation failed on a Thinkpad t440s laptop recently. Actually the memblock reservation succeeded, but later insert_resource() failed. Test steps: kexec load -> /* make sure add crashkernel param eg. crashkernel=160M */ kexec reboot -> dmesg|grep "crashkernel reserved"; crashkernel memory range like below reserved successfully: 0x00000000d0000000 - 0x00000000da000000 But no such "Crash kernel" region in /proc/iomem The background story is like below: Currently E820 code reserves setup_data regions for both the current kernel and the kexec kernel, and it inserts them into the resources list. Before the kexec kernel reboots nobody passes the old setup_data, and kexec only passes fresh SETUP_EFI and SETUP_IMA if needed. Thus the old setup data memory is not used at all. Due to old kernel updates the kexec e820 table as well so kexec kernel sees them as E820_TYPE_RESERVED_KERN regions, and later the old setup_data regions are inserted into resources list in the kexec kernel by e820__reserve_resources(). Note, due to no setup_data is passed in for those old regions they are not early reserved (by function early_reserve_memory), and the crashkernel memblock reservation will just treat them as usable memory and it could reserve the crashkernel region which overlaps with the old setup_data regions. And just like the bug I noticed here, kdump insert_resource failed because e820__reserve_resources has added the overlapped chunks in /proc/iomem already. Finally, looking at the code, the old setup_data regions are not used at all as no setup_data is passed in by the kexec boot loader. Although something like SETUP_PCI etc could be needed, kexec should pass the info as new setup_data so that kexec kernel can take care of them. This should be taken care of in other separate patches if needed. Thus drop the useless buggy code here. Signed-off-by: Dave Young --- V2: changelog grammar fixes [suggestions from Huang Kai] arch/x86/kernel/e820.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) Index: linux/arch/x86/kernel/e820.c =================================================================== --- linux.orig/arch/x86/kernel/e820.c +++ linux/arch/x86/kernel/e820.c @@ -1015,16 +1015,6 @@ void __init e820__reserve_setup_data(voi pa_next = data->next; e820__range_update(pa_data, sizeof(*data)+data->len, E820_TYPE_RAM, E820_TYPE_RESERVED_KERN); - - /* - * SETUP_EFI and SETUP_IMA are supplied by kexec and do not need - * to be reserved. - */ - if (data->type != SETUP_EFI && data->type != SETUP_IMA) - e820__range_update_kexec(pa_data, - sizeof(*data) + data->len, - E820_TYPE_RAM, E820_TYPE_RESERVED_KERN); - if (data->type == SETUP_INDIRECT) { len += data->len; early_memunmap(data, sizeof(*data)); @@ -1036,12 +1026,9 @@ void __init e820__reserve_setup_data(voi indirect = (struct setup_indirect *)data->data; - if (indirect->type != SETUP_INDIRECT) { + if (indirect->type != SETUP_INDIRECT) e820__range_update(indirect->addr, indirect->len, E820_TYPE_RAM, E820_TYPE_RESERVED_KERN); - e820__range_update_kexec(indirect->addr, indirect->len, - E820_TYPE_RAM, E820_TYPE_RESERVED_KERN); - } } pa_data = pa_next; @@ -1049,7 +1036,6 @@ void __init e820__reserve_setup_data(voi } e820__update_table(e820_table); - e820__update_table(e820_table_kexec); pr_info("extended physical RAM map:\n"); e820__print_table("reserve setup_data");