From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752439AbdGRLAy (ORCPT ); Tue, 18 Jul 2017 07:00:54 -0400 Received: from terminus.zytor.com ([65.50.211.136]:39051 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751403AbdGRLAv (ORCPT ); Tue, 18 Jul 2017 07:00:51 -0400 Date: Tue, 18 Jul 2017 03:52:41 -0700 From: tip-bot for Tom Lendacky Message-ID: Cc: tglx@linutronix.de, dyoung@redhat.com, linux-kernel@vger.kernel.org, mst@redhat.com, rkrcmar@redhat.com, luto@kernel.org, toshi.kani@hpe.com, arnd@arndb.de, pbonzini@redhat.com, glider@google.com, peterz@infradead.org, thomas.lendacky@amd.com, bp@suse.de, konrad.wilk@oracle.com, aryabinin@virtuozzo.com, brijesh.singh@amd.com, mingo@kernel.org, hpa@zytor.com, bp@alien8.de, torvalds@linux-foundation.org, dvyukov@google.com, riel@redhat.com, matt@codeblueprint.co.uk, corbet@lwn.net, lwoodman@redhat.com Reply-To: thomas.lendacky@amd.com, bp@suse.de, konrad.wilk@oracle.com, aryabinin@virtuozzo.com, mst@redhat.com, luto@kernel.org, rkrcmar@redhat.com, arnd@arndb.de, toshi.kani@hpe.com, pbonzini@redhat.com, glider@google.com, peterz@infradead.org, tglx@linutronix.de, dyoung@redhat.com, linux-kernel@vger.kernel.org, matt@codeblueprint.co.uk, corbet@lwn.net, lwoodman@redhat.com, dvyukov@google.com, riel@redhat.com, hpa@zytor.com, bp@alien8.de, torvalds@linux-foundation.org, brijesh.singh@amd.com, mingo@kernel.org In-Reply-To: References: To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/mm] x86/boot/e820: Add support to determine the E820 type of an address Git-Commit-ID: d68baa3fa6e4d703fd0c7954ee5c739789e7242f X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: d68baa3fa6e4d703fd0c7954ee5c739789e7242f Gitweb: http://git.kernel.org/tip/d68baa3fa6e4d703fd0c7954ee5c739789e7242f Author: Tom Lendacky AuthorDate: Mon, 17 Jul 2017 16:10:12 -0500 Committer: Ingo Molnar CommitDate: Tue, 18 Jul 2017 11:38:01 +0200 x86/boot/e820: Add support to determine the E820 type of an address Add a function that will return the E820 type associated with an address range. Signed-off-by: Tom Lendacky Reviewed-by: Thomas Gleixner Reviewed-by: Borislav Petkov Cc: Alexander Potapenko Cc: Andrey Ryabinin Cc: Andy Lutomirski Cc: Arnd Bergmann Cc: Borislav Petkov Cc: Brijesh Singh Cc: Dave Young Cc: Dmitry Vyukov Cc: Jonathan Corbet Cc: Konrad Rzeszutek Wilk Cc: Larry Woodman Cc: Linus Torvalds Cc: Matt Fleming Cc: Michael S. Tsirkin Cc: Paolo Bonzini Cc: Peter Zijlstra Cc: Radim Krčmář Cc: Rik van Riel Cc: Toshimitsu Kani Cc: kasan-dev@googlegroups.com Cc: kvm@vger.kernel.org Cc: linux-arch@vger.kernel.org Cc: linux-doc@vger.kernel.org Cc: linux-efi@vger.kernel.org Cc: linux-mm@kvack.org Link: http://lkml.kernel.org/r/b797aaa588803bf33263d5dd8c32377668fa931a.1500319216.git.thomas.lendacky@amd.com Signed-off-by: Ingo Molnar --- arch/x86/include/asm/e820/api.h | 2 ++ arch/x86/kernel/e820.c | 26 +++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/e820/api.h b/arch/x86/include/asm/e820/api.h index a504adc..cd266d8 100644 --- a/arch/x86/include/asm/e820/api.h +++ b/arch/x86/include/asm/e820/api.h @@ -39,6 +39,8 @@ extern void e820__setup_pci_gap(void); extern void e820__reallocate_tables(void); extern void e820__register_nosave_regions(unsigned long limit_pfn); +extern int e820__get_entry_type(u64 start, u64 end); + /* * Returns true iff the specified range [start,end) is completely contained inside * the ISA region. diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index 532da61..71c11ad 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c @@ -96,7 +96,8 @@ EXPORT_SYMBOL_GPL(e820__mapped_any); * Note: this function only works correctly once the E820 table is sorted and * not-overlapping (at least for the range specified), which is the case normally. */ -bool __init e820__mapped_all(u64 start, u64 end, enum e820_type type) +static struct e820_entry *__e820__mapped_all(u64 start, u64 end, + enum e820_type type) { int i; @@ -122,9 +123,28 @@ bool __init e820__mapped_all(u64 start, u64 end, enum e820_type type) * coverage of the desired range exists: */ if (start >= end) - return 1; + return entry; } - return 0; + + return NULL; +} + +/* + * This function checks if the entire range is mapped with type. + */ +bool __init e820__mapped_all(u64 start, u64 end, enum e820_type type) +{ + return __e820__mapped_all(start, end, type); +} + +/* + * This function returns the type associated with the range . + */ +int e820__get_entry_type(u64 start, u64 end) +{ + struct e820_entry *entry = __e820__mapped_all(start, end, 0); + + return entry ? entry->type : -EINVAL; } /*