Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752072AbcD3WMP (ORCPT ); Sat, 30 Apr 2016 18:12:15 -0400 Received: from mail-wm0-f44.google.com ([74.125.82.44]:33772 "EHLO mail-wm0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750775AbcD3WMM (ORCPT ); Sat, 30 Apr 2016 18:12:12 -0400 Date: Sat, 30 Apr 2016 23:12:09 +0100 From: Matt Fleming To: Alex Thorlton Cc: Borislav Petkov , linux-kernel@vger.kernel.org, Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, linux-efi@vger.kernel.org, Russ Anderson , Dimitri Sivanich , mike travis , Nathan Zimmer Subject: Re: [BUG] x86/efi: MMRs no longer properly mapped after switch to isolated page table Message-ID: <20160430221209.GO2839@codeblueprint.co.uk> References: <20160427154132.GB113599@stormcage.americas.sgi.com> <20160427225122.GG21282@pd.tnic> <20160428014128.GF113599@stormcage.americas.sgi.com> <20160428125711.GB9164@pd.tnic> <20160429154119.GI113599@stormcage.americas.sgi.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160429154119.GI113599@stormcage.americas.sgi.com> 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 Content-Length: 1840 Lines: 39 On Fri, 29 Apr, at 10:41:19AM, Alex Thorlton wrote: > > You can see here that we've made it past the MMR read in uv_system_init, > but we die inside of our first EFI callback. In this example, it looks > like we're using the kernel page table at the time of the failure, and I > believe that the failing address is somewhere in our EFI runtime code: > > [ 0.803396] efi: ATHORLTON EFI md dump: > [ 0.803396] type: 5 > [ 0.803396] pad: 0 > [ 0.803396] phys_addr: 6a0a6000 > [ 0.803396] virt_addr: 0 > [ 0.803396] num_pages: 184 > [ 0.803396] attribute: 800000000000000f > > So it looks like we're trying to read from EFI runtime space while using > the kernel page table, which fails, presumably because the space is also > not mapped into the kernel page table. While I understand *why* it > fails, and why the address isn't mapped, I don't fully know how we > should handle fixing it. How come you're not using the new EFI page tables while making EFI runtime calls? Who owns the MMR space and what is it used for? Do both the kernel and the firmware need access to it? My SGI UV knowledge is zero, so I'm happy to be educated! I can't think of any analogous memory regions on x86 where the EFI services require the kernel to map them, other than the EFI regions themselves. Runtime EFI regions should be opaque, isolated and self-contained. This is why there are two phases of execution for firmware; before and after ExitBootServices(). Once the kernel takes control after ExitBootServices() firmware can no longer provide timer services, for example, and doesn't care where the kernel maps the LAPIC because it never tries to access it. The fact that the UV firmware does care where the MMR space is mapped makes me suspect that there's a lack of isolation.