From patchwork Wed Feb 26 18:09:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 13992885 Received: from mx0a-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) (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 C9D9E2356A2 for ; Wed, 26 Feb 2025 18:10:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.153.30 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740593422; cv=none; b=UE8XolKRKKkXk32zLDFEqfHo0pvjgz/EuUMhvSFVZcGOowYrrdN61QIoFK3hG728l98RgK32rg5LAIx0E1nBbCOgmpUo8RhSxhF+SWO+sm7mmI5H4vS8RwQB6fwjlc++j+ZNTCd/YTcTIdOzkDP7lz7XAOCh8qDlKcJ5mef2z9s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740593422; c=relaxed/simple; bh=vXpPB62p/gOzDfVR0WVJxsPbSl2431glAEKWypdX2WI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VaJkmSBCvwrYUMgM5o0HBz1XrzibG4Z8KTDlK6BtHIM/BRlNS49Aj5q8lWXxP55m9X2pANAqofDS2m532hwEAcvpdgInD30kc+arLbkdte8oluW5+lnLGLXclvixJbbiKhw4AHky35H1ZtvsPAsZLSM84IXd9FHHpbe6RwPs3qk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=meta.com; spf=pass smtp.mailfrom=meta.com; dkim=pass (2048-bit key) header.d=meta.com header.i=@meta.com header.b=WFVoI5x+; arc=none smtp.client-ip=67.231.153.30 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=meta.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=meta.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=meta.com header.i=@meta.com header.b="WFVoI5x+" Received: from pps.filterd (m0001303.ppops.net [127.0.0.1]) by m0001303.ppops.net (8.18.1.2/8.18.1.2) with ESMTP id 51QFa4K0015056 for ; Wed, 26 Feb 2025 10:10:19 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meta.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=s2048-2021-q4; bh=rhZprq/fhlitTeHklVfwoWYolzCx7OIds6d1dWBk5OU=; b=WFVoI5x+pBUZ c+3cbYaRIfgTmZ5BjCxmXv06yV6ytFzsi1+ouoRFjNfL7eMEud+yET+QBBITXSPd 5mMQbdqdR0GH3HLHD5an763R+Do3gQZsYmTVwp22ULgnA76BxhQ2g5YQfPoHop3M zkrCEPUvVBSUlLT/KF0wFcuUY5jTdqSVtzR30ka9g1qTGC4m+qblW/yYM1m9N7wH 1O/s4OQ8j8inkOjuLzFSGaH31D/OwjItDiqIQeM+yRAFeNVH5NHOThLtg92ZKZC8 TR4aGRvLGK9z2iLkrktIqQK3sg6TZ99VXC8xdCxnWvLhQZU7N5k4UVPcSwXnhGaE H+nxyUKbRQ== Received: from maileast.thefacebook.com ([163.114.135.16]) by m0001303.ppops.net (PPS) with ESMTPS id 4525r796mp-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 26 Feb 2025 10:10:18 -0800 (PST) Received: from twshared18153.09.ash9.facebook.com (2620:10d:c0a8:1b::2d) by mail.thefacebook.com (2620:10d:c0a9:6f::8fd4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1544.14; Wed, 26 Feb 2025 18:10:05 +0000 Received: by devbig638.nha1.facebook.com (Postfix, from userid 544533) id C71C1187C4ADA; Wed, 26 Feb 2025 10:10:06 -0800 (PST) From: Keith Busch To: , , , , CC: , , , Xinyu Zhang , Keith Busch Subject: [PATCHv6 2/5] nvme: map uring_cmd data even if address is 0 Date: Wed, 26 Feb 2025 10:09:55 -0800 Message-ID: <20250226181002.2574148-5-kbusch@meta.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250226181002.2574148-1-kbusch@meta.com> References: <20250226181002.2574148-1-kbusch@meta.com> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: pwCiVuUb-OtJhYhrY9vlpjUHs0Hm1sRZ X-Proofpoint-ORIG-GUID: pwCiVuUb-OtJhYhrY9vlpjUHs0Hm1sRZ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-02-26_04,2025-02-26_01,2024-11-22_01 From: Xinyu Zhang When using kernel registered bvec fixed buffers, the "address" is actually the offset into the bvec rather than userspace address. Therefore it can be 0. We can skip checking whether the address is NULL before mapping uring_cmd data. Bad userspace address will be handled properly later when the user buffer is imported. With this patch, we will be able to use the kernel registered bvec fixed buffers in io_uring NVMe passthru with ublk zero-copy support. Reviewed-by: Caleb Sander Mateos Reviewed-by: Jens Axboe Reviewed-by: Ming Lei Signed-off-by: Xinyu Zhang Signed-off-by: Keith Busch --- drivers/nvme/host/ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c index 5078d9aaf88fc..ecf136489044f 100644 --- a/drivers/nvme/host/ioctl.c +++ b/drivers/nvme/host/ioctl.c @@ -516,7 +516,7 @@ static int nvme_uring_cmd_io(struct nvme_ctrl *ctrl, struct nvme_ns *ns, return PTR_ERR(req); req->timeout = d.timeout_ms ? msecs_to_jiffies(d.timeout_ms) : 0; - if (d.addr && d.data_len) { + if (d.data_len) { ret = nvme_map_user_request(req, d.addr, d.data_len, nvme_to_user_ptr(d.metadata), d.metadata_len, ioucmd, vec, issue_flags);