Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp394068ybh; Sun, 12 Jul 2020 09:43:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/7+6PuQFytYW851gtNOvK1mw+N+66rP0z29pOLSw89pWDNedYjySNRz5TE1sXLzQUobbm X-Received: by 2002:a05:6402:1ac4:: with SMTP id ba4mr84104787edb.60.1594572200156; Sun, 12 Jul 2020 09:43:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594572200; cv=none; d=google.com; s=arc-20160816; b=oro9zv6/FcjYfmq8glUOCAGGsq0KPBnJis+gjqY4puqecZYioo5a1HdQr8Hlah8CZt spihAEUptgz4dete8kMwF6RiEAHpux0EkV0YOZaVHDwImsSpb+OX0Et/ULt3v/NyIw5c sz990mzLml3bbJ6UoyLtmqE983jaay+dZWNgx47ueHREdWF5Apy/dPvYzaTGkPMDxGN2 H9LJMdwo8don2hpNG3nTTPxvBHd/x4grcHba/HRhOEjvKUklH8UGwohwnL0nO+yPsADe HqfCsbCVIHX39mrnG7/e23iZSJ8WeIv2Mk0iobcO1aByuN/4meaYDONAz3qoYIfaAki1 +xYg== 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:references:in-reply-to:message-id:date:cc:to:from :subject:ironport-sdr:ironport-sdr; bh=7G4qFwPHyfvEVLXbjsSiGfMyVTj2lnDxizq4jNs8o9E=; b=r7eDGtKVUJom/eOjawM4YJUrUNa/46uB5TnKorstzEEcQc48gwSRzXF2pdzZo/ikgF Rh6fWtub3fx2yPGw8weeelpbr6YDy37Rx/Y23mN6l7yaTVvP8+pqlt4uQ9f5mYHIvEhD fWxKL25eZYnombhZ+kDGeykPZvgVTA1XgCGxZ5f9CBgl4Z2G9nPIYx6T2aW9BPs/CKPO hQH/DcjGzxTYAkAVLZkiMnVc+qIka+n0lbPZIiUtU164cL/oJzD0Rb1CajZOj9XL603+ V+GnuGD0umDIVxFWhgtlrF0hkmGaXOPhEkMMM04t98xy0cfSJ8g95vFYjh+PA3HhKWI3 kg9A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id dk28si7240114edb.425.2020.07.12.09.42.57; Sun, 12 Jul 2020 09:43:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1729147AbgGLQmm (ORCPT + 99 others); Sun, 12 Jul 2020 12:42:42 -0400 Received: from mga07.intel.com ([134.134.136.100]:13126 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728854AbgGLQmi (ORCPT ); Sun, 12 Jul 2020 12:42:38 -0400 IronPort-SDR: L6+ShyQ9AlArYF/eJwfcSzs9hb7HgBYzPGR4mjcFIKBTfGPBj85fPuOTW8id7HUbw6xVWA/Tw7 vEWl5so+nCnA== X-IronPort-AV: E=McAfee;i="6000,8403,9680"; a="213360338" X-IronPort-AV: E=Sophos;i="5.75,344,1589266800"; d="scan'208";a="213360338" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jul 2020 09:42:38 -0700 IronPort-SDR: fcRd56NNqwIrBNOedQbwa5qP1vxh9INWdHOMNedxocCvC7ZJNVww5gOEkZfUIkWyRL3ckhNfWr yLWlbN3SllPw== X-IronPort-AV: E=Sophos;i="5.75,344,1589266800"; d="scan'208";a="389983039" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jul 2020 09:42:37 -0700 Subject: [PATCH v2 03/22] efi/fake_mem: Arrange for a resource entry per efi_fake_mem instance From: Dan Williams To: linux-nvdimm@lists.01.org Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org, Ard Biesheuvel , peterz@infradead.org, vishal.l.verma@intel.com, dave.hansen@linux.intel.com, ard.biesheuvel@linaro.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, hch@lst.de, joao.m.martins@oracle.com Date: Sun, 12 Jul 2020 09:26:21 -0700 Message-ID: <159457118164.754248.17900410000722040104.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <159457116473.754248.7879464730875147365.stgit@dwillia2-desk3.amr.corp.intel.com> References: <159457116473.754248.7879464730875147365.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 In preparation for attaching a platform device per iomem resource teach the efi_fake_mem code to create an e820 entry per instance. Similar to E820_TYPE_PRAM, bypass merging resource when the e820 map is sanitized. Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: "H. Peter Anvin" Cc: x86@kernel.org Acked-by: Ard Biesheuvel Signed-off-by: Dan Williams --- arch/x86/kernel/e820.c | 16 +++++++++++++++- drivers/firmware/efi/x86_fake_mem.c | 12 +++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index 983cd53ed4c9..22aad412f965 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c @@ -305,6 +305,20 @@ static int __init cpcompare(const void *a, const void *b) return (ap->addr != ap->entry->addr) - (bp->addr != bp->entry->addr); } +static bool e820_nomerge(enum e820_type type) +{ + /* + * These types may indicate distinct platform ranges aligned to + * numa node, protection domain, performance domain, or other + * boundaries. Do not merge them. + */ + if (type == E820_TYPE_PRAM) + return true; + if (type == E820_TYPE_SOFT_RESERVED) + return true; + return false; +} + int __init e820__update_table(struct e820_table *table) { struct e820_entry *entries = table->entries; @@ -380,7 +394,7 @@ int __init e820__update_table(struct e820_table *table) } /* Continue building up new map based on this information: */ - if (current_type != last_type || current_type == E820_TYPE_PRAM) { + if (current_type != last_type || e820_nomerge(current_type)) { if (last_type != 0) { new_entries[new_nr_entries].size = change_point[chg_idx]->addr - last_addr; /* Move forward only if the new size was non-zero: */ diff --git a/drivers/firmware/efi/x86_fake_mem.c b/drivers/firmware/efi/x86_fake_mem.c index e5d6d5a1b240..0bafcc1bb0f6 100644 --- a/drivers/firmware/efi/x86_fake_mem.c +++ b/drivers/firmware/efi/x86_fake_mem.c @@ -38,7 +38,7 @@ void __init efi_fake_memmap_early(void) m_start = mem->range.start; m_end = mem->range.end; for_each_efi_memory_desc(md) { - u64 start, end; + u64 start, end, size; if (md->type != EFI_CONVENTIONAL_MEMORY) continue; @@ -58,11 +58,17 @@ void __init efi_fake_memmap_early(void) */ start = max(start, m_start); end = min(end, m_end); + size = end - start + 1; if (end <= start) continue; - e820__range_update(start, end - start + 1, E820_TYPE_RAM, - E820_TYPE_SOFT_RESERVED); + + /* + * Ensure each efi_fake_mem instance results in + * a unique e820 resource + */ + e820__range_remove(start, size, E820_TYPE_RAM, 1); + e820__range_add(start, size, E820_TYPE_SOFT_RESERVED); e820__update_table(e820_table); } }