The patch titled paravirt: kpte flush has been added to the -mm tree. Its filename is paravirt-kpte-flush.patch See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find out what to do about this ------------------------------------------------------ Subject: paravirt: kpte flush From: Zachary Amsden <zach@xxxxxxxxxx> Create a new PTE function which combines clearing a kernel PTE with the subsequent flush. This allows the two to be easily combined into a single hypercall or paravirt-op. More subtly, reverse the order of the flush for kmap_atomic. Instead of flushing on establishing a mapping, flush on clearing a mapping. This eliminates the possibility of leaving stale kmap entries which may still have valid TLB mappings. This is required for direct mode hypervisors, which need to reprotect all mappings of a given page when changing the page type from a normal page to a protected page (such as a page table or descriptor table page). But it also provides some nicer semantics for real hardware, by providing extra debug-proofing against using stale mappings, as well as ensuring that no stale mappings exist when changing the cacheability attributes of a page, which could lead to cache conflicts when two different types of mappings exist for the same page. Signed-off-by: Zachary Amsden <zach@xxxxxxxxxx> Cc: Rusty Russell <rusty@xxxxxxxxxxxxxxx> Cc: Jeremy Fitzhardinge <jeremy@xxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxx> --- arch/i386/mm/highmem.c | 18 +++++++----------- include/asm-i386/pgtable.h | 7 +++++++ 2 files changed, 14 insertions(+), 11 deletions(-) diff -puN arch/i386/mm/highmem.c~paravirt-kpte-flush arch/i386/mm/highmem.c --- a/arch/i386/mm/highmem.c~paravirt-kpte-flush +++ a/arch/i386/mm/highmem.c @@ -38,22 +38,19 @@ void *kmap_atomic(struct page *page, enu idx = type + KM_TYPE_NR*smp_processor_id(); vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx); -#ifdef CONFIG_DEBUG_HIGHMEM if (!pte_none(*(kmap_pte-idx))) BUG(); -#endif set_pte(kmap_pte-idx, mk_pte(page, kmap_prot)); - __flush_tlb_one(vaddr); return (void*) vaddr; } void kunmap_atomic(void *kvaddr, enum km_type type) { -#ifdef CONFIG_DEBUG_HIGHMEM unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK; enum fixed_addresses idx = type + KM_TYPE_NR*smp_processor_id(); +#ifdef CONFIG_DEBUG_HIGHMEM if (vaddr >= PAGE_OFFSET && vaddr < (unsigned long)high_memory) { dec_preempt_count(); preempt_check_resched(); @@ -62,14 +59,14 @@ void kunmap_atomic(void *kvaddr, enum km if (vaddr != __fix_to_virt(FIX_KMAP_BEGIN+idx)) BUG(); - +#endif /* - * force other mappings to Oops if they'll try to access - * this pte without first remap it + * Force other mappings to Oops if they'll try to access this pte + * without first remap it. Keeping stale mappings around is a bad idea + * also, in case the page changes cacheability attributes or becomes + * a protected page in a hypervisor. */ - pte_clear(&init_mm, vaddr, kmap_pte-idx); - __flush_tlb_one(vaddr); -#endif + kpte_clear_flush(kmap_pte-idx, vaddr); dec_preempt_count(); preempt_check_resched(); @@ -88,7 +85,6 @@ void *kmap_atomic_pfn(unsigned long pfn, idx = type + KM_TYPE_NR*smp_processor_id(); vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx); set_pte(kmap_pte-idx, pfn_pte(pfn, kmap_prot)); - __flush_tlb_one(vaddr); return (void*) vaddr; } diff -puN include/asm-i386/pgtable.h~paravirt-kpte-flush include/asm-i386/pgtable.h --- a/include/asm-i386/pgtable.h~paravirt-kpte-flush +++ a/include/asm-i386/pgtable.h @@ -441,6 +441,13 @@ extern pte_t *lookup_address(unsigned lo #define pte_unmap_nested(pte) do { } while (0) #endif +/* Clear a kernel PTE and flush it from the TLB */ +#define kpte_clear_flush(ptep, vaddr) \ +do { \ + pte_clear(&init_mm, vaddr, ptep); \ + __flush_tlb_one(vaddr); \ +} while (0) + /* * The i386 doesn't have any external MMU info: the kernel page * tables contain all the necessary information. _ Patches currently in -mm which might be from zach@xxxxxxxxxx are split-i386-and-x86_64-ptraceh.patch uml-use-ptrace-abih-instead-of-ptraceh.patch x86-allow-a-kernel-to-not-be-in-ring-0.patch x86-allow-a-kernel-to-not-be-in-ring-0-tidy.patch x86-add-a-bootparameter-to-reserve-high-linear-address-space.patch x86-trivial-pgtableh-__assembly__-move.patch x86-trivial-move-of-__have-macros-in-i386-pagetable-headers.patch x86-trivial-move-of-ptep_set_access_flags.patch x86-remove-unused-include-from-efi_stubs.patch paravirt-remove-read-hazard-from-cow.patch paravirt-pte-clear-not-present.patch paravirt-lazy-mmu-mode-hooks.patch paravirt-combine-flush-accessed-dirty.patch paravirt-kpte-flush.patch paravirt-optimize-ptep-establish-for-pae.patch paravirt-remove-set-pte-atomic.patch paravirt-pae-compile-fix.patch paravirt-update-pte-hook.patch - To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html