From patchwork Fri Feb 17 21:59:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Lewis X-Patchwork-Id: 13145290 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71BABC05027 for ; Fri, 17 Feb 2023 22:00:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229775AbjBQWAS (ORCPT ); Fri, 17 Feb 2023 17:00:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229668AbjBQWAQ (ORCPT ); Fri, 17 Feb 2023 17:00:16 -0500 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 7A36559726 for ; Fri, 17 Feb 2023 14:00:12 -0800 (PST) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-5365780ce32so20789247b3.23 for ; Fri, 17 Feb 2023 14:00:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=4OP9lL5HFo/s6obKjyt5S7A/ZCzo8E75OA2vEjP+a6c=; b=mGkpZRo12t+BW97KkeX/KWi+6jN48HqA2C9HRu/r+amVkR01zl/dVHajZXCKugk2yD Gr9Mx4gSgtB2tRtmlb8gEYNKfps0vdbYg0hVjto7P4EHKQ2rbcPtC5JjcF3FsL5kkFJK ivRGXYz2TBX7gf+dnveX4+wN8iEYYQUCpmvGnrAwhoJWyB+FRngAjwK5RnR8QtiKfGCI PtpRiBlfn9U+vVtNbrkuEs8qc/Ok8kUnALz7pOg1giGFfjYxvFBrOv+biWbsmfzcGgx2 dEsGyuNU3/q+3chHLOy1OyLef0O7cC9oEIAszRJGJqt9K+Q3GHvCn90FSiu9s/wzIfnj dDbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=4OP9lL5HFo/s6obKjyt5S7A/ZCzo8E75OA2vEjP+a6c=; b=5bXAUzE18nyEMPFyvUwPJ+fiAXiFxStLVJNtGdG3RUQupQOunP5NwztBaYVms46rHD RUgt9LNRJLvslzempL1nD5OGVPl9QHUbcQCh+TM30QOk+Cvz/5LePt5y0YX/BavspWxB PiAJLQ78fBrr/Ot5Adhbbu99HMo2pR+zVU4J+m99VZpR8HaF77ZK24JVlaJ8Z2emGZ+M iRn7EzG3dtalsCe/bHyqcxPehs4MsPY8B721MOItoIZUYJm2IhCWA0zyVSmw10g8Mfni dvTphTLF5j9+vYTZfFDJSYzO3Ls00AQlXjh73jmE3XBVdsv0DjjMwQt2ViHJGgMXb72T 0C3A== X-Gm-Message-State: AO0yUKWHlDiC7/2KmlRDGg3Qai3bZvXYImO5EkJbwqcMckoPnOWuESql q5sEpzY4uTPRNCnzXsITu+QLIqwrv58qat+HoNJwSGJx+4O2B/zY0gGbudjt90pFEy/dUtU/8ow J6SZOMaKGOqJldzxJW7kINt0JiIx3Fz/7LBE8QPm3hq3R90YV0UiByg352d3085+O5ypU X-Google-Smtp-Source: AK7set94FbZvnoiYBE2Pg2P3PTOo96M4b4j/Zvrb+xLnXVvu/Np5zUDtYIb/awWKZ0+2mDqN+FjsWAvlaLMjznl0 X-Received: from aaronlewis-2.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:519c]) (user=aaronlewis job=sendgmr) by 2002:a0d:d449:0:b0:527:9d77:e4f6 with SMTP id w70-20020a0dd449000000b005279d77e4f6mr1466405ywd.488.1676671211729; Fri, 17 Feb 2023 14:00:11 -0800 (PST) Date: Fri, 17 Feb 2023 21:59:55 +0000 In-Reply-To: <20230217215959.1569092-1-aaronlewis@google.com> Mime-Version: 1.0 References: <20230217215959.1569092-1-aaronlewis@google.com> X-Mailer: git-send-email 2.39.2.637.g21b0678d19-goog Message-ID: <20230217215959.1569092-2-aaronlewis@google.com> Subject: [PATCH 1/5] KVM: selftests: Assert that XTILE is XSAVE-enabled From: Aaron Lewis To: kvm@vger.kernel.org Cc: pbonzini@redhat.com, jmattson@google.com, seanjc@google.com, Aaron Lewis Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org The check in amx_test that ensures that XTILE is XSAVE-enabled, doesn't actually check anything. It simply returns a bool which the test does nothing with. Add the intended assert. Opportunistically, move the assert to a more appropriate location; immediately after XSETBV. Fixes: 5dc19f1c7dd3 ("KVM: selftests: Convert AMX test to use X86_PROPRETY_XXX") Signed-off-by: Aaron Lewis --- tools/testing/selftests/kvm/x86_64/amx_test.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/tools/testing/selftests/kvm/x86_64/amx_test.c b/tools/testing/selftests/kvm/x86_64/amx_test.c index bd72c6eb3b670..7ee8b68064000 100644 --- a/tools/testing/selftests/kvm/x86_64/amx_test.c +++ b/tools/testing/selftests/kvm/x86_64/amx_test.c @@ -119,11 +119,6 @@ static inline void check_cpuid_xsave(void) GUEST_ASSERT(this_cpu_has(X86_FEATURE_OSXSAVE)); } -static bool check_xsave_supports_xtile(void) -{ - return __xgetbv(0) & XFEATURE_MASK_XTILE; -} - static void check_xtile_info(void) { GUEST_ASSERT(this_cpu_has_p(X86_PROPERTY_XSTATE_MAX_SIZE_XCR0)); @@ -180,6 +175,7 @@ static void init_regs(void) xcr0 = __xgetbv(0); xcr0 |= XFEATURE_MASK_XTILE; __xsetbv(0x0, xcr0); + GUEST_ASSERT(__xgetbv(0) & XFEATURE_MASK_XTILE); } static void __attribute__((__flatten__)) guest_code(struct tile_config *amx_cfg, @@ -188,7 +184,6 @@ static void __attribute__((__flatten__)) guest_code(struct tile_config *amx_cfg, { init_regs(); check_cpuid_xsave(); - check_xsave_supports_xtile(); check_xtile_info(); GUEST_SYNC(1); From patchwork Fri Feb 17 21:59:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Lewis X-Patchwork-Id: 13145289 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52351C636D6 for ; Fri, 17 Feb 2023 22:00:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229701AbjBQWAR (ORCPT ); Fri, 17 Feb 2023 17:00:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229461AbjBQWAP (ORCPT ); Fri, 17 Feb 2023 17:00:15 -0500 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 4F32D5CF0B for ; Fri, 17 Feb 2023 14:00:14 -0800 (PST) Received: by mail-yb1-xb4a.google.com with SMTP id y33-20020a25ad21000000b00953ffdfbe1aso1889981ybi.23 for ; Fri, 17 Feb 2023 14:00:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=TJtZTJ5JPqffWwmGPbVek61zu2r3MSyWTFGKlIawwkM=; b=iKLRxe0rf3EWYa+Pt1E8vG3dn2F4qcuf/e3ku6voeXWUjIbyEYEksXTUskxcMFzWDI fr5h4Rf3Akchs0uVv2Ox2wsYCKIzWWNklfgWUGf3jrMvtz9VsXdPeWh0j09VzcFXRTp2 9xevs/y81AjTSE41TU2UgO+aKiWhvIBvms8F8XlH2u9IJ53eyuwPlBaHIsFmzb1WOkyO mc/DU559ErQBrWWeKUymiSCRCVHYauT68xadOSVVNlYIgcQSa2RXGxIHKC4SatbrGxh9 d0lQVzx8f3oSPNuGDdNTY9cCC68NFcBra6yuBBJc1ldCCAoYqEIRfxg9v1AJalbpLN9d l/MQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=TJtZTJ5JPqffWwmGPbVek61zu2r3MSyWTFGKlIawwkM=; b=D3foZb2cQCXjkCvifP9C1sfbmEAJMF+QnisHVqApvDt0iCguHUuBjwFuWo1FrDbwJ8 nuu3wJD/bpseFkdz/h/znKnoxElLhZTV4jFKae70W8C6uUaPkyO680Tub1w+6QFCBsre I9KJ4rkM1X6nF1gB1WbhVq2DxeIgUSC8+7MQT4HYNUp1hGOdC70LEK1I9l8bKS3yAQDe 0moC4Hhzm0VgCmIlkmXEMZYwqoLI7qcoSHdx2xZe4yv7tgyZn2Zkj/UO/AggdxX/KgfV TbsHvVTonZOy61o1j/S4YxyFz0uK+vZfwJfWADGOHBOfDopj6bzjsdsEm3ES8y1nsB1L xXEw== X-Gm-Message-State: AO0yUKXzz6rksK2EwFQasMvXADQhuMO2PRHFOKp33Nc0oYVTpTYTn5Vl EQ83KCiprORzKhoL9OqeT6KHx2mZlYuafnAsvMYwetT2NkQBjolYHo1eepWLUJpj7TzqQk5LebW qrnrDyoVw4CyLO/EP309/y4CAc/nKhbcr6NZf8fk3XNJZsNEZOxiFrJtTYToAesV0PIUk X-Google-Smtp-Source: AK7set/PPFkFHLKHvAGlrjHFuARA3toeaA9W5KtYV9p1U6BAKLNAMhPJbia/OiEcPbe9LA3awIb0alH4idxmWnGB X-Received: from aaronlewis-2.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:519c]) (user=aaronlewis job=sendgmr) by 2002:a05:6902:4f0:b0:98e:6280:74ca with SMTP id w16-20020a05690204f000b0098e628074camr147679ybs.1.1676671213425; Fri, 17 Feb 2023 14:00:13 -0800 (PST) Date: Fri, 17 Feb 2023 21:59:56 +0000 In-Reply-To: <20230217215959.1569092-1-aaronlewis@google.com> Mime-Version: 1.0 References: <20230217215959.1569092-1-aaronlewis@google.com> X-Mailer: git-send-email 2.39.2.637.g21b0678d19-goog Message-ID: <20230217215959.1569092-3-aaronlewis@google.com> Subject: [PATCH 2/5] KVM: selftests: Assert that both XTILE{CFG,DATA} are XSAVE-enabled From: Aaron Lewis To: kvm@vger.kernel.org Cc: pbonzini@redhat.com, jmattson@google.com, seanjc@google.com, Aaron Lewis Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org The check in amx_test that ensures that XTILE is XSAVE-enabled makes sure at least one of the XTILE bits are set, XTILECFG or XTILEDATA, when it really should be checking that both are set. Assert that both XTILECFG and XTILEDATA a set. Fixes: bf70636d9443 ("selftest: kvm: Add amx selftest") Signed-off-by: Aaron Lewis --- tools/testing/selftests/kvm/x86_64/amx_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/kvm/x86_64/amx_test.c b/tools/testing/selftests/kvm/x86_64/amx_test.c index 7ee8b68064000..27889e5acbedb 100644 --- a/tools/testing/selftests/kvm/x86_64/amx_test.c +++ b/tools/testing/selftests/kvm/x86_64/amx_test.c @@ -175,7 +175,7 @@ static void init_regs(void) xcr0 = __xgetbv(0); xcr0 |= XFEATURE_MASK_XTILE; __xsetbv(0x0, xcr0); - GUEST_ASSERT(__xgetbv(0) & XFEATURE_MASK_XTILE); + GUEST_ASSERT((__xgetbv(0) & XFEATURE_MASK_XTILE) == XFEATURE_MASK_XTILE); } static void __attribute__((__flatten__)) guest_code(struct tile_config *amx_cfg, From patchwork Fri Feb 17 21:59:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Lewis X-Patchwork-Id: 13145291 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F6E7C636D7 for ; Fri, 17 Feb 2023 22:00:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229791AbjBQWAT (ORCPT ); Fri, 17 Feb 2023 17:00:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229616AbjBQWAQ (ORCPT ); Fri, 17 Feb 2023 17:00:16 -0500 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E464D5B2E7 for ; Fri, 17 Feb 2023 14:00:15 -0800 (PST) Received: by mail-pg1-x54a.google.com with SMTP id 11-20020a63030b000000b004fb3343142dso944765pgd.5 for ; Fri, 17 Feb 2023 14:00:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=k00jmPPGYoi9g64coPtuhUtlvtYczcvpQTMQxklUXCQ=; b=ac+v7qEX9B/6UJ8OfDDwMOOOr21TQ4e0Gq2Zvv0XMhfqk7HFbYk/spUlOfAKaIpLrp Pvp0a25a0FnkLESTDgIN+lCrXGLOlWhr+HsVdVi8/1MylWbWRIz9cdjV0feNxMOoMIiu iVdwqoJpNq4NHoAG2uKv8hBtwDdiJkLAjtYZUM0LPrvQZDHWjDvbPpyhoSEhEp/ynf6/ CKvHpNrbDJ392LeMoRpX5Wj4s2aP9YxfdKVMNZidprTIXjqC2tNJaCsT28zTxy8BGe0x pNtYq7lc4yo3n3S2tP/fC8faBecJRaYwrs+kzULw+us3plERqaJaRSCGIQLw5Q56BXgJ Mm8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=k00jmPPGYoi9g64coPtuhUtlvtYczcvpQTMQxklUXCQ=; b=0kPO4t+EAcZQZU8t970rMY0LAoqIA93vJ7Du8kuuBoxpynnxGIaZSj4Jl90T9djeNa 2DOJvXl1gnHiVVjjXevff3IFHbIBlX1MZaXaXi6/QJ4EcWYPNnUODrEhB0qj4tEAsaQq NtkugYD61zieZwA9tYSULLb7t+Xsh5wrKYtucGpCgBFTrzpAq+FF9X4GggtlFwOqJiZ3 8xmuW7Y2Ptswljq2QyGvb5DE539tkGrk5PwDJl1VF5pFt5KgUDjqogWA8VvsfvepayZE hvk8e9Aqgp5kq8dwMwkeCZ4LYGW7jj7cJ0CTKMER4mydiC8zbXTaeJgE7MtKRwVPFU8U 568Q== X-Gm-Message-State: AO0yUKVcrH9ESFFMu6aqQkzl3Ik74Isz2g69uRZRk5ohGbx4BUvLpUCn izAfgG+QIs/lec3vUBpXdshCOrIzX8uZM3La6TNuig43eYEsg2t/+Yc2esSShuSa98CBpPh3lD6 5xiM70gbGWlDuy0QjvIOVObPEpoMQXIbJrOwebZKyg5qGhVsGVjcM8wmlbSu+gXOvOv3a X-Google-Smtp-Source: AK7set9+1Tp5Ui5p93h4tcgTKX8MIOjiOKP16aFibOJrtVPk4qWXNuUg2WSPm6qNhjwA+C7P2OocUpBrclTUeAGZ X-Received: from aaronlewis-2.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:519c]) (user=aaronlewis job=sendgmr) by 2002:a17:903:48f:b0:199:4bc:1fed with SMTP id jj15-20020a170903048f00b0019904bc1fedmr346262plb.9.1676671215332; Fri, 17 Feb 2023 14:00:15 -0800 (PST) Date: Fri, 17 Feb 2023 21:59:57 +0000 In-Reply-To: <20230217215959.1569092-1-aaronlewis@google.com> Mime-Version: 1.0 References: <20230217215959.1569092-1-aaronlewis@google.com> X-Mailer: git-send-email 2.39.2.637.g21b0678d19-goog Message-ID: <20230217215959.1569092-4-aaronlewis@google.com> Subject: [PATCH 3/5] KVM: selftests: Remove redundant check that XSAVE is supported From: Aaron Lewis To: kvm@vger.kernel.org Cc: pbonzini@redhat.com, jmattson@google.com, seanjc@google.com, Aaron Lewis Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org In amx_test, userspace requires that XSAVE is supported before running the test, then the guest checks that it is supported after enabling AMX. Remove the redundant check in the guest that XSAVE is supported. Opportunistically, move the check that OSXSAVE is set to immediately after the guest sets it, rather than in a separate helper. Signed-off-by: Aaron Lewis --- tools/testing/selftests/kvm/x86_64/amx_test.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/tools/testing/selftests/kvm/x86_64/amx_test.c b/tools/testing/selftests/kvm/x86_64/amx_test.c index 27889e5acbedb..9772b9fb6a15f 100644 --- a/tools/testing/selftests/kvm/x86_64/amx_test.c +++ b/tools/testing/selftests/kvm/x86_64/amx_test.c @@ -113,12 +113,6 @@ static inline void __xsavec(struct xsave_data *data, uint64_t rfbm) : "memory"); } -static inline void check_cpuid_xsave(void) -{ - GUEST_ASSERT(this_cpu_has(X86_FEATURE_XSAVE)); - GUEST_ASSERT(this_cpu_has(X86_FEATURE_OSXSAVE)); -} - static void check_xtile_info(void) { GUEST_ASSERT(this_cpu_has_p(X86_PROPERTY_XSTATE_MAX_SIZE_XCR0)); @@ -171,6 +165,7 @@ static void init_regs(void) cr4 = get_cr4(); cr4 |= X86_CR4_OSXSAVE; set_cr4(cr4); + GUEST_ASSERT(this_cpu_has(X86_FEATURE_OSXSAVE)); xcr0 = __xgetbv(0); xcr0 |= XFEATURE_MASK_XTILE; @@ -183,7 +178,6 @@ static void __attribute__((__flatten__)) guest_code(struct tile_config *amx_cfg, struct xsave_data *xsave_data) { init_regs(); - check_cpuid_xsave(); check_xtile_info(); GUEST_SYNC(1); From patchwork Fri Feb 17 21:59:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Lewis X-Patchwork-Id: 13145292 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8936CC636D6 for ; Fri, 17 Feb 2023 22:00:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229806AbjBQWAU (ORCPT ); Fri, 17 Feb 2023 17:00:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229736AbjBQWAT (ORCPT ); Fri, 17 Feb 2023 17:00:19 -0500 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 169FD59736 for ; Fri, 17 Feb 2023 14:00:18 -0800 (PST) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-536587ff9e1so18719277b3.21 for ; Fri, 17 Feb 2023 14:00:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=XyL5Bx8sLnyrbUv2Ja89Nz0/VW7yUTYVKDiYHW4EV4g=; b=pdpWancJNNWBQwlIi1TswPWWLHJFMi64yUqtvb+TTPHpfMJxSeyHsiUtfXMTyPVflF oZx/NJIDKjJfDcoSOKrOZ9/EReZy8yr3Rv39vLFIYBSZawrJ8Vudso1LgeafLNKUfBR8 d3s6PKwGShQYU/Y6o3hQIj6jEBtpQGklNVy0ckdWKJd3D0L7Y3cZZrDyyzTokiwU0FiG IFZRbg1EK4rkfnHoQKqRVeJGFUG+8FrwiTOGgyHrZ8iiS0Ull87kHJaV6Fe57HY/BMKz iYue+YIE9JfGTb4OqiD3ZoyjGFamZc1dfVROb1s/v722Mn0wv9wC90nr9+Sx/tHjySTP Jiow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=XyL5Bx8sLnyrbUv2Ja89Nz0/VW7yUTYVKDiYHW4EV4g=; b=tRHpfQ3X7ve0G189D7xtiQjOXTYw3UCx9SuwVzD+GrGSsxriXNBSSVHvO//9UE2oe/ d8rQ3aDDIRZv64IsUc3Qp2RySZW0VZkd/kz2+gm8Mbo+9ma7Xt36m3DjzkzD9gyTkYtR FrPs08/0faWXJkY0FxywJcLnmAq/9nChIXog6m8dfnIkxo8VMyJPqarn5OCYwDILvj8t 2lJEcuiS7maeUa5k3nLSCIQ3kdm/CEMfEqecLoub5yq8YWZyJurhvxBfOLjuZBp7FbBH mKfBTMlNhwV7spBtmkxeWHugM1exXbD+OyNve+JnehPm2ZcOxnb8PRUyzF4eRsj+vU5H OQUQ== X-Gm-Message-State: AO0yUKX0zO1gNe8x8+F5zEG6Qu31pDjQQqgKo10DUFVeUKAY8/bR8wFr vIhbTd1q2mTb+Jq+4BLqoO+lDRhAcoMgBfMft0JTOlqEKpq4czffFuHlYMF0j7xLFniFAbnP3u9 HLHiIDv5CSc5Gu2yK8kPai+58+v40LtBOy6tuCEnZJtp/gyPC5W2GQECnVBvVWz1hQRNA X-Google-Smtp-Source: AK7set93DCd+2lLh0TGvk09rvo2bqSwP2j1Vr54YGm/qlGS6hWySCohHtd9xUtGLoi5sAKJL3LfHffsTVqvT9s6f X-Received: from aaronlewis-2.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:519c]) (user=aaronlewis job=sendgmr) by 2002:a5b:108:0:b0:8e3:bd3:3674 with SMTP id 8-20020a5b0108000000b008e30bd33674mr215730ybx.8.1676671217149; Fri, 17 Feb 2023 14:00:17 -0800 (PST) Date: Fri, 17 Feb 2023 21:59:58 +0000 In-Reply-To: <20230217215959.1569092-1-aaronlewis@google.com> Mime-Version: 1.0 References: <20230217215959.1569092-1-aaronlewis@google.com> X-Mailer: git-send-email 2.39.2.637.g21b0678d19-goog Message-ID: <20230217215959.1569092-5-aaronlewis@google.com> Subject: [PATCH 4/5] KVM: selftests: Check that the palette table exists before using it From: Aaron Lewis To: kvm@vger.kernel.org Cc: pbonzini@redhat.com, jmattson@google.com, seanjc@google.com, Aaron Lewis Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org The maximum number of AMX palette tables is enumerated by CPUID.1DH:EAX. Assert that the palette used in amx_test, CPUID.1DH.1H, does not exceed that maximum. Signed-off-by: Aaron Lewis --- tools/testing/selftests/kvm/include/x86_64/processor.h | 1 + tools/testing/selftests/kvm/x86_64/amx_test.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/tools/testing/selftests/kvm/include/x86_64/processor.h b/tools/testing/selftests/kvm/include/x86_64/processor.h index c5d062cf919d0..8211b9de6e7b9 100644 --- a/tools/testing/selftests/kvm/include/x86_64/processor.h +++ b/tools/testing/selftests/kvm/include/x86_64/processor.h @@ -208,6 +208,7 @@ struct kvm_x86_cpu_property { #define X86_PROPERTY_XSTATE_MAX_SIZE KVM_X86_CPU_PROPERTY(0xd, 0, ECX, 0, 31) #define X86_PROPERTY_XSTATE_TILE_SIZE KVM_X86_CPU_PROPERTY(0xd, 18, EAX, 0, 31) #define X86_PROPERTY_XSTATE_TILE_OFFSET KVM_X86_CPU_PROPERTY(0xd, 18, EBX, 0, 31) +#define X86_PROPERTY_AMX_MAX_PALETTE_TABLES KVM_X86_CPU_PROPERTY(0x1d, 0, EAX, 0, 31) #define X86_PROPERTY_AMX_TOTAL_TILE_BYTES KVM_X86_CPU_PROPERTY(0x1d, 1, EAX, 0, 15) #define X86_PROPERTY_AMX_BYTES_PER_TILE KVM_X86_CPU_PROPERTY(0x1d, 1, EAX, 16, 31) #define X86_PROPERTY_AMX_BYTES_PER_ROW KVM_X86_CPU_PROPERTY(0x1d, 1, EBX, 0, 15) diff --git a/tools/testing/selftests/kvm/x86_64/amx_test.c b/tools/testing/selftests/kvm/x86_64/amx_test.c index 9772b9fb6a15f..ab66a51228fff 100644 --- a/tools/testing/selftests/kvm/x86_64/amx_test.c +++ b/tools/testing/selftests/kvm/x86_64/amx_test.c @@ -30,6 +30,7 @@ #define XSAVE_SIZE ((NUM_TILES * TILE_SIZE) + PAGE_SIZE) /* Tile configuration associated: */ +#define PALETTE_TABLE_INDEX 1 #define MAX_TILES 16 #define RESERVED_BYTES 14 @@ -124,6 +125,10 @@ static void check_xtile_info(void) GUEST_ASSERT(xtile.xsave_size == 8192); GUEST_ASSERT(sizeof(struct tile_data) >= xtile.xsave_size); + GUEST_ASSERT(this_cpu_has_p(X86_PROPERTY_AMX_MAX_PALETTE_TABLES)); + GUEST_ASSERT(this_cpu_property(X86_PROPERTY_AMX_MAX_PALETTE_TABLES) >= + PALETTE_TABLE_INDEX); + GUEST_ASSERT(this_cpu_has_p(X86_PROPERTY_AMX_NR_TILE_REGS)); xtile.max_names = this_cpu_property(X86_PROPERTY_AMX_NR_TILE_REGS); GUEST_ASSERT(xtile.max_names == 8); From patchwork Fri Feb 17 21:59:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Lewis X-Patchwork-Id: 13145293 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4D78C64ED6 for ; Fri, 17 Feb 2023 22:00:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229838AbjBQWAV (ORCPT ); Fri, 17 Feb 2023 17:00:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229795AbjBQWAU (ORCPT ); Fri, 17 Feb 2023 17:00:20 -0500 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8195F64B17 for ; Fri, 17 Feb 2023 14:00:19 -0800 (PST) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5366333bdb5so12519007b3.19 for ; Fri, 17 Feb 2023 14:00:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Ax1DcGoLiLxZwgQzmuNdmNdXr6vzAEjDqxAb7c6JEUk=; b=IMPJ+mcHcIXW/UTi2L5jv9YTQUPSXf986Vqjn1IQ5yFma7mqU050Jll0vTJnGuHcXO xhoDOYHUBW9ws706UrHkfzDGrctbXqNBMAVmlhTm4ZKA4HKvf98v+rQ+p21fSDanhi+j hCoLMeD1sIF0GTIQo/Iqo6sAzSVuqwimdmSRnd7kLngHl1mfJb7mdVytCFr3Dj8lGGiA zILSGb2kznAoXrApI7uAPAxDmhVkD30WxQYkMoWH95bwFZgfaPjYli1wHtree2nUX7fi Qv9R684Vu0XSoKKah+65CdIS7Ly6XA4bDiuuQBhxrSQYIbmEJzLbpjPiQ+mTh8Lbw8eO JvkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Ax1DcGoLiLxZwgQzmuNdmNdXr6vzAEjDqxAb7c6JEUk=; b=ue4Pw+oyIPowAEDzg14gCi28j0myVZ22b2v6z+8i3/QntWrKt1JbGMaL5nLg5TcKNc iAY59K36i4H55+UNj8IzkJgDNtjshmKJRpHdINriRsTLHautvVUk6eH1ASggPFqiNuaB WDvroIOtZa+dcq05ltXP1Vekai6vuHxoDUPL36FXo2cXpx64PMPVKW5x2gBUielbDiEg U7i3PLCRS3dDTFSzFy/RIQWm0ZcjxETtah9P9r3bp8hnHRWc2x3nXSqN5Tw7lDa8CZvB kY3avnu9LaMGaP659mwrWDCoEc0cEfm0x88lGV4/PMVsJrDGvRO9escP0cO5b/OMf7lB I65A== X-Gm-Message-State: AO0yUKU82rVvnrQ0uSZykFHlCO2qanS2YyxDAwO13hB/nDBcuB8UfuvR q8awUDZsCHXxIibkE/BCXa9/AbSIZi93pA0P4ANp5xaqLqkoWqL0qXvFexWRdu797EOfDDpoMMj 6ZSJbl5qwbSaCiAUbLuCAaT8ByG78Mvqb1NLAH9JNe/53qV84LQ/LHbB3/fa5vBwers5R X-Google-Smtp-Source: AK7set9eNWsRwlNHBEftQgg1CO9RzIf8fdO4PIbsnjoMB7dMzLV0R7geKgvzRBU5TecHmT3ttnS1/E2alM2rSE3y X-Received: from aaronlewis-2.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:519c]) (user=aaronlewis job=sendgmr) by 2002:a0d:e8c2:0:b0:52e:c5e0:6564 with SMTP id r185-20020a0de8c2000000b0052ec5e06564mr1119623ywe.280.1676671218760; Fri, 17 Feb 2023 14:00:18 -0800 (PST) Date: Fri, 17 Feb 2023 21:59:59 +0000 In-Reply-To: <20230217215959.1569092-1-aaronlewis@google.com> Mime-Version: 1.0 References: <20230217215959.1569092-1-aaronlewis@google.com> X-Mailer: git-send-email 2.39.2.637.g21b0678d19-goog Message-ID: <20230217215959.1569092-6-aaronlewis@google.com> Subject: [PATCH 5/5] KVM: selftests: Check that XTILEDATA supports XFD From: Aaron Lewis To: kvm@vger.kernel.org Cc: pbonzini@redhat.com, jmattson@google.com, seanjc@google.com, Aaron Lewis Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org In amx_test, add the requirement that the guest allows the xfeature, XTILEDATA, to be set in XFD. The test relies on it. Signed-off-by: Aaron Lewis --- tools/testing/selftests/kvm/include/x86_64/processor.h | 1 + tools/testing/selftests/kvm/x86_64/amx_test.c | 1 + 2 files changed, 2 insertions(+) diff --git a/tools/testing/selftests/kvm/include/x86_64/processor.h b/tools/testing/selftests/kvm/include/x86_64/processor.h index 8211b9de6e7b9..647cc6b9839d5 100644 --- a/tools/testing/selftests/kvm/include/x86_64/processor.h +++ b/tools/testing/selftests/kvm/include/x86_64/processor.h @@ -125,6 +125,7 @@ struct kvm_x86_cpu_feature { #define X86_FEATURE_XTILEDATA KVM_X86_CPU_FEATURE(0xD, 0, EAX, 18) #define X86_FEATURE_XSAVES KVM_X86_CPU_FEATURE(0xD, 1, EAX, 3) #define X86_FEATURE_XFD KVM_X86_CPU_FEATURE(0xD, 1, EAX, 4) +#define X86_FEATURE_XTILEDATA_XFD KVM_X86_CPU_FEATURE(0xD, 18, ECX, 2) /* * Extended Leafs, a.k.a. AMD defined diff --git a/tools/testing/selftests/kvm/x86_64/amx_test.c b/tools/testing/selftests/kvm/x86_64/amx_test.c index ab66a51228fff..d1a029f132d94 100644 --- a/tools/testing/selftests/kvm/x86_64/amx_test.c +++ b/tools/testing/selftests/kvm/x86_64/amx_test.c @@ -254,6 +254,7 @@ int main(int argc, char *argv[]) TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_AMX_TILE)); TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_XTILECFG)); TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_XTILEDATA)); + TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_XTILEDATA_XFD)); /* Create VM */ vm = vm_create_with_one_vcpu(&vcpu, guest_code);