Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2174995imu; Thu, 29 Nov 2018 00:13:43 -0800 (PST) X-Google-Smtp-Source: AFSGD/WQNstvNMri0TQs6x9pBnCiSiWVqsRV/vS5CbjwWEVDESVu7IsvkdYOLknzKcqSeBhsUogm X-Received: by 2002:a63:ff62:: with SMTP id s34mr408971pgk.325.1543479223492; Thu, 29 Nov 2018 00:13:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543479223; cv=none; d=google.com; s=arc-20160816; b=PRTfCU2EWOyq+6pR+ZtxFbWoYo41+Hx6gxo4mQtaT+RvS1fgUQUmRzQaZL1OXQWGn0 74NsB53zK9L/qV5CiI7JFQedUGqMr4kD589+ARJxW2in/3XRgs0LrhGx+jQCy9x+SWpZ hbx8dELQbpDKU5NkNCRdCJF3vM57Qbj6qtTESPDTPqujp/TtSkKY8iKrdx6bEMsoIj+E 2E17Xo2+ZFDW/p8jXwHykSirTRATx4Izsq/ifXXRoolTSwv9dW6jM7YpSPcXbxsS/8tU 46xYr49Of+kgQcdZFfSRIyL1KloMw1zMjm9DriQReLDC2EoRrvpJiDMNfqx4QZ1Co9FJ lVMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=646rMxe/dzkX+zYhzMryqZIkOlYXveFlqyCpxZDS1jw=; b=e5dIuZsoQo7VWKtLyKN7JMPmxgXU2ot5wGcFlEiJ8nvfWGJvaOn5dtw+i6vb21hJuR aP40rsEFf7NMx8VKRB6pZR+PZxl0vwp4ee0MqSQ5OfmZLNIk/fLhlsxitjF0b4l23oiB m6MQFHWJxE65C1w6G2mjL9D8JzRn26dy9qA3z9kALdLoGF2BWls1EElyRV+npbsZRrsx B7Gr8hLEbzNT+qODum488WdEbYp3CF/0IqKP1RtPtIIhuaRYz7kLt3JAbiTAsZ1y3nep 31uDDPRfa020dk07Q3msw66byQgTNqhww5D9izA/pMhW4Wr1bUW1kDjuRQKgp/8Q4AS9 iPlQ== 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 w2si1284286pgh.565.2018.11.29.00.13.28; Thu, 29 Nov 2018 00:13:43 -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; 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 S1728029AbeK2TOx (ORCPT + 99 others); Thu, 29 Nov 2018 14:14:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57288 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727775AbeK2TOw (ORCPT ); Thu, 29 Nov 2018 14:14:52 -0500 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 60BEB3001DAB; Thu, 29 Nov 2018 08:10:20 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-12-78.pek2.redhat.com [10.72.12.78]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8197B60CCF; Thu, 29 Nov 2018 08:10:02 +0000 (UTC) From: Lianbo Jiang To: linux-kernel@vger.kernel.org Cc: kexec@lists.infradead.org, x86@kernel.org, linux-ia64@vger.kernel.org, linux-efi@vger.kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, akpm@linux-foundation.org, dave.hansen@linux.intel.com, luto@kernel.org, peterz@infradead.org, ard.biesheuvel@linaro.org, tony.luck@intel.com, fenghua.yu@intel.com, dyoung@redhat.com, bhe@redhat.com Subject: [PATCH 0/2 v8] add reserved e820 ranges to the kdump kernel e820 table Date: Thu, 29 Nov 2018 16:09:54 +0800 Message-Id: <20181129080956.20776-1-lijiang@redhat.com> 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.44]); Thu, 29 Nov 2018 08:10:20 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patchset did two things: a). add a new I/O resource descriptor 'IORES_DESC_RESERVED' When doing kexec_file_load, the first kernel needs to pass the e820 reserved ranges to the second kernel. But kernel can not exactly match the e820 reserved ranges when walking through the iomem resources with the descriptor 'IORES_DESC_NONE', because several e820 types( e.g. E820_TYPE_RESERVED_KERN/E820_TYPE_RAM/E820_TYPE_UNUSABLE/E820 _TYPE_RESERVED) are converted to the descriptor 'IORES_DESC_NONE'. It may pass these four types to the kdump kernel, that is not desired result. So, this patch adds a new I/O resource descriptor 'IORES_DESC_RESERVED' for the iomem resources search interfaces. It is helpful to exactly match the reserved resource ranges when walking through iomem resources. In addition, since the new descriptor 'IORES_DESC_RESERVED' is introduced, these code originally related to the descriptor 'IORES_DESC_NONE' need to be updated. Otherwise, it will be easily confused and also cause some errors. Because the 'E820_TYPE_RESERVED' type is converted to the new descriptor 'IORES_DESC_RESERVED' instead of 'IORES_DESC_NONE', it has been changed. b). add the e820 reserved ranges to kdump kernel e820 table At present, when use the kexec_file_load syscall to load the kernel image and initramfs(for example: kexec -s -p xxx), kernel does not pass the e820 reserved ranges to the second kernel, which might cause two problems: The first one is the MMCONFIG issue. The basic problem is that this device is in PCI segment 1 and the kernel PCI probing can not find it without all the e820 I/O reservations being present in the e820 table. And the kdump kernel does not have those reservations because the kexec command does not pass the I/O reservation via the "memmap=xxx" command line option. (This problem does not show up for other vendors, as SGI is apparently the actually fails for everyone, but devices in segment 0 are then found by some legacy lookup method.) The workaround for this is to pass the I/O reserved regions to the kdump kernel. MMCONFIG(aka ECAM) space is described in the ACPI MCFG table. If you don't have ECAM: (a) PCI devices won't work at all on non-x86 systems that use only ECAM for config access, (b) you won't be albe to access devices on non-0 segments, (c) you won't be able to access extended config space( address 0x100-0xffff), which means none of the Extended Capabilities will be available(AER, ACS, ATS, etc). [Bjorn's comment] The second issue is that the SME kdump kernel doesn't work without the e820 reserved ranges. When SME is active in kdump kernel, actually, those reserved regions are still decrypted, but because those reserved ranges are not present at all in kdump kernel e820 table, those reserved regions are considered as encrypted, it goes wrong. The e820 reserved range is useful in kdump kernel, so it is necessary to pass the e820 reserved ranges to kdump kernel. Changes since v1: 1. Modified the value of flags to "0", when walking through the whole tree for e820 reserved ranges. Changes since v2: 1. Modified the value of flags to "0", when walking through the whole tree for e820 reserved ranges. 2. Modified the invalid SOB chain issue. Changes since v3: 1. Dropped [PATCH 1/3 v3] resource: fix an error which walks through iomem resources. Please refer to this commit <010a93bf97c7> "resource: Fix find_next_iomem_res() iteration issue" Changes since v4: 1. Improve the patch log, and add kernel log. Changes since v5: 1. Rewrite these patches log. Changes since v6: 1. Modify the [PATCH 1/2], and add the new I/O resource descriptor 'IORES_DESC_RESERVED' for the iomem resources search interfaces, and also updates these codes relates to 'IORES_DESC_NONE'. 2. Modify the [PATCH 2/2], and walk through io resource based on the new descriptor 'IORES_DESC_RESERVED'. 3. Update patch log. Changes since v7: 1. Improve patch log. 2. Improve this function __ioremap_check_desc_other(). 3. Modify code comment in the __ioremap_check_desc_other() Lianbo Jiang (2): resource: add the new I/O resource descriptor 'IORES_DESC_RESERVED' x86/kexec_file: add reserved e820 ranges to kdump kernel e820 table arch/ia64/kernel/efi.c | 4 ++++ arch/x86/kernel/crash.c | 6 ++++++ arch/x86/kernel/e820.c | 2 +- arch/x86/mm/ioremap.c | 13 ++++++++++++- include/linux/ioport.h | 1 + kernel/resource.c | 6 +++--- 6 files changed, 27 insertions(+), 5 deletions(-) -- 2.17.1