Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp1940957rwb; Fri, 28 Jul 2023 18:44:19 -0700 (PDT) X-Google-Smtp-Source: APBJJlGa4Ovzr06b89yzJYifSuAMk1VHXsLZ8p+L5B5VdSQyVblc3SGNuXyCNZH+/rmZm3slTFKN X-Received: by 2002:a05:6a20:9195:b0:135:38b5:7e58 with SMTP id v21-20020a056a20919500b0013538b57e58mr3496277pzd.37.1690595058922; Fri, 28 Jul 2023 18:44:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690595058; cv=none; d=google.com; s=arc-20160816; b=UB2qZMvvHUPONznjwsYs3HOzp14CIT7XeIdzLC/XzypS7wxMr2bFVkgfOXUjSlf7Pa FzC9eq3tSbCA60BKTo/AiYvkSOSV7bGzJ0YQvr2ZKs7dXQfPq2eprNdeoZB76fUzeNtd yFIt9tVt0GTekuNSa29SFZ8t5KPOR3uqqXw/fiOMwFAmzY4z+wDTcthdLqMw4G+YXBMA FOaFrYzNaVGa2a3IphmP6k9x6w3LVYvAZ6OEyjGy4GhVBQFITWkR+nfN1jg4npAIUqIR jnPIJhsRD5V2OJLB/fE73Rbn3y1fe8BtrkaJqtdJAEgTg2Odlz5frivzrUpW4JMIoX1Q tbzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:reply-to:dkim-signature; bh=62IIfbK+fVHnQpHB0LZHeva+9zsTyACR3DAXgqGUpUY=; fh=Ctt0ydInMKwei8YFBFbw7rU4p8H0G/T51ZI/KkO6Md4=; b=TMBu/o/2RSUfiqSzmMySTJvQt9fLg4eyYgqK6vc87DUX9VraDsZPL6lB5CInks6u0C FLCIqPh/SORyNLyUlGIbvJjpx8XU+SlGGtuMqKfy1sZhc+O9kJ1shKnuNURXgMkiEI/s sZxAZhTZQKE/ZGIMqoGxUvXyNZBqcow3UrR8u6XLpDJHt2AVnlB0IUQG6AoV2SyRQNMr kqlxH42lEgT/PtertFTjojmv9I4eksCmzk0zLirvIe8rUkWkz9r8OtVSk6kbLJXP0OVp NomjjartUnimsNCYkauosYLNHclQSdn2VLBVpgdzc4oTq66sILZ8FQuv66Gh4clXaOAt R27g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=SjpYkHcU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g67-20020a636b46000000b0054294720d51si3831814pgc.386.2023.07.28.18.44.06; Fri, 28 Jul 2023 18:44:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=SjpYkHcU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236254AbjG2AjG (ORCPT + 99 others); Fri, 28 Jul 2023 20:39:06 -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-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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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/testing/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) } if (run->exit_reason == KVM_EXIT_IO && cmd == UCALL_ABORT) - REPORT_GUEST_ASSERT_1(uc, "val = %lu"); + REPORT_GUEST_ASSERT(uc); 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 = guest_spin_on_val(0); - GUEST_ASSERT_1(val == 1 || val == MMIO_VAL, val); + __GUEST_ASSERT(val == 1 || val == MMIO_VAL, + "Expected '1' or MMIO ('%llx'), got '%llx'", MMIO_VAL, val); /* Spin until the misaligning memory region move completes. */ val = guest_spin_on_val(MMIO_VAL); - GUEST_ASSERT_1(val == 1 || val == 0, val); + __GUEST_ASSERT(val == 1 || val == 0, + "Expected '0' or '1' (no MMIO), got '%llx'", val); /* Spin until the memory region starts to get re-aligned. */ val = guest_spin_on_val(0); - GUEST_ASSERT_1(val == 1 || val == MMIO_VAL, val); + __GUEST_ASSERT(val == 1 || val == MMIO_VAL, + "Expected '1' or MMIO ('%llx'), got '%llx'", MMIO_VAL, val); /* Spin until the re-aligning memory region move completes. */ val = guest_spin_on_val(MMIO_VAL); - GUEST_ASSERT_1(val == 1, val); + GUEST_ASSERT_EQ(val, 1); GUEST_DONE(); } @@ -224,15 +229,15 @@ static void guest_code_delete_memory_region(void) /* Spin until the memory region is deleted. */ val = guest_spin_on_val(0); - GUEST_ASSERT_1(val == MMIO_VAL, val); + GUEST_ASSERT_EQ(val, MMIO_VAL); /* Spin until the memory region is recreated. */ val = guest_spin_on_val(MMIO_VAL); - GUEST_ASSERT_1(val == 0, val); + GUEST_ASSERT_EQ(val, 0); /* Spin until the memory region is deleted. */ val = guest_spin_on_val(0); - GUEST_ASSERT_1(val == MMIO_VAL, val); + GUEST_ASSERT_EQ(val, MMIO_VAL); 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"); - GUEST_ASSERT_1(0, 0); + GUEST_ASSERT(0); } static void test_delete_memory_region(void) -- 2.41.0.487.g6d72f3e995-goog