Skip to contentSkip to conversation

CONFIG_XEN_COMPAT_030002 broken?

DISCUSSION Gerd Hoffmann 4 participants 22 messages Nov 13, 2006 – Nov 15, 2006

lore
Share & tools
lore
#0 lore raw

Hi,

$subject says all. Running latest bits from the 3.0.2 testing tree, trying to boot a 3.0.3 linux guest kernel with the compat option enabled, doesn't boot on x86_64 (32bit works ok). Kernel dies very early at boot:

(XEN) ----[ Xen-3.0.2-3 Not tainted ]----
(XEN) CPU: 1
(XEN) RIP: e033:[<ffffffff8010734a>]
(XEN) RFLAGS: 0000000000000246 CONTEXT: guest

(XEN) rax: 0000000000000000   rbx: ffffffff7fffffff   rcx: ffffffff8010734a
(XEN) rdx: 0000000000000000   rsi: 0000000000000001   rdi: ffffffff8041ff70
(XEN) rbp: ffffffff8041ff90   rsp: ffffffff8041ff10   r8:  0000000000000000
(XEN) r9:  0000000000000000   r10: 0000000000007ff0   r11: 0000000000000246
(XEN) r12: ffffffff8040c000   r13: 0000000000000000   r14: 0000000000000000
(XEN) r15: 0000000000000000   cr0: 000000008005003b   cr3: 0000000021bdc000

(XEN) ds: 0000 es: 0000 fs: 0000 gs: 0000 ss: e02b cs: e033
(XEN) Guest stack trace from rsp=ffffffff8041ff10:
(XEN) ffffffff8010734a 0000000000000246 0000000000000011
ffffffff8010734a
(XEN) 000000010000e030 0000000000010046 ffffffff8041ff58
000000000000e02b
(XEN) 0000000021bdbff8 0000000000000000 0000000000000101
ffffffff80116f9b
(XEN) 0000000000000005 0000000000021bdc ffffffff8040c000
0000000000000000
(XEN) ffffffff8041ffb0 ffffffff80110424 0000000000000000
0000000000000000
(XEN) ffffffff8041fff0 ffffffff804210e1 ffff800000000000
ffff804000000000
(XEN) 00000007ffffffff 0000000000000000 0000000000000000
0000000000000000
(XEN) 0000000000000000 0000000000000000

### (XEN) RIP: e033:[<ffffffff8010734a>]
### (XEN) Guest stack trace from rsp=ffffffff8041ff10:
ffffffff80116f9b - func ffffffff80116f4a + 51 xen_pt_switch
ffffffff80110424 - func ffffffff80110357 + cd pda_init -
call xen_pt_switch
ffffffff804210e1 - func ffffffff80421000 + e1 x86_64_start_kernel - call pda_init

Signature · 2 lines
Gerd Hoffmann <[email protected]>
http://www.suse.de/~kraxel/julika-dora.jpeg
#1 lore raw
Quoted 6 lines · Gerd Hoffmann

Hi,

$subject says all. Running latest bits from the 3.0.2 testing tree, trying to boot a 3.0.3 linux guest kernel with the compat option enabled, doesn't boot on x86_64 (32bit works ok). Kernel dies very early at boot:

changeset 11226 is the culprit (stop setting _PAGE_USER for kernel pages).

cheers,
Gerd

Signature · 2 lines
Gerd Hoffmann <[email protected]>
http://www.suse.de/~kraxel/julika-dora.jpeg
#2 lore raw
Quoted 6 lines · Gerd Hoffmann
Quoted 4 lines

$subject says all. Running latest bits from the 3.0.2 testing tree, trying to boot a 3.0.3 linux guest kernel with the compat option enabled, doesn't boot on x86_64 (32bit works ok). Kernel dies very early at boot:

changeset 11226 is the culprit (stop setting _PAGE_USER for kernel pages).

To fix this we'd need to make all the KERNPG_XXX macros into variables and poke in PAGE_USER if running on an older version of Xen.

-- Keir

#3 lore raw
Quoted 8 lines · Keir Fraser
Quoted 5 lines
Quoted 4 lines

$subject says all. Running latest bits from the 3.0.2 testing tree, trying to boot a 3.0.3 linux guest kernel with the compat option enabled, doesn't boot on x86_64 (32bit works ok). Kernel dies very early at boot:

changeset 11226 is the culprit (stop setting _PAGE_USER for kernel pages).

To fix this we'd need to make all the KERNPG_XXX macros into variables and poke in PAGE_USER if running on an older version of Xen.

As xen must be able to deal with PAGE_USER being set anyway (to deal with old guests) I'd simply make that a compile time option depending on CONFIG_XEN_COMPAT_030002, so we can avoid the extra cost of checking some variable at runtime ...

What was the reason for that change btw? Just make the differences between native and paravirtualized smaller?

cheers,
Gerd

Signature · 2 lines
Gerd Hoffmann <[email protected]>
http://www.suse.de/~kraxel/julika-dora.jpeg
#4 lore raw
Quoted 10 lines · Gerd Hoffmann
Quoted 2 lines

To fix this we'd need to make all the KERNPG_XXX macros into variables and poke in PAGE_USER if running on an older version of Xen.

As xen must be able to deal with PAGE_USER being set anyway (to deal with old guests) I'd simply make that a compile time option depending on CONFIG_XEN_COMPAT_030002, so we can avoid the extra cost of checking some variable at runtime ...

What was the reason for that change btw? Just make the differences between native and paravirtualized smaller?

Yes, and to allow fewer TLB entries to be flushed when switching between guest kernel and guest user. That optimisation is foiled if PAGE_USER is set everywhere.

-- Keir

#5 lore raw
Quoted 4 lines · Keir Fraser

Yes, and to allow fewer TLB entries to be flushed when switching between guest kernel and guest user. That optimisation is foiled if PAGE_USER is set everywhere.

Ok, so the extra cost to decide that at runtime (if CONFIG_XEN_COMPAT_030002 is set) probably is outweighed by the tlb flush optimization ...

cheers,
Gerd

Signature · 2 lines
Gerd Hoffmann <[email protected]>
http://www.suse.de/~kraxel/julika-dora.jpeg
#6 lore raw
Quoted 7 lines · Gerd Hoffmann
Quoted 3 lines

Yes, and to allow fewer TLB entries to be flushed when switching between guest kernel and guest user. That optimisation is foiled if PAGE_USER is set everywhere.

Ok, so the extra cost to decide that at runtime (if CONFIG_XEN_COMPAT_030002 is set) probably is outweighed by the tlb flush optimization ...

Definitely!

The only potential problem is I don't know whether any code depends on those definitions being compile-time constant. If not, it should be a straightforward patch.

By the way, the test of whether to poke in PAGE_USER can be done by looking at one of the initial mappings provided by the domain builder. If one of those ptes contains PAGE_USER, you know you need to use PAGE_USER for all kernel mappings.

-- Keir

#7 lore raw
Quoted 4 lines

By the way, the test of whether to poke in PAGE_USER can be done by looking at one of the initial mappings provided by the domain builder. If one of those ptes contains PAGE_USER, you know you need to use PAGE_USER for all kernel mappings.

How would this work? adjust_guest_l1e() (and BASE_PROT for dom0) forces PAGE_USER on even on 3.0.3, so I still shouldn't find any L1 page table entries not having this bit set when looking at them from kernel code.

Jan

#8 lore raw
Quoted 9 lines · Jan Beulich
Quoted 4 lines

By the way, the test of whether to poke in PAGE_USER can be done by looking at one of the initial mappings provided by the domain builder. If one of those ptes contains PAGE_USER, you know you need to use PAGE_USER for all kernel mappings.

How would this work? adjust_guest_l1e() (and BASE_PROT for dom0) forces PAGE_USER on even on 3.0.3, so I still shouldn't find any L1 page table entries
not having this bit set when looking at them from kernel code.

Oh, good point! Okay then the more straightforward XENVER_version check will have to be used: 3.0.3 and newer, versus 3.0.2 and older.

-- Keir

#9 lore raw
Quoted 8 lines
Quoted 1 line
Quoted 1 line

Keir Fraser <[email protected]> 14.11.06 12:50 >>>

Quoted 5 lines · Jan Beulich
Quoted 4 lines

By the way, the test of whether to poke in PAGE_USER can be done by looking at one of the initial mappings provided by the domain builder. If one of those ptes contains PAGE_USER, you know you need to use PAGE_USER for all kernel mappings.

Quoted 7 lines
Quoted 4 lines

How would this work? adjust_guest_l1e() (and BASE_PROT for dom0) forces PAGE_USER on even on 3.0.3, so I still shouldn't find any L1 page table entries
not having this bit set when looking at them from kernel code.

Oh, good point! Okay then the more straightforward XENVER_version check will have to be used: 3.0.3 and newer, versus 3.0.2 and older.

More strait forward? The .3 is part of extraversion, so in order to do a comparison one would have to parse that string (and hence make certain assumptions). That's not nice for use in (early) feature detection. Maybe it'd be better to try and write a page table entry without PAGE_USER, and check whether that bit got turned on implicitly...

Jan

#10 lore raw
Quoted 11 lines · Jan Beulich
Quoted 2 lines

Oh, good point! Okay then the more straightforward XENVER_version check will have to be used: 3.0.3 and newer, versus 3.0.2 and older.

More strait forward? The .3 is part of extraversion, so in order to do a comparison
one would have to parse that string (and hence make certain assumptions). That's
not nice for use in (early) feature detection. Maybe it'd be better to try and write
a page table entry without PAGE_USER, and check whether that bit got turned on implicitly...

Yes, that sounds reasonable.

-- Keir

#11 lore raw

Oh, as I'm changing this - is there a reason for pmd_bad() to use PAGE_MASK rather than PTE_MASK? (I already agreed with Andi that pmd_bad() in native should be cleaned up to match pgd_bad/pud_bad). Jan

Quoted 1 line
Quoted 1 line
Quoted 1 line

Keir Fraser <[email protected]> 14.11.06 13:42 >>>

Quoted 11 lines · Jan Beulich
Quoted 2 lines

Oh, good point! Okay then the more straightforward XENVER_version check will have to be used: 3.0.3 and newer, versus 3.0.2 and older.

More strait forward? The .3 is part of extraversion, so in order to do a comparison
one would have to parse that string (and hence make certain assumptions). That's
not nice for use in (early) feature detection. Maybe it'd be better to try and write
a page table entry without PAGE_USER, and check whether that bit got turned on implicitly...

Yes, that sounds reasonable.

-- Keir

#12 lore raw

Not as far as I know.

Quoted 29 lines · Jan Beulich

Oh, as I'm changing this - is there a reason for pmd_bad() to use PAGE_MASK rather than PTE_MASK? (I already agreed with Andi that pmd_bad() in native should be cleaned up to match pgd_bad/pud_bad). Jan

Quoted 1 line
Quoted 1 line
Quoted 1 line

Keir Fraser <[email protected]> 14.11.06 13:42 >>>

Quoted 12 lines · Jan Beulich
Quoted 2 lines

Oh, good point! Okay then the more straightforward XENVER_version check will have to be used: 3.0.3 and newer, versus 3.0.2 and older.

More strait forward? The .3 is part of extraversion, so in order to do a comparison
one would have to parse that string (and hence make certain assumptions). That's
not nice for use in (early) feature detection. Maybe it'd be better to try and
write
a page table entry without PAGE_USER, and check whether that bit got turned on implicitly...

Yes, that sounds reasonable.

-- Keir

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#13 lore raw
In reply to Jan Beulich
Quoted 3 lines · Jan Beulich

not nice for use in (early) feature detection. Maybe it'd be better to try and write a page table entry without PAGE_USER, and check whether that bit got turned on implicitly...

Patch attached, seems to work ok, survived quick test with ttylinux on both 3.0.3 and 3.0.2 without crashing and detected both versions correctly.

cheers,
Gerd

Signature · 2 lines
Gerd Hoffmann <[email protected]>
http://www.suse.de/~kraxel/julika-dora.jpeg
---
 linux-2.6-xen-sparse/arch/i386/mm/ioremap-xen.c                |    4 
 linux-2.6-xen-sparse/arch/x86_64/mm/init-xen.c                 |   52 +++++++++-
 linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/pgtable.h |   26 +++--
 3 files changed, 73 insertions(+), 9 deletions(-)
linux-2.6-xen-sparse/arch/i386/mm/ioremap-xen.c +4 -0
Index: build-64-testing-11774/linux-2.6-xen-sparse/arch/i386/mm/ioremap-xen.c
===================================================================
@@ -250,6 +250,10 @@ void __iomem * __ioremap(unsigned long p
 	area->phys_addr = phys_addr;
 	addr = (void __iomem *) area->addr;
 	flags |= _PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED;
+#if defined(__x86_64__) && defined(CONFIG_XEN_COMPAT_030002)
+	if (kernel_pages_need_user_flag)
+		flags |= _PAGE_USER;
+#endif
 	if (__direct_remap_pfn_range(&init_mm, (unsigned long)addr,
 				     phys_addr>>PAGE_SHIFT,
 				     size, __pgprot(flags), domid)) {
linux-2.6-xen-sparse/arch/x86_64/mm/init-xen.c +51 -1

70 lines not on this page · raw message

linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/pgtable.h +18 -8
Index: build-64-testing-11774/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/pgtable.h
===================================================================
@@ -205,8 +205,16 @@ static inline pte_t ptep_get_and_clear_f
 #define _PAGE_PROTNONE	0x080	/* If not present */
 #define _PAGE_NX        (1UL<<_PAGE_BIT_NX)
 
+#ifdef CONFIG_XEN_COMPAT_030002
+extern int kernel_pages_need_user_flag;
+extern unsigned long kernel_page_user;
+#else
+#define kernel_pages_need_user_flag 0
+#define kernel_page_user 0
+#endif
+
 #define _PAGE_TABLE	(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED | _PAGE_DIRTY)
-#define _KERNPG_TABLE	(_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY)
+#define _KERNPG_TABLE	(_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY | kernel_page_user)
 
 #define _PAGE_CHG_MASK	(PTE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY)
 
@@ -218,22 +226,24 @@ static inline pte_t ptep_get_and_clear_f
 #define PAGE_COPY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED)
 #define PAGE_READONLY	__pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED | _PAGE_NX)
 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED)
+
 #define __PAGE_KERNEL \
-	(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_NX)
+	(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_NX | kernel_page_user )
 #define __PAGE_KERNEL_EXEC \
-	(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED)
+	(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | kernel_page_user )
 #define __PAGE_KERNEL_NOCACHE \
-	(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_PCD | _PAGE_ACCESSED | _PAGE_NX)
+	(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_PCD | _PAGE_ACCESSED | _PAGE_NX | kernel_page_user )
 #define __PAGE_KERNEL_RO \
-	(_PAGE_PRESENT | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_NX)
+	(_PAGE_PRESENT | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_NX | kernel_page_user )
 #define __PAGE_KERNEL_VSYSCALL \
 	(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED)
 #define __PAGE_KERNEL_VSYSCALL_NOCACHE \
 	(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED | _PAGE_PCD)
 #define __PAGE_KERNEL_LARGE \
-	(__PAGE_KERNEL | _PAGE_PSE)
+	(__PAGE_KERNEL | _PAGE_PSE | kernel_page_user )
 #define __PAGE_KERNEL_LARGE_EXEC \
-	(__PAGE_KERNEL_EXEC | _PAGE_PSE)
+	(__PAGE_KERNEL_EXEC | _PAGE_PSE | kernel_page_user )
+
 
 /*
  * We don't support GLOBAL page in xenolinux64
@@ -422,7 +432,7 @@ static inline pud_t *pud_offset_k(pgd_t 
    can temporarily clear it. */
 #define pmd_present(x)	(pmd_val(x))
 #define pmd_clear(xp)	do { set_pmd(xp, __pmd(0)); } while (0)
-#define	pmd_bad(x)	((pmd_val(x) & (~PAGE_MASK & ~_PAGE_USER & ~_PAGE_PRESENT)) != (_KERNPG_TABLE & ~_PAGE_PRESENT))
+#define	pmd_bad(x)	((pmd_val(x) & (~PAGE_MASK & ~_PAGE_USER & ~_PAGE_PRESENT)) != (_KERNPG_TABLE & ~_PAGE_USER & ~_PAGE_PRESENT))
 #define pfn_pmd(nr,prot) (__pmd(((nr) << PAGE_SHIFT) | pgprot_val(prot)))
 #define pmd_pfn(x)  ((pmd_val(x) & __PHYSICAL_MASK) >> PAGE_SHIFT)
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#14 lore raw
Quoted 10 lines · Gerd Hoffmann
Quoted 4 lines

not nice for use in (early) feature detection. Maybe it'd be better to try and write
a page table entry without PAGE_USER, and check whether that bit got turned on implicitly...

Patch attached, seems to work ok, survived quick test with ttylinux on both 3.0.3 and 3.0.2 without crashing and detected both versions correctly.

cheers,
Gerd

Kernel_pages_need_user_flag seems unnecessary. The one consumer of that flag could simply do 'flags |= kernel_page_user' unconditionally.

Also, is it necessary to default to 3.0.2 behaviour? Could we have kernel_page_user==0 initially and then change the value only if 3.0.2 is detected? This would provide a sanity check that check_page_user_flag() is being executed early enough. We could even set kernel_page_user to a garbage value initially, like ~0.

So far we have maintained the COMPAT code to be easily entirely strippable. So the change to pmd_bad() should either use kernel_page_user rather than _PAGE_USER, or its definition should be conditional on the COMPAT flag.

-- Keir

#15 lore raw
Quoted 2 lines · Keir Fraser

Kernel_pages_need_user_flag seems unnecessary. The one consumer of that flag could simply do 'flags |= kernel_page_user' unconditionally.

Yep, noticed that too meanwhile ;)

Quoted 1 line

Also, is it necessary to default to 3.0.2 behaviour?

I've started coding it that way before I found the final place for the test, just to be sure it doesn't crash on pgtable ops before the test. Defaulting to 3.0.3 behavior should work though as test happens early enough.

Quoted 3 lines

So far we have maintained the COMPAT code to be easily entirely strippable. So the change to pmd_bad() should either use kernel_page_user rather than _PAGE_USER, or its definition should be conditional on the COMPAT flag.

Both ways should have the same effect as kernel_page_user is defined to 0 for the non-compat case.

cheers,

Gerd

Signature · 2 lines
Gerd Hoffmann <[email protected]>
http://www.suse.de/~kraxel/julika-dora.jpeg
#21 lore raw
In reply to Gerd Hoffmann
Quoted 2 lines

Patch attached, seems to work ok, survived quick test with ttylinux on both 3.0.3 and 3.0.2 without crashing and detected both versions correctly.

Hmm, just saw that you already posted a patch - though in addition to Keir's remark regarding kernel_pages_need_user_flag I'd also like to point out that changing __PAGE_KERNEL_LARGE{,_EXEC} is unnecessary as those already derive from __PAGE_KERNEL{,_EXEC}. Additionally I think your change to arch/i386/mm/ioremap-xen.c makes the code more complicated than it needs to be (I know, it had been that way before).

Jan

#20 lore raw
In reply to Keir Fraser
Quoted 5 lines

Also, is it necessary to default to 3.0.2 behaviour? Could we have kernel_page_user==0 initially and then change the value only if 3.0.2 is detected? This would provide a sanity check that check_page_user_flag() is being executed early enough. We could even set kernel_page_user to a garbage value initially, like ~0.

I think it's better the way Gerd had it (my patch also does it that way) - adding extra _PAGE_USER when not needed is not wrong afaics, only hurts performance, whereas missing to add it when needed would crash the kernel. While that might help verify that the check is done early enough, it doesn't guarantee anything since certain code paths may not be taken, and so we may enjoy false safety.

Jan

#16 lore raw
In reply to Gerd Hoffmann
Quoted 6 lines · Gerd Hoffmann
Quoted 3 lines

So far we have maintained the COMPAT code to be easily entirely strippable. So the change to pmd_bad() should either use kernel_page_user rather than _PAGE_USER, or its definition should be conditional on the COMPAT flag.

Both ways should have the same effect as kernel_page_user is defined to 0 for the non-compat case.

Well, thinko in there, wasn't that simple. Went with the #ifdef, new version attached.

cheers,
Gerd

Signature · 2 lines
Gerd Hoffmann <[email protected]>
http://www.suse.de/~kraxel/julika-dora.jpeg
---
 linux-2.6-xen-sparse/arch/i386/mm/ioremap-xen.c                |    3 
 linux-2.6-xen-sparse/arch/x86_64/mm/init-xen.c                 |   51 +++++++++-
 linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/pgtable.h |   22 +++-
 3 files changed, 70 insertions(+), 6 deletions(-)
linux-2.6-xen-sparse/arch/i386/mm/ioremap-xen.c +3 -0
Index: build-64-testing-11774/linux-2.6-xen-sparse/arch/i386/mm/ioremap-xen.c
===================================================================
@@ -250,6 +250,9 @@ void __iomem * __ioremap(unsigned long p
 	area->phys_addr = phys_addr;
 	addr = (void __iomem *) area->addr;
 	flags |= _PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED;
+#if defined(__x86_64__)
+	flags |= kernel_page_user;
+#endif
 	if (__direct_remap_pfn_range(&init_mm, (unsigned long)addr,
 				     phys_addr>>PAGE_SHIFT,
 				     size, __pgprot(flags), domid)) {
linux-2.6-xen-sparse/arch/x86_64/mm/init-xen.c +50 -1

69 lines not on this page · raw message

linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/pgtable.h +17 -5
Index: build-64-testing-11774/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/pgtable.h
===================================================================
@@ -205,8 +205,14 @@ static inline pte_t ptep_get_and_clear_f
 #define _PAGE_PROTNONE	0x080	/* If not present */
 #define _PAGE_NX        (1UL<<_PAGE_BIT_NX)
 
+#ifdef CONFIG_XEN_COMPAT_030002
+extern unsigned long kernel_page_user;
+#else
+#define kernel_page_user 0
+#endif
+
 #define _PAGE_TABLE	(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED | _PAGE_DIRTY)
-#define _KERNPG_TABLE	(_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY)
+#define _KERNPG_TABLE	(_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY | kernel_page_user)
 
 #define _PAGE_CHG_MASK	(PTE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY)
 
@@ -218,14 +224,15 @@ static inline pte_t ptep_get_and_clear_f
 #define PAGE_COPY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED)
 #define PAGE_READONLY	__pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED | _PAGE_NX)
 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED)
+
 #define __PAGE_KERNEL \
-	(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_NX)
+	(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_NX | kernel_page_user )
 #define __PAGE_KERNEL_EXEC \
-	(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED)
+	(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | kernel_page_user )
 #define __PAGE_KERNEL_NOCACHE \
-	(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_PCD | _PAGE_ACCESSED | _PAGE_NX)
+	(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_PCD | _PAGE_ACCESSED | _PAGE_NX | kernel_page_user )
 #define __PAGE_KERNEL_RO \
-	(_PAGE_PRESENT | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_NX)
+	(_PAGE_PRESENT | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_NX | kernel_page_user )
 #define __PAGE_KERNEL_VSYSCALL \
 	(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED)
 #define __PAGE_KERNEL_VSYSCALL_NOCACHE \
@@ -235,6 +242,7 @@ static inline pte_t ptep_get_and_clear_f
 #define __PAGE_KERNEL_LARGE_EXEC \
 	(__PAGE_KERNEL_EXEC | _PAGE_PSE)
 
+
 /*
  * We don't support GLOBAL page in xenolinux64
  */
@@ -422,7 +430,11 @@ static inline pud_t *pud_offset_k(pgd_t 
    can temporarily clear it. */
 #define pmd_present(x)	(pmd_val(x))
 #define pmd_clear(xp)	do { set_pmd(xp, __pmd(0)); } while (0)
+#ifdef CONFIG_XEN_COMPAT_030002
+#define	pmd_bad(x)	((pmd_val(x) & (~PAGE_MASK & ~_PAGE_USER & ~_PAGE_PRESENT)) != (_KERNPG_TABLE & ~_PAGE_USER & ~_PAGE_PRESENT))
+#else
 #define	pmd_bad(x)	((pmd_val(x) & (~PAGE_MASK & ~_PAGE_USER & ~_PAGE_PRESENT)) != (_KERNPG_TABLE & ~_PAGE_PRESENT))
+#endif
 #define pfn_pmd(nr,prot) (__pmd(((nr) << PAGE_SHIFT) | pgprot_val(prot)))
 #define pmd_pfn(x)  ((pmd_val(x) & __PHYSICAL_MASK) >> PAGE_SHIFT)
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#17 lore raw
Quoted 5 lines · Gerd Hoffmann
Quoted 2 lines

Both ways should have the same effect as kernel_page_user is defined to 0 for the non-compat case.

Well, thinko in there, wasn't that simple. Went with the #ifdef, new version attached.

I've applied a version that is part yours, part Jan's, and part mine. Changeset 12404:bb76a76985fe. It would be great if you could test that it actually still works on Xen 3.0.2! :-)

-- Keir

#18 lore raw
Quoted 5 lines · Keir Fraser

On 14/11/06 16:06, "Gerd Hoffmann" <[email protected]> wrote:

I've applied a version that is part yours, part Jan's, and part mine. Changeset 12404:bb76a76985fe. It would be great if you could test that it actually still works on Xen 3.0.2! :-)

Works for me, thanks. Maybe that should be added to the regression tests?

BTW: what is the state of the testing mercurial tree? It hasn't seen updates for quite some time. I'd expect bugfixes like this one being queued for 3.0.3 too ...

cheers,
Gerd

Signature · 2 lines
Gerd Hoffmann <[email protected]>
http://www.suse.de/~kraxel/julika-dora.jpeg
#19 lore raw
Quoted 9 lines · Gerd Hoffmann
Quoted 3 lines

I've applied a version that is part yours, part Jan's, and part mine. Changeset 12404:bb76a76985fe. It would be great if you could test that it actually still works on Xen 3.0.2! :-)

Works for me, thanks. Maybe that should be added to the regression tests?

BTW: what is the state of the testing mercurial tree? It hasn't seen updates for quite some time. I'd expect bugfixes like this one being queued for 3.0.3 too ...

We currently maintain a patch queue against 3.0.3-testing and we'll apply patches to 3.0.3-testing from that.

-- Keir