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 84C81221543; Mon, 23 Jun 2025 22:25:33 +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=1750717533; cv=none; b=Au7g4KHG/zRNlpJOZDRvD7kV7sjlXlCaklSclU4iZCnmhFIANm7BzTkMy9dqtc4HQhZ0Z1WYLvmNCb+8BL3aSrEpI1WE8Fqs678Fm7QsPNAOnMk3Rk8zNZTtinO9SWSmrQyu9d8GkOc5LERz20UUG8PlGymBLpbpdkA1JJhn5bs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750717533; c=relaxed/simple; bh=h2ESqK2WhJoIF47qLaO9/LWsJ6meponAZsQ3Xb78no8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QdeWCZve8LwUL/lGI3Z8+Ju6mEb8PRtSesz79c8OR8HAgCnjHi+HkqUrDsLFtk93WP6fRkDpnQG7BqwDSmjk7hXjfbHsxc3wjIWVWGCpoD/4Qt66Ndqj2cuIx0JiO7erq36Kedw/DjtdeE201+yFFDad3dk2iLCTDEC25hODlDE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ZE3pL9Dk; 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="ZE3pL9Dk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1CC40C4CEEA; Mon, 23 Jun 2025 22:25:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1750717533; bh=h2ESqK2WhJoIF47qLaO9/LWsJ6meponAZsQ3Xb78no8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZE3pL9DkZgIkBMUh3ZEhcDcaF+e++nwkzkB/fuS+V4GilWgTgndVSIwE6v6G19w8j 0mFpE/trTm7hihLSzVZCt9S47vjhkUFNaJ8hcBCR77EJx9r71e051/QjeiCD2yi5hu 4Ayx9T+vCexFKHMvk4EmF1XYO3d6+Ofbp5GJWCVc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Atish Patra , Anup Patel , Anup Patel , Sasha Levin Subject: [PATCH 6.12 408/414] RISC-V: KVM: Fix the size parameter check in SBI SFENCE calls Date: Mon, 23 Jun 2025 15:09:05 +0200 Message-ID: <20250623130652.147953373@linuxfoundation.org> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250623130642.015559452@linuxfoundation.org> References: <20250623130642.015559452@linuxfoundation.org> User-Agent: quilt/0.68 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.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Anup Patel [ Upstream commit 6aba0cb5bba6141158d5449f2cf53187b7f755f9 ] As-per the SBI specification, an SBI remote fence operation applies to the entire address space if either: 1) start_addr and size are both 0 2) size is equal to 2^XLEN-1 >>From the above, only #1 is checked by SBI SFENCE calls so fix the size parameter check in SBI SFENCE calls to cover #2 as well. Fixes: 13acfec2dbcc ("RISC-V: KVM: Add remote HFENCE functions based on VCPU requests") Reviewed-by: Atish Patra Signed-off-by: Anup Patel Link: https://lore.kernel.org/r/20250605061458.196003-2-apatel@ventanamicro.com Signed-off-by: Anup Patel Signed-off-by: Sasha Levin --- arch/riscv/kvm/vcpu_sbi_replace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/riscv/kvm/vcpu_sbi_replace.c b/arch/riscv/kvm/vcpu_sbi_replace.c index 5fbf3f94f1e85..9752d2ffff683 100644 --- a/arch/riscv/kvm/vcpu_sbi_replace.c +++ b/arch/riscv/kvm/vcpu_sbi_replace.c @@ -103,7 +103,7 @@ static int kvm_sbi_ext_rfence_handler(struct kvm_vcpu *vcpu, struct kvm_run *run kvm_riscv_vcpu_pmu_incr_fw(vcpu, SBI_PMU_FW_FENCE_I_SENT); break; case SBI_EXT_RFENCE_REMOTE_SFENCE_VMA: - if (cp->a2 == 0 && cp->a3 == 0) + if ((cp->a2 == 0 && cp->a3 == 0) || cp->a3 == -1UL) kvm_riscv_hfence_vvma_all(vcpu->kvm, hbase, hmask); else kvm_riscv_hfence_vvma_gva(vcpu->kvm, hbase, hmask, @@ -111,7 +111,7 @@ static int kvm_sbi_ext_rfence_handler(struct kvm_vcpu *vcpu, struct kvm_run *run kvm_riscv_vcpu_pmu_incr_fw(vcpu, SBI_PMU_FW_HFENCE_VVMA_SENT); break; case SBI_EXT_RFENCE_REMOTE_SFENCE_VMA_ASID: - if (cp->a2 == 0 && cp->a3 == 0) + if ((cp->a2 == 0 && cp->a3 == 0) || cp->a3 == -1UL) kvm_riscv_hfence_vvma_asid_all(vcpu->kvm, hbase, hmask, cp->a4); else -- 2.39.5