Skip to contentSkip to conversation

include/asm-x86_64/pgtable.h pgd_offset_gate()

PATCH New John Blackwood 1 participant 1 message Dec 10, 2004

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 include/asm-x86_64/pgtable.h pgd_offset_gate()

Hi Andi,

We noticed a problem on x86_64 platforms where a /proc read of the vsyscall area (address 0xffffffffff600000) would cause the kernel to oops in get_user_pages().

I believe that the fix is to pull in the include/asm-ia64/pgtable.h changes for pgd_offset_gate() into the x86_64 pgtable.h header file.

This seems to fix the problem nicely for us.

The original ia64 patch was:

# ChangeSet
# 2004/07/28 23:01:30-07:00 [email protected]
# [PATCH] Make get_user_pages() work again for ia64 gate area
#
# Changeset
#
# [email protected][torvalds]|ChangeSet|20040624165002|30880
#

#   inadvertently broke ia64 because the patch assumed that pgd_offset_k() is
#   just an optimization of pgd_offset(), which it is not.  This patch fixes
#   the problem by introducing pgd_offset_gate().  On architectures on which
#   the gate area lives in the user's address-space, this should be aliased to
#   pgd_offset() and on architectures on which the gate area lives in the
#   kernel-mapped segment, this should be aliased to pgd_offset_k().
#
#   This bug was found and tracked down by Peter Chubb.
#
#   Signed-off-by: <[email protected]>
#   Signed-off-by: Andrew Morton <[email protected]>
#   Signed-off-by: Linus Torvalds <[email protected]>

The changes to pgtable.h for x86_64 are below.

Thank you for your time and considerations.

include/asm-x86_64/pgtable.h 2004-12-10 16:00:30.434277001 -0500 renamed from include/asm-x86_64/pgtable.h 2004-10-18 17:54:40.000000000 -0400 +6 -0
diff -ru linux-2.6.9/include/asm-x86_64/pgtable.h linux/include/asm-x86_64/pgtable.h
@@ -340,6 +340,11 @@
        return __pgd_offset_k((pgd_t *)__va(addr), address);
 }
 
+/* Look up a pgd entry in the gate area.  On x86_64, the gate-area
+   resides in the kernel-mapped segment, hence we use pgd_offset_k()
+   here.  */
+#define pgd_offset_gate(mm, addr)      pgd_offset_k(addr)
+
 #define pgd_offset(mm, address) ((mm)->pgd+pgd_index(address))
 
 /* PMD  - Level 2 access */
@@ -442,6 +447,7 @@
 #define __HAVE_ARCH_PTEP_SET_WRPROTECT
 #define __HAVE_ARCH_PTEP_MKDIRTY
 #define __HAVE_ARCH_PTE_SAME
+#define __HAVE_ARCH_PGD_OFFSET_GATE
 #include <asm-generic/pgtable.h>
 
 #endif /* _X86_64_PGTABLE_H */