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 6DA98C5AC75 for ; Wed, 26 Jan 2022 01:23:11 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id A992140B87; Tue, 25 Jan 2022 20:23:10 -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=@google.com 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 5vr9wRrGuNIP; Tue, 25 Jan 2022 20:23:09 -0500 (EST) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 00A9640B41; Tue, 25 Jan 2022 20:23:09 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 954DF4076C for ; Tue, 25 Jan 2022 20:23:07 -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 lBhl8728akpZ for ; Tue, 25 Jan 2022 20:23:06 -0500 (EST) Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 2A0004076A for ; Tue, 25 Jan 2022 20:23:06 -0500 (EST) Received: by mail-pj1-f53.google.com with SMTP id q63so17100799pja.1 for ; Tue, 25 Jan 2022 17:23:06 -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=qp4BntvRZm9hTr6l3zGlLo/U2BcJeqsTUdhiP4SKrfc=; b=rnMb5VODVOzw+bv9bS2Xh/FWWtA0ngwR5DIt+Eo6WtS6Vq3bu0jdGnsnzLxJOCMDSF 3sZYL4sHTlkLgSt07lNK6NTk7Ohc91R982WORpBXrfy32BHbh8apbLZbEq6iNcHcYE+6 kLRZgGsIB7vAQDROpGqNVavQ2hWrbh94yAxs9+jhALNKxRMiMVBmQ/5l18fGqc33aSYk /6WzA0JspTrE0U6yjgA+l7V89fh84lGmtLjC23lM723iKZHGvqaXzXWp+uG8Pe8sAMDL c1pei8gFnnxoRhaxF2kRSdqzGHqGs4tQ+EwGyMmp5h+d/AElW0VuAJMeiwXS0gQBPigP aOGg== 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=qp4BntvRZm9hTr6l3zGlLo/U2BcJeqsTUdhiP4SKrfc=; b=S4gsQ/p9z4loeqZ2O/H2fwIqiim/i/VMJiRsijwwbB73tzaT4g4O2R9GB3W/Y6MZEv GfGkhuWT5mK15iHKPsSJ4rQ8dT+0H7ysUHPJb+ONhCw7NhbLqSX+kxjSJLVKT3+J8ao7 pdLeNuHJ9DhK6JmFob1LzZW2cY8HBInn7Mc6LDDQAaZzQRVWVNzHmldIA+vIcYHwikui 2w6uEQt3FILe3fkGKtRYv1n2CpF2qR8Eq0YRXnC/ZmMC3Qb2vfNcm9a685yhZ9/Gbbg3 BVXBPgdJqJxpySgymAFX+DibYu6usgy2OH/Hh7BGZGwwOqYtF7arYCCqdBJ6TAtUm9eX iv0Q== X-Gm-Message-State: AOAM530sE/D/5fFz+heeGsbBRvpUV3uoXcpoXwwhHkeZcrkB+JEsYJ0l Az3sa3bCG1sqyHKzTLB/YpOQVw== X-Google-Smtp-Source: ABdhPJy6cZxhtYaWpqQmPdBWff89FNYeHqo7ViO8layI33gz7tVSxvOa9Wo7gfzqkIxzBwDanL5/MA== X-Received: by 2002:a17:90a:e38d:: with SMTP id b13mr6198622pjz.205.1643160184936; Tue, 25 Jan 2022 17:23:04 -0800 (PST) Received: from google.com (150.12.83.34.bc.googleusercontent.com. [34.83.12.150]) by smtp.gmail.com with ESMTPSA id u16sm220313pfg.192.2022.01.25.17.23.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jan 2022 17:23:04 -0800 (PST) Date: Tue, 25 Jan 2022 17:23:00 -0800 From: Ricardo Koller To: Mark Brown Subject: Re: [PATCH] kselftest: kvm/arm64: Skip tests if we can't create a vgic-v3 Message-ID: References: <20220125192851.3907611-1-broonie@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220125192851.3907611-1-broonie@kernel.org> Cc: linux-arm-kernel@lists.infradead.org, Marc Zyngier , Shuah Khan , kvmarm@lists.cs.columbia.edu, linux-kselftest@vger.kernel.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-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu On Tue, Jan 25, 2022 at 07:28:51PM +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 > --- > 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); > + if (gic_fd == -1) > + 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 Reviewed-by: Ricardo Koller _______________________________________________ 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 AC69DC3525A for ; Wed, 26 Jan 2022 01:23:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235828AbiAZBXG (ORCPT ); Tue, 25 Jan 2022 20:23:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235831AbiAZBXF (ORCPT ); Tue, 25 Jan 2022 20:23:05 -0500 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6B05C06161C for ; Tue, 25 Jan 2022 17:23:05 -0800 (PST) Received: by mail-pj1-x1031.google.com with SMTP id h12so21762831pjq.3 for ; Tue, 25 Jan 2022 17:23:05 -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=qp4BntvRZm9hTr6l3zGlLo/U2BcJeqsTUdhiP4SKrfc=; b=rnMb5VODVOzw+bv9bS2Xh/FWWtA0ngwR5DIt+Eo6WtS6Vq3bu0jdGnsnzLxJOCMDSF 3sZYL4sHTlkLgSt07lNK6NTk7Ohc91R982WORpBXrfy32BHbh8apbLZbEq6iNcHcYE+6 kLRZgGsIB7vAQDROpGqNVavQ2hWrbh94yAxs9+jhALNKxRMiMVBmQ/5l18fGqc33aSYk /6WzA0JspTrE0U6yjgA+l7V89fh84lGmtLjC23lM723iKZHGvqaXzXWp+uG8Pe8sAMDL c1pei8gFnnxoRhaxF2kRSdqzGHqGs4tQ+EwGyMmp5h+d/AElW0VuAJMeiwXS0gQBPigP aOGg== 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=qp4BntvRZm9hTr6l3zGlLo/U2BcJeqsTUdhiP4SKrfc=; b=sBnLZ/y0gaIuxCk/urYJ5Yvn51M0MnNzUnVAiyztE2yAbCKHfzkgjrHmjRhFiK0WRU FH0OT18bDOdCO9D/o3mI5BIv4d3cprWmcIfpbjJbNVEjkPFBgmVFGhsrF6Ju2xw6Ky6J +USG8/pajKL0cNXfW34uoeU2i/Y2fXb/crpQ3moct91xuINhOuteVAzl4r1Par54pU8x gxbfj2FhYrjuTqHxizHeenBmxSlp8fqgMPqhzX1wLMW9uD1aBZyktb2f2aaUdfuY+rLu 5mtbi4PCD7c48VV/lF0NgWaVN+tRabWSvcALaBZFy9eI9zMkD1nzPl0pfyh2XSLoUuja +GOA== X-Gm-Message-State: AOAM530rtsLsA/Hk058stUFXjeIhVMuB52Li2j9Rnqmsi8sei8HOLsgE EspMdSAy8GgK/tAFNwV89EKN3w== X-Google-Smtp-Source: ABdhPJy6cZxhtYaWpqQmPdBWff89FNYeHqo7ViO8layI33gz7tVSxvOa9Wo7gfzqkIxzBwDanL5/MA== X-Received: by 2002:a17:90a:e38d:: with SMTP id b13mr6198622pjz.205.1643160184936; Tue, 25 Jan 2022 17:23:04 -0800 (PST) Received: from google.com (150.12.83.34.bc.googleusercontent.com. [34.83.12.150]) by smtp.gmail.com with ESMTPSA id u16sm220313pfg.192.2022.01.25.17.23.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jan 2022 17:23:04 -0800 (PST) Date: Tue, 25 Jan 2022 17:23:00 -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] kselftest: kvm/arm64: Skip tests if we can't create a vgic-v3 Message-ID: References: <20220125192851.3907611-1-broonie@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220125192851.3907611-1-broonie@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org On Tue, Jan 25, 2022 at 07:28:51PM +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 > --- > 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); > + if (gic_fd == -1) > + 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 Reviewed-by: Ricardo Koller 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 1F9F2C5AC75 for ; Wed, 26 Jan 2022 01:24:42 +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=TP2vRmNaTKafZLI4kve3OVELYTs3mUR/rkUmQqPTQyQ=; b=RPESVxJW6k2H1e M8F/jaNXlyvH0jpYg8J/X1FyJUIAQFcPyyh7Fvk2FS3VJtY7wv2ya1VNT7BfhgzY2p4S1Fv0MioCj qiHQCLWbmRqUnyLKsmxWeANsWIU0Zfo3s14hDKRBBbW0CSBsoa3T0YqDoOSjQ7Y+rzfmLfU6LuWSh EQVO9Y8EHin1ZXnwrwItm/1uSwDA+PGn/UMJVR7iHU+abm/3tu7knXxNgUolwJ7xI6gpLikfynTVY XOVKNdiXrD3PeXezLmXQZc4UAcPY5xYUrmRiZ3Mpr/TucwdsZncwtFxPyFHV3H96jl4eSpD5bRpU8 KWKJqAN5UBAkzDXgTlbw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nCX1n-009no3-VO; Wed, 26 Jan 2022 01:23:16 +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 1nCX1h-009nml-BH for linux-arm-kernel@lists.infradead.org; Wed, 26 Jan 2022 01:23:13 +0000 Received: by mail-pj1-x1035.google.com with SMTP id b1-20020a17090a990100b001b14bd47532so4641231pjp.0 for ; Tue, 25 Jan 2022 17:23:05 -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=qp4BntvRZm9hTr6l3zGlLo/U2BcJeqsTUdhiP4SKrfc=; b=rnMb5VODVOzw+bv9bS2Xh/FWWtA0ngwR5DIt+Eo6WtS6Vq3bu0jdGnsnzLxJOCMDSF 3sZYL4sHTlkLgSt07lNK6NTk7Ohc91R982WORpBXrfy32BHbh8apbLZbEq6iNcHcYE+6 kLRZgGsIB7vAQDROpGqNVavQ2hWrbh94yAxs9+jhALNKxRMiMVBmQ/5l18fGqc33aSYk /6WzA0JspTrE0U6yjgA+l7V89fh84lGmtLjC23lM723iKZHGvqaXzXWp+uG8Pe8sAMDL c1pei8gFnnxoRhaxF2kRSdqzGHqGs4tQ+EwGyMmp5h+d/AElW0VuAJMeiwXS0gQBPigP aOGg== 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=qp4BntvRZm9hTr6l3zGlLo/U2BcJeqsTUdhiP4SKrfc=; b=VLj/ht5z35xZnbTJqSyIHammtUGdHqFdDutE7rFAYHRp7EvIAMZF9HuyCkiUP+Pip9 muOC63DL15p2XxezlPPtDyM5D/YBanh51hP9Q8BxPXOZAuGMm4jVn70wLLKtW4NllH7q hoOYBmFqTsbQOUaay+Rgl4ZfjdwA41mvtBAlWG5M3dvDQvIXc1QC+U71EWIZRnENoiCG r4rUC5RtcuQ1ATqr3Y3c1CmeSAFBl7XesIFSXyjLQsVY40qy9yP+uxpL1yPmQl8arX6C MSHUiqCXRbsn8YKLyH8zAK3pKBHfwlsN9ZSZ0VY+b8T5wKFlRurx972NCQwIJHUV/xgt bcYg== X-Gm-Message-State: AOAM532IrKGCjQkqi1SR+333DZ1g5EWwEpvDCWRjJmLEw7VJlgP5t5NN yG6wTINxv1xCrJRtOdOqbDBGYA== X-Google-Smtp-Source: ABdhPJy6cZxhtYaWpqQmPdBWff89FNYeHqo7ViO8layI33gz7tVSxvOa9Wo7gfzqkIxzBwDanL5/MA== X-Received: by 2002:a17:90a:e38d:: with SMTP id b13mr6198622pjz.205.1643160184936; Tue, 25 Jan 2022 17:23:04 -0800 (PST) Received: from google.com (150.12.83.34.bc.googleusercontent.com. [34.83.12.150]) by smtp.gmail.com with ESMTPSA id u16sm220313pfg.192.2022.01.25.17.23.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jan 2022 17:23:04 -0800 (PST) Date: Tue, 25 Jan 2022 17:23:00 -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] kselftest: kvm/arm64: Skip tests if we can't create a vgic-v3 Message-ID: References: <20220125192851.3907611-1-broonie@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220125192851.3907611-1-broonie@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220125_172309_414806_91E0FB32 X-CRM114-Status: GOOD ( 27.85 ) 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 Tue, Jan 25, 2022 at 07:28:51PM +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 > --- > 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); > + if (gic_fd == -1) > + 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 Reviewed-by: Ricardo Koller _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel