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 86D4FC4321E for ; Tue, 12 Apr 2022 08:40:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383950AbiDLIim (ORCPT ); Tue, 12 Apr 2022 04:38:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357106AbiDLHjr (ORCPT ); Tue, 12 Apr 2022 03:39:47 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2DC060E9; Tue, 12 Apr 2022 00:12:11 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B35E9B81A8F; Tue, 12 Apr 2022 07:12:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0BA4CC385A6; Tue, 12 Apr 2022 07:12:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747529; bh=qLmXZONcjAfLhV8Fgzrg3A5r3faqxtmtZPA9U6hBnwE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S7Z+sPsiwR7nxvtj+MAvAm0ar8ORz3M3FwsFM/jDwMOyEdnErt+G8RaAXoSyN7+VS X88w6CQB6j3cWLy8E2NaWJlS1D5ctRJTihQGWWvLufXXScGEBz8Tjr9a+NmwqeLIQi 8CnImrzVllEwj3K+oAYtYPacLr3P2Jcnebj+wFGo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ricardo Koller , Reiji Watanabe , Andrew Jones , Marc Zyngier , Sasha Levin Subject: [PATCH 5.17 061/343] kvm: selftests: aarch64: fix assert in gicv3_access_reg Date: Tue, 12 Apr 2022 08:27:59 +0200 Message-Id: <20220412062952.863589103@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ricardo Koller [ Upstream commit cc94d47ce16d4147d546e47c8248e8bd12ba5fe5 ] The val argument in gicv3_access_reg can have any value when used for a read, not necessarily 0. Fix the assert by checking val only for writes. Signed-off-by: Ricardo Koller Reported-by: Reiji Watanabe Cc: Andrew Jones Reviewed-by: Andrew Jones Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/20220127030858.3269036-2-ricarkol@google.com Signed-off-by: Sasha Levin --- tools/testing/selftests/kvm/lib/aarch64/gic_v3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/kvm/lib/aarch64/gic_v3.c b/tools/testing/selftests/kvm/lib/aarch64/gic_v3.c index 00f613c0583c..e4945fe66620 100644 --- a/tools/testing/selftests/kvm/lib/aarch64/gic_v3.c +++ b/tools/testing/selftests/kvm/lib/aarch64/gic_v3.c @@ -159,7 +159,7 @@ static void gicv3_access_reg(uint32_t intid, uint64_t offset, uint32_t cpu_or_dist; GUEST_ASSERT(bits_per_field <= reg_bits); - GUEST_ASSERT(*val < (1U << bits_per_field)); + GUEST_ASSERT(!write || *val < (1U << bits_per_field)); /* Some registers like IROUTER are 64 bit long. Those are currently not * supported by readl nor writel, so just asserting here until then. */ -- 2.35.1