From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754842AbbIIJ6b (ORCPT ); Wed, 9 Sep 2015 05:58:31 -0400 Received: from mail-wi0-f175.google.com ([209.85.212.175]:36306 "EHLO mail-wi0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753371AbbIIJ6J (ORCPT ); Wed, 9 Sep 2015 05:58:09 -0400 Date: Wed, 9 Sep 2015 10:58:06 +0100 From: Matt Fleming To: Ard Biesheuvel Cc: "linux-efi@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "x86@kernel.org" , Matt Fleming , Borislav Petkov , Leif Lindholm , Peter Jones , James Bottomley , Matthew Garrett , "H. Peter Anvin" , Dave Young , "stable@vger.kernel.org" Subject: Re: [PATCH] x86/efi: Map EFI memmap entries in-order at runtime Message-ID: <20150909095806.GA4973@codeblueprint.co.uk> References: <1441372447-23439-1-git-send-email-matt@codeblueprint.co.uk> <20150904182307.GE2737@codeblueprint.co.uk> <20150908131622.GA2854@codeblueprint.co.uk> <20150908203630.GB2854@codeblueprint.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 09 Sep, at 09:37:21AM, Ard Biesheuvel wrote: > On 8 September 2015 at 22:37, Matt Fleming wrote: > > > > diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c > > index 691b333e0038..a2af35f6093a 100644 > > --- a/arch/x86/platform/efi/efi.c > > +++ b/arch/x86/platform/efi/efi.c > > @@ -704,6 +704,44 @@ out: > > return ret; > > } > > > > +static inline void *efi_map_next_entry_reverse(void *entry) > > +{ > > + if (!entry) > > + return memmap.map_end - memmap.desc_size; > > + > > + entry -= memmap.desc_size; > > + if (entry < memmap.map) > > + return NULL; > > + > > + return entry; > > +} > > + > > +static void *efi_map_next_entry(void *entry) > > +{ > > + bool reverse = false; > > + > > + if (!efi_enabled(EFI_OLD_MEMMAP) && efi_enabled(EFI_64BIT)) { > > Here, you could also test whether the > EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA bit > (sigh) is set No, leaving this out was intentional because we're already suffering from the combinatoral explosion of config options. Introducing more code paths is very much the wrong thing to do unless absolutely necessary. If we can get away with using one mapping scheme here, we should. When trying to debug this code in the future I do not want to be thinking "Do you have EFI_PROPERTIES_RUNTIME_OMG_THIS_IS_SILLY bit set? because that means we're mapping the runtime regions in a different order". -- Matt Fleming, Intel Open Source Technology Center