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 mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by smtp.lore.kernel.org (Postfix) with ESMTP id 555D1C2BA4C for ; Wed, 26 Jan 2022 09:16:28 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id C4AAB49AF7; Wed, 26 Jan 2022 04:16:27 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@linuxfoundation.org Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2cxdMss9Ht2m; Wed, 26 Jan 2022 04:16:26 -0500 (EST) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 6C09C40FD6; Wed, 26 Jan 2022 04:16:26 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 92C8040B80 for ; Tue, 25 Jan 2022 14:48:04 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FeFDvRc8P5aG for ; Tue, 25 Jan 2022 14:48:03 -0500 (EST) Received: from mail-io1-f47.google.com (mail-io1-f47.google.com [209.85.166.47]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 73D1C408F4 for ; Tue, 25 Jan 2022 14:48:03 -0500 (EST) Received: by mail-io1-f47.google.com with SMTP id s18so8510441ioa.12 for ; Tue, 25 Jan 2022 11:48:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=UhLIm0K4haH8bYFhDCpqtBWqTKC3e3dD5n20TDHCsEU=; b=LQmFhxo97JuO3uJKyBgLhODQfyiRm33Fa7nwDLgCR6dbQVF8VzDu7zZhzHJ29NKlYt C76zQtUnK+Xr9cHfdRMIJJDI6G+vSQPym8ss7dguvlhs0rQpyenT1aGH+73QKh1St/6h g41sB7aSWHA/vmmWVnJqcR9hT9FwXGtTrFmjY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=UhLIm0K4haH8bYFhDCpqtBWqTKC3e3dD5n20TDHCsEU=; b=tH5wdsWZAdIPLzGbcKk35lC8Dnn5qvO9BRwsXMRi+iWbrYrpelBvQtdjC9fvG6GCsL Q4FBaGUwYlkWEUrowIGfG9zK+fcqd5dAp6pcdYOHf7MWgjoEidLm1BZFHrI+1j1zAXJm DrSAI/456LHXoan6hFvNnVdcdI6Y6SmjfTzr373/MQ6BWl3ACr5AflN/kvgkgquJuES5 wVgiQODd+JN3xfYhvM/LcJOzY8ryNacVrNXD7V/roVFbC+QUdwOQB0nuQsjsdgP/HCl9 vyrOgTIhyijTf027FGPjBSG7IgxpdXLxcq54EW/2sJdcuhqw+iZxd7olVaHI65NsxNMq 2ywQ== X-Gm-Message-State: AOAM532TYNbQ16jCCSRRo/fQn1Q+7eYhquGQ6D7vEn0FdGt2TDe3logF omYkEZLS/8hsINNW2G7pVEyRKQ== X-Google-Smtp-Source: ABdhPJzKaByjZS2TCv+LDaZM1ersKACGdc0hYfosLk3drvVpzlg/TCFdUx7usK/mXeitxXxhamL43g== X-Received: by 2002:a5e:9b07:: with SMTP id j7mr11438878iok.136.1643140082829; Tue, 25 Jan 2022 11:48:02 -0800 (PST) Received: from ?IPv6:2601:282:8200:4c:4ef8:d404:554b:9671? ([2601:282:8200:4c:4ef8:d404:554b:9671]) by smtp.gmail.com with ESMTPSA id l7sm9486227ilv.75.2022.01.25.11.48.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 25 Jan 2022 11:48:02 -0800 (PST) Subject: Re: [PATCH] kselftest: kvm/arm64: Skip tests if we can't create a vgic-v3 To: Mark Brown , Marc Zyngier , Shuah Khan References: <20220125192851.3907611-1-broonie@kernel.org> From: Shuah Khan Message-ID: Date: Tue, 25 Jan 2022 12:48:00 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20220125192851.3907611-1-broonie@kernel.org> Content-Language: en-US X-Mailman-Approved-At: Wed, 26 Jan 2022 04:16:24 -0500 Cc: linux-kselftest@vger.kernel.org, Shuah Khan , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu On 1/25/22 12:28 PM, 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 > --- > tools/testing/selftests/kvm/aarch64/arch_timer.c | 7 ++++++- > tools/testing/selftests/kvm/aarch64/vgic_irq.c | 5 +++++ > tools/testing/selftests/kvm/lib/aarch64/vgic.c | 4 +++- > 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"); > + 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..8c6b61b8e6aa 100644 > --- a/tools/testing/selftests/kvm/aarch64/vgic_irq.c > +++ b/tools/testing/selftests/kvm/aarch64/vgic_irq.c > @@ -761,6 +761,11 @@ 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"); > + 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..647c18733e1b 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); > + gic_fd = kvm_create_device(vm, KVM_DEV_TYPE_ARM_VGIC_V3, true); Assume the flag change is intentional. The reason isn't obvious in the change log > + if (gic_fd == -1) > + return -1; > > kvm_device_access(gic_fd, KVM_DEV_ARM_VGIC_GRP_NR_IRQS, > 0, &nr_irqs, true); > Looks good to me otherwise - thanks for adding the skips Reviewed-by: Shuah Khan thanks, -- Shuah _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78F84C433EF for ; Tue, 25 Jan 2022 19:48:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230261AbiAYTsF (ORCPT ); Tue, 25 Jan 2022 14:48:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230383AbiAYTsD (ORCPT ); Tue, 25 Jan 2022 14:48:03 -0500 Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE75FC061744 for ; Tue, 25 Jan 2022 11:48:03 -0800 (PST) Received: by mail-io1-xd2d.google.com with SMTP id h23so24936403iol.11 for ; Tue, 25 Jan 2022 11:48:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=UhLIm0K4haH8bYFhDCpqtBWqTKC3e3dD5n20TDHCsEU=; b=LQmFhxo97JuO3uJKyBgLhODQfyiRm33Fa7nwDLgCR6dbQVF8VzDu7zZhzHJ29NKlYt C76zQtUnK+Xr9cHfdRMIJJDI6G+vSQPym8ss7dguvlhs0rQpyenT1aGH+73QKh1St/6h g41sB7aSWHA/vmmWVnJqcR9hT9FwXGtTrFmjY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=UhLIm0K4haH8bYFhDCpqtBWqTKC3e3dD5n20TDHCsEU=; b=oU4n1XQEUzeFJVVs3jexdC1KSJj4Y0OFkyziLR7ni/LFCXx3sW3R638CprhgafwHNo YATQ5Ep3ICrjerQDO7O3wT7tTN2eQyNECCwx5c6jfrdVZp07MZevmEdrXxZpjfLj4sdj d+TjpbnOSV9R5Tyr98xXRp35v0rVps30DPtf9nc/wSHb7rUIxytoSfSP+i1pp4w3JpVa Ok+9b3W6u1JRSkCMkOOlY+VKfb74PqZC/bJExd/nul+zMGlv+a5p2rukcFzR2mQKX79P cwNdnwXkioHzAwlTJK9Nl5EnLMtAPmbH6q/mtP9fgFH5X/OtfRkm9O4E0GEyHDWKTmbV EgTA== X-Gm-Message-State: AOAM531a0bivNx7K89X22h9OSy17P8r0a4SlEbybdSK2VSqdqFxOrNtQ S7ka2QGn43v1Mh7wG0u+mQz4jA== X-Google-Smtp-Source: ABdhPJzKaByjZS2TCv+LDaZM1ersKACGdc0hYfosLk3drvVpzlg/TCFdUx7usK/mXeitxXxhamL43g== X-Received: by 2002:a5e:9b07:: with SMTP id j7mr11438878iok.136.1643140082829; Tue, 25 Jan 2022 11:48:02 -0800 (PST) Received: from ?IPv6:2601:282:8200:4c:4ef8:d404:554b:9671? ([2601:282:8200:4c:4ef8:d404:554b:9671]) by smtp.gmail.com with ESMTPSA id l7sm9486227ilv.75.2022.01.25.11.48.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 25 Jan 2022 11:48:02 -0800 (PST) Subject: Re: [PATCH] kselftest: kvm/arm64: Skip tests if we can't create a vgic-v3 To: Mark Brown , Marc Zyngier , Shuah Khan Cc: James Morse , Alexandru Elisei , Suzuki K Poulose , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kselftest@vger.kernel.org, Shuah Khan References: <20220125192851.3907611-1-broonie@kernel.org> From: Shuah Khan Message-ID: Date: Tue, 25 Jan 2022 12:48:00 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20220125192851.3907611-1-broonie@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org On 1/25/22 12:28 PM, 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 > --- > tools/testing/selftests/kvm/aarch64/arch_timer.c | 7 ++++++- > tools/testing/selftests/kvm/aarch64/vgic_irq.c | 5 +++++ > tools/testing/selftests/kvm/lib/aarch64/vgic.c | 4 +++- > 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"); > + 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..8c6b61b8e6aa 100644 > --- a/tools/testing/selftests/kvm/aarch64/vgic_irq.c > +++ b/tools/testing/selftests/kvm/aarch64/vgic_irq.c > @@ -761,6 +761,11 @@ 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"); > + 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..647c18733e1b 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); > + gic_fd = kvm_create_device(vm, KVM_DEV_TYPE_ARM_VGIC_V3, true); Assume the flag change is intentional. The reason isn't obvious in the change log > + if (gic_fd == -1) > + return -1; > > kvm_device_access(gic_fd, KVM_DEV_ARM_VGIC_GRP_NR_IRQS, > 0, &nr_irqs, true); > Looks good to me otherwise - thanks for adding the skips Reviewed-by: Shuah Khan thanks, -- Shuah 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 3F36DC433F5 for ; Tue, 25 Jan 2022 19:49:49 +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-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:Cc:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=gbdoYVXEdMxY2XbtmduA4+ZWHHT5+ONZjgO8Wq/ynR4=; b=F6PizewIJ9SB6UwMdnnc1P1ZUd 84ukdgdy3c1o7ydk5QIRP0PQPkXRMS8iHseLSeoUI2svTq96XpPf7jAIp8uNYgjDNvGirq5S6vSec NPXAIB0fpbYWLMKsqH3GpCa0eXIlBTQ4mmUUyhXK4BDdde8ObW09rDgnkXurKy7zyLFfBLYPCLqlt /A/EcH9PjGBZDuN35gRkRhpLJSthqxvtXPU5WuxzifCxcU2dmXGsi/ST5lpyAdOaUPZB0uF02Gwqc oG5DbxPTxHfXtpDmFnlUM9k7upfcwQTspAfE1oy3hhjuaoSiUFk8ImGEt+O+e0XgMAY4/WGR43i4M j6fyIJCA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nCRnY-009PMV-Hc; Tue, 25 Jan 2022 19:48:12 +0000 Received: from mail-io1-xd35.google.com ([2607:f8b0:4864:20::d35]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nCRnR-009PKr-3s for linux-arm-kernel@lists.infradead.org; Tue, 25 Jan 2022 19:48:06 +0000 Received: by mail-io1-xd35.google.com with SMTP id h7so7088206iof.3 for ; Tue, 25 Jan 2022 11:48:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=UhLIm0K4haH8bYFhDCpqtBWqTKC3e3dD5n20TDHCsEU=; b=LQmFhxo97JuO3uJKyBgLhODQfyiRm33Fa7nwDLgCR6dbQVF8VzDu7zZhzHJ29NKlYt C76zQtUnK+Xr9cHfdRMIJJDI6G+vSQPym8ss7dguvlhs0rQpyenT1aGH+73QKh1St/6h g41sB7aSWHA/vmmWVnJqcR9hT9FwXGtTrFmjY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=UhLIm0K4haH8bYFhDCpqtBWqTKC3e3dD5n20TDHCsEU=; b=G597dZgujoeueOdb6fErwAt/N5vQ0430gxSMB3qvT0nFuOWP/Zt84FPJDUhlZZg0el 8qCxfGQRrEiVOz8dFvQFY7YHfEahuh4+53QX5PBwdabwqQpuiCZWK7p0yN6at2JjAA6V 3jNbLiYW4PbUtEFoQcMM7RjCcj0wg2LmqtbCcw1CwgjggArHSCtb5BK2S8gMVopSZAwP Enm/ZXar6u+QG0XtaNyrm/YPSODZZT1kCZieSiNewO1h3k9Jy9OOtqxtU7vsbyNptyvT F4BwE/wHJDyJsc0pbsvX1BHhty/ORKwWsYgiGy8nzApWZ8W6BA0tU0GOLf7Xea6Zqvbm qtkQ== X-Gm-Message-State: AOAM530MUY8f+dcYLhSr1rvuhigwUelpOJB95TKeUrbuhl6s3s+IW4x3 R9/33ho+hpL1+0ZNIbGaV4bQXw== X-Google-Smtp-Source: ABdhPJzKaByjZS2TCv+LDaZM1ersKACGdc0hYfosLk3drvVpzlg/TCFdUx7usK/mXeitxXxhamL43g== X-Received: by 2002:a5e:9b07:: with SMTP id j7mr11438878iok.136.1643140082829; Tue, 25 Jan 2022 11:48:02 -0800 (PST) Received: from ?IPv6:2601:282:8200:4c:4ef8:d404:554b:9671? ([2601:282:8200:4c:4ef8:d404:554b:9671]) by smtp.gmail.com with ESMTPSA id l7sm9486227ilv.75.2022.01.25.11.48.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 25 Jan 2022 11:48:02 -0800 (PST) Subject: Re: [PATCH] kselftest: kvm/arm64: Skip tests if we can't create a vgic-v3 To: Mark Brown , Marc Zyngier , Shuah Khan Cc: James Morse , Alexandru Elisei , Suzuki K Poulose , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kselftest@vger.kernel.org, Shuah Khan References: <20220125192851.3907611-1-broonie@kernel.org> From: Shuah Khan Message-ID: Date: Tue, 25 Jan 2022 12:48:00 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20220125192851.3907611-1-broonie@kernel.org> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220125_114805_253220_D43EA89E X-CRM114-Status: GOOD ( 28.73 ) 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 1/25/22 12:28 PM, 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 > --- > tools/testing/selftests/kvm/aarch64/arch_timer.c | 7 ++++++- > tools/testing/selftests/kvm/aarch64/vgic_irq.c | 5 +++++ > tools/testing/selftests/kvm/lib/aarch64/vgic.c | 4 +++- > 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"); > + 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..8c6b61b8e6aa 100644 > --- a/tools/testing/selftests/kvm/aarch64/vgic_irq.c > +++ b/tools/testing/selftests/kvm/aarch64/vgic_irq.c > @@ -761,6 +761,11 @@ 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"); > + 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..647c18733e1b 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); > + gic_fd = kvm_create_device(vm, KVM_DEV_TYPE_ARM_VGIC_V3, true); Assume the flag change is intentional. The reason isn't obvious in the change log > + if (gic_fd == -1) > + return -1; > > kvm_device_access(gic_fd, KVM_DEV_ARM_VGIC_GRP_NR_IRQS, > 0, &nr_irqs, true); > Looks good to me otherwise - thanks for adding the skips Reviewed-by: Shuah Khan thanks, -- Shuah _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel