]> xenbits.xensource.com Git - people/sstabellini/xen-unstable.git/.git/commitdiff
x86/PV: use get_unsafe() instead of copy_from_unsafe()
authorJan Beulich <jbeulich@suse.com>
Thu, 25 Feb 2021 14:39:09 +0000 (15:39 +0100)
committerJan Beulich <jbeulich@suse.com>
Thu, 25 Feb 2021 14:39:09 +0000 (15:39 +0100)
The former expands to a single (memory accessing) insn, which the latter
does not guarantee (the __builtin_constant_p() based switch() statement
there is just an optimization). Yet we'd prefer to read consistent PTEs
rather than risking a split read racing with an update done elsewhere.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Release-Acked-by: Ian Jackson <iwj@xenproject.org>
xen/arch/x86/pv/mm.c
xen/arch/x86/pv/mm.h

index cb8614383209543de54a72a6ff263527d2d4c8ed..5ed7b3ccdbf209fb94b45c8e6c72eb510aeb5f19 100644 (file)
@@ -41,9 +41,7 @@ l1_pgentry_t *map_guest_l1e(unsigned long linear, mfn_t *gl1mfn)
         return NULL;
 
     /* Find this l1e and its enclosing l1mfn in the linear map. */
-    if ( copy_from_unsafe(&l2e,
-                          &__linear_l2_table[l2_linear_offset(linear)],
-                          sizeof(l2_pgentry_t)) )
+    if ( get_unsafe(l2e, &__linear_l2_table[l2_linear_offset(linear)]) )
         return NULL;
 
     /* Check flags that it will be safe to read the l1e. */
index 7e2259c4887a9afe30f178ed05026a03aa6daf5d..5a117c735d5e476d732ae5a49422bad0e83957a9 100644 (file)
@@ -22,9 +22,7 @@ static inline l1_pgentry_t guest_get_eff_kern_l1e(unsigned long linear)
         toggle_guest_pt(curr);
 
     if ( unlikely(!__addr_ok(linear)) ||
-         copy_from_unsafe(&l1e,
-                          &__linear_l1_table[l1_linear_offset(linear)],
-                          sizeof(l1_pgentry_t)) )
+         get_unsafe(l1e, &__linear_l1_table[l1_linear_offset(linear)]) )
         l1e = l1e_empty();
 
     if ( user_mode )