Commit 2dcea57a authored by Heiko Carstens's avatar Heiko Carstens Committed by Linus Torvalds

[PATCH] convert s390 page handling macros to functions

Convert s390 page handling macros to functions.  In particular this fixes a
problem with s390's SetPageUptodate macro which uses its input parameter
twice which again can cause subtle bugs.

[akpm@osdl.org: build fix]
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent d1807793
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/page-flags.h> #include <linux/mm.h>
#include <linux/swap.h> #include <linux/swap.h>
#include <linux/pagemap.h> #include <linux/pagemap.h>
#include <linux/sysctl.h> #include <linux/sysctl.h>
......
...@@ -31,9 +31,9 @@ ...@@ -31,9 +31,9 @@
* the S390 page table tree. * the S390 page table tree.
*/ */
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
#include <linux/mm_types.h>
#include <asm/bug.h> #include <asm/bug.h>
#include <asm/processor.h> #include <asm/processor.h>
#include <linux/threads.h>
struct vm_area_struct; /* forward declaration (include/linux/mm.h) */ struct vm_area_struct; /* forward declaration (include/linux/mm.h) */
struct mm_struct; struct mm_struct;
...@@ -597,31 +597,31 @@ ptep_establish(struct vm_area_struct *vma, ...@@ -597,31 +597,31 @@ ptep_establish(struct vm_area_struct *vma,
* should therefore only be called if it is not mapped in any * should therefore only be called if it is not mapped in any
* address space. * address space.
*/ */
#define page_test_and_clear_dirty(_page) \ static inline int page_test_and_clear_dirty(struct page *page)
({ \ {
struct page *__page = (_page); \ unsigned long physpage = __pa((page - mem_map) << PAGE_SHIFT);
unsigned long __physpage = __pa((__page-mem_map) << PAGE_SHIFT); \ int skey = page_get_storage_key(physpage);
int __skey = page_get_storage_key(__physpage); \
if (__skey & _PAGE_CHANGED) \ if (skey & _PAGE_CHANGED)
page_set_storage_key(__physpage, __skey & ~_PAGE_CHANGED);\ page_set_storage_key(physpage, skey & ~_PAGE_CHANGED);
(__skey & _PAGE_CHANGED); \ return skey & _PAGE_CHANGED;
}) }
/* /*
* Test and clear referenced bit in storage key. * Test and clear referenced bit in storage key.
*/ */
#define page_test_and_clear_young(page) \ static inline int page_test_and_clear_young(struct page *page)
({ \ {
struct page *__page = (page); \ unsigned long physpage = __pa((page - mem_map) << PAGE_SHIFT);
unsigned long __physpage = __pa((__page-mem_map) << PAGE_SHIFT);\ int ccode;
int __ccode; \
asm volatile( \ asm volatile (
" rrbe 0,%1\n" \ "rrbe 0,%1\n"
" ipm %0\n" \ "ipm %0\n"
" srl %0,28\n" \ "srl %0,28\n"
: "=d" (__ccode) : "a" (__physpage) : "cc"); \ : "=d" (ccode) : "a" (physpage) : "cc" );
(__ccode & 2); \ return ccode & 2;
}) }
/* /*
* Conversion functions: convert a page and protection to a page entry, * Conversion functions: convert a page and protection to a page entry,
...@@ -634,32 +634,28 @@ static inline pte_t mk_pte_phys(unsigned long physpage, pgprot_t pgprot) ...@@ -634,32 +634,28 @@ static inline pte_t mk_pte_phys(unsigned long physpage, pgprot_t pgprot)
return __pte; return __pte;
} }
#define mk_pte(pg, pgprot) \ static inline pte_t mk_pte(struct page *page, pgprot_t pgprot)
({ \ {
struct page *__page = (pg); \ unsigned long physpage = __pa((page - mem_map) << PAGE_SHIFT);
pgprot_t __pgprot = (pgprot); \
unsigned long __physpage = __pa((__page-mem_map) << PAGE_SHIFT); \
pte_t __pte = mk_pte_phys(__physpage, __pgprot); \
__pte; \
})
#define pfn_pte(pfn, pgprot) \ return mk_pte_phys(physpage, pgprot);
({ \ }
pgprot_t __pgprot = (pgprot); \
unsigned long __physpage = __pa((pfn) << PAGE_SHIFT); \ static inline pte_t pfn_pte(unsigned long pfn, pgprot_t pgprot)
pte_t __pte = mk_pte_phys(__physpage, __pgprot); \ {
__pte; \ unsigned long physpage = __pa((pfn) << PAGE_SHIFT);
})
return mk_pte_phys(physpage, pgprot);
}
#ifdef __s390x__ #ifdef __s390x__
#define pfn_pmd(pfn, pgprot) \ static inline pmd_t pfn_pmd(unsigned long pfn, pgprot_t pgprot)
({ \ {
pgprot_t __pgprot = (pgprot); \ unsigned long physpage = __pa((pfn) << PAGE_SHIFT);
unsigned long __physpage = __pa((pfn) << PAGE_SHIFT); \
pmd_t __pmd = __pmd(__physpage + pgprot_val(__pgprot)); \ return __pmd(physpage + pgprot_val(pgprot));
__pmd; \ }
})
#endif /* __s390x__ */ #endif /* __s390x__ */
......
...@@ -128,12 +128,11 @@ ...@@ -128,12 +128,11 @@
#define PageUptodate(page) test_bit(PG_uptodate, &(page)->flags) #define PageUptodate(page) test_bit(PG_uptodate, &(page)->flags)
#ifdef CONFIG_S390 #ifdef CONFIG_S390
#define SetPageUptodate(_page) \ static inline void SetPageUptodate(struct page *page)
do { \ {
struct page *__page = (_page); \ if (!test_and_set_bit(PG_uptodate, &page->flags))
if (!test_and_set_bit(PG_uptodate, &__page->flags)) \ page_test_and_clear_dirty(page);
page_test_and_clear_dirty(_page); \ }
} while (0)
#else #else
#define SetPageUptodate(page) set_bit(PG_uptodate, &(page)->flags) #define SetPageUptodate(page) set_bit(PG_uptodate, &(page)->flags)
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment