* [PATCH 1/2] Xen PV support for hugepages
@ 2008-10-10 13:29 dcm
2008-10-10 13:30 ` [PATCH 2/2] Linux support for hugepages as a Xen PV guest dcm
2008-10-10 15:28 ` [PATCH 1/2] Xen PV support for hugepages Jan Beulich
0 siblings, 2 replies; 11+ messages in thread
From: dcm @ 2008-10-10 13:29 UTC (permalink / raw)
To: Keir Fraser, xen-devel
This patch adds support to Xen for hugepages in a PV environment. The patch
is against the latest xen-unstable tree on xenbits.xensource.com.
It must be enabled via the command-line option "allowhugepage".
It is assumed that the guest has guaranteed that the hugepage is physically
aligned and contiguous.
There is no support yet for save/restore/migrate.
Signed-off-by: Dave McCracken <dave.mccracken@oracle.com>
----
--- xen-unstable//./xen/include/asm-x86/x86_32/page.h 2008-07-17 09:49:27.000000000 -0500
+++ xen-hpage/./xen/include/asm-x86/x86_32/page.h 2008-10-02 15:07:34.000000000 -0500
@@ -112,7 +112,7 @@ extern unsigned int PAGE_HYPERVISOR_NOCA
* Disallow unused flag bits plus PAT/PSE, PCD, PWT and GLOBAL.
* Permit the NX bit if the hardware supports it.
*/
-#define BASE_DISALLOW_MASK (0xFFFFF198U & ~_PAGE_NX)
+#define BASE_DISALLOW_MASK (0xFFFFF118U & ~_PAGE_NX)
#define L1_DISALLOW_MASK (BASE_DISALLOW_MASK | _PAGE_GNTTAB)
#define L2_DISALLOW_MASK (BASE_DISALLOW_MASK)
--- xen-unstable//./xen/include/asm-x86/x86_64/page.h 2008-10-02 14:23:17.000000000 -0500
+++ xen-hpage/./xen/include/asm-x86/x86_64/page.h 2008-10-02 15:07:34.000000000 -0500
@@ -112,7 +112,7 @@ typedef l4_pgentry_t root_pgentry_t;
* Permit the NX bit if the hardware supports it.
* Note that range [62:52] is available for software use on x86/64.
*/
-#define BASE_DISALLOW_MASK (0xFF800198U & ~_PAGE_NX)
+#define BASE_DISALLOW_MASK (0xFF800118U & ~_PAGE_NX)
#define L1_DISALLOW_MASK (BASE_DISALLOW_MASK | _PAGE_GNTTAB)
#define L2_DISALLOW_MASK (BASE_DISALLOW_MASK)
--- xen-unstable//./xen/arch/x86/mm.c 2008-10-02 14:23:17.000000000 -0500
+++ xen-hpage/./xen/arch/x86/mm.c 2008-10-09 09:07:47.000000000 -0500
@@ -160,6 +160,9 @@ unsigned long total_pages;
#define PAGE_CACHE_ATTRS (_PAGE_PAT|_PAGE_PCD|_PAGE_PWT)
+static int opt_allow_hugepage = 0;
+boolean_param("allowhugepage", opt_allow_hugepage);
+
#define l1_disallow_mask(d) \
((d != dom_io) && \
(rangeset_is_empty((d)->iomem_caps) && \
@@ -584,6 +587,26 @@ static int get_page_and_type_from_pagenr
return rc;
}
+static int get_data_page(struct page_info *page, struct domain *d, int writeable)
+{
+ int rc;
+
+ if ( writeable )
+ rc = get_page_and_type(page, d, PGT_writable_page);
+ else
+ rc = get_page(page, d);
+
+ return rc;
+}
+
+static void put_data_page(struct page_info *page, int writeable)
+{
+ if ( writeable )
+ put_page_and_type(page);
+ else
+ put_page(page);
+}
+
/*
* We allow root tables to map each other (a.k.a. linear page tables). It
* needs some special care with reference counts and access permissions:
@@ -656,6 +679,7 @@ get_page_from_l1e(
struct vcpu *curr = current;
struct domain *owner;
int okay;
+ int writeable;
if ( !(l1f & _PAGE_PRESENT) )
return 1;
@@ -698,10 +722,9 @@ get_page_from_l1e(
* contribute to writeable mapping refcounts. (This allows the
* qemu-dm helper process in dom0 to map the domain's memory without
* messing up the count of "real" writable mappings.) */
- okay = (((l1f & _PAGE_RW) &&
- !(unlikely(paging_mode_external(d) && (d != curr->domain))))
- ? get_page_and_type(page, d, PGT_writable_page)
- : get_page(page, d));
+ writeable = (l1f & _PAGE_RW) &&
+ !( unlikely(paging_mode_external(d) && (d != curr->domain)) );
+ okay = get_data_page(page, d, writeable);
if ( !okay )
{
MEM_LOG("Error getting mfn %lx (pfn %lx) from L1 entry %" PRIpte
@@ -759,11 +782,43 @@ get_page_from_l2e(
MEM_LOG("Bad L2 flags %x", l2e_get_flags(l2e) & L2_DISALLOW_MASK);
return -EINVAL;
}
+ if ( l2e_get_flags(l2e) & _PAGE_PSE )
+ {
+ unsigned long mfn = l2e_get_pfn(l2e);
+ unsigned long m, me;
+ struct page_info *page = mfn_to_page(mfn);
+ int writeable;
- rc = get_page_and_type_from_pagenr(
- l2e_get_pfn(l2e), PGT_l1_page_table, d, 0);
- if ( unlikely(rc == -EINVAL) && get_l2_linear_pagetable(l2e, pfn, d) )
- rc = 0;
+ if ( !opt_allow_hugepage )
+ return -EINVAL;
+
+ writeable = l2e_get_flags(l2e) & _PAGE_RW;
+
+ rc = get_data_page(page, d, writeable);
+ if ( unlikely(!rc) )
+ return rc;
+
+ for ( m = mfn+1, me = m + (L1_PAGETABLE_ENTRIES-1); m <= me; m++ )
+ {
+ rc = get_data_page(mfn_to_page(m), d, writeable);
+ if ( unlikely(!rc) )
+ {
+ for ( --m; m > mfn; --m )
+ put_data_page(mfn_to_page(m), writeable);
+ put_data_page(page, writeable);
+ return 0;
+ }
+ }
+#ifdef __x86_64__
+ map_pages_to_xen((unsigned long)mfn_to_virt(mfn), mfn, L1_PAGETABLE_ENTRIES,
+ PAGE_HYPERVISOR | l2e_get_flags(l2e));
+#endif
+ } else {
+ rc = get_page_and_type_from_pagenr(
+ l2e_get_pfn(l2e), PGT_l1_page_table, d, 0);
+ if ( unlikely(rc == -EINVAL) && get_l2_linear_pagetable(l2e, pfn, d) )
+ rc = 0;
+ }
return rc;
}
@@ -955,7 +1010,18 @@ static int put_page_from_l2e(l2_pgentry_
if ( (l2e_get_flags(l2e) & _PAGE_PRESENT) &&
(l2e_get_pfn(l2e) != pfn) )
{
- put_page_and_type(l2e_get_page(l2e));
+ if ( l2e_get_flags(l2e) & _PAGE_PSE )
+ {
+ unsigned long mfn = l2e_get_pfn(l2e);
+ unsigned long m, me;
+ struct page_info *page = mfn_to_page(mfn);
+ int writeable = l2e_get_flags(l2e) & _PAGE_RW;
+
+ for ( m = mfn+1, me = m + (L1_PAGETABLE_ENTRIES-1); m <= me; m++ )
+ put_data_page(mfn_to_page(m), writeable);
+ put_data_page(page, writeable);
+ } else
+ put_page_and_type(l2e_get_page(l2e));
return 0;
}
return 1;
^ permalink raw reply [flat|nested] 11+ messages in thread* [PATCH 2/2] Linux support for hugepages as a Xen PV guest
2008-10-10 13:29 [PATCH 1/2] Xen PV support for hugepages dcm
@ 2008-10-10 13:30 ` dcm
2008-10-10 13:38 ` Keir Fraser
2008-10-10 15:32 ` [PATCH 2/2] Linux support for hugepages as a Xen PVguest Jan Beulich
2008-10-10 15:28 ` [PATCH 1/2] Xen PV support for hugepages Jan Beulich
1 sibling, 2 replies; 11+ messages in thread
From: dcm @ 2008-10-10 13:30 UTC (permalink / raw)
To: Keir Fraser, xen-devel
This patch adds support to Linux for hugepages as a Xen guest. It is
against the linux-2.6.18-xen on xenbits.xensource.com.
It currently assumes that the guest memory is physically aligned and
contiguous. Detection and avoidance of non-aligned memory will be
available in a future patch.
Signed-off-by: Dave McCracken <dave.mccracken@oracle.com>
----
--- linux-2.6.18-xen//./fs/Kconfig 2008-07-17 09:54:14.000000000 -0500
+++ linux-hpage/./fs/Kconfig 2008-10-02 15:07:54.000000000 -0500
@@ -870,7 +870,7 @@ config TMPFS
config HUGETLBFS
bool "HugeTLB file system support"
depends X86 || IA64 || PPC64 || SPARC64 || SUPERH || BROKEN
- depends on !XEN
+# depends on !XEN
help
hugetlbfs is a filesystem backing for HugeTLB pages, based on
ramfs. For architectures that support it, say Y here and read
--- linux-2.6.18-xen//./include/asm-x86_64/mach-xen/asm/page.h 2008-07-17 09:54:18.000000000 -0500
+++ linux-hpage/./include/asm-x86_64/mach-xen/asm/page.h 2008-10-02 15:07:54.000000000 -0500
@@ -62,6 +62,8 @@
#define HPAGE_MASK (~(HPAGE_SIZE - 1))
#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
+#define ARCH_HAS_SETCLEAR_HUGE_PTE
+
#ifdef __KERNEL__
#ifndef __ASSEMBLY__
--- linux-2.6.18-xen//./include/asm-x86_64/mach-xen/asm/pgtable.h 2008-08-14 10:06:46.000000000 -0500
+++ linux-hpage/./include/asm-x86_64/mach-xen/asm/pgtable.h 2008-10-02 15:07:54.000000000 -0500
@@ -261,6 +261,12 @@ static inline unsigned long pud_bad(pud_
set_pte((ptep), (pteval)); \
} while (0)
+static inline void set_huge_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pteval) {
+ if ((mm != current->mm && mm != &init_mm) ||
+ HYPERVISOR_update_va_mapping(addr, pteval, 0))
+ set_pmd((pmd_t *)ptep, (pmd_t){__pte_val(pteval)});
+}
+
#define pte_none(x) (!(x).pte)
#define pte_present(x) ((x).pte & (_PAGE_PRESENT | _PAGE_PROTNONE))
#define pte_clear(mm,addr,xp) do { set_pte_at(mm, addr, xp, __pte(0)); } while (0)
@@ -296,6 +302,19 @@ static inline pte_t ptep_get_and_clear(s
return pte;
}
+static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
+{
+ pte_t pte = *ptep;
+ if (!pte_none(pte)) {
+ if ((mm != &init_mm) ||
+ HYPERVISOR_update_va_mapping(addr, __pte(0), 0)) {
+ pte = *ptep;
+ set_pmd((pmd_t *)ptep, __pmd(0));
+ }
+ }
+ return pte;
+}
+
static inline pte_t ptep_get_and_clear_full(struct mm_struct *mm, unsigned long addr, pte_t *ptep, int full)
{
if (full) {
--- linux-2.6.18-xen//./arch/x86_64/mm/pageattr-xen.c 2008-07-17 09:54:10.000000000 -0500
+++ linux-hpage/./arch/x86_64/mm/pageattr-xen.c 2008-10-02 15:07:54.000000000 -0500
@@ -62,6 +62,8 @@ static void _pin_lock(struct mm_struct *
if (pmd_none(*pmd))
continue;
+ if (pte_huge(*(pte_t *)pmd))
+ continue;
ptl = pte_lockptr(0, pmd);
if (lock)
spin_lock(ptl);
--- linux-2.6.18-xen//./mm/hugetlb.c 2008-07-17 09:54:19.000000000 -0500
+++ linux-hpage/./mm/hugetlb.c 2008-10-02 15:07:54.000000000 -0500
@@ -294,12 +294,14 @@ static pte_t make_huge_pte(struct vm_are
int writable)
{
pte_t entry;
+ pgprot_t pgprot;
+ pgprot = __pgprot(pgprot_val(vma->vm_page_prot) | _PAGE_PRESENT);
if (writable) {
entry =
- pte_mkwrite(pte_mkdirty(mk_pte(page, vma->vm_page_prot)));
+ pte_mkwrite(pte_mkdirty(mk_pte(page, pgprot)));
} else {
- entry = pte_wrprotect(mk_pte(page, vma->vm_page_prot));
+ entry = pte_wrprotect(mk_pte(page, pgprot));
}
entry = pte_mkyoung(entry);
entry = pte_mkhuge(entry);
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH 2/2] Linux support for hugepages as a Xen PV guest
2008-10-10 13:30 ` [PATCH 2/2] Linux support for hugepages as a Xen PV guest dcm
@ 2008-10-10 13:38 ` Keir Fraser
2008-10-10 15:06 ` Dave McCracken
2008-10-10 15:32 ` [PATCH 2/2] Linux support for hugepages as a Xen PVguest Jan Beulich
1 sibling, 1 reply; 11+ messages in thread
From: Keir Fraser @ 2008-10-10 13:38 UTC (permalink / raw)
To: dcm, xen-devel
On 10/10/08 14:30, "dcm@mccr.org" <dcm@mccr.org> wrote:
> This patch adds support to Linux for hugepages as a Xen guest. It is
> against the linux-2.6.18-xen on xenbits.xensource.com.
>
> It currently assumes that the guest memory is physically aligned and
> contiguous. Detection and avoidance of non-aligned memory will be
> available in a future patch.
>
> Signed-off-by: Dave McCracken <dave.mccracken@oracle.com>
hugetlbfs should only be enabled at runtime if supported by the hypervisor.
Perhaps we can enable the PSE CPUID flag if the hypervisor supports
superpages?
> --- linux-2.6.18-xen//./mm/hugetlb.c 2008-07-17 09:54:19.000000000 -0500
> +++ linux-hpage/./mm/hugetlb.c 2008-10-02 15:07:54.000000000 -0500
> @@ -294,12 +294,14 @@ static pte_t make_huge_pte(struct vm_are
> int writable)
> {
> pte_t entry;
> + pgprot_t pgprot;
>
> + pgprot = __pgprot(pgprot_val(vma->vm_page_prot) | _PAGE_PRESENT);
> if (writable) {
> entry =
> - pte_mkwrite(pte_mkdirty(mk_pte(page, vma->vm_page_prot)));
> + pte_mkwrite(pte_mkdirty(mk_pte(page, pgprot)));
> } else {
> - entry = pte_wrprotect(mk_pte(page, vma->vm_page_prot));
> + entry = pte_wrprotect(mk_pte(page, pgprot));
> }
> entry = pte_mkyoung(entry);
> entry = pte_mkhuge(entry);
Why do we need to do something different for Xen here?
-- Keir
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH 2/2] Linux support for hugepages as a Xen PV guest
2008-10-10 13:38 ` Keir Fraser
@ 2008-10-10 15:06 ` Dave McCracken
2008-10-10 15:35 ` [PATCH 2/2] Linux support for hugepages as a Xen PVguest Jan Beulich
2008-10-15 17:01 ` Re: [PATCH 2/2] Linux support for hugepages as a Xen PV guest Dave McCracken
0 siblings, 2 replies; 11+ messages in thread
From: Dave McCracken @ 2008-10-10 15:06 UTC (permalink / raw)
To: Keir Fraser; +Cc: xen-devel
On Friday 10 October 2008, Keir Fraser wrote:
> hugetlbfs should only be enabled at runtime if supported by the hypervisor.
> Perhaps we can enable the PSE CPUID flag if the hypervisor supports
> superpages?
I'll look into it.
> > --- linux-2.6.18-xen//./mm/hugetlb.c 2008-07-17 09:54:19.000000000 -0500
> > +++ linux-hpage/./mm/hugetlb.c 2008-10-02 15:07:54.000000000 -0500
> > @@ -294,12 +294,14 @@ static pte_t make_huge_pte(struct vm_are
> > int writable)
> > {
> > pte_t entry;
> > + pgprot_t pgprot;
> >
> > + pgprot = __pgprot(pgprot_val(vma->vm_page_prot) | _PAGE_PRESENT);
> > if (writable) {
> > entry =
> > - pte_mkwrite(pte_mkdirty(mk_pte(page, vma->vm_page_prot)));
> > + pte_mkwrite(pte_mkdirty(mk_pte(page, pgprot)));
> > } else {
> > - entry = pte_wrprotect(mk_pte(page, vma->vm_page_prot));
> > + entry = pte_wrprotect(mk_pte(page, pgprot));
> > }
> > entry = pte_mkyoung(entry);
> > entry = pte_mkhuge(entry);
>
> Why do we need to do something different for Xen here?
In the original implementation _PAGE_PRESENT is set in later macros. Xen
needs it early to trigger the proper phys_to_machine() translation.
Dave McCracken
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH 2/2] Linux support for hugepages as a Xen PVguest
2008-10-10 15:06 ` Dave McCracken
@ 2008-10-10 15:35 ` Jan Beulich
2008-10-15 17:01 ` Re: [PATCH 2/2] Linux support for hugepages as a Xen PV guest Dave McCracken
1 sibling, 0 replies; 11+ messages in thread
From: Jan Beulich @ 2008-10-10 15:35 UTC (permalink / raw)
To: Dave McCracken; +Cc: xen-devel, Keir Fraser
>>> Dave McCracken <dcm@mccr.org> 10.10.08 17:06 >>>
>> > --- linux-2.6.18-xen//./mm/hugetlb.c 2008-07-17 09:54:19.000000000 -0500
>> > +++ linux-hpage/./mm/hugetlb.c 2008-10-02 15:07:54.000000000 -0500
>> > @@ -294,12 +294,14 @@ static pte_t make_huge_pte(struct vm_are
>> > int writable)
>> > {
>> > pte_t entry;
>> > + pgprot_t pgprot;
>> >
>> > + pgprot = __pgprot(pgprot_val(vma->vm_page_prot) | _PAGE_PRESENT);
>> > if (writable) {
>> > entry =
>> > - pte_mkwrite(pte_mkdirty(mk_pte(page, vma->vm_page_prot)));
>> > + pte_mkwrite(pte_mkdirty(mk_pte(page, pgprot)));
>> > } else {
>> > - entry = pte_wrprotect(mk_pte(page, vma->vm_page_prot));
>> > + entry = pte_wrprotect(mk_pte(page, pgprot));
>> > }
>> > entry = pte_mkyoung(entry);
>> > entry = pte_mkhuge(entry);
>>
>> Why do we need to do something different for Xen here?
>
>In the original implementation _PAGE_PRESENT is set in later macros. Xen
>needs it early to trigger the proper phys_to_machine() translation.
That should then better be taken care of in the place where _PAGE_PRESENT
gets actually set. Also, doesn't vma->vm_page_prot already properly
reflect the intended setting of _PAGE_PRESENT?
Jan
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: Re: [PATCH 2/2] Linux support for hugepages as a Xen PV guest
2008-10-10 15:06 ` Dave McCracken
2008-10-10 15:35 ` [PATCH 2/2] Linux support for hugepages as a Xen PVguest Jan Beulich
@ 2008-10-15 17:01 ` Dave McCracken
2008-10-15 21:48 ` Jeremy Fitzhardinge
1 sibling, 1 reply; 11+ messages in thread
From: Dave McCracken @ 2008-10-15 17:01 UTC (permalink / raw)
To: xen-devel; +Cc: Keir Fraser
On Friday 10 October 2008, Dave McCracken wrote:
> On Friday 10 October 2008, Keir Fraser wrote:
> > hugetlbfs should only be enabled at runtime if supported by the
> > hypervisor. Perhaps we can enable the PSE CPUID flag if the hypervisor
> > supports superpages?
>
> I'll look into it.
Opening the cover to this exposed some very interesting things on the Linux
side.
For starters, Xen currently does remove PSE from the CPUID it returns to the
guest. I'll add some code to allow PSE when hugepages are enabled.
Second, in Linux for the x86_64 architecture the macro to check for PSE is
hard-wired to always be true.
Third, hugepages in Linux makes no check whatsoever for the presence or
absence of PSE. It assumes it's there.
I'll look into the simplest way to make the various Linux parts obey the PSE
flag properly.
Dave McCracken
Oracle Corp.
This is all for the Linux-xen-2.6.18 tree on xensource.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Re: [PATCH 2/2] Linux support for hugepages as a Xen PV guest
2008-10-15 17:01 ` Re: [PATCH 2/2] Linux support for hugepages as a Xen PV guest Dave McCracken
@ 2008-10-15 21:48 ` Jeremy Fitzhardinge
2008-10-15 22:12 ` Dave McCracken
0 siblings, 1 reply; 11+ messages in thread
From: Jeremy Fitzhardinge @ 2008-10-15 21:48 UTC (permalink / raw)
To: Dave McCracken; +Cc: xen-devel, Keir Fraser
Dave McCracken wrote:
> For starters, Xen currently does remove PSE from the CPUID it returns to the
> guest. I'll add some code to allow PSE when hugepages are enabled.
>
Yep.
> Second, in Linux for the x86_64 architecture the macro to check for PSE is
> hard-wired to always be true.
>
Not in current kernels.
> Third, hugepages in Linux makes no check whatsoever for the presence or
> absence of PSE. It assumes it's there.
>
Not in current kernels. But it does assume that if PSE is present, then
physical memory can always be mapped with large pages.
> I'll look into the simplest way to make the various Linux parts obey the PSE
> flag properly.
>
No, use a current mainline git linux kernel.
J
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: Re: [PATCH 2/2] Linux support for hugepages as a Xen PV guest
2008-10-15 21:48 ` Jeremy Fitzhardinge
@ 2008-10-15 22:12 ` Dave McCracken
2008-10-15 22:31 ` Jeremy Fitzhardinge
0 siblings, 1 reply; 11+ messages in thread
From: Dave McCracken @ 2008-10-15 22:12 UTC (permalink / raw)
To: Jeremy Fitzhardinge; +Cc: xen-devel, Keir Fraser
On Wednesday 15 October 2008, Jeremy Fitzhardinge wrote:
> No, use a current mainline git linux kernel.
I'm currently using xen-unstable and linux-2.6.18-xen as the base for my
development. Are you saying I should move to the current Linux mainline
instead? Is linux-2.6.18-xen now obsolete?
Dave McCracken
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Re: [PATCH 2/2] Linux support for hugepages as a Xen PV guest
2008-10-15 22:12 ` Dave McCracken
@ 2008-10-15 22:31 ` Jeremy Fitzhardinge
0 siblings, 0 replies; 11+ messages in thread
From: Jeremy Fitzhardinge @ 2008-10-15 22:31 UTC (permalink / raw)
To: Dave McCracken; +Cc: xen-devel, Keir Fraser
Dave McCracken wrote:
> I'm currently using xen-unstable and linux-2.6.18-xen as the base for my
> development. Are you saying I should move to the current Linux mainline
> instead?
Yes.
> Is linux-2.6.18-xen now obsolete?
>
More or less. Mainline is missing a few features, but it is stable and
useful. 2.6.18-xen shouldn't be used for any new work.
J
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/2] Linux support for hugepages as a Xen PVguest
2008-10-10 13:30 ` [PATCH 2/2] Linux support for hugepages as a Xen PV guest dcm
2008-10-10 13:38 ` Keir Fraser
@ 2008-10-10 15:32 ` Jan Beulich
1 sibling, 0 replies; 11+ messages in thread
From: Jan Beulich @ 2008-10-10 15:32 UTC (permalink / raw)
To: dcm; +Cc: xen-devel, Keir Fraser
>+static inline void set_huge_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pteval) {
>+ if ((mm != current->mm && mm != &init_mm) ||
>+ HYPERVISOR_update_va_mapping(addr, pteval, 0))
>+ set_pmd((pmd_t *)ptep, (pmd_t){__pte_val(pteval)});
>+}
Your Xen patch made no attempt at implementing L2 modifications through
update_va_mapping, so why have the guest even try?
>+static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
>+{
>+ pte_t pte = *ptep;
>+ if (!pte_none(pte)) {
>+ if ((mm != &init_mm) ||
>+ HYPERVISOR_update_va_mapping(addr, __pte(0), 0)) {
>+ pte = *ptep;
>+ set_pmd((pmd_t *)ptep, __pmd(0));
Same here.
Jan
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] Xen PV support for hugepages
2008-10-10 13:29 [PATCH 1/2] Xen PV support for hugepages dcm
2008-10-10 13:30 ` [PATCH 2/2] Linux support for hugepages as a Xen PV guest dcm
@ 2008-10-10 15:28 ` Jan Beulich
1 sibling, 0 replies; 11+ messages in thread
From: Jan Beulich @ 2008-10-10 15:28 UTC (permalink / raw)
To: dcm; +Cc: xen-devel, Keir Fraser
>--- xen-unstable//./xen/include/asm-x86/x86_32/page.h 2008-07-17 09:49:27.000000000 -0500
>+++ xen-hpage/./xen/include/asm-x86/x86_32/page.h 2008-10-02 15:07:34.000000000 -0500
>@@ -112,7 +112,7 @@ extern unsigned int PAGE_HYPERVISOR_NOCA
> * Disallow unused flag bits plus PAT/PSE, PCD, PWT and GLOBAL.
> * Permit the NX bit if the hardware supports it.
> */
>-#define BASE_DISALLOW_MASK (0xFFFFF198U & ~_PAGE_NX)
>+#define BASE_DISALLOW_MASK (0xFFFFF118U & ~_PAGE_NX)
>
> #define L1_DISALLOW_MASK (BASE_DISALLOW_MASK | _PAGE_GNTTAB)
> #define L2_DISALLOW_MASK (BASE_DISALLOW_MASK)
You ought to or in the bit you removed from BASE_DISALLOW_MASK into
L1_DISALLOW_MASK.
>--- xen-unstable//./xen/include/asm-x86/x86_64/page.h 2008-10-02 14:23:17.000000000 -0500
>+++ xen-hpage/./xen/include/asm-x86/x86_64/page.h 2008-10-02 15:07:34.000000000 -0500
>@@ -112,7 +112,7 @@ typedef l4_pgentry_t root_pgentry_t;
> * Permit the NX bit if the hardware supports it.
> * Note that range [62:52] is available for software use on x86/64.
> */
>-#define BASE_DISALLOW_MASK (0xFF800198U & ~_PAGE_NX)
>+#define BASE_DISALLOW_MASK (0xFF800118U & ~_PAGE_NX)
>
> #define L1_DISALLOW_MASK (BASE_DISALLOW_MASK | _PAGE_GNTTAB)
> #define L2_DISALLOW_MASK (BASE_DISALLOW_MASK)
Same here, but also for L3 (unless you also support Gb pages) and L4.
>--- xen-unstable//./xen/arch/x86/mm.c 2008-10-02 14:23:17.000000000 -0500
>+++ xen-hpage/./xen/arch/x86/mm.c 2008-10-09 09:07:47.000000000 -0500
>@@ -160,6 +160,9 @@ unsigned long total_pages;
>
> #define PAGE_CACHE_ATTRS (_PAGE_PAT|_PAGE_PCD|_PAGE_PWT)
>
>+static int opt_allow_hugepage = 0;
>+boolean_param("allowhugepage", opt_allow_hugepage);
>+
> #define l1_disallow_mask(d) \
> ((d != dom_io) && \
> (rangeset_is_empty((d)->iomem_caps) && \
And you also need to adjust l1_disallow_mask() to honor
opt_allow_hugepage.
>+ rc = get_data_page(page, d, writeable);
>+ if ( unlikely(!rc) )
>+ return rc;
>+
>+ for ( m = mfn+1, me = m + (L1_PAGETABLE_ENTRIES-1); m <= me; m++ )
Isn't this off by one (i.e. shouldn't the condition be m < me)?
>+ map_pages_to_xen((unsigned long)mfn_to_virt(mfn), mfn, L1_PAGETABLE_ENTRIES,
>+ PAGE_HYPERVISOR | l2e_get_flags(l2e));
You need to translate flags to l1 notion here - map_pages_to_xen() expects
it this way. Even more, it's not valid to simply or in PAGE_HYPERVISOR - you need
to follow the same logic as used in get_page_from_l1e().
>+ for ( m = mfn+1, me = m + (L1_PAGETABLE_ENTRIES-1); m <= me; m++ )
Same as above.
Jan
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2008-10-15 22:31 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-10 13:29 [PATCH 1/2] Xen PV support for hugepages dcm
2008-10-10 13:30 ` [PATCH 2/2] Linux support for hugepages as a Xen PV guest dcm
2008-10-10 13:38 ` Keir Fraser
2008-10-10 15:06 ` Dave McCracken
2008-10-10 15:35 ` [PATCH 2/2] Linux support for hugepages as a Xen PVguest Jan Beulich
2008-10-15 17:01 ` Re: [PATCH 2/2] Linux support for hugepages as a Xen PV guest Dave McCracken
2008-10-15 21:48 ` Jeremy Fitzhardinge
2008-10-15 22:12 ` Dave McCracken
2008-10-15 22:31 ` Jeremy Fitzhardinge
2008-10-10 15:32 ` [PATCH 2/2] Linux support for hugepages as a Xen PVguest Jan Beulich
2008-10-10 15:28 ` [PATCH 1/2] Xen PV support for hugepages Jan Beulich
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.