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 A95AFC28CF5 for ; Wed, 26 Jan 2022 14:19:20 +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=n8Lv5nXEnDY5ILBunT0PWaOad7y6Y7pYE13zBDvRKXA=; b=K2ddI0Lx+7cXhs EhUQuGU4eYhJVrLRiMBKcKzyyMX0RgHv/OcNtzDUkWyzoCNwINBk/zpM4f/Zq+b+dGBwEclptW3cZ y726WhCE1hv5M852be50EO6VyBz9aS82hW5x8/zC6Gbfi+knQCIp0UA0elmG/idInS/Dn/T3vgHnv IJuZIfl2NJxsgbVA/bTkViYBXJFpQZNVO2WltvmBzSLXl/XyoTOw2APwLN0a1ygzIHAzQsly4/zCp aSbHZGieH2zBRhthA3KbmF9v/Lzue4zQgicwRJ/5X+7g0yPdMQKiQBBeC7fHpvU65hQGu864O/VvI IdWN/eGL7mHznhPF3vzw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nCj7W-00Bynw-MP; Wed, 26 Jan 2022 14:17:58 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nCj7P-00BymO-WF for linux-arm-kernel@lists.infradead.org; Wed, 26 Jan 2022 14:17:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643206669; 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: in-reply-to:in-reply-to:references:references; bh=pBsc1hWd3oxs011RR96KjS1IY2+oHS5R8Wd9986U2nM=; b=cnvqEtpu+/hzcw625IIdjzNAV6WnYOLltrioiAJMuCDFOUZAI2aQ27uDzIhulZNTu0Hwoz VJkSce7HLKFHiN/bnSbeYZb0psh7dl9lKBocg20419xOfcQkZ5KcAZ4Si9f0B+meyAhqYV UizxqhojETkRsSSQw9jn9C4mxZ6lqA4= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-176-ABkUNmckMheUVUpHp2CHpw-1; Wed, 26 Jan 2022 09:17:44 -0500 X-MC-Unique: ABkUNmckMheUVUpHp2CHpw-1 Received: by mail-ej1-f71.google.com with SMTP id ky6-20020a170907778600b0068e4bd99fd1so4937707ejc.15 for ; Wed, 26 Jan 2022 06:17:44 -0800 (PST) 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=pBsc1hWd3oxs011RR96KjS1IY2+oHS5R8Wd9986U2nM=; b=JXT9LX5IZHIoTCb+I4hPwSpqG1HgfnJ3/StMSiqnAkG11GJjmm75i//8wIiiOBC/OD Bue8+Fi5UBF5aimSmOvlPlmx6hxgm3tij2vTQ2qy4WT4IxmyRCr/q72O00eL92cyDZ7v SdmGVTAO7zoefqsmj5Sf0+F/XxeROZmUrJ6QCDYisquL3V2WAf7x3c140B9PW3Cl3yOR LT/4HfyO74JwjA96kXGO/xmfRKOyeHNFmyFOtjdIDLm3+HWP9pTpAwv1KRCMqYZMU8mI fH+dfcN473WdpAFmrYKvs5AF7qt2bdDjtGNZYQx+I5xTdGEBaPFJ0KZWoDvN/pIWsyj2 Wtgg== X-Gm-Message-State: AOAM532DmO8qMQ7syKfsAzyS9UbBkmUvzzP6Yea/H6I3QZrnCQXv0P4L tB8o7dfXEC05S0umWaR6dWKK5g9ZeX5cuXn8MU5YJw226U4ZenI6iLigcrJqWiMxtCN4AFagXCz s0lxrl/mlHWRgbqo1lo8nntk1L+queRvtOxE= X-Received: by 2002:a17:906:4347:: with SMTP id z7mr21046212ejm.671.1643206663605; Wed, 26 Jan 2022 06:17:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJyzjw+1AXpd7hzxxgJS9LZv/KCQ4BAHMGkrSijf7nugItNU7ldGtWLdTM8SkChNzJwfiV99uQ== X-Received: by 2002:a17:906:4347:: with SMTP id z7mr21046190ejm.671.1643206663327; Wed, 26 Jan 2022 06:17:43 -0800 (PST) Received: from gator (cst2-173-70.cust.vodafone.cz. [31.30.173.70]) by smtp.gmail.com with ESMTPSA id k23sm7491029ejr.65.2022.01.26.06.17.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jan 2022 06:17:42 -0800 (PST) Date: Wed, 26 Jan 2022 15:17:41 +0100 From: Andrew Jones 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 v2] kselftest: kvm/arm64: Skip tests if we can't create a vgic-v3 Message-ID: <20220126141741.zxxltis5zdtjzz33@gator> References: <20220126135319.1918802-1-broonie@kernel.org> MIME-Version: 1.0 In-Reply-To: <20220126135319.1918802-1-broonie@kernel.org> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=drjones@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220126_061752_161919_E686FBE9 X-CRM114-Status: GOOD ( 35.21 ) 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 01:53:19PM +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 > --- > > 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 | 5 ++++- > 3 files changed, 14 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..791d38404652 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) { > + pr_info("Failed to create vgic-v3, skipping\n"); Please use 'print_skip', which appends ", skipping test" to keep the skip messages consistent. Also, print_skip can't be disabled with -DQUIET like pr_info. > + 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..b127a261fd29 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) { > + pr_info("Failed to create vgic-v3, skipping\n"); print_skip > + 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..4ea65e119bdd 100644 > --- a/tools/testing/selftests/kvm/lib/aarch64/vgic.c > +++ b/tools/testing/selftests/kvm/lib/aarch64/vgic.c > @@ -51,7 +51,10 @@ int vgic_v3_setup(struct kvm_vm *vm, unsigned int nr_vcpus, uint32_t nr_irqs, > "Number of vCPUs requested (%u) doesn't match with the ones created for the VM (%u)\n", > nr_vcpus, nr_vcpus_created); > > - /* Distributor setup */ > + /* Distributor setup - test if it's possible then actually do it */ > + gic_fd = kvm_create_device(vm, KVM_DEV_TYPE_ARM_VGIC_V3, true); > + if (gic_fd != 0) > + return -1; > gic_fd = kvm_create_device(vm, KVM_DEV_TYPE_ARM_VGIC_V3, false); kvm selftests generally asserts on failure with the nonunderscore prefixed KVM ioctl wrapper functions, which is why you appear to be forced to do this nasty dance. However, kvm selftests usually always also offers an underscore prefixed version of the KVM ioctl wrapper function too for cases like these. So we can just do if (_kvm_create_device(vm, KVM_DEV_TYPE_ARM_VGIC_V3, false, &gic_fd) != 0) return -1; Thanks, drew > > kvm_device_access(gic_fd, KVM_DEV_ARM_VGIC_GRP_NR_IRQS, > -- > 2.30.2 > > _______________________________________________ > kvmarm mailing list > kvmarm@lists.cs.columbia.edu > https://lists.cs.columbia.edu/mailman/listinfo/kvmarm > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel