Skip to content

Commit f99afd0

Browse files
tlendackyIngo Molnar
authored andcommitted
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: Tom Lendacky <thomas.lendacky@amd.com> Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Matt Fleming <matt@codeblueprint.co.uk> Reviewed-by: Borislav 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.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent a19d66c commit f99afd0

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

arch/ia64/kernel/efi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -757,14 +757,14 @@ efi_memmap_intersects (unsigned long phys_addr, unsigned long size)
757757
return 0;
758758
}
759759

760-
u32
760+
int
761761
efi_mem_type (unsigned long phys_addr)
762762
{
763763
efi_memory_desc_t *md = efi_memory_descriptor(phys_addr);
764764

765765
if (md)
766766
return md->type;
767-
return 0;
767+
return -EINVAL;
768768
}
769769

770770
u64

arch/x86/platform/efi/efi.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,20 +1035,20 @@ void __init efi_enter_virtual_mode(void)
10351035
/*
10361036
* Convenience functions to obtain memory types and attributes
10371037
*/
1038-
u32 efi_mem_type(unsigned long phys_addr)
1038+
int efi_mem_type(unsigned long phys_addr)
10391039
{
10401040
efi_memory_desc_t *md;
10411041

10421042
if (!efi_enabled(EFI_MEMMAP))
1043-
return 0;
1043+
return -ENOTSUPP;
10441044

10451045
for_each_efi_memory_desc(md) {
10461046
if ((md->phys_addr <= phys_addr) &&
10471047
(phys_addr < (md->phys_addr +
10481048
(md->num_pages << EFI_PAGE_SHIFT))))
10491049
return md->type;
10501050
}
1051-
return 0;
1051+
return -EINVAL;
10521052
}
10531053

10541054
static int __init arch_parse_efi_cmdline(char *str)

include/linux/efi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,7 @@ static inline void efi_esrt_init(void) { }
985985
extern int efi_config_parse_tables(void *config_tables, int count, int sz,
986986
efi_config_table_type_t *arch_tables);
987987
extern u64 efi_get_iobase (void);
988-
extern u32 efi_mem_type (unsigned long phys_addr);
988+
extern int efi_mem_type(unsigned long phys_addr);
989989
extern u64 efi_mem_attributes (unsigned long phys_addr);
990990
extern u64 efi_mem_attribute (unsigned long phys_addr, unsigned long size);
991991
extern int __init efi_uart_console_only (void);

0 commit comments

Comments
 (0)