Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp2013096rwb; Fri, 28 Jul 2023 20:47:07 -0700 (PDT) X-Google-Smtp-Source: APBJJlEEiNzDYuAbExPxuQPrfRMfhc77dvQBcja/yMFbrXuG6bD4KO7PEWwbtHgyg5FgL8EXoyGm X-Received: by 2002:a17:906:cc11:b0:99b:bdff:b0ac with SMTP id ml17-20020a170906cc1100b0099bbdffb0acmr1001079ejb.16.1690602426732; Fri, 28 Jul 2023 20:47:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690602426; cv=none; d=google.com; s=arc-20160816; b=cjUreL2pDIdOQBXw0eFRg6nt56B88hW7Bj/ttWSflHZBDgAyGeHrZqgDcvQx7Izyne 2y5eV5HJvyhBlzd1Wvbf3cs/gJcwWXLvj39zIeFFbaLIoPoQBR5O1IgEO44UAsB2Rn4o VGVA55w3u8vHZoKTlWYxjzQTHgMJKNwLaBBNZddFlp7YbHNdgKxSg7p7QqmrzdXur+qY IGTNEp98pxEfFinf8lTiOjb3Xjk3BxhQErUO1ezmHNxd4UU1xpUCY1LoaR88ZR0KF3j3 StEDuDQ0fb9WVlW70GlCBEaKNwFew+vp6sJNMC5s9doWQ98JK+WJcPIYml/yib/yKIcm b1UA== 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=w199spolidmz1fyWW2Lr4cL/pHW9KEOboysIoigRNpA=; fh=Ctt0ydInMKwei8YFBFbw7rU4p8H0G/T51ZI/KkO6Md4=; b=C5h1H+2+TCP1eqtqZTtXfs5g59HxOs8Fqd+KXBcKfuRYK6Do6yKR7XxoPUCiy/Que4 i5W4klVn6xTTNji08MiPYE09f9S1cWwKIntSi91m9s2vnUYT4u1fwzKmfZn9IOdGCqC+ p8UNfHnv7bXKfCbrjFHN0i/0qXZ/bbLFvQTCkU6LJWhhzUJKafxXXz4p6KGVELt1yjV/ b1vAwve2zpANkc85WRSgM5JJYza0DW2/22QGRea0qRPWHToi/b3S1eeitf0HLcNMdVKj f5fWwfVdjXCw26Ly3Tty8ija0V/JSb3LANHXsnVOjXLk2ByuVMnOlmSUa/LngQf7ag8k BbzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=DrhecqVP; 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 gl23-20020a170906e0d700b0099bc038eb2esi3833599ejb.201.2023.07.28.20.46.41; Fri, 28 Jul 2023 20:47:06 -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=DrhecqVP; 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 S236430AbjG2Ajj (ORCPT + 99 others); Fri, 28 Jul 2023 20:39:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236412AbjG2Air (ORCPT ); Fri, 28 Jul 2023 20:38:47 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0889049EB for ; Fri, 28 Jul 2023 17:37:55 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-d0fff3cf2d7so2562484276.2 for ; Fri, 28 Jul 2023 17:37:55 -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=UWX7HBiso//n+ywEMz1+/+yN27WdVwxui3XEDwkE/b14NnAyzwvtXXqW8pfKMAknIe XkZVz5/Cj5R4tA2iULdWcV38fwl2+QQFRjl325PFivGqV7VYDzI5A4YyfhvKjBim8SX5 vl2smMFgqdiRZgtASpqx+yUxJlaAyRDiRMF9RH8TpdtBcfZY4y278hce4B6h89bfTS89 /v/k2lh10iF52ixfy7QW1EUPvZVv9ulJv03RcJzhcIaxfLHdT73ieL6bpfevdnW8fSRw t2qlwuyoFATFGpcE9KNsJd8tLSmlBjXoRqufyaWwQU5GNv+MdGGe5lT2bYFM09GnuUKE ZQ6Q== X-Gm-Message-State: ABy/qLZzq0QRsQi4iEd6jW4kOcS4IFPqLtzYrOnNX/o1nDGOzclDxDFi k4bYmizc/minNskKdI9aG1Q9i8RGQS0= 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) Reply-To: Sean Christopherson 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=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=unavailable 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 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; -- 2.41.0.487.g6d72f3e995-goog