From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 09D64C433EF for ; Thu, 27 Jan 2022 04:18:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=CXOqHbty428TQzG9MbqB2Oyp9RKx82ySUSBH6bOrpzU=; b=20lSQvr14YCQUn GBoDlMfXiBKbEmXLsVxY9OlhTO062hkCguvymnO9mv5JTDttVy/KaIMq4SvPWM2IDl1Sjaj0sBg4s XBGwl3IpQzI+yuFgwnaMrlhdmekF1OLAPqmaQdrEfOs2LPQysFZbovbtJwgAXxzAeNDqpzlW8aGID xU5bdPGkOSYHMM8zVm/7N+Aq9dQL08oQEKvCXVCKHSOVKAXLI7SMTT2lYNdGq/2SCrMIocTGOkXF4 YtuA8Q8pAwaAo3ywB0nV4uQSwGYFjMRScBMK6TJ0fM8eZ9hCqFdXUSL7NXHdHjXpT6SwdTuGy7yHz JLtcge/98z8F2hjm+9pQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nCwDi-00EKiO-SB; Thu, 27 Jan 2022 04:17:15 +0000 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nCwDb-00EKhw-Tv for linux-arm-kernel@lists.infradead.org; Thu, 27 Jan 2022 04:17:13 +0000 Received: by mail-pj1-x1035.google.com with SMTP id b1-20020a17090a990100b001b14bd47532so1708935pjp.0 for ; Wed, 26 Jan 2022 20:17:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=MlI851lUoHdmSjJoGiyp5I4kiqlKaCdV4NPdXhxRA+8=; b=C8VvuZFe4rCP2uCFSONmb99RN1LdQn529TOYmrpKoK7PYZcziPiAhrOW11oPx+kR43 opz70CnPxzxoZTYSSVhdERYlJMV8TdO2QuyuvwmFnkgUYxlX3/+xpOKrqI+Z+SedE8V0 b2zhdCzpSnUjJajZlBYXB+FSVxcFj2HkqHfh92IhUWwU9i3Q4biweQtzgZksk14c+YiH 52bQWQ89Jcu87pb3B4VxHhWSQojQZDN4MzrgykfnIRP/6lSrZxJ1K92QfFOGFIVPjDYw 3UM41Q/sdGDYKwy0SqhzCI9wShehVrMqDwPAZ1e+aIL1TRmW3bpwLdmcoEgNXDTVMahN 1OPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=MlI851lUoHdmSjJoGiyp5I4kiqlKaCdV4NPdXhxRA+8=; b=VtZUSxqlsVWOMUhhH1YpENJjaPBKpyy1QAz+QKoZn0yvm4qdSmhFM9+JEyZp4S3ro2 6H+3j4umcWhGBit97RypyFmFpzFPCUZF2oQlrLwiL6ezLvXcVcwkZUOHIyFs2hFA9CyS KFgZ1FlIqVC6iEmiSuWjvx96KG938186wWnmfl+2F//3lHW5AW0kwiO8aNkOmfFpzvd/ CRZ0gs8SFvTi04YKBFUzNnv2P4/kTjUOWQhorT4FbpQcS4IwYBAa1irNf3UFDheER8Eo 6EHUSJoJZ8eGyTcrxVt5ngvJXN5+4RUfhVlfO4KT4LuZWX/Iogbu91RNwclUTTKCIMaW Ii7g== X-Gm-Message-State: AOAM530N05o3OnJgKb15YSsUH2SDZ47xgWpcVsHcUZRaYIdBOmBTf8oh qwRDusQfvJEsnUfc861x4oHRug== X-Google-Smtp-Source: ABdhPJzz3u8vPsKiH9OPkvGE3abpQ/af8KLmu4FJ0c7+83/vDdWzlReCnpAVhOP8ndMIaORK9xGeGg== X-Received: by 2002:a17:902:f083:: with SMTP id p3mr2247927pla.72.1643257023220; Wed, 26 Jan 2022 20:17:03 -0800 (PST) Received: from google.com (150.12.83.34.bc.googleusercontent.com. [34.83.12.150]) by smtp.gmail.com with ESMTPSA id z7sm3556746pfe.49.2022.01.26.20.17.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jan 2022 20:17:02 -0800 (PST) Date: Wed, 26 Jan 2022 20:16:59 -0800 From: Ricardo Koller To: Mark Brown Cc: Marc Zyngier , Shuah Khan , linux-kselftest@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v3] kselftest: kvm/arm64: Skip tests if we can't create a vgic-v3 Message-ID: References: <20220126145242.3473836-1-broonie@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220126145242.3473836-1-broonie@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220126_201708_000325_F1EA2786 X-CRM114-Status: GOOD ( 31.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Jan 26, 2022 at 02:52:42PM +0000, Mark Brown wrote: > The arch_timer and vgic_irq kselftests assume that they can create a > vgic-v3, using the library function vgic_v3_setup() which aborts with a > test failure if it is not possible to do so. Since vgic-v3 can only be > instantiated on systems where the host has GICv3 this leads to false > positives on older systems where that is not the case. > > Fix this by changing vgic_v3_setup() to return an error if the vgic can't > be instantiated and have the callers skip if this happens. We could also > exit flagging a skip in vgic_v3_setup() but this would prevent future test > cases conditionally deciding which GIC to use or generally doing more > complex output. > > Signed-off-by: Mark Brown > --- > > v3: > - Use custom print_skip() helper. > - Use internal version of _kvm_create_device. > v2: > - The test for being able to create the GIC doesn't actually > instantiate it, add a call doing so in that case. > > tools/testing/selftests/kvm/aarch64/arch_timer.c | 7 ++++++- > tools/testing/selftests/kvm/aarch64/vgic_irq.c | 4 ++++ > tools/testing/selftests/kvm/lib/aarch64/vgic.c | 4 +++- > 3 files changed, 13 insertions(+), 2 deletions(-) > > diff --git a/tools/testing/selftests/kvm/aarch64/arch_timer.c b/tools/testing/selftests/kvm/aarch64/arch_timer.c > index 9ad38bd360a4..b08d30bf71c5 100644 > --- a/tools/testing/selftests/kvm/aarch64/arch_timer.c > +++ b/tools/testing/selftests/kvm/aarch64/arch_timer.c > @@ -366,6 +366,7 @@ static struct kvm_vm *test_vm_create(void) > { > struct kvm_vm *vm; > unsigned int i; > + int ret; > int nr_vcpus = test_args.nr_vcpus; > > vm = vm_create_default_with_vcpus(nr_vcpus, 0, 0, guest_code, NULL); > @@ -382,7 +383,11 @@ static struct kvm_vm *test_vm_create(void) > > ucall_init(vm, NULL); > test_init_timer_irq(vm); > - vgic_v3_setup(vm, nr_vcpus, 64, GICD_BASE_GPA, GICR_BASE_GPA); > + ret = vgic_v3_setup(vm, nr_vcpus, 64, GICD_BASE_GPA, GICR_BASE_GPA); > + if (ret < 0) { > + print_skip("Failed to create vgic-v3"); > + exit(KSFT_SKIP); > + } > > /* Make all the test's cmdline args visible to the guest */ > sync_global_to_guest(vm, test_args); > diff --git a/tools/testing/selftests/kvm/aarch64/vgic_irq.c b/tools/testing/selftests/kvm/aarch64/vgic_irq.c > index e6c7d7f8fbd1..7eca97799917 100644 > --- a/tools/testing/selftests/kvm/aarch64/vgic_irq.c > +++ b/tools/testing/selftests/kvm/aarch64/vgic_irq.c > @@ -761,6 +761,10 @@ static void test_vgic(uint32_t nr_irqs, bool level_sensitive, bool eoi_split) > > gic_fd = vgic_v3_setup(vm, 1, nr_irqs, > GICD_BASE_GPA, GICR_BASE_GPA); > + if (gic_fd < 0) { > + print_skip("Failed to create vgic-v3, skipping"); > + exit(KSFT_SKIP); > + } > > vm_install_exception_handler(vm, VECTOR_IRQ_CURRENT, > guest_irq_handlers[args.eoi_split][args.level_sensitive]); > diff --git a/tools/testing/selftests/kvm/lib/aarch64/vgic.c b/tools/testing/selftests/kvm/lib/aarch64/vgic.c > index b3a0fca0d780..f5cd0c536d85 100644 > --- a/tools/testing/selftests/kvm/lib/aarch64/vgic.c > +++ b/tools/testing/selftests/kvm/lib/aarch64/vgic.c > @@ -52,7 +52,9 @@ int vgic_v3_setup(struct kvm_vm *vm, unsigned int nr_vcpus, uint32_t nr_irqs, > nr_vcpus, nr_vcpus_created); > > /* Distributor setup */ > - gic_fd = kvm_create_device(vm, KVM_DEV_TYPE_ARM_VGIC_V3, false); > + if (_kvm_create_device(vm, KVM_DEV_TYPE_ARM_VGIC_V3, > + false, &gic_fd) != 0) > + return -1; > > kvm_device_access(gic_fd, KVM_DEV_ARM_VGIC_GRP_NR_IRQS, > 0, &nr_irqs, true); > -- > 2.30.2 > > _______________________________________________ > kvmarm mailing list > kvmarm@lists.cs.columbia.edu > https://lists.cs.columbia.edu/mailman/listinfo/kvmarm Tried both gicv2 and v3 and the change works as expected. Tested-by: Ricardo Koller _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel