Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp15747377ybl; Tue, 31 Dec 2019 14:22:04 -0800 (PST) X-Google-Smtp-Source: APXvYqyUxWgbPZ7w8UAmCqjypi4L4PaOMCczRi/sQdJSdGJRaUL5krmEA0xbuCBfaZ4WpJCGxoRE X-Received: by 2002:a50:fb08:: with SMTP id d8mr77851010edq.79.1577830923902; Tue, 31 Dec 2019 14:22:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577830923; cv=none; d=google.com; s=arc-20160816; b=nW0PZ1yAtnHG0UMr2v38/SSPCHjOlZuxu8bxz0saZQFXwGZulaHQAnbw1PN+LGN+tN MZX+dk2RH0YTjCT9MP+cFJwFcVJwEkJh1TQ0BjicD1INLsEaXe4Xq3wJfyshzyDwUxDU R4Aquqb9eJqBMUe1R/px8BNzxSZNws/8xdemlaPfd0gnbyiRNptHT9rORrbPjuuMGbIE St0m8QveqkBWAuAsrj1pOSlkAAVuNPVNyV/r1ByG1DUTS3I/9r+Ylxee6Ia6MyRPNrCt xD+hgomRiQjVEaQoX7Zu1rixR4vJK9tIatFydVTRRraL7VPFW7F/Nh9+U/ON5lDVRWhr rG7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:message-id:date:cc:to:from:subject; bh=j7Ksp6UpEL8JHS3jaYyUybdRQeCqe2wm5bMkBUu626I=; b=bqkFCPyZu+qofmBMvXl+KJAU2efshCFFpy6DfL1cxuKYNjjWda4Ec6fidbi1v4zS6P mq09X805haMaLQjEKejqetZYzaxL7yAevjcnitdplT4U/YSjc0pgqbhbaJLep5r2aD0W NRLO0ZpUbVPmh1e+Wh+PekQ3E4/+ZzFi3CfAzbq5dswgyPGZ7eBjvT/q++PM5XoASHur NPdyAbcHaFqqRD0SYFxXdgnXCTdeNJ8xXhHp3U283G98fXq+ZuU1Ia5GFdmHxspk9kPn F09EuODCfVkdO5D+0nJBWc4DdZGfn9tkSYSjgDlj+PM1wjbSJw6r97vy6kE3p+q890cE oDBA== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gv22si32794805ejb.99.2019.12.31.14.21.39; Tue, 31 Dec 2019 14:22:03 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727104AbfLaWUU (ORCPT + 99 others); Tue, 31 Dec 2019 17:20:20 -0500 Received: from mga02.intel.com ([134.134.136.20]:40298 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727054AbfLaWUU (ORCPT ); Tue, 31 Dec 2019 17:20:20 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 Dec 2019 14:20:20 -0800 X-IronPort-AV: E=Sophos;i="5.69,380,1571727600"; d="scan'208";a="393645183" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 Dec 2019 14:20:19 -0800 Subject: [PATCH v2 0/4] efi: Fix handling of multiple efi_fake_mem= entries From: Dan Williams To: mingo@redhat.com Cc: Taku Izumi , Thomas Gleixner , Dave Young , Ingo Molnar , Michael Weiser , Ard Biesheuvel , linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, kexec@lists.infradead.org, x86@kernel.org Date: Tue, 31 Dec 2019 14:04:17 -0800 Message-ID: <157782985777.367056.14741265874314204783.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Changes since v1 [1]: - Add support for garbage collecting idle efi_memmap_alloc() allocations - As Dave noticed the same problem of calling efi_memmap_split_count() multiple times with the old map also applies to efi_memmap_insert(). Update efi_fake_memmap() to invoke efi_memmap_install() after every efi_memmap_insert() call. [1]: https://lore.kernel.org/r/157773590338.4153451.5898675419563883883.stgit@dwillia2-desk3.amr.corp.intel.com/ --- Copied from patch4: Dave noticed that when specifying multiple efi_fake_mem= entries only the last entry was successfully being reflected in the efi memory map. This is due to the fact that the efi_memmap_insert() is being called multiple times, but on successive invocations the insertion should be applied to the last new memmap rather than the original map at efi_fake_memmap() entry. Rework efi_fake_memmap() to install the new memory map after each efi_fake_mem= entry is parsed. This also fixes an issue in efi_fake_memmap() that caused it to litter emtpy entries into the end of the efi memory map. The empty entry causes efi_memmap_insert() to attempt more memmap splits / copies than efi_memmap_split_count() accounted for when sizing the new map. BUG: unable to handle page fault for address: ffffffffff281000 [..] RIP: 0010:efi_memmap_insert+0x11d/0x191 [..] Call Trace: ? bgrt_init+0xbe/0xbe ? efi_arch_mem_reserve+0x1cb/0x228 ? acpi_parse_bgrt+0xa/0xd ? acpi_table_parse+0x86/0xb8 ? acpi_boot_init+0x494/0x4e3 ? acpi_parse_x2apic+0x87/0x87 ? setup_acpi_sci+0xa2/0xa2 ? setup_arch+0x8db/0x9e1 ? start_kernel+0x6a/0x547 ? secondary_startup_64+0xb6/0xc0 Commit af1648984828 "x86/efi: Update e820 with reserved EFI boot services data to fix kexec breakage" is listed in Fixes: since it introduces more occurrences where efi_memmap_insert() is invoked after an efi_fake_mem= configuration has been parsed. Previously the side effects of vestigial empty entries were benign, but with commit af1648984828 that follow-on efi_memmap_insert() invocation triggers the above crash signature. --- Dan Williams (4): efi: Add a flags parameter to efi_memory_map efi: Add tracking for dynamically allocated memmaps efi: Fix efi_memmap_alloc() leaks efi: Fix handling of multiple efi_fake_mem= entries arch/x86/platform/efi/efi.c | 2 + arch/x86/platform/efi/quirks.c | 11 ++++--- drivers/firmware/efi/fake_mem.c | 37 +++++++++++++------------ drivers/firmware/efi/memmap.c | 58 ++++++++++++++++++++++++++++++--------- include/linux/efi.h | 13 +++++++-- 5 files changed, 81 insertions(+), 40 deletions(-)