From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3565A13DB90; Wed, 19 Jun 2024 13:00:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718802022; cv=none; b=R6el+4oldiKvwrpbKnUmp98h4GCSDgobDYuBAkmw5g/GeljUjVtMelQXpWQQC7H5r60WwIN9Vrxyd34YrcuC3W2hTg7mDdQ96fVQcnvmzPMOItcCjvHb8VSumgXEsr/ByP9Df3JVh0vGAWkvELoy6xRqC+el6uL2FDgqnbmxz1Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718802022; c=relaxed/simple; bh=YBuf8o2pj8Fcobwo9z9qEG/yfhBRLMieUmEPQtJ4RtM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rD7mf6xnuMWO3ja1LK/0CKmNDbog6Sd57jWDLxJHc8Y1l4phngMMnG7NiGGvkZ18FcqxBfJet65QnY1y2Xx5f6vN2GPaXWU8MmPN9dXR/kChliHW+yVt4omCJRLiUDBiw4+UwW9uColADiIAhTAVaj97Xbse67p+Fn9DY2/X5GU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=M+fyFueK; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="M+fyFueK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD861C32786; Wed, 19 Jun 2024 13:00:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1718802022; bh=YBuf8o2pj8Fcobwo9z9qEG/yfhBRLMieUmEPQtJ4RtM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M+fyFueK1nMPIU/+Kg5BeVaKAOqTHIZrFZ/mHZmKzAlbkqYwiegZbbJwvRk3FpThr lTZrJgHoAi7lLp2EvvLK+zTj5quZSArLHrhFwvZu8QrtIakMbw8c83qMzs0CtOtClD 7bJbC8zkoO/uHP1ZMWcgV2lZbQjPxQWraTrbolho= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yong-Xuan Wang , Andrew Jones , Anup Patel , Sasha Levin Subject: [PATCH 6.6 014/267] RISC-V: KVM: No need to use mask when hart-index-bit is 0 Date: Wed, 19 Jun 2024 14:52:45 +0200 Message-ID: <20240619125606.901893949@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240619125606.345939659@linuxfoundation.org> References: <20240619125606.345939659@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yong-Xuan Wang [ Upstream commit 2d707b4e37f9b0c37b8b2392f91b04c5b63ea538 ] When the maximum hart number within groups is 1, hart-index-bit is set to 0. Consequently, there is no need to restore the hart ID from IMSIC addresses and hart-index-bit settings. Currently, QEMU and kvmtool do not pass correct hart-index-bit values when the maximum hart number is a power of 2, thereby avoiding this issue. Corresponding patches for QEMU and kvmtool will also be dispatched. Fixes: 89d01306e34d ("RISC-V: KVM: Implement device interface for AIA irqchip") Signed-off-by: Yong-Xuan Wang Reviewed-by: Andrew Jones Link: https://lore.kernel.org/r/20240415064905.25184-1-yongxuan.wang@sifive.com Signed-off-by: Anup Patel Signed-off-by: Sasha Levin --- arch/riscv/kvm/aia_device.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/riscv/kvm/aia_device.c b/arch/riscv/kvm/aia_device.c index 0eb689351b7d0..5cd407c6a8e4f 100644 --- a/arch/riscv/kvm/aia_device.c +++ b/arch/riscv/kvm/aia_device.c @@ -237,10 +237,11 @@ static gpa_t aia_imsic_ppn(struct kvm_aia *aia, gpa_t addr) static u32 aia_imsic_hart_index(struct kvm_aia *aia, gpa_t addr) { - u32 hart, group = 0; + u32 hart = 0, group = 0; - hart = (addr >> (aia->nr_guest_bits + IMSIC_MMIO_PAGE_SHIFT)) & - GENMASK_ULL(aia->nr_hart_bits - 1, 0); + if (aia->nr_hart_bits) + hart = (addr >> (aia->nr_guest_bits + IMSIC_MMIO_PAGE_SHIFT)) & + GENMASK_ULL(aia->nr_hart_bits - 1, 0); if (aia->nr_group_bits) group = (addr >> aia->nr_group_shift) & GENMASK_ULL(aia->nr_group_bits - 1, 0); -- 2.43.0