From patchwork Sat Jul 29 00:36:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13332810 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0BB0BC41513 for ; Sat, 29 Jul 2023 00:38:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID :References:Mime-Version:In-Reply-To:Date:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Gy+eXPN86ziBYsrxve52t2Pl2QRpsHIlwefykOJ53zU=; b=lyLQoZ0kca5A/C 49QszxcmHfgYCRoYQ2LzOTR1eamxdXVQ2OALbWglyXpmZ2CBqRg+mlvCgZj23NlpDOs0QMQ5f4eAn 9vOGNCo/OAz64woYdiw8/0590KxgDw1yLHEuZgCyB8BwhOI0JKbcFuwayUD/UiZe/BHr9e9ckkuL0 DzgfrvFLTCYQZnS5sYt0VMKN2zyFCWqu+gHgGiKJpipK+dkSeTVv2W+TuCnWabNUJF8xBnhuK9+Ge Q1XmtVGD55m34454bLN+7lewtcokub2Cl4vLqahX6IYsv8Pap0AK4C3tcqSjBhiWozvc5MJLWD1zq fKxx/mh7gPta4SXOqIAQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qPXyO-005dJl-05; Sat, 29 Jul 2023 00:38:20 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qPXxG-005cf7-14 for linux-arm-kernel@lists.infradead.org; Sat, 29 Jul 2023 00:37:12 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-5840ea40c59so28095577b3.2 for ; Fri, 28 Jul 2023 17:37:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690591025; x=1691195825; 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=MTnhp9X0lvYUZIL9WzwgJz1fC/FCDEfshbcoz/56eco=; b=lx0KZzEtIsU0AdZ9qnXZlqbpjsDtaC9HcUC6zEB5z+kgdFIehygXDlCxd/jAA0wTwd 4gRgNK3LibVhKtGBS+OwiXCm8B21jgDt2+6DxZvJ76oM47lhWAHJHFB0tKxpVNtgeF+B RMIjaJHwQQvB52Sgbeem3LaxJb7s8wsgeNOUhXWjnrzAyjFTAF0QPmYoh9DFE9SHjp9N WYQ7gSBDcpm+zTFhDttDC7VO88WNVZrNOtJn/gyTAZoWDTKtnoLkUSHxC6+D3Ctlvpda PH1Z199C1u+Cu7YlHc7/jYTzKlazFn0t0RJr3GmJfdmakqJtYgm5QBnYq03xGWhI10A8 DNdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690591025; x=1691195825; 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=MTnhp9X0lvYUZIL9WzwgJz1fC/FCDEfshbcoz/56eco=; b=dZZ7da4HpdtZzYvPCk6B1kwp8D9v4pJxmf0FyUrOTXjW4WJqNJwfJ2awB8xd5TXUf/ ClZBkS/O5yWIrMMOyGXivYRffKYgRmp0tGY+4BYCE9IULaVG+mIqTlSH9VLeA6AzM4rv 9VzzZcc/jW0XZCkNbsagsvAABDYij6xqGg4iSLesadCHaGWQG52mwP56BOCbMoWP6AkY f8zbXWeXaBL6jQLZHlHQlCQ+9sb825/bRgcI5zT8Rgia1URI3AzqGB2O8mxImTv4gdT4 UAAe+pOpSWBOEE7K2HuzRJBiidbek5igME1OVIx2v4BzXzx0jG0qX7wEqH2RNu9zfliN iFiA== X-Gm-Message-State: ABy/qLYRRBHbTckrF4H8XaBkRwifexdzj1u5kIgt5gRkKyUCv8Pizjos 9OGIYsJujM9kEDh7soomLTXE59q4Ny8= X-Google-Smtp-Source: APBJJlGkPJLpvMgBhZQZngegrJd5H8lH0SpYQU1t+gpMp8O4I9K80z10fyRXj9c+AjJBWPrkzcKXkpDJEd0= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a81:ad42:0:b0:56f:f62b:7a11 with SMTP id l2-20020a81ad42000000b0056ff62b7a11mr22723ywk.8.1690591025745; Fri, 28 Jul 2023 17:37:05 -0700 (PDT) Date: Fri, 28 Jul 2023 17:36:19 -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-11-seanjc@google.com> Subject: [PATCH v4 10/34] KVM: selftests: Convert aarch_timer to printf style 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_Mathieu-Daud=C3=A9?= " , Aaron Lewis X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230728_173710_378634_5547A0D9 X-CRM114-Status: GOOD ( 11.10 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Sean Christopherson Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Convert ARM's aarch_timer test to use printf-based GUEST_ASSERT(). To maintain existing functionality, manually print the host information, e.g. stage and iteration, to stderr prior to reporting the guest assert. Signed-off-by: Sean Christopherson --- .../selftests/kvm/aarch64/arch_timer.c | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/tools/testing/selftests/kvm/aarch64/arch_timer.c b/tools/testing/selftests/kvm/aarch64/arch_timer.c index 8ef370924a02..b53bcf126e6a 100644 --- a/tools/testing/selftests/kvm/aarch64/arch_timer.c +++ b/tools/testing/selftests/kvm/aarch64/arch_timer.c @@ -19,6 +19,7 @@ * * Copyright (c) 2021, Google LLC. */ +#define USE_GUEST_ASSERT_PRINTF 1 #define _GNU_SOURCE @@ -155,11 +156,13 @@ static void guest_validate_irq(unsigned int intid, xcnt_diff_us = cycles_to_usec(xcnt - shared_data->xcnt); /* Make sure we are dealing with the correct timer IRQ */ - GUEST_ASSERT_2(intid == timer_irq, intid, timer_irq); + GUEST_ASSERT_EQ(intid, timer_irq); /* Basic 'timer condition met' check */ - GUEST_ASSERT_3(xcnt >= cval, xcnt, cval, xcnt_diff_us); - GUEST_ASSERT_1(xctl & CTL_ISTATUS, xctl); + __GUEST_ASSERT(xcnt >= cval, + "xcnt = 0x%llx, cval = 0x%llx, xcnt_diff_us = 0x%llx", + xcnt, cval, xcnt_diff_us); + __GUEST_ASSERT(xctl & CTL_ISTATUS, "xcnt = 0x%llx", xcnt); WRITE_ONCE(shared_data->nr_iter, shared_data->nr_iter + 1); } @@ -192,8 +195,7 @@ static void guest_run_stage(struct test_vcpu_shared_data *shared_data, TIMER_TEST_ERR_MARGIN_US); irq_iter = READ_ONCE(shared_data->nr_iter); - GUEST_ASSERT_2(config_iter + 1 == irq_iter, - config_iter + 1, irq_iter); + GUEST_ASSERT_EQ(config_iter + 1, irq_iter); } } @@ -243,13 +245,9 @@ static void *test_vcpu_run(void *arg) break; case UCALL_ABORT: sync_global_from_guest(vm, *shared_data); - REPORT_GUEST_ASSERT_N(uc, "values: %lu, %lu; %lu, vcpu %u; stage; %u; iter: %u", - GUEST_ASSERT_ARG(uc, 0), - GUEST_ASSERT_ARG(uc, 1), - GUEST_ASSERT_ARG(uc, 2), - vcpu_idx, - shared_data->guest_stage, - shared_data->nr_iter); + fprintf(stderr, "Guest assert failed, vcpu %u; stage; %u; iter: %u\n", + vcpu_idx, shared_data->guest_stage, shared_data->nr_iter); + REPORT_GUEST_ASSERT(uc); break; default: TEST_FAIL("Unexpected guest exit\n");