public inbox for linux-efi@vger.kernel.org
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: Linux EFI <linux-efi@vger.kernel.org>
Cc: Borislav Petkov <bp@suse.de>, Dave Young <dyoung@redhat.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	James Bottomley <James.Bottomley@HansenPartnership.com>,
	Matt Fleming <matt@console-pimps.org>,
	Matthew Garrett <mjg59@srcf.ucam.org>,
	Vivek Goyal <vgoyal@redhat.com>,
	LKML <linux-kernel@vger.kernel.org>, X86 ML <x86@kernel.org>
Subject: [PATCH 02/11] x86, pageattr: Lookup address in an arbitrary PGD
Date: Thu, 31 Oct 2013 17:25:00 +0100	[thread overview]
Message-ID: <1383236709-19716-3-git-send-email-bp@alien8.de> (raw)
In-Reply-To: <1383236709-19716-1-git-send-email-bp@alien8.de>

From: Borislav Petkov <bp@suse.de>

This is preparatory work in order to be able to map pages into a
specified PGD and not implicitly and only into init_mm.

Signed-off-by: Borislav Petkov <bp@suse.de>
---
 arch/x86/mm/pageattr.c | 36 ++++++++++++++++++++++++++----------
 1 file changed, 26 insertions(+), 10 deletions(-)

diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
index bb32480c2d71..c53de62a1170 100644
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -30,6 +30,7 @@
  */
 struct cpa_data {
 	unsigned long	*vaddr;
+	pgd_t		*pgd;
 	pgprot_t	mask_set;
 	pgprot_t	mask_clr;
 	int		numpages;
@@ -322,17 +323,9 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
 	return prot;
 }
 
-/*
- * Lookup the page table entry for a virtual address. Return a pointer
- * to the entry and the level of the mapping.
- *
- * Note: We return pud and pmd either when the entry is marked large
- * or when the present bit is not set. Otherwise we would return a
- * pointer to a nonexisting mapping.
- */
-pte_t *lookup_address(unsigned long address, unsigned int *level)
+static pte_t *__lookup_address_in_pgd(pgd_t *pgd, unsigned long address,
+				      unsigned int *level)
 {
-	pgd_t *pgd = pgd_offset_k(address);
 	pud_t *pud;
 	pmd_t *pmd;
 
@@ -361,8 +354,31 @@ pte_t *lookup_address(unsigned long address, unsigned int *level)
 
 	return pte_offset_kernel(pmd, address);
 }
+
+/*
+ * Lookup the page table entry for a virtual address. Return a pointer
+ * to the entry and the level of the mapping.
+ *
+ * Note: We return pud and pmd either when the entry is marked large
+ * or when the present bit is not set. Otherwise we would return a
+ * pointer to a nonexisting mapping.
+ */
+pte_t *lookup_address(unsigned long address, unsigned int *level)
+{
+        return __lookup_address_in_pgd(pgd_offset_k(address), address, level);
+}
 EXPORT_SYMBOL_GPL(lookup_address);
 
+static pte_t *_lookup_address_cpa(struct cpa_data *cpa, unsigned long address,
+				  unsigned int *level)
+{
+        if (cpa->pgd)
+		return __lookup_address_in_pgd(cpa->pgd + pgd_index(address),
+					       address, level);
+
+        return lookup_address(address, level);
+}
+
 /*
  * This is necessary because __pa() does not work on some
  * kinds of memory, like vmalloc() or the alloc_remap()
-- 
1.8.4

  parent reply	other threads:[~2013-10-31 16:25 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-31 16:24 [PATCH 00/11] EFI runtime services virtual mapping, vN++ Borislav Petkov
2013-10-31 16:24 ` [PATCH 01/11] efi: Simplify EFI_DEBUG Borislav Petkov
2013-10-31 16:25 ` Borislav Petkov [this message]
2013-10-31 16:25 ` [PATCH 05/11] x86, pageattr: Add a PMD pagetable populating function Borislav Petkov
     [not found] ` <1383236709-19716-1-git-send-email-bp-Gina5bIWoIWzQB+pC5nmwQ@public.gmane.org>
2013-10-31 16:25   ` [PATCH 03/11] x86, pageattr: Add a PGD " Borislav Petkov
2013-10-31 16:25   ` [PATCH 04/11] x86, pageattr: Add a PUD " Borislav Petkov
2013-10-31 16:25   ` [PATCH 06/11] x86, pageattr: Add a PTE " Borislav Petkov
2013-10-31 16:25   ` [PATCH 07/11] x86, pageattr: Add a PUD error unwinding path Borislav Petkov
2013-10-31 16:25   ` [PATCH 08/11] x86, pageattr: Add last levels of error path Borislav Petkov
2013-10-31 16:25 ` [PATCH 09/11] x86, cpa: Map in an arbitrary pgd Borislav Petkov
2013-10-31 16:25 ` [PATCH 10/11] EFI: Runtime services virtual mapping Borislav Petkov
     [not found]   ` <1383236709-19716-11-git-send-email-bp-Gina5bIWoIWzQB+pC5nmwQ@public.gmane.org>
2013-11-01  3:25     ` Dave Young
     [not found]       ` <20131101032551.GC4378-je1gSBvt1TcFLmT5oZ11vB/sF2h8X+2i0E9HWUfgJXw@public.gmane.org>
2013-11-01  3:35         ` Dave Young
     [not found]           ` <20131101033508.GA13527-je1gSBvt1TcFLmT5oZ11vB/sF2h8X+2i0E9HWUfgJXw@public.gmane.org>
2013-11-01 12:50             ` Matt Fleming
     [not found]               ` <20131101125057.GA21688-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org>
2013-11-03 12:35                 ` Dave Young
2013-11-03 12:31         ` Dave Young
     [not found]           ` <20131103123115.GA5313-je1gSBvt1TcFLmT5oZ11vB/sF2h8X+2i0E9HWUfgJXw@public.gmane.org>
2013-11-04  9:18             ` Matt Fleming
2013-10-31 16:25 ` [PATCH 11/11] efi: Check krealloc return value Borislav Petkov
2013-11-04  9:21 ` [PATCH 00/11] EFI runtime services virtual mapping, vN++ Matt Fleming

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1383236709-19716-3-git-send-email-bp@alien8.de \
    --to=bp@alien8.de \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=bp@suse.de \
    --cc=dyoung@redhat.com \
    --cc=hpa@zytor.com \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matt@console-pimps.org \
    --cc=mjg59@srcf.ucam.org \
    --cc=vgoyal@redhat.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox