Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp1929324rwb; Fri, 28 Jul 2023 18:24:17 -0700 (PDT) X-Google-Smtp-Source: APBJJlF1+064BtwRyhuYKF9UEsrBMXKEHi33EFQ5UwWaUYhK984VD0sEvc7p7z7Fl1kHx4zgJMhm X-Received: by 2002:a17:902:e74a:b0:1bb:98de:251d with SMTP id p10-20020a170902e74a00b001bb98de251dmr2991446plf.63.1690593857302; Fri, 28 Jul 2023 18:24:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690593857; cv=none; d=google.com; s=arc-20160816; b=MnJnK6Ip41zlva6gHFWRAwBm/FcTYQATWW4T3wEI4/Gu+ZqiL/9NRGDl2qYmog2ojo YtfkyZ3xs4eEjCoOGBgaTd3L/w00qxSCk9JXlES5IU0QYlORP6NFJPhBexCX7y8Yw49E +LkTyBFqUkfKGeeg9/7gXSGecVdwZEMnRoc0iQd/UpGZGP/URVAHFE3c4fjBaz8kCRc1 qkZjDvBlFSNXbhYVcBsVIMGw1Z56kVQGnpCmk8S4wCPGqcVB1qzPXstzkNWBOYR98OW5 gF4pPWw8NWEqaSdvNOIeP4t6sEfIaaBNnj56w+r1oc7T5JtSAZ01BA+Ez9/k14LoLF7D NjqQ== 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=xqj9FFp3GbJzdxodUT2xF7JQwG5o4CpUta+kXT/J/Zc=; fh=Ctt0ydInMKwei8YFBFbw7rU4p8H0G/T51ZI/KkO6Md4=; b=0Jvt9lUE8BJVk4qYrqhLheCib6r6t29F347KWnnM9PM0ijfOIwnsjexpxGN836QFeL bKyY2/oTFuBKH1H8jkUVGmDYJDQite0t5jKHYA/68qaJ45HNGf/WiF/OUqnQlbsQ6dW8 vqPHEQ49d3Z+ZVc3bKdsN4rO8SpfROzNVnvP+8caKCHLqIQKd/o/ZeKr3GUsa2nLhtTK dqwvCg5S9KXO7LlFwa5XDLKsk9QQMQy+ccZk9YBVnACrqxQ1WDdx2EjQ2XsjkJuUHykd xVCL1YG/nDfGQU4rYxUAdtEzCVt+o6U6L2IhHAFdRGgXv4MXd9bmzt8THDx5sXbcLayS 41uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=6mRTmQ0s; 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 kg14-20020a170903060e00b001bbfbe6bf3esi226955plb.504.2023.07.28.18.24.05; Fri, 28 Jul 2023 18:24:17 -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=6mRTmQ0s; 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 S236874AbjG2Akn (ORCPT + 99 others); Fri, 28 Jul 2023 20:40:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236675AbjG2AkL (ORCPT ); Fri, 28 Jul 2023 20:40:11 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BEBF5255 for ; Fri, 28 Jul 2023 17:38:34 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-56942667393so26533817b3.2 for ; Fri, 28 Jul 2023 17:38:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690591066; x=1691195866; 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=xqj9FFp3GbJzdxodUT2xF7JQwG5o4CpUta+kXT/J/Zc=; b=6mRTmQ0sMBjNlnuCoCc0BasP9WSyh4U3UNy+I62mmSF7PQnu5S9L9TmW4nCeJc1yEc NqvtlAqSC0Q516Jk1Y9Rkwxmg3AkjhBvkZaMC4+blSIxvv8aNAf4tDwiCWdS/mz3OFyS 484OUBkMcHObYZQp7hJuJGDR6C5dr7avJVyoJNKl8w3G72UdYYEPxOT+z9Svg5rGM0wS ouYYaujR5212sPk4ldidMcjlqiJEBwgSW5vHQDioiBNoBbun5DWGQmKTJ76i9vFQfE+c hei//58Ou40y1sKp/lzuKZ07tJ4APhkr7vVnixNLY3U8h3ZP2nDbOyvBDVAvcnxyn5kY c1SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690591066; x=1691195866; 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=xqj9FFp3GbJzdxodUT2xF7JQwG5o4CpUta+kXT/J/Zc=; b=RxmqJNG8hdMFVqoZf1g+6an0ND932B4HpenVSKyly1sIjaWxC05jz8CYX0cSCYRhP8 UEDFwABv4mnfek/HAqSKcwOs49VaWJtBb+Rx3Ji2a4eMvhaARw8aaYCW5p20dVtwlcqd t5fqtgdDCZuZme/RXR0HByzbGyKPCha29O2n5U2BqVhvx8nqETdFFb7mvRyGv/H/xQVP TN7fAs/AR+ubp0cydvFCPMPo6uukkb2gx4xsMur9tKiY0KdBHEsM3w8CTF4/rTwBMr9Y 3AuBeGFeOmN5rkd3vIG40WUz4Ot01dLlm6mJvKWFMpXtrYeZElb3cZAi24dW6TCkmlmD xgoA== X-Gm-Message-State: ABy/qLbCcFN572h4p3UqqVOmVRfI9htYJgYAZYtc0bhw9zs++qhWl2Sk 65ytHH2d0vdXt19ZyQksP7CU15EakFE= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a81:eb14:0:b0:56c:e585:8b19 with SMTP id n20-20020a81eb14000000b0056ce5858b19mr22779ywm.2.1690591065884; Fri, 28 Jul 2023 17:37:45 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 28 Jul 2023 17:36:40 -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-32-seanjc@google.com> Subject: [PATCH v4 31/34] KVM: selftests: Convert x86's XCR0 test to use printf-based 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=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 XCR0 vs. CPUID test to use printf-based guest asserts. Signed-off-by: Sean Christopherson --- .../selftests/kvm/x86_64/xcr0_cpuid_test.c | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/tools/testing/selftests/kvm/x86_64/xcr0_cpuid_test.c b/tools/testing/selftests/kvm/x86_64/xcr0_cpuid_test.c index 905bd5ae4431..5e8290797720 100644 --- a/tools/testing/selftests/kvm/x86_64/xcr0_cpuid_test.c +++ b/tools/testing/selftests/kvm/x86_64/xcr0_cpuid_test.c @@ -4,6 +4,7 @@ * * Copyright (C) 2022, Google LLC. */ +#define USE_GUEST_ASSERT_PRINTF 1 #include #include @@ -20,13 +21,14 @@ * Assert that architectural dependency rules are satisfied, e.g. that AVX is * supported if and only if SSE is supported. */ -#define ASSERT_XFEATURE_DEPENDENCIES(supported_xcr0, xfeatures, dependencies) \ -do { \ - uint64_t __supported = (supported_xcr0) & ((xfeatures) | (dependencies)); \ - \ - GUEST_ASSERT_3((__supported & (xfeatures)) != (xfeatures) || \ - __supported == ((xfeatures) | (dependencies)), \ - __supported, (xfeatures), (dependencies)); \ +#define ASSERT_XFEATURE_DEPENDENCIES(supported_xcr0, xfeatures, dependencies) \ +do { \ + uint64_t __supported = (supported_xcr0) & ((xfeatures) | (dependencies)); \ + \ + __GUEST_ASSERT((__supported & (xfeatures)) != (xfeatures) || \ + __supported == ((xfeatures) | (dependencies)), \ + "supported = 0x%llx, xfeatures = 0x%llx, dependencies = 0x%llx", \ + __supported, (xfeatures), (dependencies)); \ } while (0) /* @@ -41,7 +43,8 @@ do { \ do { \ uint64_t __supported = (supported_xcr0) & (xfeatures); \ \ - GUEST_ASSERT_2(!__supported || __supported == (xfeatures), \ + __GUEST_ASSERT(!__supported || __supported == (xfeatures), \ + "supported = 0x%llx, xfeatures = 0x%llx", \ __supported, (xfeatures)); \ } while (0) @@ -79,14 +82,18 @@ static void guest_code(void) XFEATURE_MASK_XTILE); vector = xsetbv_safe(0, supported_xcr0); - GUEST_ASSERT_2(!vector, supported_xcr0, vector); + __GUEST_ASSERT(!vector, + "Expected success on XSETBV(0x%llx), got vector '0x%x'", + supported_xcr0, vector); for (i = 0; i < 64; i++) { if (supported_xcr0 & BIT_ULL(i)) continue; vector = xsetbv_safe(0, supported_xcr0 | BIT_ULL(i)); - GUEST_ASSERT_3(vector == GP_VECTOR, supported_xcr0, vector, BIT_ULL(i)); + __GUEST_ASSERT(vector == GP_VECTOR, + "Expected #GP on XSETBV(0x%llx), supported XCR0 = %llx, got vector '0x%x'", + BIT_ULL(i), supported_xcr0, vector); } GUEST_DONE(); @@ -117,7 +124,7 @@ int main(int argc, char *argv[]) switch (get_ucall(vcpu, &uc)) { case UCALL_ABORT: - REPORT_GUEST_ASSERT_3(uc, "0x%lx 0x%lx 0x%lx"); + REPORT_GUEST_ASSERT(uc); break; case UCALL_DONE: goto done; -- 2.41.0.487.g6d72f3e995-goog