From patchwork Fri Feb 10 00:31:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 55167 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp662558wrn; Thu, 9 Feb 2023 16:38:36 -0800 (PST) X-Google-Smtp-Source: AK7set9Cgb1D8ssm0owaGzS0B88xcvFUSIThWg6pHLOKU5CJBBwAix9U4G1jzQS0veik8wxwWxDQ X-Received: by 2002:a50:a6d7:0:b0:4ab:255d:a48 with SMTP id f23-20020a50a6d7000000b004ab255d0a48mr2607586edc.36.1675989515907; Thu, 09 Feb 2023 16:38:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675989515; cv=none; d=google.com; s=arc-20160816; b=Zjn22zKPjXwcai/qoi43zPeoee7ZPm7/wIGqc15R/isQDaJfQVJOJelVflBoulSsMF QZi+JwnQvjzbOgpmNZqKitH863aNed870l3AbhX9oeQ3L7W5arwcGpJbrwarteKNlGG4 zLRxkVTT0SX1nrWHLBy6QfPILLHs3J3sUwptmZl2WoqqoTvXPDA7hd1itl9C6e3G1Qco 3kLfe00y/IVIew7VsgfMr9JQ/4J97fxdoZmPOqNR6wpRTCYOOCev9QyDdmTHu4XrYz0q kIQP0WrQgfZrGBB+G19MIkaN/kuZgo6+uKuawrVhQFeWbOClKIyeG7oYZToMKQSGCZJD 6ZLQ== 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=zEtJJXP/d2l8cjo3sRdPdCH/uW1qOGz7yYT36ga6XYA=; b=bQ/+97Ivo04/KO2wBW1Unow44VtHOSAAYcETUbUcznIGzcqnLV/b+Lor3NyrsdkjmH R3FnfeV/YXoReZTqfKnEBkfP9YHnuSsri+71M24VGFEtX9epwMny/izmY/u/2Wa0Buz5 r8JMCZBo8lLnXflouNhgaTBeTLKhJZxY6TSN6Eh/+bsikfnyfZizEvu5FphtgB//LOKm i8dncAtsNYagpO8HrrPXnQ7DmUDLJS8XbIDe1Zqcn3KwtSMElH7q1rQh5i84BDQDCVGp 0S/XGSmBSys7VPL71EXlukB2CwaAsuzMoLoa0X+kE5RQvKzNEJf7BukBKc9ffbplffuN X7xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=OIn25dnG; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a26-20020aa7d75a000000b004aaddb8cd93si3930621eds.71.2023.02.09.16.38.12; Thu, 09 Feb 2023 16:38:35 -0800 (PST) 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=20210112 header.b=OIn25dnG; 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 S230474AbjBJAeR (ORCPT + 99 others); Thu, 9 Feb 2023 19:34:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230140AbjBJAdc (ORCPT ); Thu, 9 Feb 2023 19:33:32 -0500 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C2A570960 for ; Thu, 9 Feb 2023 16:32:45 -0800 (PST) Received: by mail-pj1-x104a.google.com with SMTP id l18-20020a17090add9200b00230f60889d6so1595704pjv.3 for ; Thu, 09 Feb 2023 16:32:45 -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:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=zEtJJXP/d2l8cjo3sRdPdCH/uW1qOGz7yYT36ga6XYA=; b=OIn25dnGFHK3/GsuBf+shRFLsxjVK3A7daMICpgIh6b1/dOcT0jb4kv+ccWY8XrZYW Sh4A5EYfXrqr054hEP0OLCQX1e4XV3tdYGdgi0LcQkkd32Lf9sLdc999ImHUh4Wx9SVy 97ZQ+gMw31UrvhT8Gzbrh2YgeNsxWrp5IWX3SDN+xomuh/7zQp3uUeuVnOzqlB2mftKs UIVT6kpcyNPBKO4dyxWeeQJ20PSw2X2W9oroWk3uKEC2ceVgxgZ3n0/QTS2wZsta3Pf4 LGtUx/enKWsPMrgI5Qlt+FI7kYZmN6+1+E1fniNFKY148RvTdb6HJAI040rD//yjvXiJ 3PAA== 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:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=zEtJJXP/d2l8cjo3sRdPdCH/uW1qOGz7yYT36ga6XYA=; b=owN4jxAlzx/WaxUE+h9dYAa3dBfKZ/A8pnhaJ1f6ZHZh22QAE6BZp3i59MZTeo0mT3 X7qGcSFPdn2GQuod4H+PIFuV11LqZ9yafblGpWydg6RyJsIibkFAqm3+J8QoKlOr+O+z RsHUGkEOhDnd2WH1DyXXEdyzV9JwptjyyijUlmylk9y7Y5Op6RZTemv4JFCxy50mSGeF wT8G1Cb8WYgK/Auy+wp9OW5xpnlvfDb3lX/sp61LJl6AFquei1imiS3DKLca9Oj76kH0 tLJoJQQjW4k1eAoczoHARqL8O91RofQlWzKW7MD/YcRqzQTqbz4huf6zk1/m4X3hv/wd QZ7w== X-Gm-Message-State: AO0yUKVDPhJeq+DTcWHoPAqufAr4EVrgWh5DQRzLc3x07XSnxG5RsH31 DFGP1TjtdmUPWOkACwD6F0PwSscxoSM= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:aa7:9a09:0:b0:593:8deb:820a with SMTP id w9-20020aa79a09000000b005938deb820amr2872910pfj.53.1675989144638; Thu, 09 Feb 2023 16:32:24 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 10 Feb 2023 00:31:47 +0000 In-Reply-To: <20230210003148.2646712-1-seanjc@google.com> Mime-Version: 1.0 References: <20230210003148.2646712-1-seanjc@google.com> X-Mailer: git-send-email 2.39.1.581.gbfd45094c4-goog Message-ID: <20230210003148.2646712-21-seanjc@google.com> Subject: [PATCH v2 20/21] KVM: selftests: Add negative testcase for PEBS format in PERF_CAPABILITIES From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Xiaoyao Li , Like Xu 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,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757402382573638036?= X-GMAIL-MSGID: =?utf-8?q?1757402382573638036?= Expand the immutable features sub-test for PERF_CAPABILITIES to verify KVM rejects any attempt to use a PEBS format other than the host's. Signed-off-by: Sean Christopherson --- tools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 38aec88d733b..29aaa0419294 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 @@ -191,6 +191,16 @@ static void test_immutable_perf_capabilities(union perf_capabilities host_cap) val.lbr_format, host_cap.lbr_format); } + /* Ditto for the PEBS format. */ + for (val.pebs_format = 1; val.pebs_format; val.pebs_format++) { + if (val.pebs_format == host_cap.pebs_format) + continue; + + r = _vcpu_set_msr(vcpu, MSR_IA32_PERF_CAPABILITIES, val.capabilities); + TEST_ASSERT(!r, "Bad PEBS FMT = 0x%x didn't fail, host = 0x%x", + val.pebs_format, host_cap.pebs_format); + } + kvm_vm_free(vm); }