From patchwork Tue Jan 2 16:46:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himanshu Chauhan X-Patchwork-Id: 1887250 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=NDqXTfx1; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ventanamicro.com header.i=@ventanamicro.com header.a=rsa-sha256 header.s=google header.b=cJL4QW01; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=198.137.202.133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TFDLN3bqtz1yPg for ; Wed, 17 Jan 2024 16:03:54 +1100 (AEDT) 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:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=3ex52bqce+lDDp0WGbyOuUH72jGKUc/EZttdmPySuXc=; b=NDqXTfx1njH4fK wVf0O80V9EXkgbv6TThZBjqOcl0mImp1NrFWMOqk7jd8bsrtru+CL1L0zWIwlXIRiqeyVdUi2z06q fVUMpUt2eapmSxdPMBHTVjjQP1J+yfRvJ4+RPvl8Tz7NNQ+qza3fArd+qu4U5qSMviBkC2AAgREJA zFINJ+N776jnN9nbwd7gExtruIt/10yxxzm5BrvCpl0PGXlgQA3NyvT8V8f9VZBb9iJ7EDILuA3ZJ 5K7vl9pHr3cPRsUzOpYufNG3kw049mMbQTj91IU3rXrtPOIe+j+BtL3d5WYl5Vt7/rHS9KR42BWk4 Zq6/CM/qq+FpprG/kIhA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rPy5I-00ES9D-2y; Wed, 17 Jan 2024 05:03:28 +0000 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rPy5E-00ES7H-2Y for opensbi@lists.infradead.org; Wed, 17 Jan 2024 05:03:26 +0000 Received: by mail-pj1-x1030.google.com with SMTP id 98e67ed59e1d1-28e141e677cso665465a91.0 for ; Tue, 16 Jan 2024 21:03:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1705467802; x=1706072602; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=pUQY6zdqm+dRWyVzYMijo6fWsrn2mY406YidFgS9hkU=; b=cJL4QW01s0Ya5uM+1qPyJjJFmPa622HFfUBFoyM/J4X5XZSj05hBie+8rtIFHBLZvv KMPrrjHWEeNGLFH7oGKMKu4JqCU+q2yjb5RoGiD1bb7deYHYwUusrbRGQ+p/vhhsa7Ox ZxCyyZrflM+xFtwouVZjpA7XX7IQaKgoG+aE0/4mJk3P+rHKpLBTDRese6N+5pHEruTb /zHcpNjNdJhMyak/RcPXQF2VoNsD+FLuu852QwMCZZyWmYIwhwtqbk4rwQSc5C3BoiNY xyujO6d/jYMV9lXX7MDIwvlWwDA9NKMRzsCONitbRz6hDbdd2y/v1etYENMc9p8fmPd0 WvWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705467802; x=1706072602; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=pUQY6zdqm+dRWyVzYMijo6fWsrn2mY406YidFgS9hkU=; b=gPZ/sVaHja5QA9Hxy7ceUH0LI+lJsXeXLQfYaNTvNqyvsV52tdvUrOWCyTqgOYHK+H 2nPO3ix00qnYdS7/4JmUw55ar2LNRgY5wpVhowanHRbIrow4ZJGoGj/EMiVAHUAYhKiY dwG+u16H3KitaDqudSvUFaNxjUZhpSs2EtpabophCSpjqjRyIfPScjENh25BYBDJKZvF MAdWlx44RW1n4xXNv06ZctLRP4EZUUnqlte+PRoa3sV1Aq9D6NjqPe+kAShz40aj7L96 9tsA9hi4XCUH3orMmqtYMnLPX6D1hfzrMFlb69vgmxBMLmpGfxEQsrAiBfateXYWGBtO G4gQ== X-Gm-Message-State: AOJu0YxByEH46ufsu0/mryTvaTiJIPQtAv7TDVgKrQuy/MShsTdZQ7rI bVzdH6geAjt2jgnLr0A6CO0iD9KZvSwj2n6BSn4dXX2NEL0= X-Google-Smtp-Source: AGHT+IE/QnnhV6kBXlQFNNIfeqGLKjX6d/Vb3K0MqKYpCOjOxwz6/h5hXhDi08HZyosEnyXyvJcDjg== X-Received: by 2002:a17:90b:4d90:b0:28e:425d:8420 with SMTP id oj16-20020a17090b4d9000b0028e425d8420mr8722625pjb.4.1705467802325; Tue, 16 Jan 2024 21:03:22 -0800 (PST) Received: from indra.localdomain ([152.58.232.161]) by smtp.gmail.com with ESMTPSA id sx4-20020a17090b2cc400b0028ce9c709e4sm15062818pjb.26.2024.01.16.21.03.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 21:03:22 -0800 (PST) From: Himanshu Chauhan To: opensbi@lists.infradead.org Subject: [PATCH] lib: sbi: Use mask to check the free bit during trigger allocation Date: Tue, 2 Jan 2024 22:16:24 +0530 Message-ID: <20240102164624.85482-1-hchauhan@ventanamicro.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240116_210324_853464_AF982D3E X-CRM114-Status: GOOD ( 11.17 ) X-Spam-Score: 1.9 (+) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: The trigger allocation function uses bit shift instead of mask to check the mapped status of the triggers. This causes index 0 to be return always. As a result, the older triggers are overwritten. Use the mask for MAPPED field in state word to check if the trigger is mapped. Content analysis details: (1.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1030 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 2.1 DATE_IN_PAST_96_XX Date: is 96 hours or more before Received: date -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The trigger allocation function uses bit shift instead of mask to check the mapped status of the triggers. This causes index 0 to be return always. As a result, the older triggers are overwritten. Use the mask for MAPPED field in state word to check if the trigger is mapped. Fixes: 97f234f15 ("lib: sbi: Introduce the SBI debug triggers extension support") Signed-off-by: Himanshu Chauhan Reviewed-by: Anup Patel --- lib/sbi/sbi_dbtr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sbi/sbi_dbtr.c b/lib/sbi/sbi_dbtr.c index 019e702..7142fed 100644 --- a/lib/sbi/sbi_dbtr.c +++ b/lib/sbi/sbi_dbtr.c @@ -129,7 +129,7 @@ static inline struct sbi_dbtr_trigger *sbi_alloc_trigger(void) for (i = 0; i < hart_state->total_trigs; i++) { f_trig = INDEX_TO_TRIGGER(i); - if (f_trig->state & RV_DBTR_BIT(TS, MAPPED)) + if (f_trig->state & RV_DBTR_BIT_MASK(TS, MAPPED)) continue; hart_state->available_trigs--; break;