Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932977AbbKMQTS (ORCPT ); Fri, 13 Nov 2015 11:19:18 -0500 Received: from mail-wm0-f48.google.com ([74.125.82.48]:34643 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932455AbbKMQTQ (ORCPT ); Fri, 13 Nov 2015 11:19:16 -0500 Date: Fri, 13 Nov 2015 16:19:13 +0000 From: Matt Fleming To: Borislav Petkov Cc: Ingo Molnar , Thomas Gleixner , "H . Peter Anvin" , Toshi Kani , linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, Sai Praneeth Prakhya , Linus Torvalds , Dave Jones , Andrew Morton , Andy Lutomirski , Denys Vlasenko , Stephen Smalley Subject: Re: [PATCH 4/6] x86/efi: Hoist page table switching code into efi_call_virt() Message-ID: <20151113161913.GF2716@codeblueprint.co.uk> References: <1447342823-3612-1-git-send-email-matt@codeblueprint.co.uk> <1447342823-3612-5-git-send-email-matt@codeblueprint.co.uk> <20151112184432.GG3838@pd.tnic> <20151112200108.GF2681@codeblueprint.co.uk> <20151113075943.GB23605@pd.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20151113075943.GB23605@pd.tnic> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1947 Lines: 48 On Fri, 13 Nov, at 08:59:43AM, Borislav Petkov wrote: > On Thu, Nov 12, 2015 at 08:01:08PM +0000, Matt Fleming wrote: > > > That PUSHF implicitly pushes on the stack pointed by %rsp. But(!) we > > > have switched the pagetable (i.e., %cr3 has efi_scratch.efi_pgt) and > > > we're pushing to the VA where the stack *was* but is not anymore. > > > > All the kernel mappings will still exist in the page table we switch > > to, so pushing to the stack should be fine. > > > > The mappings have to exist so that the firmware can dereference > > pointer arguments, e.g. when writing variable data to a kernel buffer. > > > > Or have I misunderstood your point? > > > > > Or maybe it is because you're copying all the PUDs. It is still not 100% > > > clean, IMHO. > ^^^^^^^^^^^^^^^^^ > > I think we're on the same page - you're copying the PUDs in > efi_sync_low_kernel_mappings() so the stack should be there. Correct. > > > Can you do the prolog/epilog calls inside the IRQs-off section? > > > > Not really because in the efi_enabled(EFI_OLD_MEMMAP) case we perform > > kmalloc(), see commit 23a0d4e8fa6d ("efi: Disable interrupts around > > EFI calls, not in the epilog/prolog calls"). > > n_pgds = DIV_ROUND_UP((max_pfn << PAGE_SHIFT), PGDIR_SIZE); > save_pgd = kmalloc(n_pgds * sizeof(pgd_t), GFP_KERNEL); > > This? > > That n_pgds thing is of static size so you can pre-alloc it maybe even > once during boot and reuse it all the time when EFI_OLD_MEMMAP is > enabled. Well, this code is only executed once during boot anyway, for phys_efi_set_virtual_address_map(). FYI, I'm still planning on ripping out all the EFI_OLD_MEMMAP code, as it's getting particularly crufty. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/