[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-4.1-testing] gnttab: miscellaneous fixes



# HG changeset patch
# User Jan Beulich <jbeulich@xxxxxxxx>
# Date 1329993254 0
# Node ID 8435c27b34990831718a8f625e5addddee74d62b
# Parent  0b0d74c970102af1ddcc4eddd9563b5a945df5e1
gnttab: miscellaneous fixes

- _GTF_* constants name bit positions, so binary arithmetic on them is
  wrong
- gnttab_clear_flag() cannot (on x86 and ia64 at least) simply use
  clear_bit(), as that may access more than the two bytes that are
  intended to be accessed

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Acked-by: Keir Fraser <keir@xxxxxxx>
xen-unstable changeset:   24742:9fc810bb8145
xen-unstable date:        Thu Feb 09 16:39:16 2012 +0100
---


diff -r 0b0d74c97010 -r 8435c27b3499 xen/common/grant_table.c
--- a/xen/common/grant_table.c  Thu Feb 23 10:32:48 2012 +0000
+++ b/xen/common/grant_table.c  Thu Feb 23 10:34:14 2012 +0000
@@ -389,7 +389,8 @@
              (id != domid) ||
              (!readonly && (flags & GTF_readonly)) )
         {
-            gnttab_clear_flag(_GTF_reading | _GTF_writing, status);
+            gnttab_clear_flag(_GTF_writing, status);
+            gnttab_clear_flag(_GTF_reading, status);
             PIN_FAIL(done, GNTST_general_error,
                      "Unstable flags (%x) or dom (%d). (expected dom %d) "
                      "(r/w: %d)\n",
@@ -1703,14 +1704,14 @@
    under the domain's grant table lock. */
 /* Only safe on transitive grants.  Even then, note that we don't
    attempt to drop any pin on the referent grant. */
-static void __fixup_status_for_pin(struct active_grant_entry *act,
+static void __fixup_status_for_pin(const struct active_grant_entry *act,
                                    uint16_t *status)
 {
     if ( !(act->pin & GNTPIN_hstw_mask) )
-        *status &= ~_GTF_writing;
+        *status &= ~GTF_writing;
 
     if ( !(act->pin & GNTPIN_hstr_mask) )
-        *status &= ~_GTF_reading;
+        *status &= ~GTF_reading;
 }
 
 /* Grab a frame number from a grant entry and update the flags and pin
diff -r 0b0d74c97010 -r 8435c27b3499 xen/include/asm-ia64/grant_table.h
--- a/xen/include/asm-ia64/grant_table.h        Thu Feb 23 10:32:48 2012 +0000
+++ b/xen/include/asm-ia64/grant_table.h        Thu Feb 23 10:34:14 2012 +0000
@@ -5,6 +5,8 @@
 #ifndef __ASM_GRANT_TABLE_H__
 #define __ASM_GRANT_TABLE_H__
 
+#include <asm/intrinsics.h>
+
 #define INITIAL_NR_GRANT_FRAMES 1
 
 // for grant map/unmap
@@ -82,9 +84,19 @@
 
 #define gnttab_mark_dirty(d, f) ((void)f)
 
-static inline void gnttab_clear_flag(unsigned long nr, uint16_t *addr)
+static inline void gnttab_clear_flag(unsigned int nr, volatile uint16_t *st)
 {
-       clear_bit(nr, addr);
+       /*
+        * Note that this cannot be clear_bit(), as the access must be
+        * confined to the specified 2 bytes.
+        */
+       uint16_t mask = ~(1 << nr), old;
+       CMPXCHG_BUGCHECK_DECL
+
+       do {
+               CMPXCHG_BUGCHECK(st);
+               old = *st;
+       } while (cmpxchg_rel(st, old, old & mask) != old);
 }
 
 #define gnttab_host_mapping_get_page_type(op, ld, rd)   \
diff -r 0b0d74c97010 -r 8435c27b3499 xen/include/asm-x86/grant_table.h
--- a/xen/include/asm-x86/grant_table.h Thu Feb 23 10:32:48 2012 +0000
+++ b/xen/include/asm-x86/grant_table.h Thu Feb 23 10:34:14 2012 +0000
@@ -48,9 +48,13 @@
 
 #define gnttab_mark_dirty(d, f) paging_mark_dirty((d), (f))
 
-static inline void gnttab_clear_flag(unsigned long nr, uint16_t *addr)
+static inline void gnttab_clear_flag(unsigned int nr, uint16_t *st)
 {
-    clear_bit(nr, (unsigned long *)addr);
+    /*
+     * Note that this cannot be clear_bit(), as the access must be
+     * confined to the specified 2 bytes.
+     */
+    asm volatile ("lock btrw %1,%0" : "=m" (*st) : "Ir" (nr), "m" (*st));
 }
 
 /* Foreign mappings of HHVM-guest pages do not modify the type count. */

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.