Fix kunmap_atomic's use of kpte_clear_flush()
PATCH 1/1 Fix kunmap_atomic's use of kpte_clear_flush()
kunmap_atomic() will call kpte_clear_flush with vaddr/ptep arguments which don't correspond if the vaddr is just a normal lowmem address (ie, not in the KMAP area). This patch makes sure that the pte is only cleared if kmap area was actually used for the mapping.
===================================================================
arch/i386/mm/highmem.c +0 -0
@@ -56,22 +56,20 @@ void kunmap_atomic(void *kvaddr, enum km
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) {
- pagefault_enable();
- return;
- }
-
- 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. Keeping stale mappings around is a bad idea
* also, in case the page changes cacheability attributes or becomes
* a protected page in a hypervisor.
*/
- kpte_clear_flush(kmap_pte-idx, vaddr);
+ if (vaddr == __fix_to_virt(FIX_KMAP_BEGIN+idx))
+ kpte_clear_flush(kmap_pte-idx, vaddr);
+ else {
+#ifdef CONFIG_DEBUG_HIGHMEM
+ BUG_ON(vaddr < PAGE_OFFSET);
+ BUG_ON(vaddr >= (unsigned long)high_memory);
+#endif
+ }
pagefault_enable(); }
Quoted 8 lines · Jeremy Fitzhardinge
kunmap_atomic()will callkpte_clear_flushwith vaddr/ptep arguments which don't correspond if the vaddr is just a normal lowmem address (ie, not in the KMAP area). This patch makes sure that the pte is only cleared if kmap area was actually used for the mapping.Signed-off-by Jeremy Fitzhardinge <[email protected]>Signed-off-by Rusty Russell <[email protected]>Cc Zachary Amsden <[email protected]>
Ack.
Quoted 4 lines · Jeremy Fitzhardinge
kunmap_atomic()will callkpte_clear_flushwith vaddr/ptep arguments which don't correspond if the vaddr is just a normal lowmem address (ie, not in the KMAP area). This patch makes sure that the pte is only cleared if kmap area was actually used for the mapping.
Or in other words, if kmap_atomic() does nothing, kunmap_atomic() should do nothing.
Rusty.
Quoted 11 lines · Rusty Russell
Quoted 5 lines · Jeremy Fitzhardinge
kunmap_atomic()will callkpte_clear_flushwith vaddr/ptep arguments which don't correspond if the vaddr is just a normal lowmem address (ie, not in the KMAP area). This patch makes sure that the pte is only cleared if kmap area was actually used for the mapping.Or in other words, if
kmap_atomic()does nothing,kunmap_atomic()should do nothing.
Sure. I guess there's no particular reason why kmap_atomic() couldn't always map, but I guess avoid the pagetable updates is worthwhile.
J