Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp1937934rwb; Fri, 28 Jul 2023 18:38:47 -0700 (PDT) X-Google-Smtp-Source: APBJJlG8xVH2j/I0QHspJ2JEqWTyWPCVRd2HhVU7ho9cpn0DQ3sar5Jy9gFbO8C4UzBzj1X8pOAV X-Received: by 2002:aa7:d745:0:b0:522:289d:8dcd with SMTP id a5-20020aa7d745000000b00522289d8dcdmr2889990eds.35.1690594726812; Fri, 28 Jul 2023 18:38:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690594726; cv=none; d=google.com; s=arc-20160816; b=z9IAcZ5UWlJDYpPadLMpxon5fIlqD4Jjj0TLURTPTT/iOz+imkz75WODTmbvOP1clT 6iFk2vlzsm9LqO1A3GdJL6fvnDZ1ZuoD0fA8WVcgiZ9ewDZIg8QAgmQGQFEzH4bmN8Ht sdVzgYRvxRhjnfuZnb3TP7pHaRIO/0MVjNCzpCf/jEBkxAnidjd9ram1MDXx2mliNXde p2BOXN+QmP2t43XwsLaFpwVGYvHQ+QEghEVxySpSq+nrQkv3X3Fbewd1WjdhicQ1P7TP PedtIeQnr5zvyCGyUFyC8klTNvdrKPSKJIlxm610kYb9D02I2VLACL5zbzs3L6WlkCTj gr3g== 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=sEeXYbzgZRVXR5YLFfEtQVAczR2xalSf9MVNMlCNrPc=; fh=Ctt0ydInMKwei8YFBFbw7rU4p8H0G/T51ZI/KkO6Md4=; b=QFRiO/JZPqO3KE1OH+J8r5ltf7d7Q1+EjYfFPJn9UMiYSrMxW+gEw7zbxzMXizTUjM yO6/ef4v2H1DQphi7Hr98M1+WOs3AawgvI++Xi9EExjGGzBywiOB/JvpoeP21AFF7tK/ 4ihcdXIqLKE8iyc+HLEkxVVpsuBjjmZFXMCnsaCObLwGBeFmdjOBV6+RQCPTAlzQXSMW TwljxkZPGDYVYYEu4A952DrgmrrV1AefHJdhjCaj+kK+TZ+zw1C+deysfgRe/jJ8Y3LZ DHfgNjf7GcGh4sxVo8R548WCrfy1TLYikOSi55m7t5ZMoWB5On8HH9SHUfr7OxcU0pPT dNAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=510yqVUE; 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 c19-20020aa7c993000000b005224df8cb79si3380466edt.364.2023.07.28.18.38.21; Fri, 28 Jul 2023 18:38:46 -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=510yqVUE; 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 S236772AbjG2Akc (ORCPT + 99 others); Fri, 28 Jul 2023 20:40:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236775AbjG2AkJ (ORCPT ); Fri, 28 Jul 2023 20:40:09 -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 073545249 for ; Fri, 28 Jul 2023 17:38:29 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-c926075a50cso6757389276.1 for ; Fri, 28 Jul 2023 17:38:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690591063; x=1691195863; 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=sEeXYbzgZRVXR5YLFfEtQVAczR2xalSf9MVNMlCNrPc=; b=510yqVUE3dJrmTFvMRZmUgU2asXSH3DoFW0Fghi574CxyywdgdIv8Y/diDFElXqlyf jU6KsQmAZf71nxPH+MSup9/mIF1uemfLZbDWceTG4BdkFGD9rcuSR2n/9/0/bk8De/N9 25VV8tPUNlntY3Fv3oSuGTysrAQ/6Y6iPssCSdafPx304Mq6vNfG78lBD+9VDgXAqZkq em5cPcrt8KHlMBFm8vm0+E08hW/a6en+YbJ7ZZAKPcaON8hlum758WmUnT3f2Lw6PHXK Z/cAhUBz5bE1+QxdbyvOLhdn7yGVpm4px3BGKkYiY2arDrtsqFhkBbGF+doEA8uqBr8T 5T5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690591063; x=1691195863; 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=sEeXYbzgZRVXR5YLFfEtQVAczR2xalSf9MVNMlCNrPc=; b=TWV5z5Nw/Unb9SmFqzLbqTPpJGq9Q5QnP9dvyVDZXLYTNJw9VgZMNd4DuLGHWGn3mD 1Jn0ifGoJ2QWQLh4X/mXjTMA6YaOZiASS0WgIKe8Ux/WGSwS3PY/UCE0h76SdlbLPnUG zCsLLrIYxzcvZZOZpBkDIssHXBAMMxaN9BI3OHtHxtUfaGSWctdLiFe8IYpB1jowZ5Bi V52r0xrhG8gAc26xNZdkTreUqNpME44hcmlzj3JL9r+6yvutkAVoAr0r3dhRQwbMgENw Kt5mqIOaNPafrYni78QQg14gZG7g+sKAgF0wZlHVl45oLLtOfGKdgXMyHGClOyW+8nZS DR8A== X-Gm-Message-State: ABy/qLbaNEn5vEsb1PZktvBb84YNH4H8U16vRe/sf7yy1XMAPvGQ7xoH arAnAfwj0/o9tVsICF4yRVWIHlHFwIc= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:11cb:b0:d16:7ccc:b406 with SMTP id n11-20020a05690211cb00b00d167cccb406mr31838ybu.5.1690591063821; Fri, 28 Jul 2023 17:37:43 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 28 Jul 2023 17:36:39 -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-31-seanjc@google.com> Subject: [PATCH v4 30/34] KVM: selftests: Convert VMX's PMU capabilities test to printf guest asserts 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 x86's VMX PMU capabilities test to use printf-based guest asserts. Opportunstically add a helper to do the WRMSR+assert so as to reduce the amount of copy+paste needed to spit out debug information. Signed-off-by: Sean Christopherson --- .../selftests/kvm/x86_64/vmx_pmu_caps_test.c | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/tools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c b/tools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c index 34efd57c2b32..ba09d5a01c39 100644 --- a/tools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c +++ b/tools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c @@ -10,6 +10,7 @@ * and check it can be retrieved with KVM_GET_MSR, also test * the invalid LBR formats are rejected. */ +#define USE_GUEST_ASSERT_PRINTF 1 #define _GNU_SOURCE /* for program_invocation_short_name */ #include @@ -52,23 +53,24 @@ static const union perf_capabilities format_caps = { .pebs_format = -1, }; +static void guest_test_perf_capabilities_gp(uint64_t val) +{ + uint8_t vector = wrmsr_safe(MSR_IA32_PERF_CAPABILITIES, val); + + __GUEST_ASSERT(vector == GP_VECTOR, + "Expected #GP for value '0x%llx', got vector '0x%x'", + val, vector); +} + static void guest_code(uint64_t current_val) { - uint8_t vector; int i; - vector = wrmsr_safe(MSR_IA32_PERF_CAPABILITIES, current_val); - GUEST_ASSERT_2(vector == GP_VECTOR, current_val, vector); + guest_test_perf_capabilities_gp(current_val); + guest_test_perf_capabilities_gp(0); - vector = wrmsr_safe(MSR_IA32_PERF_CAPABILITIES, 0); - GUEST_ASSERT_2(vector == GP_VECTOR, 0, vector); - - for (i = 0; i < 64; i++) { - vector = wrmsr_safe(MSR_IA32_PERF_CAPABILITIES, - current_val ^ BIT_ULL(i)); - GUEST_ASSERT_2(vector == GP_VECTOR, - current_val ^ BIT_ULL(i), vector); - } + for (i = 0; i < 64; i++) + guest_test_perf_capabilities_gp(current_val ^ BIT_ULL(i)); GUEST_DONE(); } @@ -95,7 +97,7 @@ static void test_guest_wrmsr_perf_capabilities(union perf_capabilities host_cap) switch (get_ucall(vcpu, &uc)) { case UCALL_ABORT: - REPORT_GUEST_ASSERT_2(uc, "val = 0x%lx, vector = %lu"); + REPORT_GUEST_ASSERT(uc); break; case UCALL_DONE: break; -- 2.41.0.487.g6d72f3e995-goog