From d0ee8e9ca4d4163e42dcd5f1cf13e4fae30a4190 Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Mon, 27 Apr 2020 09:30:16 +0200 Subject: [PATCH] guestcopy: evaluate {,__}copy{,_field}_to_guest*() ptr argument just once There's nothing wrong with having e.g. copy_to_guest(uarg, ptr++, 1); yet until now this would increment "ptr" twice. Also drop a pair of unneeded parentheses from every instance at this occasion. Fixes: b7954cc59831 ("Enhance guest memory accessor macros so that source operands can be") Signed-off-by: Jan Beulich Reviewed-by: Julien Grall --- xen/include/asm-arm/guest_access.h | 8 ++++---- xen/include/asm-x86/guest_access.h | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/xen/include/asm-arm/guest_access.h b/xen/include/asm-arm/guest_access.h index 3b8d4ec322..64d01951a9 100644 --- a/xen/include/asm-arm/guest_access.h +++ b/xen/include/asm-arm/guest_access.h @@ -80,7 +80,7 @@ int access_guest_memory_by_ipa(struct domain *d, paddr_t ipa, void *buf, char (*_d)[sizeof(*_s)] = (void *)(hnd).p; \ /* Check that the handle is not for a const type */ \ void *__maybe_unused _t = (hnd).p; \ - ((void)((hnd).p == (ptr))); \ + (void)((hnd).p == _s); \ raw_copy_to_guest(_d+(off), _s, sizeof(*_s)*(nr)); \ }) @@ -107,7 +107,7 @@ int access_guest_memory_by_ipa(struct domain *d, paddr_t ipa, void *buf, #define copy_field_to_guest(hnd, ptr, field) ({ \ const typeof(&(ptr)->field) _s = &(ptr)->field; \ void *_d = &(hnd).p->field; \ - ((void)(&(hnd).p->field == &(ptr)->field)); \ + (void)(&(hnd).p->field == _s); \ raw_copy_to_guest(_d, _s, sizeof(*_s)); \ }) @@ -131,7 +131,7 @@ int access_guest_memory_by_ipa(struct domain *d, paddr_t ipa, void *buf, char (*_d)[sizeof(*_s)] = (void *)(hnd).p; \ /* Check that the handle is not for a const type */ \ void *__maybe_unused _t = (hnd).p; \ - ((void)((hnd).p == (ptr))); \ + (void)((hnd).p == _s); \ __raw_copy_to_guest(_d+(off), _s, sizeof(*_s)*(nr));\ }) @@ -148,7 +148,7 @@ int access_guest_memory_by_ipa(struct domain *d, paddr_t ipa, void *buf, #define __copy_field_to_guest(hnd, ptr, field) ({ \ const typeof(&(ptr)->field) _s = &(ptr)->field; \ void *_d = &(hnd).p->field; \ - ((void)(&(hnd).p->field == &(ptr)->field)); \ + (void)(&(hnd).p->field == _s); \ __raw_copy_to_guest(_d, _s, sizeof(*_s)); \ }) diff --git a/xen/include/asm-x86/guest_access.h b/xen/include/asm-x86/guest_access.h index a22745ceb4..064527895f 100644 --- a/xen/include/asm-x86/guest_access.h +++ b/xen/include/asm-x86/guest_access.h @@ -89,7 +89,7 @@ char (*_d)[sizeof(*_s)] = (void *)(hnd).p; \ /* Check that the handle is not for a const type */ \ void *__maybe_unused _t = (hnd).p; \ - ((void)((hnd).p == (ptr))); \ + (void)((hnd).p == _s); \ raw_copy_to_guest(_d+(off), _s, sizeof(*_s)*(nr)); \ }) @@ -112,7 +112,7 @@ #define copy_field_to_guest(hnd, ptr, field) ({ \ const typeof(&(ptr)->field) _s = &(ptr)->field; \ void *_d = &(hnd).p->field; \ - ((void)(&(hnd).p->field == &(ptr)->field)); \ + (void)(&(hnd).p->field == _s); \ raw_copy_to_guest(_d, _s, sizeof(*_s)); \ }) @@ -141,7 +141,7 @@ char (*_d)[sizeof(*_s)] = (void *)(hnd).p; \ /* Check that the handle is not for a const type */ \ void *__maybe_unused _t = (hnd).p; \ - ((void)((hnd).p == (ptr))); \ + (void)((hnd).p == _s); \ __raw_copy_to_guest(_d+(off), _s, sizeof(*_s)*(nr));\ }) @@ -159,7 +159,7 @@ #define __copy_field_to_guest(hnd, ptr, field) ({ \ const typeof(&(ptr)->field) _s = &(ptr)->field; \ void *_d = &(hnd).p->field; \ - ((void)(&(hnd).p->field == &(ptr)->field)); \ + (void)(&(hnd).p->field == _s); \ __raw_copy_to_guest(_d, _s, sizeof(*_s)); \ }) -- 2.30.2