提交 f99afd08 编写于 作者: T Tom Lendacky 提交者: Ingo Molnar

efi: Update efi_mem_type() to return an error rather than 0

The efi_mem_type() function currently returns a 0, which maps to
EFI_RESERVED_TYPE, if the function is unable to find a memmap entry for
the supplied physical address. Returning EFI_RESERVED_TYPE implies that
a memmap entry exists, when it doesn't.  Instead of returning 0, change
the function to return a negative error value when no memmap entry is
found.
Signed-off-by: NTom Lendacky <thomas.lendacky@amd.com>
Reviewed-by: NThomas Gleixner <tglx@linutronix.de>
Reviewed-by: NMatt Fleming <matt@codeblueprint.co.uk>
Reviewed-by: NBorislav Petkov <bp@suse.de>
Cc: Alexander Potapenko <glider@google.com>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Larry Woodman <lwoodman@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Toshimitsu Kani <toshi.kani@hpe.com>
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/7fbf40a9dc414d5da849e1ddcd7f7c1285e4e181.1500319216.git.thomas.lendacky@amd.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
上级 a19d66c5
...@@ -757,14 +757,14 @@ efi_memmap_intersects (unsigned long phys_addr, unsigned long size) ...@@ -757,14 +757,14 @@ efi_memmap_intersects (unsigned long phys_addr, unsigned long size)
return 0; return 0;
} }
u32 int
efi_mem_type (unsigned long phys_addr) efi_mem_type (unsigned long phys_addr)
{ {
efi_memory_desc_t *md = efi_memory_descriptor(phys_addr); efi_memory_desc_t *md = efi_memory_descriptor(phys_addr);
if (md) if (md)
return md->type; return md->type;
return 0; return -EINVAL;
} }
u64 u64
......
...@@ -1035,12 +1035,12 @@ void __init efi_enter_virtual_mode(void) ...@@ -1035,12 +1035,12 @@ void __init efi_enter_virtual_mode(void)
/* /*
* Convenience functions to obtain memory types and attributes * Convenience functions to obtain memory types and attributes
*/ */
u32 efi_mem_type(unsigned long phys_addr) int efi_mem_type(unsigned long phys_addr)
{ {
efi_memory_desc_t *md; efi_memory_desc_t *md;
if (!efi_enabled(EFI_MEMMAP)) if (!efi_enabled(EFI_MEMMAP))
return 0; return -ENOTSUPP;
for_each_efi_memory_desc(md) { for_each_efi_memory_desc(md) {
if ((md->phys_addr <= phys_addr) && if ((md->phys_addr <= phys_addr) &&
...@@ -1048,7 +1048,7 @@ u32 efi_mem_type(unsigned long phys_addr) ...@@ -1048,7 +1048,7 @@ u32 efi_mem_type(unsigned long phys_addr)
(md->num_pages << EFI_PAGE_SHIFT)))) (md->num_pages << EFI_PAGE_SHIFT))))
return md->type; return md->type;
} }
return 0; return -EINVAL;
} }
static int __init arch_parse_efi_cmdline(char *str) static int __init arch_parse_efi_cmdline(char *str)
......
...@@ -985,7 +985,7 @@ static inline void efi_esrt_init(void) { } ...@@ -985,7 +985,7 @@ static inline void efi_esrt_init(void) { }
extern int efi_config_parse_tables(void *config_tables, int count, int sz, extern int efi_config_parse_tables(void *config_tables, int count, int sz,
efi_config_table_type_t *arch_tables); efi_config_table_type_t *arch_tables);
extern u64 efi_get_iobase (void); extern u64 efi_get_iobase (void);
extern u32 efi_mem_type (unsigned long phys_addr); extern int efi_mem_type(unsigned long phys_addr);
extern u64 efi_mem_attributes (unsigned long phys_addr); extern u64 efi_mem_attributes (unsigned long phys_addr);
extern u64 efi_mem_attribute (unsigned long phys_addr, unsigned long size); extern u64 efi_mem_attribute (unsigned long phys_addr, unsigned long size);
extern int __init efi_uart_console_only (void); extern int __init efi_uart_console_only (void);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册