Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1269056

Re: [PATCH 4/6] x86/efi: Hoist page table switching code into efi_call_virt()

Path csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod
From Matt Fleming <matt@codeblueprint.co.uk>
Newsgroups linux.kernel
Subject Re: [PATCH 4/6] x86/efi: Hoist page table switching code into efi_call_virt()
Date Fri, 13 Nov 2015 17:20:02 +0100
Message-ID <qupeW-eJ-15@gated-at.bofh.it> (permalink)
References <qu2il-2in-3@gated-at.bofh.it> <qu2il-2in-1@gated-at.bofh.it> <qu56y-46h-21@gated-at.bofh.it> <qu6lY-55s-9@gated-at.bofh.it> <quhAJ-3Rt-5@gated-at.bofh.it>
X-Original-To Borislav Petkov <bp@alien8.de>
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=codeblueprint_co_uk.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=gh7wJ/hp5gLANrvj0/bmxSklh6keuSu7HaCpCW/9sjs=; b=m3Jk0hiwIhMbmFUGTvQUc7N2pzY7xofpDDl/B7D/GNFSOoreRK+oDLyMRos7OQWP/0 h0A/HM0Oc9h5Oq6eo/dgLsegqkV4mFa3GhKs4kdCNyLzLJCuWNlOjZ0FjwvRo9bLacwO EaLN2xU/gHJrdfrakrw5LV7vLI5n9bfhCMO2hFwBsCXi02WPCLmkxEJ8J5EkBnc9Ff0u 3svaghtQMnED2U2h70u6LZ/eSCVi+F3GrZXpvgGgqjEu4hUUOZFwgNkR3uZpgXPl2BTs gvd8/H1DpO5u+TzXv3WsVdBvb12Jwn04i+TKjIMSOdijJCFRHjI/4wlwu7NuBa6kXXf4 xoSw==
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=gh7wJ/hp5gLANrvj0/bmxSklh6keuSu7HaCpCW/9sjs=; b=DZaKSqlLmR5R8GAMOBPtXFLo68fVw2M4jTaOLm9qZDha1I5II389IF+nmapcx9949b /ACkUqi8bfD3LwSvBeFwAy3/C+F1l7sePISl5OUqe1saOwd1kJH6wYt5sCFLhNCDOfOX yCEYP2JMBPRxAmrzOiDV9Rx3R3HaBEsCjHVlRXI8lh+o5uTYB5dz3Ebwjo/SdBKSMyWT 6z/Je+TnmkYUlBHPoma5SvIkgU/fyFa0BSta7ODjyRkJl2+6KhG3axU36Q70HT9sCred qutOmYJNlTaKlcBDZrihlOnMAfhfhz9fbpXT4ZIKxKsHmK5kRwATbWA55ktl1UBvESdM M+xg==
X-Gm-Message-State ALoCoQnVrsaErh8h9lBCAulPHstXPivxOjnZak2nDV1wi8k9SfIX9VcU98Co5f4NG70KP/bYySWE
X-Received by 10.194.59.108 with SMTP id y12mr23050420wjq.33.1447431555379; Fri, 13 Nov 2015 08:19:15 -0800 (PST)
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Disposition inline
User-Agent Mutt/1.5.24 (2015-08-30)
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 48
Organization linux.* mail to news gateway
X-Original-Cc Ingo Molnar <mingo@kernel.org>, Thomas Gleixner <tglx@linutronix.de>, "H . Peter Anvin" <hpa@zytor.com>, Toshi Kani <toshi.kani@hp.com>, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>, Linus Torvalds <torvalds@linux-foundation.org>, Dave Jones <davej@codemonkey.org.uk>, Andrew Morton <akpm@linux-foundation.org>, Andy Lutomirski <luto@kernel.org>, Denys Vlasenko <dvlasenk@redhat.com>, Stephen Smalley <sds@tycho.nsa.gov>
X-Original-Date Fri, 13 Nov 2015 16:19:13 +0000
X-Original-Message-ID <20151113161913.GF2716@codeblueprint.co.uk>
X-Original-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>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1269056

Show key headers only | View raw


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/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 4/6] x86/efi: Hoist page table switching code into efi_call_virt() Matt Fleming <matt@codeblueprint.co.uk> - 2015-11-12 16:50 +0100
  Re: [PATCH 4/6] x86/efi: Hoist page table switching code into  efi_call_virt() Borislav Petkov <bp@alien8.de> - 2015-11-12 19:50 +0100
    Re: [PATCH 4/6] x86/efi: Hoist page table switching code into  efi_call_virt() Matt Fleming <matt@codeblueprint.co.uk> - 2015-11-12 21:10 +0100
      Re: [PATCH 4/6] x86/efi: Hoist page table switching code into  efi_call_virt() Borislav Petkov <bp@alien8.de> - 2015-11-13 09:10 +0100
        Re: [PATCH 4/6] x86/efi: Hoist page table switching code into  efi_call_virt() Matt Fleming <matt@codeblueprint.co.uk> - 2015-11-13 17:20 +0100
  Re: [PATCH 4/6] x86/efi: Hoist page table switching code into  efi_call_virt() Borislav Petkov <bp@alien8.de> - 2015-11-12 19:50 +0100
    Re: [PATCH 4/6] x86/efi: Hoist page table switching code into  efi_call_virt() Matt Fleming <matt@codeblueprint.co.uk> - 2015-11-12 21:20 +0100

csiph-web