Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp353435rwd; Wed, 24 May 2023 19:50:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4w4GS4IJc9maXUtSlb+OoXvE4puIwrQcsDfRJpezer+zDgDUrH4DtKmyT5NNl0Qr5S4BJJ X-Received: by 2002:a05:6a21:3293:b0:10b:9dc1:c5e5 with SMTP id yt19-20020a056a21329300b0010b9dc1c5e5mr14872732pzb.34.1684983042983; Wed, 24 May 2023 19:50:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684983042; cv=none; d=google.com; s=arc-20160816; b=og/TZZVBbAn556M3llRNUVudzl7w3DuF0PWpRQWiUGrkmBc2lUj0wCkNo4wWNqWewT ufN2pjaCYbPes6Wq99fbheYps5TyzmZo4yrcD4L/qL1RFuTxdTgOTN4apIShfdwl4TMW ZSHKJMifkddYN8ic9VIEAgSCcEpibzAyP1A2jPsW47De7rQr3vjjcnQXjUXEJ2ro1wD1 fduOo/dVfN9z1KiEM90Gb4AdEtgmDJBhhwRfJbSpWZopp9WZN+WsQwtrKD9vEoATRgnI FMarrtbZHZCkRg7zKgsgd8Hi32ik2G5VS8KbnKBJFfVsT8p5YshCphECVmexHw7mMrJA sn+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=S52oQA0/VeO5+jyq6l06Dvqhz2AgZ7EQ+KLBmziYDnM=; b=o2rVzyzV6Qm5N1zg5ElcmJXKw8tWFHaUoe9NktR10rhYqRVRWdSUrJSFgCB8LbAOMb q4Dy0dhwk+WhhTW2+ZFLVQm97B4qgryQTXfv5cu5AO8CK/J18FXCGDbHm7FaBVL4FaIT 1IJcuQCB1CJ3CSQTNPxRcLXK40vdjciDXhos+0zELbxv2W85DZR3UYtYczBhDyQnkYzX 1Uua3HyBAccG5V57OFnP1hTd7f10+FoDjcYV8FOQ1Pr4GVFBGniBfUhaF509ZR856OkB jWoJLDgZJ7pwq9GUYtSqTO/Fzhw/B3JTqViYsHd4+IUeDXtUjV7amiYGlgOg/KqRgXWp 0pvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=Fzva5FWV; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s1-20020a637701000000b0053ef05fcf1esi72931pgc.35.2023.05.24.19.50.29; Wed, 24 May 2023 19:50:42 -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=@gmail.com header.s=20221208 header.b=Fzva5FWV; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233048AbjEYCUB (ORCPT + 99 others); Wed, 24 May 2023 22:20:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237551AbjEYCT6 (ORCPT ); Wed, 24 May 2023 22:19:58 -0400 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 569A112E; Wed, 24 May 2023 19:19:57 -0700 (PDT) Received: by mail-ej1-x642.google.com with SMTP id a640c23a62f3a-96f7bf3cf9eso9037266b.0; Wed, 24 May 2023 19:19:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684981196; x=1687573196; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=S52oQA0/VeO5+jyq6l06Dvqhz2AgZ7EQ+KLBmziYDnM=; b=Fzva5FWVqV/5xC30wA4lZUgXN9VgTPyU6CQ26eRLuSjH1YI5JJZC+5cu5BTbuAOsYp 3BJ96JISVhpgwQDkT7WDf8xvGVcfwskKILfV/xGolHelLuERNyIRTn+Kp95wT5Ihp5yP 6t6uY6MUdalUBM5VYqm+0cblXix9FwkIG8TqrPITAPMIcfqQGHly4ueQvlyG5tpqDpz3 Suc2h/8cyiPmp8WHhwqfyeD0VxCyv5TZ0fFC846O1Yl1cmIf9rHCiTACZLvOMO8XfJW8 lmfZI9CNlEHaMqsOA6Q5YrjzW7r+3U8EJN9CZ8Qu6xbL+5iP18dwrdrq7r4ZqFdmm4J2 /4zA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684981196; x=1687573196; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=S52oQA0/VeO5+jyq6l06Dvqhz2AgZ7EQ+KLBmziYDnM=; b=M+vmHsSyRYvqeVKIkG4Ccg4dimEngzsc9r1iKIne3bFBqznG5BjXzqCuMweDHbjiRB 9cYcGcIeX+eibIeRhYTQN6h/pbTnSePxAQoR24kf3lB+3ac6iuzC4NWFa/44zzlCne1B giguUitWQ3ImwBOZo/UmgaHzmJF3WAKyllzoLZLnxo7rRiVo78vXQRLl1/HvT0WOYSH8 COc9z1fHswKK9moHqmYtB6RQO4UTg7Ld+6s3CowE4aCvuB0/uASfhzgJfnguPIi0dR/s Mspp+1HW9Ecz58BXx2M3JEkdmYLiIRmGImwNfbsOLixSaUQOZO+Jf4zSIsX9ILmRkQz4 h8Jg== X-Gm-Message-State: AC+VfDyRmJ4GxP3p2F0fWTa6BDIubcTRujXxNXT2NH1+pFuyoLwozNpv GYkecdrN03IISLCik/RWsE5QJfyDTsubLK4r11o= X-Received: by 2002:a17:906:6a0f:b0:969:e88a:6071 with SMTP id qw15-20020a1709066a0f00b00969e88a6071mr38037ejc.61.1684981195615; Wed, 24 May 2023 19:19:55 -0700 (PDT) MIME-Version: 1.0 References: <20230420104622.12504-1-ljrcore@126.com> <20230420104622.12504-8-ljrcore@126.com> In-Reply-To: From: Jinrong Liang Date: Thu, 25 May 2023 10:19:44 +0800 Message-ID: Subject: Re: [PATCH v2 7/7] KVM: selftests: Test pmu event filter with incompatible kvm_pmu_event_filter To: Sean Christopherson Cc: Like Xu , Paolo Bonzini , Jonathan Corbet , Shuah Khan , Aaron Lewis , David Matlack , Vishal Annapurve , Wanpeng Li , Bagas Sanjaya , Jinrong Liang , linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Sean Christopherson =E4=BA=8E2023=E5=B9=B45=E6=9C=8825= =E6=97=A5=E5=91=A8=E5=9B=9B 07:50=E5=86=99=E9=81=93=EF=BC=9A > > On Thu, Apr 20, 2023, Jinrong Liang wrote: > > From: Jinrong Liang > > > > From: Jinrong Liang > > > > Add test to verify the behavior of the pmu event filter when an > > incomplete kvm_pmu_event_filter structure is used. By running the > > test, we can ensure that the pmu event filter correctly handles > > incomplete structures and does not allow events to be counted when > > they should not be. > > > > Signed-off-by: Jinrong Liang > > --- > > .../kvm/x86_64/pmu_event_filter_test.c | 23 +++++++++++++++++++ > > 1 file changed, 23 insertions(+) > > > > diff --git a/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c= b/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c > > index 9be4c6f8fb7e..a6b6e0d086ae 100644 > > --- a/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c > > +++ b/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c > > @@ -881,6 +881,24 @@ static bool fixed_ctr_is_allowed(uint8_t idx, uint= 32_t action, uint32_t bitmap) > > (action =3D=3D KVM_PMU_EVENT_DENY && !(bitmap & BIT_ULL(i= dx))); > > } > > > > +struct incompatible_pmu_event_filter { > > + __u32 action; > > + __u32 nevents; > > + __u32 fixed_counter_bitmap; > > +}; > > + > > +static uint64_t test_incompatible_filter(struct kvm_vcpu *vcpu, uint32= _t action, > > + uint32_t bitmap) > > +{ > > + struct incompatible_pmu_event_filter err_f; > > + > > + err_f.action =3D action; > > + err_f.fixed_counter_bitmap =3D bitmap; > > + ioctl((vcpu->vm)->fd, KVM_SET_PMU_EVENT_FILTER, &err_f.action); > > This is completely busted. It "passes" by luck, not because it's a valid= test. > The size of the argument is embedded in the IOCTL number itself, which me= ans that > unless glibc is being very nice and using a macro + typeof + sizeof to sa= nity check > things, which I highly doubt is the case, this ioctl() is passing random = stack data, > a.k.a. garbage, to KVM. > > In short, drop this patch. Thank you for letting us know about the issues with the patch. I will drop the patch as suggested. Would you advise me to prepare version 3 to remove this patch?