All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: selftests: hyperv_tlb_flush: use swap() to swap PTEs
@ 2026-05-28  9:45 Piotr Zarycki
  2026-05-28 13:13 ` Sean Christopherson
  0 siblings, 1 reply; 7+ messages in thread
From: Piotr Zarycki @ 2026-05-28  9:45 UTC (permalink / raw)
  To: seanjc, pbonzini
  Cc: shuah, dmatlack, vkuznets, kvm, linux-kselftest, linux-kernel,
	Piotr Zarycki

Replace the open-coded swap with the swap() macro.

Signed-off-by: Piotr Zarycki <piotr.zarycki@gmail.com>
---
 tools/testing/selftests/kvm/include/test_util.h    | 2 ++
 tools/testing/selftests/kvm/x86/hyperv_tlb_flush.c | 6 +-----
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/tools/testing/selftests/kvm/include/test_util.h b/tools/testing/selftests/kvm/include/test_util.h
index d9b433b834f1..a66bc9ccba65 100644
--- a/tools/testing/selftests/kvm/include/test_util.h
+++ b/tools/testing/selftests/kvm/include/test_util.h
@@ -26,6 +26,8 @@
 
 #define msecs_to_usecs(msec)    ((msec) * 1000ULL)
 
+#define swap(a, b)  do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0)
+
 static inline __printf(1, 2) int _no_printf(const char *format, ...) { return 0; }
 
 #ifdef DEBUG
diff --git a/tools/testing/selftests/kvm/x86/hyperv_tlb_flush.c b/tools/testing/selftests/kvm/x86/hyperv_tlb_flush.c
index 15ee8b7bfc11..514d41f00714 100644
--- a/tools/testing/selftests/kvm/x86/hyperv_tlb_flush.c
+++ b/tools/testing/selftests/kvm/x86/hyperv_tlb_flush.c
@@ -131,14 +131,10 @@ static void set_expected_val(void *addr, u64 val, int vcpu_id)
 
 /*
  * Update PTEs swapping two test pages.
- * TODO: use swap()/xchg() when these are provided.
  */
 static void swap_two_test_pages(gpa_t pte_gva1, gpa_t pte_gva2)
 {
-	u64 tmp = *(u64 *)pte_gva1;
-
-	*(u64 *)pte_gva1 = *(u64 *)pte_gva2;
-	*(u64 *)pte_gva2 = tmp;
+	swap(*(u64 *)pte_gva1, *(u64 *)pte_gva2);
 }
 
 /*
-- 
2.54.0


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

end of thread, other threads:[~2026-05-28 16:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-28  9:45 [PATCH] KVM: selftests: hyperv_tlb_flush: use swap() to swap PTEs Piotr Zarycki
2026-05-28 13:13 ` Sean Christopherson
2026-05-28 14:07   ` Piotr Zarycki
2026-05-28 14:10   ` [PATCH v2] " Piotr Zarycki
2026-05-28 14:35     ` sashiko-bot
2026-05-28 15:35   ` Piotr Zarycki
2026-05-28 16:04     ` sashiko-bot

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.