From nobody Tue Dec 16 08:58:32 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C345C00528 for ; Sat, 29 Jul 2023 00:39:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236275AbjG2AjJ (ORCPT ); Fri, 28 Jul 2023 20:39:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236109AbjG2Aig (ORCPT ); Fri, 28 Jul 2023 20:38:36 -0400 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B80744A0 for ; Fri, 28 Jul 2023 17:37:44 -0700 (PDT) Received: by mail-pl1-x64a.google.com with SMTP id d9443c01a7336-1bb982d2572so17301585ad.0 for ; Fri, 28 Jul 2023 17:37:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690591040; x=1691195840; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=62IIfbK+fVHnQpHB0LZHeva+9zsTyACR3DAXgqGUpUY=; b=SjpYkHcU8DfvLPEP6EE3BSTR/2/6/dg3QI3BV6WrrOhgfT/Axj5gvHKmQEj21aynvu IfZBARD2/rsjLEVGbvM2z0q99N1PWdAcl7DYCxNnNaLdHcIlkyRkdk/nbDMn7F9+/a8e CuhyiC1DAy4v3U+R4k7YfRnm9iEAN42L+6VgqENHy+0Z6wsFjfHa7L8g5WSPsmjJnyFt JMTcqvgBf/Y0L040z/FF0Q6nEsDXIJggJlKlAjnI6jY0WsZnbHhBByPRE33YgvMkNqkb Z4gitISbvjzVi4D6FyklqEUoPL0KOcodWo1FLrcSiCq7BZ7n03kIFlkuicSVwDz5Bgxw MEig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690591040; x=1691195840; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=62IIfbK+fVHnQpHB0LZHeva+9zsTyACR3DAXgqGUpUY=; b=NPoxcl4DKbmAbfOoc0sdc+ofLg7Xaqz2afTWmuRdun5SMUjMSDTA02BkuoA88jKAE7 ursRYnGgO3YzL6jpwSFKdfzneOdUTYsCLLdwVSjcOaw49rmDZhpE5RVJDYWIdoEF9dQ4 K0wDYX66/U1te1+xkj69akNuOucdvo4ycW6t+YmbqLwU1uKdpU/jtpE+fQQVpYipiy4P wcQTOkOqPMVNG8SB/t925B80Ughv+KJhHvGn5eA/J9OjKitPz6jFT87PUxoQy9DMGonT cD5fpHkDDRvDUOeeQsqRIhSLPXIZkrFuonlAKASL9GuHbcPgLrtOv4PfcFTEfbvoMdng gIJQ== X-Gm-Message-State: ABy/qLZK8cbwqQ9FV8SnphsoTmQ5khma4UufCc/1mJA45xg/iC1QQss3 bEu3bSlmIbs/xt49ITdgCxFwuqh3AQA= X-Google-Smtp-Source: APBJJlH6iRT9Dvs1GTfRtC3q4lJnWblWrURV+JKeAmNtjrPWw6VO8hwBqRMxcLpxte+WdCjaXOyJVdz5jAY= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:903:1d1:b0:1b5:2496:8c0d with SMTP id e17-20020a17090301d100b001b524968c0dmr12013plh.3.1690591040630; Fri, 28 Jul 2023 17:37:20 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 28 Jul 2023 17:36:27 -0700 In-Reply-To: <20230729003643.1053367-1-seanjc@google.com> Mime-Version: 1.0 References: <20230729003643.1053367-1-seanjc@google.com> X-Mailer: git-send-email 2.41.0.487.g6d72f3e995-goog Message-ID: <20230729003643.1053367-19-seanjc@google.com> Subject: [PATCH v4 18/34] KVM: selftests: Convert set_memory_region_test to printf-based GUEST_ASSERT From: Sean Christopherson To: Paolo Bonzini , Marc Zyngier , Oliver Upton , Christian Borntraeger , Janosch Frank , Claudio Imbrenda Cc: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, Sean Christopherson , Thomas Huth , "=?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?=" , Aaron Lewis Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Convert set_memory_region_test to print-based GUEST_ASSERT, using a combo of newfangled macros to report (hopefully) useful information. Signed-off-by: Sean Christopherson --- .../selftests/kvm/set_memory_region_test.c | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/kvm/set_memory_region_test.c b/tools/t= esting/selftests/kvm/set_memory_region_test.c index a849ce23ca97..dd8f4bac9df8 100644 --- a/tools/testing/selftests/kvm/set_memory_region_test.c +++ b/tools/testing/selftests/kvm/set_memory_region_test.c @@ -1,4 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 +#define USE_GUEST_ASSERT_PRINTF 1 + #define _GNU_SOURCE /* for program_invocation_short_name */ #include #include @@ -88,7 +90,7 @@ static void *vcpu_worker(void *data) } =20 if (run->exit_reason =3D=3D KVM_EXIT_IO && cmd =3D=3D UCALL_ABORT) - REPORT_GUEST_ASSERT_1(uc, "val =3D %lu"); + REPORT_GUEST_ASSERT(uc); =20 return NULL; } @@ -156,19 +158,22 @@ static void guest_code_move_memory_region(void) * window where the memslot is invalid is usually quite small. */ val =3D guest_spin_on_val(0); - GUEST_ASSERT_1(val =3D=3D 1 || val =3D=3D MMIO_VAL, val); + __GUEST_ASSERT(val =3D=3D 1 || val =3D=3D MMIO_VAL, + "Expected '1' or MMIO ('%llx'), got '%llx'", MMIO_VAL, val); =20 /* Spin until the misaligning memory region move completes. */ val =3D guest_spin_on_val(MMIO_VAL); - GUEST_ASSERT_1(val =3D=3D 1 || val =3D=3D 0, val); + __GUEST_ASSERT(val =3D=3D 1 || val =3D=3D 0, + "Expected '0' or '1' (no MMIO), got '%llx'", val); =20 /* Spin until the memory region starts to get re-aligned. */ val =3D guest_spin_on_val(0); - GUEST_ASSERT_1(val =3D=3D 1 || val =3D=3D MMIO_VAL, val); + __GUEST_ASSERT(val =3D=3D 1 || val =3D=3D MMIO_VAL, + "Expected '1' or MMIO ('%llx'), got '%llx'", MMIO_VAL, val); =20 /* Spin until the re-aligning memory region move completes. */ val =3D guest_spin_on_val(MMIO_VAL); - GUEST_ASSERT_1(val =3D=3D 1, val); + GUEST_ASSERT_EQ(val, 1); =20 GUEST_DONE(); } @@ -224,15 +229,15 @@ static void guest_code_delete_memory_region(void) =20 /* Spin until the memory region is deleted. */ val =3D guest_spin_on_val(0); - GUEST_ASSERT_1(val =3D=3D MMIO_VAL, val); + GUEST_ASSERT_EQ(val, MMIO_VAL); =20 /* Spin until the memory region is recreated. */ val =3D guest_spin_on_val(MMIO_VAL); - GUEST_ASSERT_1(val =3D=3D 0, val); + GUEST_ASSERT_EQ(val, 0); =20 /* Spin until the memory region is deleted. */ val =3D guest_spin_on_val(0); - GUEST_ASSERT_1(val =3D=3D MMIO_VAL, val); + GUEST_ASSERT_EQ(val, MMIO_VAL); =20 asm("1:\n\t" ".pushsection .rodata\n\t" @@ -249,7 +254,7 @@ static void guest_code_delete_memory_region(void) "final_rip_end: .quad 1b\n\t" ".popsection"); =20 - GUEST_ASSERT_1(0, 0); + GUEST_ASSERT(0); } =20 static void test_delete_memory_region(void) --=20 2.41.0.487.g6d72f3e995-goog