From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752090AbdBUMFS (ORCPT ); Tue, 21 Feb 2017 07:05:18 -0500 Received: from mail-wr0-f176.google.com ([209.85.128.176]:36152 "EHLO mail-wr0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752095AbdBUMFJ (ORCPT ); Tue, 21 Feb 2017 07:05:09 -0500 Date: Tue, 21 Feb 2017 12:05:05 +0000 From: Matt Fleming To: Tom Lendacky Cc: linux-arch@vger.kernel.org, linux-efi@vger.kernel.org, kvm@vger.kernel.org, linux-doc@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, iommu@lists.linux-foundation.org, Rik van Riel , Radim =?utf-8?B?S3LEjW3DocWZ?= , Toshimitsu Kani , Arnd Bergmann , Jonathan Corbet , "Michael S. Tsirkin" , Joerg Roedel , Konrad Rzeszutek Wilk , Paolo Bonzini , Brijesh Singh , Ingo Molnar , Alexander Potapenko , Andy Lutomirski , "H. Peter Anvin" , Borislav Petkov , Andrey Ryabinin , Thomas Gleixner , Larry Woodman , Dmitry Vyukov Subject: Re: [RFC PATCH v4 13/28] efi: Update efi_mem_type() to return defined EFI mem types Message-ID: <20170221120505.GQ28416@codeblueprint.co.uk> References: <20170216154158.19244.66630.stgit@tlendack-t1.amdoffice.net> <20170216154457.19244.5369.stgit@tlendack-t1.amdoffice.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170216154457.19244.5369.stgit@tlendack-t1.amdoffice.net> User-Agent: Mutt/1.5.24+41 (02bc14ed1569) (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 16 Feb, at 09:44:57AM, Tom Lendacky wrote: > Update the efi_mem_type() to return EFI_RESERVED_TYPE instead of a > hardcoded 0. > > Signed-off-by: Tom Lendacky > --- > arch/x86/platform/efi/efi.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c > index a15cf81..6407103 100644 > --- a/arch/x86/platform/efi/efi.c > +++ b/arch/x86/platform/efi/efi.c > @@ -1037,7 +1037,7 @@ u32 efi_mem_type(unsigned long phys_addr) > efi_memory_desc_t *md; > > if (!efi_enabled(EFI_MEMMAP)) > - return 0; > + return EFI_RESERVED_TYPE; > > for_each_efi_memory_desc(md) { > if ((md->phys_addr <= phys_addr) && > @@ -1045,7 +1045,7 @@ u32 efi_mem_type(unsigned long phys_addr) > (md->num_pages << EFI_PAGE_SHIFT)))) > return md->type; > } > - return 0; > + return EFI_RESERVED_TYPE; > } I see what you're getting at here, but arguably the return value in these cases never should have been zero to begin with (your change just makes that more obvious). Returning EFI_RESERVED_TYPE implies an EFI memmap entry exists for this address, which is misleading because it doesn't in the hunks you've modified above. Instead, could you look at returning a negative error value in the usual way we do in the Linux kernel, and update the function prototype to match? I don't think any callers actually require the return type to be u32.