From patchwork Sat Jul 29 00:36:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13332823 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 7EF2DC41513 for ; Sat, 29 Jul 2023 00:39:10 +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=Fci9cPTgWAADJfp1x8tWcn2AdwwBrP3Sh2FhMAGHf1Q=; b=2A27YjMU33VviU 2lwMycy/uMN06jXhYou0uO7Tbk2HQUoY1dUqNVvIAAyEZKHil6CqGmn9Hwg7HL0uXiaKGSAdYR50g jbWonxXG6FBUFdN5PqI9kPmJWH8m8Ts9Lnz9ox7ZbZjtUJDW5BV5gyY4CJi+kbsKE7S5usORB7GbQ 8Mo84/y3VFlTOcOCSyIMkdFHYI2vxyjHEiaVu3T/eiS3gK/6hRJbT6L9gdIJKjv/QdXv7EidBbmot h97JZmUtX17uhbDHRm6dpMxmhQjMA5ctqPmSC4ZBfLjP86CLf4Z6vlk1kZToP5Mi5ipP2Y84InmQc kFQyufG1P9czPK1XSR3w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qPXyZ-005dWb-00; Sat, 29 Jul 2023 00:38:31 +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 1qPXxr-005d7E-0p for linux-arm-kernel@lists.infradead.org; Sat, 29 Jul 2023 00:37:48 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-56cf9a86277so26564857b3.3 for ; Fri, 28 Jul 2023 17:37:46 -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=OxGS1zIcixqRdgZQW0VQn6qzPKMf02ihNzjvtf1wlINH9FVqfaPabXLoZ+cvOpRXUD Ahom/xolA5FRhOqgIe4CLU20KJUqgr3DRSxHVpHF5qHfIKlQ13X/D2DHYOVgRBhG3Pjx caU13miktbj9biY6pW3AKKIV3obDTCFoo912QOQ5qFYnbLbioFR71PaW9nCZ12hTxiMr jEZlZvwAYm3rzMb2y9K49mNUmSdPc3UCEFilBGbSEuvIxjO8OJM7OTgnwhzLpQ2ZGNit 8u5Wug61DzoNyad7F9RU1I5YRheefaXgZddcKE+lOnVFEkfCNo6cB6xYfgNvpLhiBZPq WenQ== X-Gm-Message-State: ABy/qLaEVYtvSwAZP80KuESjrQKKADnyPnViK0mGL+CId420anS+LMZP k15EmsiUaisxYUKCkHP3lmqLEUoJQc4= X-Google-Smtp-Source: APBJJlGUaaiUxSD6v+uHtzJn5Bok5HEB27UnUCHcnqVc3N6UWv+PT7JG5G0++htnoOGnrQBKyXgZZKI8MMA= 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) 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_Mathieu-Daud=C3=A9?= " , Aaron Lewis X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230728_173747_296484_A2696B30 X-CRM114-Status: GOOD ( 13.50 ) 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 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;