From patchwork Sat Jul 29 00:36:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13332828 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 74CAFC04A94 for ; Sat, 29 Jul 2023 00:39:13 +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=qLYKFEj/Dzy3+YMAhGR+p2TSATIiXQC885WeB/bsmmo=; b=viTdpsOylrCIMK WgcS7IiXr59o/lYioO1Wy25OoUmen3qm2yZzWLztYFYnHzMaQJA7CSES2NXWzRHk290cK97CcR/gK 0P+dYe3wPgE1LaQQ3sFanERMLjtpZhNpEwH9ydSGYc18vtvBctsFSDytqERdRWH85/ARjx0LsxXnd pvdrEnNZr1LKg0HsHTx9gCbfhchQULbHhhBwu1hpsNZ+MSNYrT1psZV/zNeX23gApHkCfCUkjrfjY ygytwzVYvh3FYfixlEJQ6k89HJXSvQzCO/qTglNj9+1k52HRHfjVyIH0UzxzRtYmjCx6Os3Rd9n4R j+p92bhLBaV+WDyWIMvg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qPXyU-005dQI-1O; Sat, 29 Jul 2023 00:38:26 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qPXxc-005cw8-1G for linux-arm-kernel@lists.infradead.org; Sat, 29 Jul 2023 00:37:37 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-c6db61f7f64so2575972276.0 for ; Fri, 28 Jul 2023 17:37:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690591048; x=1691195848; 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=w199spolidmz1fyWW2Lr4cL/pHW9KEOboysIoigRNpA=; b=DrhecqVPQeLMP91ubgEGu6G/jHyWR4//Lad7FZiEySEklpS4P1wiOZupUHqW/ZjTAY Qc2O+aSQCxUoaI2hSjEjV6ICPMoEYiI/GB3LLTYh8g6SG83BAN4KuJG0rOSqKHyJQ6+k paUMofkHmyHbueb3IEOlz7jeH0HHA+RoEI9CWRflI8qxBnLZeDeBhpL76Rd0pFtN6BFv V8G7CP4W7qnDGSWeKWVac5kpCNXWOdfPOm0KSvSo4TZgIjbmMLsl4KYqh5wpnE4g/fxP UZIo3ILZlXQ8MTNA4ijFkX0NpuTKiC4UU3mKTPYa6sQJtt/aDbT7apbEJQfp0Nikwdi0 8MKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690591048; x=1691195848; 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=w199spolidmz1fyWW2Lr4cL/pHW9KEOboysIoigRNpA=; b=S2WPQ+ZYYJ1aoPAJxLAC5oO+oitzwGuyonjMwJjJSJZvWxGRfXu5KGnsCkFmZsW2yz FcTOmgqN8qPo9snmQEjQ4LmN7maZCie63JOmsns+UJkQArvZREV1DLNXUT9anEFcd4Zh fqqLpbY8lxHdFLH+DjTaCq8cf4EmxCmIbpwQF712Xck/ZGEJzmtFJiuAnwVoie+XgEtJ Y4SWkC5IQWhC1CuqTL43C14neWOxb16B1ZUMLZvZRaNDbSfNzOf6vFSRW6ns6rhXU5J8 04yN4NBYvnsrHjAC8vX63zJ4SO5KlToRq4lXvS2MMvuN6k2+WELDzWGo0dr0hgNNJYHL owcQ== X-Gm-Message-State: ABy/qLYIlS4Svzizq6xHO8yvdDO7Tor5ASoFX6ukJ4nZsmuldTSISI+O NGkZGb4HZhX0fpeQVjCshnf/QMLuJIg= X-Google-Smtp-Source: APBJJlEkIujTI85kXI9jRFQI7RC5mYrZ6Cg6VIZeTCAXQQnRxYdIDgUz9r2skvpYxnizApg4b/YiqoDb0dM= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a25:4d4:0:b0:d1a:4d0e:c11c with SMTP id 203-20020a2504d4000000b00d1a4d0ec11cmr16550ybe.11.1690591048693; Fri, 28 Jul 2023 17:37:28 -0700 (PDT) Date: Fri, 28 Jul 2023 17:36:31 -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-23-seanjc@google.com> Subject: [PATCH v4 22/34] KVM: selftests: Convert the Hyper-V feature test 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_173732_458168_6B442A0D X-CRM114-Status: GOOD ( 11.06 ) 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 x86's Hyper-V feature test to use print-based guest asserts. Opportunistically use the EQ and NE variants in a few places to capture additional information. Signed-off-by: Sean Christopherson --- .../selftests/kvm/x86_64/hyperv_features.c | 31 +++++++++++++------ 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/kvm/x86_64/hyperv_features.c b/tools/testing/selftests/kvm/x86_64/hyperv_features.c index 78606de9385d..41a6beff78c4 100644 --- a/tools/testing/selftests/kvm/x86_64/hyperv_features.c +++ b/tools/testing/selftests/kvm/x86_64/hyperv_features.c @@ -4,6 +4,8 @@ * * Tests for Hyper-V features enablement */ +#define USE_GUEST_ASSERT_PRINTF 1 + #include #include #include @@ -53,16 +55,21 @@ static void guest_msr(struct msr_data *msr) vector = rdmsr_safe(msr->idx, &msr_val); if (msr->fault_expected) - GUEST_ASSERT_3(vector == GP_VECTOR, msr->idx, vector, GP_VECTOR); + __GUEST_ASSERT(vector == GP_VECTOR, + "Expected #GP on %sMSR(0x%x), got vector '0x%x'", + msr->idx, msr->write ? "WR" : "RD", vector); else - GUEST_ASSERT_3(!vector, msr->idx, vector, 0); + __GUEST_ASSERT(!vector, + "Expected success on %sMSR(0x%x), got vector '0x%x'", + msr->idx, msr->write ? "WR" : "RD", vector); if (vector || is_write_only_msr(msr->idx)) goto done; if (msr->write) - GUEST_ASSERT_3(msr_val == msr->write_val, msr->idx, - msr_val, msr->write_val); + __GUEST_ASSERT(!vector, + "WRMSR(0x%x) to '0x%llx', RDMSR read '0x%llx'", + msr->idx, msr->write_val, msr_val); /* Invariant TSC bit appears when TSC invariant control MSR is written to */ if (msr->idx == HV_X64_MSR_TSC_INVARIANT_CONTROL) { @@ -82,7 +89,7 @@ static void guest_hcall(vm_vaddr_t pgs_gpa, struct hcall_data *hcall) u64 res, input, output; uint8_t vector; - GUEST_ASSERT(hcall->control); + GUEST_ASSERT_NE(hcall->control, 0); wrmsr(HV_X64_MSR_GUEST_OS_ID, HYPERV_LINUX_OS_ID); wrmsr(HV_X64_MSR_HYPERCALL, pgs_gpa); @@ -96,10 +103,14 @@ static void guest_hcall(vm_vaddr_t pgs_gpa, struct hcall_data *hcall) vector = __hyperv_hypercall(hcall->control, input, output, &res); if (hcall->ud_expected) { - GUEST_ASSERT_2(vector == UD_VECTOR, hcall->control, vector); + __GUEST_ASSERT(vector == UD_VECTOR, + "Expected #UD for control '%u', got vector '0x%x'", + hcall->control, vector); } else { - GUEST_ASSERT_2(!vector, hcall->control, vector); - GUEST_ASSERT_2(res == hcall->expect, hcall->expect, res); + __GUEST_ASSERT(!vector, + "Expected no exception for control '%u', got vector '0x%x'", + hcall->control, vector); + GUEST_ASSERT_EQ(res, hcall->expect); } GUEST_DONE(); @@ -495,7 +506,7 @@ static void guest_test_msrs_access(void) switch (get_ucall(vcpu, &uc)) { case UCALL_ABORT: - REPORT_GUEST_ASSERT_3(uc, "MSR = %lx, arg1 = %lx, arg2 = %lx"); + REPORT_GUEST_ASSERT(uc); return; case UCALL_DONE: break; @@ -665,7 +676,7 @@ static void guest_test_hcalls_access(void) switch (get_ucall(vcpu, &uc)) { case UCALL_ABORT: - REPORT_GUEST_ASSERT_2(uc, "arg1 = %lx, arg2 = %lx"); + REPORT_GUEST_ASSERT(uc); return; case UCALL_DONE: break;