Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp639374rdb; Thu, 15 Feb 2024 10:31:35 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVLxnVs+2zCRch3rAWET4l/H6fChIDOLu2i0GzB8wqM7t9rZrP+mSRL20XNIuFJq48qxqyJueejFSjqGXgb0ZirK4TzIWfYg/1nAGsldg== X-Google-Smtp-Source: AGHT+IHF0DHvxTpr2o+euEBNQY+prPo4BsI28khjU2lTHLHPDD93PTzG3dmXck0oBg80AvM1IU2Q X-Received: by 2002:a0c:e454:0:b0:68c:4a73:a82b with SMTP id d20-20020a0ce454000000b0068c4a73a82bmr2441936qvm.43.1708021895383; Thu, 15 Feb 2024 10:31:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708021895; cv=pass; d=google.com; s=arc-20160816; b=r+myG+W+474hzNJLKF/JNz4/b8Qgqst5P+eYvBfcc0vzOiAvh/ewvsITFP8+rNuvGL 44970Kobl/wJP+5gD6zaJYd5LpVTYbt75RBg6gro4UcYd1VmFgr0FefG/89dGRFhsFgv USLui0mazRantqfT7evJwsDu5pSy7C4YLPBIqCqyP64NS6qp07suHGMRCFR9GHQUz2VM yTDZS1kOybRM1ZcdYgRrHH6Z7dNGIiTqPXTYfPnIQDKZzsRMe5avrV+/podUhngsM8g8 T13KID700DT9vN2ONSMPN0pjqQjVVruv9BfEBsYjtAT97Wv7HJ/W+zZtM9dfzqOdKPwV VXwA== 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=5rcuei6vVHQzEyNnihSudUV2QF1nleva1UrlbPjP+8U=; fh=oMpe5Zz3SCblVCNYj1b1G+aH840Dwpf7Bd4bOfofgS0=; b=u+rggKSVsYWgXUVCRqDdfZ6sv8PNpvlcCbiiPIIwj8Ej2GAjPIRi4KuTkM9rrurYiB +KkeY1h5vS/ftvAB1h6IC+6SYr4m1+f7rGtGnkH518XiBnCuM2Li3/2eGvx/i6Fm4maZ 231zPa1B2GeU1cAdHbTZHvu0BMoQT0Y5mJU7O8SMR4qJv9mA7DY4UXC/QxVJDtgPEWps 268tdjyVU4SgUB5W85H0SVWnvd+cW7qXtgIeBbW+CXz+rMpdcQCuoqVS9As9o8h9TZbC ZMTe/oxoY+t/kfg3Bw4erwV9JxkYJrsTWBoTxNUqBCmuS+IbM9QysbkjPXGL+adyHw67 1qzA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YH4PhfY9; 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-67506-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67506-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 eo3-20020ad45943000000b0068f2eb1e4a9si228952qvb.236.2024.02.15.10.31.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 10:31:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67506-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=YH4PhfY9; 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-67506-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67506-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 17A101C220E9 for ; Thu, 15 Feb 2024 18:31:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 38E191386BF; Thu, 15 Feb 2024 18:27:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="YH4PhfY9" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 6150F1386C4 for ; Thu, 15 Feb 2024 18:27:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708021651; cv=none; b=TJLq9DmcuWSZ/czxa8WAyk3BwMhZWhxc69JTKRBpse1/vM9H3GzqnvewOHzx4bLIMlEUyOAMExwEM5UiK07szGRRD/rvq5wQQq4eJopxiNegImmE/weFGSF3DnWDToKDHbhHcuQotspBhGEcP+AzRMgDsz1rw5YGfSaCHF76F4g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708021651; c=relaxed/simple; bh=2wCnvjkhvn5BKoVcdNdw7iQW17hpGsSpN4YYTCOKtus=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=cCjoWDcqYPLyAaaUKmGG8etqDWXENaoqd5WAYmDMGbNfGNlz5qG5AnVfPYbJSVjnl+gQVDeFlf5HeF6/u7vo66oiHGKRic7YyaknAHQqKEAr+Q55V8CVwN7v6ga4n9+aee5TNL5B1jHb1F5JsCcJMoJJooNiYHNRRAXmtECkoOc= 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=YH4PhfY9; arc=none smtp.client-ip=170.10.129.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=1708021646; 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=5rcuei6vVHQzEyNnihSudUV2QF1nleva1UrlbPjP+8U=; b=YH4PhfY9hnjyophTCH+oPPxrmHCjBS+U+PO+g15wFlxQDwHSzwLA4bm20+giq3hVMzKpfm qabzGeuf6RiYyDCmyRnJiH71lgkYLU4+Yj/GFlKWVAZr6iV02zuYyCtT7qiCzmlJPSL/BW iCA9qfx/zRBlOrFIs/ApCsissBqoW2Q= Received: from mail-oi1-f200.google.com (mail-oi1-f200.google.com [209.85.167.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-627-kkZf-YuxPDuqXdVo2Gnz0w-1; Thu, 15 Feb 2024 13:27:25 -0500 X-MC-Unique: kkZf-YuxPDuqXdVo2Gnz0w-1 Received: by mail-oi1-f200.google.com with SMTP id 5614622812f47-3c045f4a135so1533442b6e.3 for ; Thu, 15 Feb 2024 10:27:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708021645; x=1708626445; 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=5rcuei6vVHQzEyNnihSudUV2QF1nleva1UrlbPjP+8U=; b=dQSlay4axgVP2TNJMf1Eloj2qwEKcUVu40SyncLpye5hZ6mqXmjCaHNSbsWZCzNC0m M7MrqO32w0s/Mfb4ucQRwjD24gHKFiwdwWcVALk+6U7iwdyB/0TIINNcJAMsuBH1XyLh /ZFtFo6K/BNPzAAP8rhoI2EQb/WnW2MYTnWTPjaV09Tru+ES9oojxjlUg3C/igb47qUE 7NzVeKjMZovpRIJ+NZ1e2GjwRRK6YqJP14FOE80DH8Cdj4mZpIUSUbaiWZOOpeEjh/74 UtdBUK/F77IRXGUuB0+6pFPPRqZz+5gqoU5Aq7DOllrcJuCHz7lWL7yvlrjMQU5yMxjx 0xLg== X-Forwarded-Encrypted: i=1; AJvYcCVBRoiEu3TkwqN3kpY4hRk8mSUL7Hjn/LILnEIKPE91bD+op40sSPTiIrxnOYB/E/aMkLoKV+VXgVAKwgAGssx+a88acUarfBbcvtWZ X-Gm-Message-State: AOJu0YyAOrjTAWv+OotZWMlXLxNJBj/vRhDrIi/C1Je7iw5jODJXMx4n H/IoQr8/MW8/6ase4GSoDbTkpOVmtY/wgpoFX5pVLyO5LTZGqOrVl87+uQIZ1p5aoOE2N1pXsyD FdGTtzCHUH/mZuoZtVhD7LKQKHK1Rv7NyLLp9St5vI+EkBTgPVrXbZWgULvopTw== X-Received: by 2002:aca:1204:0:b0:3c0:4056:a2ed with SMTP id 4-20020aca1204000000b003c04056a2edmr2420207ois.52.1708021644919; Thu, 15 Feb 2024 10:27:24 -0800 (PST) X-Received: by 2002:aca:1204:0:b0:3c0:4056:a2ed with SMTP id 4-20020aca1204000000b003c04056a2edmr2420190ois.52.1708021644653; Thu, 15 Feb 2024 10:27:24 -0800 (PST) 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 q15-20020a05622a030f00b0042c7f028606sm795543qtw.32.2024.02.15.10.27.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 15 Feb 2024 10:27:24 -0800 (PST) Message-ID: <94ae4343-487a-4782-8b15-6f1201eed882@redhat.com> Date: Thu, 15 Feb 2024 19:27:20 +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 v4 5/5] 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: <20240202025659.5065-1-shahuang@redhat.com> <20240202025659.5065-6-shahuang@redhat.com> From: Eric Auger In-Reply-To: <20240202025659.5065-6-shahuang@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi Shaoqin, On 2/2/24 03:56, Shaoqin Huang wrote: > Add the invalid filter test includes sets the filter beyond the event s/includes/which > 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 | 36 +++++++++++++++++++ > 1 file changed, 36 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 d280382f362f..68e1f2003312 100644 > --- a/tools/testing/selftests/kvm/aarch64/pmu_event_filter_test.c > +++ b/tools/testing/selftests/kvm/aarch64/pmu_event_filter_test.c > @@ -7,6 +7,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. > */ > @@ -183,6 +184,39 @@ static void for_each_test(void) > run_test(t); > } > > +static void set_invalid_filter(struct vpmu_vm *vm, void *arg) > +{ > + struct kvm_pmu_event_filter invalid; > + struct kvm_device_attr attr = { > + .group = KVM_ARM_VCPU_PMU_V3_CTRL, > + .attr = KVM_ARM_VCPU_PMU_V3_FILTER, > + .addr = (uint64_t)&invalid, > + }; > + int ret = 0; > + > + /* The max event number is (1 << 16), set a range largeer than it. */ in practice it is 16b on ARMv8.1 and 10b on ARMv8.0 but obvioulsy the check below works for both ;-) larger typ > + invalid = __DEFINE_FILTER(BIT(15), BIT(15)+1, 0); space between "+" > + ret = __vcpu_ioctl(vm->vcpu, KVM_SET_DEVICE_ATTR, &attr); kvm_device_attr_set() as commented by Oliver > + TEST_ASSERT(ret && errno == EINVAL, "Set Invalid filter range " > + "ret = %d, errno = %d (expected ret = -1, errno = EINVAL)", > + ret, errno); > + > + ret = 0; > + > + /* Set the Invalid action. */ > + invalid = __DEFINE_FILTER(0, 1, 3); > + ret = __vcpu_ioctl(vm->vcpu, KVM_SET_DEVICE_ATTR, &attr); > + TEST_ASSERT(ret && errno == EINVAL, "Set Invalid filter action " > + "ret = %d, errno = %d (expected ret = -1, errno = EINVAL)", > + ret, errno); > +} > + > +static void test_invalid_filter(void) > +{ > + vpmu_vm = __create_vpmu_vm(guest_code, set_invalid_filter, NULL); > + destroy_vpmu_vm(vpmu_vm); > +} > + > static bool kvm_supports_pmu_event_filter(void) > { > int r; > @@ -216,4 +250,6 @@ int main(void) > TEST_REQUIRE(host_pmu_supports_events()); > > for_each_test(); > + > + test_invalid_filter(); > } Thanks Eric