Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1141588lqt; Tue, 19 Mar 2024 14:07:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWIf6gbzhTPUrSbMM688tL3ouwsrpfahqi2+D+mGdSPNc8S9KLjCkzUThpEyGyjZHlgd58fgy+tcLDjOa4TpQ1lTWdS7P4b4NuF8j8JTg== X-Google-Smtp-Source: AGHT+IECa9Q516YOpi6sW79IpFtaGDegYdR7fO6/190h7ZcNqJpSdAy1q4sGLkI64FMN+MTVnorN X-Received: by 2002:a05:620a:a8a:b0:789:d00a:c008 with SMTP id v10-20020a05620a0a8a00b00789d00ac008mr17197688qkg.50.1710882434213; Tue, 19 Mar 2024 14:07:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710882434; cv=pass; d=google.com; s=arc-20160816; b=FKwV7xG7fFcUJD2aeL/bXkCJyOnSCq8BoatAMXgeGqaXZYAE3AIcHr6IQ5RulJwZ/v 1dc1whf1CAzcSUU2SD6J8eTYFsrkZXKjaiRl+aNK2rFQ8A+b5qaqkzn2nZI5i3HdzRta 4OSP8/hwbBrnwvCycAmmQefCOdjIKjDA9I3pSKvPQAa1DSPeVDeDrFeW0s/8GTUV129u pvQ45x+ilsPayIF1We5wmkStTwHIKcmsLGsjSQgolSxECNS6C2ocKa02nTiGUA3Kg7DH NByygsv4zcIIswe4anw+ptO0Ny2h6MIu+X5B+d6D+BIAlf5vaB3Bohd+v7QWO1VprjV7 TBzg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=7qoGIHh6upwj5gPJ9J4YHu4wJ6ui1GNstsfCG9nUc0E=; fh=8hYDRJX2r5zc3yCj2s2rebNQ+wGw0IB79FfSTiKZ6CQ=; b=CWwCoJ+3nJu7PN33I/neFgeq5ypkG3mFnRgbNHHovxS2Srct7PZEqNRFi1l3hqa33F XbM1MnYjrJDbmIE4j86+Pj8Ke6aD/xnuigh5vB3887f8L2+Hzb57nX3A99DwnELK+T89 n50io7cmtZHKcRZVIsMjl3u+jm5aoArGi5FDghvD29/vvS54TJTeqLONT6c7xSNowxQ+ ozuMT4Lo0AC/69u6hiWSWeGGubAiFqHb2a8Tx0kn9Sbm0s1OehCVyM0wxdb+Ldz20cbV CuZON6XFINTwyd9rpuORut1rZsX3AlWIrFj4/HF6VabK1e27mOYkMsuxa97O3XH7RQYw MuXA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VDJCz5Ty; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-108137-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108137-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id wl3-20020a05620a57c300b00789ed75b223si8138806qkn.186.2024.03.19.14.07.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 14:07:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-108137-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VDJCz5Ty; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-108137-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108137-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id D9E2E1C21F1E for ; Tue, 19 Mar 2024 21:07:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 16F633F9D4; Tue, 19 Mar 2024 21:07:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="VDJCz5Ty" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A395E3CF58 for ; Tue, 19 Mar 2024 21:06:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710882421; cv=none; b=i1NG7x+vwyTiXXCS1ZH4Zoy68O/EZy2Re5P6xhySQDoXrhYdmEh0Cl5cSJ9OLtUQ6zsiSJfneZeYOrnthBpgErM8JgZH1GpczdHzvldxgGw5w0hwswlE1jBEl+vd+4bjNw8WFakkuOy9OjZ6JMiM6bSY6DbV4WflGhXFuC6QmCs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710882421; c=relaxed/simple; bh=p3CVVv7j8KqfxO3Oc3YIg4XiUxGaF43J1xHbfkpZWUY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=NCeBV5yxVrrtdlBVsbokl/k8Fr76n5tG8nBX1rhGbfRN/tUyakTWI3vVVYC8s3v4a506sPOzUATcLxuZNyAgki/FLs76qL2OOkjJSdm7HrPn2w1RMisxhcC4/l1y2oFTshi8enoR66k9CHXjapEUbtFlJahT0RiFa/Io7wP8eyE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=VDJCz5Ty; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710882417; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7qoGIHh6upwj5gPJ9J4YHu4wJ6ui1GNstsfCG9nUc0E=; b=VDJCz5Tynnr2Xh5kNuxMOSfalhvGJ3W3kd5n4gg5Km3HBNVuxmUL9xCIZbL3RNK2wd18hh eZioHpnHA9BfGYTcuxW3RbiFRFOIOKmxtcBe4CErce+MvpXFtM6mxgbPsCKzQRzafC/utK Pq2q+vQktK8NzqN5H7X8KGg5dkRas/g= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-686-cfOe8Z7OPsiA2tjnBTTAUA-1; Tue, 19 Mar 2024 17:06:56 -0400 X-MC-Unique: cfOe8Z7OPsiA2tjnBTTAUA-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-41407fd718dso19869765e9.1 for ; Tue, 19 Mar 2024 14:06:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710882415; x=1711487215; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7qoGIHh6upwj5gPJ9J4YHu4wJ6ui1GNstsfCG9nUc0E=; b=JPfOVacx2OiVPTuQLB1jq8V8jjzCL8JrFPQv1VqC0cNVW702mHDtiDdB3MM0ZLndgM MnfIDppMR2wQSeC+X955x1tamiXB8dX/i2mTuDOd1PHLCiWFAArJGLOJEbxhJ6AM3tI/ Ja7GsXuSzLgEKLpZV3vTckWeQlU8+GQp5Eis7iVmgBbPy93siJPbNfdCv9ekkhajfrvY QB+R0AOofIn2yiaekwGSNXuZZXzkHD6Q8S0wlNt0yaxcsJTPIH2jAZEJyvvanY6iP3oG nlvb29QIweRRc8F/JPnNCqQJdSwcSvtuhnEEeenEPDRb6Yhzyi5rDyAB/hQo0RWTBD/j mFDg== X-Forwarded-Encrypted: i=1; AJvYcCV0m0t3pVJUGct9jOYRCmVlbUbx1eL9z18bqGma1Kth+4FpxNUP1FaHPBGhhh2r13EVikLi0w6Aa8NBe1VAri2kffbnqc61KvqJiL8f X-Gm-Message-State: AOJu0YzmW8T6WCjoOiYPFHyGY3icdZH64t9JnjK1+12zdI9ND6YWV76A vJ+JM6tTKUKOSDjHmKrv1g/W23LVaTibFqxtL32DUMUuKgfF6kBjyy7KPdC+L/PaCa0RzeLwiFU KgXdtdjkFqZsQ7fvyV4bb35Fv4HyP/sM0wY+feO3Apqfsvn6lnhfN2fT6dTpvBw== X-Received: by 2002:a05:6000:18c5:b0:33e:d865:422 with SMTP id w5-20020a05600018c500b0033ed8650422mr2390560wrq.29.1710882414865; Tue, 19 Mar 2024 14:06:54 -0700 (PDT) X-Received: by 2002:a05:6000:18c5:b0:33e:d865:422 with SMTP id w5-20020a05600018c500b0033ed8650422mr2390545wrq.29.1710882414365; Tue, 19 Mar 2024 14:06:54 -0700 (PDT) Received: from ?IPV6:2a01:e0a:59e:9d80:527b:9dff:feef:3874? ([2a01:e0a:59e:9d80:527b:9dff:feef:3874]) by smtp.gmail.com with ESMTPSA id n8-20020a5d6608000000b0033e45930f35sm13213779wru.6.2024.03.19.14.06.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 19 Mar 2024 14:06:53 -0700 (PDT) Message-ID: Date: Tue, 19 Mar 2024 22:06:50 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 3/3] KVM: selftests: aarch64: Add invalid filter test in pmu_event_filter_test Content-Language: en-US To: Shaoqin Huang , Oliver Upton , Marc Zyngier , kvmarm@lists.linux.dev Cc: James Morse , Suzuki K Poulose , Zenghui Yu , Paolo Bonzini , Shuah Khan , linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org References: <20240229065625.114207-1-shahuang@redhat.com> <20240229065625.114207-4-shahuang@redhat.com> From: Eric Auger In-Reply-To: <20240229065625.114207-4-shahuang@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 2/29/24 07:56, Shaoqin Huang wrote: > Add the invalid filter test which sets the filter beyond the event > space and sets the invalid action to double check if the > KVM_ARM_VCPU_PMU_V3_FILTER will return the expected error. > > Signed-off-by: Shaoqin Huang > --- > .../kvm/aarch64/pmu_event_filter_test.c | 38 +++++++++++++++++++ > 1 file changed, 38 insertions(+) > > diff --git a/tools/testing/selftests/kvm/aarch64/pmu_event_filter_test.c b/tools/testing/selftests/kvm/aarch64/pmu_event_filter_test.c > index 2dd8ea418f47..86714345ee97 100644 > --- a/tools/testing/selftests/kvm/aarch64/pmu_event_filter_test.c > +++ b/tools/testing/selftests/kvm/aarch64/pmu_event_filter_test.c > @@ -8,6 +8,7 @@ > * This test checks if the guest only see the limited pmu event that userspace > * sets, if the guest can use those events which user allow, and if the guest > * can't use those events which user deny. > + * It also checks that setting invalid filter ranges return the expected error. > * This test runs only when KVM_CAP_ARM_PMU_V3, KVM_ARM_VCPU_PMU_V3_FILTER > * is supported on the host. > */ > @@ -262,6 +263,41 @@ static void run_tests(void) > run_test(t); > } > > +static void test_invalid_filter(void) > +{ > + struct kvm_pmu_event_filter invalid; > + int ret; > + > + pr_info("Test: test_invalid_filter\n"); > + > + memset(&vpmu_vm, 0, sizeof(vpmu_vm)); > + > + vpmu_vm.vm = vm_create(1); > + vpmu_vm.vcpu = vm_vcpu_add_with_vpmu(vpmu_vm.vm, 0, guest_code); > + vpmu_vm.gic_fd = vgic_v3_setup(vpmu_vm.vm, 1, 64, > + GICD_BASE_GPA, GICR_BASE_GPA); > + __TEST_REQUIRE(vpmu_vm.gic_fd >= 0, > + "Failed to create vgic-v3, skipping"); > + > + /* The max event number is (1 << 16), set a range largeer than it. */the event space is 16b on ARMv8.1 and 10b on ARMv8.0, set a range larger than 16 s/largeer/larger > + invalid = __DEFINE_FILTER(BIT(15), BIT(15) + 1, 0); > + ret = __kvm_device_attr_set(vpmu_vm.vcpu->fd, KVM_ARM_VCPU_PMU_V3_CTRL, > + KVM_ARM_VCPU_PMU_V3_FILTER, &invalid); > + TEST_ASSERT(ret && errno == EINVAL, "Set Invalid filter range " > + "ret = %d, errno = %d (expected ret = -1, errno = EINVAL)", > + ret, errno); > + > + /* Set the Invalid action. */ s/the/an > + invalid = __DEFINE_FILTER(0, 1, 3); > + ret = __kvm_device_attr_set(vpmu_vm.vcpu->fd, KVM_ARM_VCPU_PMU_V3_CTRL, > + KVM_ARM_VCPU_PMU_V3_FILTER, &invalid); > + TEST_ASSERT(ret && errno == EINVAL, "Set Invalid filter action " > + "ret = %d, errno = %d (expected ret = -1, errno = EINVAL)", > + ret, errno); > + > + destroy_vpmu_vm(); > +} > + > static bool kvm_pmu_support_events(void) > { > create_vpmu_vm(guest_get_pmceid); > @@ -284,4 +320,6 @@ int main(void) > TEST_REQUIRE(kvm_pmu_support_events()); > > run_tests(); > + > + test_invalid_filter(); > } Besides Reviewed-by: Eric Auger Eric