From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B012EC433DB for ; Mon, 11 Jan 2021 16:47:47 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 476ED2242A for ; Mon, 11 Jan 2021 16:47:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 476ED2242A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-nvme-bounces+linux-nvme=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=AVgxqSuOQlC7xOrTjJtSN1ZW8qWM2+FkoR2UGk/o7WM=; b=tkZfbASkLmoYCaLF2JVS35pw3 /UZeLKEOdEJtf/xAfIwvORA0dG/0yA+Xte+dmy8/bU2atMQG8w003O1qwbhVJZS66XBhzLMmpm5L2 r0jLfZ0bmWTVcmUbLNqsMLaKIEug13AHFRe30EdBmX85m/Kqg7g1mFcYkRjQlN1vsoqN+FFoZWyCQ lrkG4AeeWd3Kf7QbxyGDpwGUb2HYYmZb4T9UlLeMgUoTMCowRGMBiNsnLZK3W5Jcz4e9mbXVjcnq2 qRMPq4aJ4vRL2OdPJEle6xkcr7JS4A6DQOQS42f9YkMis0rOE0r4/7tA7B7FdP+r5JuYtSf01jK+j l4xS+AIfw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kz0Lw-0005LR-6A; Mon, 11 Jan 2021 16:47:36 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kz0Lu-0005Kg-2V for linux-nvme@lists.infradead.org; Mon, 11 Jan 2021 16:47:34 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id CE3BC2242A; Mon, 11 Jan 2021 16:47:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1610383652; bh=DcoNnI5Xjdu1d4E54gqgqEnxM3nJaKUBSRb0XSqZK90=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KC25qTaAfpBeoQlnZCr2uZcDYy356hkQvSBSw7fX3qm4K9z7QgBDuV5bUzvO28GEi u7DODJ12WNWuH6mmTPoG+c63sGBRbAmcXj9yHXzyF5WUyZD7Hr9vISZs7k8z2BTZYt iQPfPmtNjvJ5o+IEIqG5B20w+Og90B0/gRiEutBCl0mNmV9s+Cn2LvR7QjXQd+qQbJ 3zPQIi8ouW53Yxfj0bG+gW3MtORKLJTOdueuskmPqW5zZk0mOFeScumFvwJt9TnI12 8ydSy2necmDZ+I1/85Nq6g8cs9hjByygHpKE7Wo02rN65UmQgcvOeWczvk0ZJBQpXs jnDkZIrjJrx0A== Date: Mon, 11 Jan 2021 08:47:29 -0800 From: Keith Busch To: Revanth Rajashekar Subject: Re: [PATCH] nvme: Check the PRINFO bit and the Metadata size before deciding the host buffer length Message-ID: <20210111164729.GB1458209@dhcp-10-100-145-180.wdc.com> References: <20210111162602.29305-1-revanth.rajashekar@intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210111162602.29305-1-revanth.rajashekar@intel.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210111_114734_215659_C1BDEDC0 X-CRM114-Status: GOOD ( 13.12 ) X-BeenThere: linux-nvme@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jonathan Derrick , hch@lst.de, linux-nvme@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Linux-nvme" Errors-To: linux-nvme-bounces+linux-nvme=archiver.kernel.org@lists.infradead.org On Mon, Jan 11, 2021 at 09:26:02AM -0700, Revanth Rajashekar wrote: > +#define NVME_PRINFO_CTRL_BIT (13) This bit already defined as 'NVME_RW_PRINFO_PRACT'. > static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio) > { > struct nvme_user_io io; > struct nvme_command c; > unsigned length, meta_len; > void __user *metadata; > + unsigned long control; You can remove this variable. > > if (copy_from_user(&io, uio, sizeof(io))) > return -EFAULT; > @@ -1297,6 +1299,12 @@ static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio) > length = (io.nblocks + 1) << ns->lba_shift; > meta_len = (io.nblocks + 1) * ns->ms; > metadata = nvme_to_user_ptr(io.metadata); > + control = cpu_to_le16(io.control); You're checking the bit with the CPU arch's native endianness, so you shouldn't be byte swapping here for BE archs. > + if (test_bit(NVME_PRINFO_CTRL_BIT, &control) && ns->ms == 8) { No need for the "test_bit()" here, you can just do: if (io.control & NVME_RW_PRINFO_PRACT && ms == 8)) > + meta_len = 0; > + metadata = NULL; > + } _______________________________________________ Linux-nvme mailing list Linux-nvme@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-nvme