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 EBC5924BBFD; Thu, 17 Apr 2025 18:50:54 +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=1744915855; cv=none; b=shz2ITNtzScfTS+tWta3lcjNnIiu4YguOvieJJRQuML/dDfBPuVnxpePzT2niEi/KywHGoMalCFoL7oxD/9iddfqTfI4f/NeejIvuXCGxEsz6kttFPCqPzUdXr1RvkA3CB3cTJuIyXdwxzoW6tCMZ5F2vkuTtnZKNigNotTPpFk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744915855; c=relaxed/simple; bh=xVGHOw/dh5VZt4TveYVpb0I+IvCGC71ocfn0f/n5WNU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VXWPJcx+JM3+EcjWuLq4hnHIvvQy9h6zOd+2CdUcNZSpPCRNRqv0CWVOOjJ/yuKXn9e0/VbAKpD/k/y8+J0iYcaH2qRErra8VAuk1CHNNRplp8asXgozwXyYqSbIiqcsgF9wNqnkhJssAd1vIAqsYm13g4yzKBecU+OMzmrNLco= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=mhhBd9Kj; 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="mhhBd9Kj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E560C4CEE4; Thu, 17 Apr 2025 18:50:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1744915854; bh=xVGHOw/dh5VZt4TveYVpb0I+IvCGC71ocfn0f/n5WNU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mhhBd9KjyW3E1xZfR7j9t7lWEyXRzk/j9PyCgql3O1KGIztoo5exMFJWYYyIGpGUR +zP16gzXE/6n6OmxtlGZRqXebEjQSDjCBSpCOMxSB3TBg7ONXfNlu9iVy7Yg+n6win yE+SeuCYFzg+1IcWo7dtZyUb6u0Aa5QSKN39hMYk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Cong Meng , Si-Wei Liu , Dragos Tatulea , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , "Michael S. Tsirkin" , Jason Wang Subject: [PATCH 6.12 262/393] vdpa/mlx5: Fix oversized null mkey longer than 32bit Date: Thu, 17 Apr 2025 19:51:11 +0200 Message-ID: <20250417175118.142700505@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250417175107.546547190@linuxfoundation.org> References: <20250417175107.546547190@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-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Si-Wei Liu commit a6097e0a54a5c24f8d577ffecbc35289ae281c2e upstream. create_user_mr() has correct code to count the number of null keys used to fill in a hole for the memory map. However, fill_indir() does not follow the same to cap the range up to the 1GB limit correspondingly. Fill in more null keys for the gaps in between, so that null keys are correctly populated. Fixes: 94abbccdf291 ("vdpa/mlx5: Add shared memory registration code") Cc: stable@vger.kernel.org Reported-by: Cong Meng Signed-off-by: Si-Wei Liu Signed-off-by: Dragos Tatulea Acked-by: Eugenio Pérez Message-Id: <20250220193732.521462-2-dtatulea@nvidia.com> Signed-off-by: Michael S. Tsirkin Acked-by: Jason Wang Signed-off-by: Greg Kroah-Hartman --- drivers/vdpa/mlx5/core/mr.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/drivers/vdpa/mlx5/core/mr.c +++ b/drivers/vdpa/mlx5/core/mr.c @@ -190,9 +190,12 @@ again: klm->bcount = cpu_to_be32(klm_bcount(dmr->end - dmr->start)); preve = dmr->end; } else { + u64 bcount = min_t(u64, dmr->start - preve, MAX_KLM_SIZE); + klm->key = cpu_to_be32(mvdev->res.null_mkey); - klm->bcount = cpu_to_be32(klm_bcount(dmr->start - preve)); - preve = dmr->start; + klm->bcount = cpu_to_be32(klm_bcount(bcount)); + preve += bcount; + goto again; } }