From: "Scott Parish" <srparish@us.ibm.com>
To: "Nakajima, Jun" <jun.nakajima@intel.com>
Cc: xen-devel@lists.xensource.com, Scott Parish <srparish@us.ibm.com>
Subject: [patch] nx bit shouldn't get set when disabled
Date: Wed, 8 Jun 2005 18:06:16 +0000 [thread overview]
Message-ID: <20050608180615.GF14747@us.ibm.com> (raw)
In-Reply-To: <7F740D512C7C1046AB53446D37200173042FECD1@scsmsx402.amr.corp.intel.com>
[-- Attachment #1: Type: text/plain, Size: 92 bytes --]
How does the attached patch look?
sRp
--
Scott Parish
Signed-off-by: srparish@us.ibm.com
[-- Attachment #2: nx.diff --]
[-- Type: text/plain, Size: 5597 bytes --]
diff -rN -u -p old-xen-64-4/linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/pci-dma.c new-xen-64-4/linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/pci-dma.c
--- old-xen-64-4/linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/pci-dma.c 2005-05-24 17:34:54.000000000 +0000
+++ new-xen-64-4/linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/pci-dma.c 2005-06-08 03:17:21.000000000 +0000
@@ -78,7 +78,7 @@ xen_contig_memory(unsigned long vstart,
pud_t *pud;
pmd_t *pmd;
pte_t *pte;
- unsigned long pfn, i, flags;
+ unsigned long mfn, i, flags;
scrub_pages(vstart, 1 << order);
@@ -90,28 +90,27 @@ xen_contig_memory(unsigned long vstart,
pud = pud_offset(pgd, (vstart + (i*PAGE_SIZE)));
pmd = pmd_offset(pud, (vstart + (i*PAGE_SIZE)));
pte = pte_offset_kernel(pmd, (vstart + (i*PAGE_SIZE)));
- pfn = pte->pte >> PAGE_SHIFT;
+ mfn = pte_mfn(*pte);
xen_l1_entry_update(pte, 0);
phys_to_machine_mapping[(__pa(vstart)>>PAGE_SHIFT)+i] =
(u32)INVALID_P2M_ENTRY;
if (HYPERVISOR_dom_mem_op(MEMOP_decrease_reservation,
- &pfn, 1, 0) != 1) BUG();
+ &mfn, 1, 0) != 1) BUG();
}
/* 2. Get a new contiguous memory extent. */
if (HYPERVISOR_dom_mem_op(MEMOP_increase_reservation,
- &pfn, 1, order) != 1) BUG();
+ &mfn, 1, order) != 1) BUG();
/* 3. Map the new extent in place of old pages. */
for (i = 0; i < (1<<order); i++) {
pgd = pgd_offset_k( (vstart + (i*PAGE_SIZE)));
pud = pud_offset(pgd, (vstart + (i*PAGE_SIZE)));
pmd = pmd_offset(pud, (vstart + (i*PAGE_SIZE)));
pte = pte_offset_kernel(pmd, (vstart + (i*PAGE_SIZE)));
- xen_l1_entry_update(
- pte, ((pfn+i)<<PAGE_SHIFT)|__PAGE_KERNEL);
+ set_pte(pte, __pte_ma(((mfn+i)<<PAGE_SHIFT)|__PAGE_KERNEL));
xen_machphys_update(
- pfn+i, (__pa(vstart)>>PAGE_SHIFT)+i);
+ mfn+i, (__pa(vstart)>>PAGE_SHIFT)+i);
phys_to_machine_mapping[(__pa(vstart)>>PAGE_SHIFT)+i] =
- pfn+i;
+ mfn+i;
}
/* Flush updates through and flush the TLB. */
xen_tlb_flush();
diff -rN -u -p old-xen-64-4/linux-2.6.11-xen-sparse/arch/xen/x86_64/mm/hypervisor.c new-xen-64-4/linux-2.6.11-xen-sparse/arch/xen/x86_64/mm/hypervisor.c
--- old-xen-64-4/linux-2.6.11-xen-sparse/arch/xen/x86_64/mm/hypervisor.c 2005-06-06 16:39:54.000000000 +0000
+++ new-xen-64-4/linux-2.6.11-xen-sparse/arch/xen/x86_64/mm/hypervisor.c 2005-06-07 20:35:16.000000000 +0000
@@ -256,7 +276,7 @@ unsigned long allocate_empty_lowmem_regi
pud = pud_offset(pgd, (vstart + (i*PAGE_SIZE)));
pmd = pmd_offset(pud, (vstart + (i*PAGE_SIZE)));
pte = pte_offset_kernel(pmd, (vstart + (i*PAGE_SIZE)));
- pfn_array[i] = pte->pte >> PAGE_SHIFT;
+ pfn_array[i] = pte_mfn(*pte);
xen_l1_entry_update(pte, 0);
phys_to_machine_mapping[(__pa(vstart)>>PAGE_SHIFT)+i] =
(u32)INVALID_P2M_ENTRY;
diff -rN -u -p old-xen-64-4/linux-2.6.11-xen-sparse/arch/xen/x86_64/mm/init.c new-xen-64-4/linux-2.6.11-xen-sparse/arch/xen/x86_64/mm/init.c
--- old-xen-64-4/linux-2.6.11-xen-sparse/arch/xen/x86_64/mm/init.c 2005-06-02 23:09:31.000000000 +0000
+++ new-xen-64-4/linux-2.6.11-xen-sparse/arch/xen/x86_64/mm/init.c 2005-06-07 15:39:50.000000000 +0000
@@ -395,7 +395,7 @@ unsigned long get_machine_pfn(unsigned l
pmd_t* pmd = pmd_offset(pud, addr);
pte_t *pte = pte_offset_kernel(pmd, addr);
- return (pte->pte >> PAGE_SHIFT);
+ return pte_mfn(*pte);
}
#define ALIGN_TO_4K __attribute__((section(".data.page_aligned")))
diff -rN -u -p old-xen-64-4/linux-2.6.11-xen-sparse/include/asm-xen/asm-x86_64/pgtable.h new-xen-64-4/linux-2.6.11-xen-sparse/include/asm-xen/asm-x86_64/pgtable.h
--- old-xen-64-4/linux-2.6.11-xen-sparse/include/asm-xen/asm-x86_64/pgtable.h 2005-05-28 09:20:36.000000000 +0000
+++ new-xen-64-4/linux-2.6.11-xen-sparse/include/asm-xen/asm-x86_64/pgtable.h 2005-06-08 02:48:53.000000000 +0000
@@ -81,7 +81,8 @@ extern inline int pud_present(pud_t pud)
#define set_pte(pteptr, pteval) xen_l1_entry_update(pteptr, (pteval).pte)
#else
-#define set_pte(pteptr, pteval) xen_l1_entry_update(pteptr, (pteval.pte))
+#define set_pte(pteptr, pteval) xen_l1_entry_update(pteptr, \
+ (pteval).pte & __supported_pte_mask)
#if 0
static inline void set_pte(pte_t *dst, pte_t val)
{
@@ -90,9 +91,23 @@ static inline void set_pte(pte_t *dst, p
#endif
#endif
-#define set_pmd(pmdptr, pmdval) xen_l2_entry_update(pmdptr, (pmdval))
-#define set_pud(pudptr, pudval) xen_l3_entry_update(pudptr, (pudval))
-#define set_pgd(pgdptr, pgdval) xen_l4_entry_update(pgdptr, (pgdval))
+static inline void set_pmd(pmd_t *ptr, pmd_t val)
+{
+ val.pmd &= __supported_pte_mask;
+ xen_l2_entry_update(ptr, val);
+}
+
+static inline void set_pud(pud_t *ptr, pud_t val)
+{
+ val.pud &= __supported_pte_mask;
+ xen_l3_entry_update(ptr, val);
+}
+
+static inline void set_pgd(pgd_t *ptr, pgd_t val)
+{
+ val.pgd &= __supported_pte_mask;
+ xen_l4_entry_update(ptr, val);
+}
extern inline void pud_clear (pud_t * pud)
{
@@ -277,9 +292,10 @@ static inline unsigned long pud_bad(pud_
*/
#define INVALID_P2M_ENTRY (~0UL)
#define FOREIGN_FRAME(_m) ((_m) | (1UL<<((sizeof(unsigned long)*8)-1)))
+#define pte_mfn(_pte) (((_pte).pte & PTE_MASK) >> PAGE_SHIFT)
#define pte_pfn(_pte) \
({ \
- unsigned long mfn = (_pte).pte >> PAGE_SHIFT; \
+ unsigned long mfn = pte_mfn(_pte); \
unsigned pfn = mfn_to_pfn(mfn); \
if ((pfn >= max_mapnr) || (pfn_to_mfn(pfn) != mfn)) \
pfn = max_mapnr; /* special: force !pfn_valid() */ \
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
next prev parent reply other threads:[~2005-06-08 18:06 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-07 21:02 [patch] predicate NX flag Nakajima, Jun
2005-06-08 18:06 ` Scott Parish [this message]
2005-06-08 19:56 ` [patch] nx bit shouldn't get set when disabled Keir Fraser
2005-06-08 19:47 ` Scott Parish
2005-06-08 21:23 ` Keir Fraser
[not found] ` <20050608204727.GH3182@us.ibm.com>
[not found] ` <d246c2258805470a73cb0b357f3a6739@cl.cam.ac.uk>
2005-06-08 22:39 ` Scott Parish
2005-06-09 12:59 ` Scott Parish
-- strict thread matches above, loose matches on Subject: below --
2005-06-08 21:30 Ian Pratt
2005-06-08 21:28 ` Keir Fraser
2005-06-08 21:56 Nakajima, Jun
2005-06-08 22:00 ` Keir Fraser
2005-06-08 22:47 Nakajima, Jun
2005-06-08 22:33 ` Scott Parish
2005-06-08 23:29 Nakajima, Jun
2005-06-09 15:02 Nakajima, Jun
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=20050608180615.GF14747@us.ibm.com \
--to=srparish@us.ibm.com \
--cc=jun.nakajima@intel.com \
--cc=xen-devel@lists.xensource.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.