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


Groups > linux.kernel > #1268038 > unrolled thread

[PATCH 3/6] x86/efi: Map RAM into the identity page table for mixed mode

Started byMatt Fleming <matt@codeblueprint.co.uk>
First post2015-11-12 16:50 +0100
Last post2015-11-12 20:50 +0100
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 3/6] x86/efi: Map RAM into the identity page table for mixed mode Matt Fleming <matt@codeblueprint.co.uk> - 2015-11-12 16:50 +0100
    Re: [PATCH 3/6] x86/efi: Map RAM into the identity page table for  mixed mode Borislav Petkov <bp@alien8.de> - 2015-11-12 19:10 +0100
      Re: [PATCH 3/6] x86/efi: Map RAM into the identity page table for  mixed mode Matt Fleming <matt@codeblueprint.co.uk> - 2015-11-12 20:50 +0100

#1268038 — [PATCH 3/6] x86/efi: Map RAM into the identity page table for mixed mode

FromMatt Fleming <matt@codeblueprint.co.uk>
Date2015-11-12 16:50 +0100
Subject[PATCH 3/6] x86/efi: Map RAM into the identity page table for mixed mode
Message-ID<qu2im-2in-5@gated-at.bofh.it>
We are relying on the pre-existing mappings in 'trampoline_pgd' when
accessing function arguments in the EFI mixed mode thunking code.

Instead let's map memory explicitly so that things will continue to
work when we move to a separate page table in the future.

Cc: Borislav Petkov <bp@alien8.de>
Cc: Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>
Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk>
---
 arch/x86/platform/efi/efi_64.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
index c8b58ac47b77..634536034e32 100644
--- a/arch/x86/platform/efi/efi_64.c
+++ b/arch/x86/platform/efi/efi_64.c
@@ -144,6 +144,7 @@ void efi_sync_low_kernel_mappings(void)
 int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)
 {
 	unsigned long pfn, text;
+	efi_memory_desc_t *md;
 	struct page *page;
 	unsigned npages;
 	pgd_t *pgd;
@@ -200,6 +201,25 @@ int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)
 
 	efi_scratch.phys_stack += PAGE_SIZE; /* stack grows down */
 
+	/*
+	 * Map all of RAM so that we can access arguments in the 1:1
+	 * mapping when making EFI runtime calls.
+	 */
+	for_each_efi_memory_desc(&memmap, md) {
+		if (md->type != EFI_CONVENTIONAL_MEMORY &&
+		    md->type != EFI_LOADER_DATA &&
+		    md->type != EFI_LOADER_CODE)
+			continue;
+
+		pfn = md->phys_addr >> PAGE_SHIFT;
+		npages = md->num_pages;
+
+		if (kernel_map_pages_in_pgd(pgd, pfn, md->phys_addr, npages, 0)) {
+			pr_err("Failed to map 1:1 memory\n");
+			return 1;
+		}
+	}
+
 	return 0;
 }
 
-- 
2.6.2

--
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/

[toc] | [next] | [standalone]


#1268157 — Re: [PATCH 3/6] x86/efi: Map RAM into the identity page table for mixed mode

FromBorislav Petkov <bp@alien8.de>
Date2015-11-12 19:10 +0100
SubjectRe: [PATCH 3/6] x86/efi: Map RAM into the identity page table for mixed mode
Message-ID<qu4tP-3RE-7@gated-at.bofh.it>
In reply to#1268038
On Thu, Nov 12, 2015 at 03:40:20PM +0000, Matt Fleming wrote:
> We are relying on the pre-existing mappings in 'trampoline_pgd' when
> accessing function arguments in the EFI mixed mode thunking code.
> 
> Instead let's map memory explicitly so that things will continue to
> work when we move to a separate page table in the future.
> 
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>
> Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk>
> ---
>  arch/x86/platform/efi/efi_64.c | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
> index c8b58ac47b77..634536034e32 100644
> --- a/arch/x86/platform/efi/efi_64.c
> +++ b/arch/x86/platform/efi/efi_64.c
> @@ -144,6 +144,7 @@ void efi_sync_low_kernel_mappings(void)
>  int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)
>  {
>  	unsigned long pfn, text;
> +	efi_memory_desc_t *md;
>  	struct page *page;
>  	unsigned npages;
>  	pgd_t *pgd;
> @@ -200,6 +201,25 @@ int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)
>  
>  	efi_scratch.phys_stack += PAGE_SIZE; /* stack grows down */
>  
> +	/*
> +	 * Map all of RAM so that we can access arguments in the 1:1

Why "all of RAM"?

> +	 * mapping when making EFI runtime calls.
> +	 */
> +	for_each_efi_memory_desc(&memmap, md) {
> +		if (md->type != EFI_CONVENTIONAL_MEMORY &&
> +		    md->type != EFI_LOADER_DATA &&
> +		    md->type != EFI_LOADER_CODE)

That's mapping all those EFI_* types...

> +			continue;
> +
> +		pfn = md->phys_addr >> PAGE_SHIFT;
> +		npages = md->num_pages;
> +
> +		if (kernel_map_pages_in_pgd(pgd, pfn, md->phys_addr, npages, 0)) {
> +			pr_err("Failed to map 1:1 memory\n");
> +			return 1;
> +		}
> +	}
> +
>  	return 0;
>  }
>  
> -- 
> 2.6.2
> 
> 

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--
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/

[toc] | [prev] | [next] | [standalone]


#1268233 — Re: [PATCH 3/6] x86/efi: Map RAM into the identity page table for mixed mode

FromMatt Fleming <matt@codeblueprint.co.uk>
Date2015-11-12 20:50 +0100
SubjectRe: [PATCH 3/6] x86/efi: Map RAM into the identity page table for mixed mode
Message-ID<qu62C-4HV-15@gated-at.bofh.it>
In reply to#1268157
On Thu, 12 Nov, at 07:01:26PM, Borislav Petkov wrote:
> On Thu, Nov 12, 2015 at 03:40:20PM +0000, Matt Fleming wrote:
> > We are relying on the pre-existing mappings in 'trampoline_pgd' when
> > accessing function arguments in the EFI mixed mode thunking code.
> > 
> > Instead let's map memory explicitly so that things will continue to
> > work when we move to a separate page table in the future.
> > 
> > Cc: Borislav Petkov <bp@alien8.de>
> > Cc: Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>
> > Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk>
> > ---
> >  arch/x86/platform/efi/efi_64.c | 20 ++++++++++++++++++++
> >  1 file changed, 20 insertions(+)
> > 
> > diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
> > index c8b58ac47b77..634536034e32 100644
> > --- a/arch/x86/platform/efi/efi_64.c
> > +++ b/arch/x86/platform/efi/efi_64.c
> > @@ -144,6 +144,7 @@ void efi_sync_low_kernel_mappings(void)
> >  int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)
> >  {
> >  	unsigned long pfn, text;
> > +	efi_memory_desc_t *md;
> >  	struct page *page;
> >  	unsigned npages;
> >  	pgd_t *pgd;
> > @@ -200,6 +201,25 @@ int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)
> >  
> >  	efi_scratch.phys_stack += PAGE_SIZE; /* stack grows down */
> >  
> > +	/*
> > +	 * Map all of RAM so that we can access arguments in the 1:1
> 
> Why "all of RAM"?
 
Because the pointers to arguments we pass to the thunk code can point
anywhere in RAM.

> > +	 * mapping when making EFI runtime calls.
> > +	 */
> > +	for_each_efi_memory_desc(&memmap, md) {
> > +		if (md->type != EFI_CONVENTIONAL_MEMORY &&
> > +		    md->type != EFI_LOADER_DATA &&
> > +		    md->type != EFI_LOADER_CODE)
> 
> That's mapping all those EFI_* types...

Hmm? This is mapping only those regions that are usable by the kernel
for general allocations. See the table in setup_e820() in the EFI boot
stub code - these types map to E820_RAM.
--
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/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web