64 bit s390 and 2.4.0-test11 (was Memory management bug)
Subsystems (5)
Hi,
good news (at least for us): linux on the 64 bit S/390 (aka zServer) is now running pretty stable. Our implementation of ptep_get_and_clear didn't clear the pte if the invalid bit was already set. But a swapped page has the invalid bit set too and in that case we didn't clear the pte. That did cause the BUG() in swap_state.c:60.
With this new backend in mind I'd like to suggest two small changes for the common code.
1) move establish_pte to the architecture dependent folders. Our implementation looks like this:
static inline void ptep_invalidate_and_flush(pte_t *ptep, unsigned long addr)
{
if (!(pte_val(*ptep) & _PAGE_INVALID))
__asm__ __volatile__ ("ipte %0,%1" : : "a" (ptep), "a"(addr));
}
static inline void establish_pte(struct vm_area_struct * vma,
unsigned long address, pte_t *page_table, pte_t entry)
{
ptep_invalidate_and_flush(page_table, address);
set_pte(page_table, entry);
}The question I face at the moment is: where is the right place in include/asm for establish_pte. I added it to include/asm-generic/pgtable.h and include/asm-i386/pgtable.h but I now face the problem that the default implementation has a call to flush_tlb_page and that is defined in pgalloc.h. I added an #include <asm/pgalloc.h> but I fear that this could
cause compile errors. For details see establish_pte.diff.
2) add a check for EI_CLASS in the binfmt_elf loader. We will use the same EM_S390 for 31 bit and 64 bit binaries. The distinction is done by means of the EI_CLASS byte in the ELF header. See binfmt_elf.diff
blue skies,
Martin
Linux/390 Design & Development, IBM Deutschland Entwicklung GmbH Schönaicherstr. 220, D-71032 Böblingen, Telefon: 49 - (0)7031 - 16-2247
E-Mail: [email protected]
(See attached file: establish_pte.diff)(See attached file: binfmt_elf.diff)
include/asm-generic/pgtable.h +15 -0
@@ -1,6 +1,8 @@#ifndef _ASM_GENERIC_PGTABLE_H#define _ASM_GENERIC_PGTABLE_H +#include <asm/pgalloc.h> +static inline int ptep_test_and_clear_young (pte_t *ptep) {pte_t pte = *ptep;
@@ -40,4 +40,17 @@#define pte_same (A ,B ) (pte_val(A) == pte_val(B)) +/* +* Establish a new mapping: +* - flush the old one +* - update the page tables +* - inform the TLB about the new one +*/ +static inline void establish_pte (struct vm_area_struct * vma,unsigned long address,pte_t *page_table,pte_t entry) +{ +set_pte (page_table, entry); +flush_tlb_page (vma, address); +update_mmu_cache (vma, address, entry); +} +#endif /* _ASM_GENERIC_PGTABLE_H */
include/asm-i386/pgtable.h +14 -0
@@ -287,6 +287,20 @@static inline void ptep_mkdirty (pte_t *ptep) {set_bit (_PAGE_BIT_RW, ptep); }/* +* Establish a new mapping: +* - flush the old one +* - update the page tables +* - inform the TLB about the new one +*/ +static inline void establish_pte (struct vm_area_struct * vma,unsigned long address,pte_t *page_table,pte_t entry) +{ +set_pte (page_table, entry); +if (vma->vm_mm == current->active_mm) +__flush_tlb_one (addr); +update_mmu_cache (vma, address, entry); +} + +/* * Conversion functions: convert a page and protection to a page entry, * and a page entry and page directory to the page they refer to. */
mm/memory.c +0 -13
@@ -773,19 +773,6 @@return error; } -/* -* Establish a new mapping: -* - flush the old one -* - update the page tables -* - inform the TLB about the new one -*/ -static inline void establish_pte (struct vm_area_struct * vma,unsigned long address,pte_t *page_table,pte_t entry) -{ -set_pte (page_table, entry); -flush_tlb_page (vma, address); -update_mmu_cache (vma, address, entry); -} -static inline void break_cow (struct vm_area_struct * vma,struct page * old_page,struct page * new_page,unsigned long address,pte_t *page_table) {
fs/binfmt_elf.c +4 -0
@@ -247,6 +247,8 @@ goto out;if (!elf_check_arch (interp_elf_ex)) goto out; +if (interp_elf_ex->e_ident[EI_CLASS ] !=ELF_CLASS ) + goto out;if (!interpreter->f_op->mmap) goto out;
@@ -422,6 +424,8 @@if (elf_ex.e_type !=ET_EXEC && elf_ex.e_type !=ET_DYN ) goto out;if (!elf_check_arch (&elf_ex)) + goto out; +if (elf_ex.e_ident[EI_CLASS ] !=ELF_CLASS ) goto out;if (!bprm->file->f_op||!bprm->file->f_op->mmap) goto out;