All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix kunmap_atomic's use of kpte_clear_flush()
@ 2006-11-08  0:22 Jeremy Fitzhardinge
  2006-11-08  0:42 ` Zachary Amsden
  2006-11-08  0:42 ` Rusty Russell
  0 siblings, 2 replies; 4+ messages in thread
From: Jeremy Fitzhardinge @ 2006-11-08  0:22 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Zachary Amsden, Rusty Russell, Linux Kernel Mailing List

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.

Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Cc: Zachary Amsden <zach@vmware.com>

===================================================================
--- a/arch/i386/mm/highmem.c
+++ b/arch/i386/mm/highmem.c
@@ -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();
 }


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Fix kunmap_atomic's use of kpte_clear_flush()
  2006-11-08  0:22 [PATCH] Fix kunmap_atomic's use of kpte_clear_flush() Jeremy Fitzhardinge
@ 2006-11-08  0:42 ` Zachary Amsden
  2006-11-08  0:42 ` Rusty Russell
  1 sibling, 0 replies; 4+ messages in thread
From: Zachary Amsden @ 2006-11-08  0:42 UTC (permalink / raw)
  To: Jeremy Fitzhardinge
  Cc: Andrew Morton, Rusty Russell, Linux Kernel Mailing List

Jeremy Fitzhardinge wrote:
> 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.
>
> Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com>
> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
> Cc: Zachary Amsden <zach@vmware.com>

Ack.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Fix kunmap_atomic's use of kpte_clear_flush()
  2006-11-08  0:22 [PATCH] Fix kunmap_atomic's use of kpte_clear_flush() Jeremy Fitzhardinge
  2006-11-08  0:42 ` Zachary Amsden
@ 2006-11-08  0:42 ` Rusty Russell
  2006-11-08  1:10   ` Jeremy Fitzhardinge
  1 sibling, 1 reply; 4+ messages in thread
From: Rusty Russell @ 2006-11-08  0:42 UTC (permalink / raw)
  To: Jeremy Fitzhardinge
  Cc: Andrew Morton, Zachary Amsden, Linux Kernel Mailing List

On Tue, 2006-11-07 at 16:22 -0800, Jeremy Fitzhardinge wrote:
> 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.

Or in other words, if kmap_atomic() does nothing, kunmap_atomic() should
do nothing.

Rusty.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Fix kunmap_atomic's use of kpte_clear_flush()
  2006-11-08  0:42 ` Rusty Russell
@ 2006-11-08  1:10   ` Jeremy Fitzhardinge
  0 siblings, 0 replies; 4+ messages in thread
From: Jeremy Fitzhardinge @ 2006-11-08  1:10 UTC (permalink / raw)
  To: Rusty Russell; +Cc: Andrew Morton, Zachary Amsden, Linux Kernel Mailing List

Rusty Russell wrote:
> On Tue, 2006-11-07 at 16:22 -0800, Jeremy Fitzhardinge wrote:
>   
>> 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.
>>     
>
> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-11-08  1:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-08  0:22 [PATCH] Fix kunmap_atomic's use of kpte_clear_flush() Jeremy Fitzhardinge
2006-11-08  0:42 ` Zachary Amsden
2006-11-08  0:42 ` Rusty Russell
2006-11-08  1:10   ` Jeremy Fitzhardinge

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.