From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) (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 52C6C1D0DC7 for ; Wed, 30 Oct 2024 18:10:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730311826; cv=none; b=KSsAbev90MRl/xIhfEFiYmo7Mr0WyeybU20qtouK55SSJoefC9TXG+g+t8fJRmm4oQKi6QTqXnPFmQQpVpVdtfNdzwZqaDXi8LIgiMKQxTEAk3uIU5jnXkgVSaovkZuz6A9ZqzjQ90B5jWQ8qmQEHOQJOlkInjOFRqqEhVujogQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730311826; c=relaxed/simple; bh=YXb7qnO3lu5vkwg1bZcdx5PFo4CJX/dp1xu0WKlJFxM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=b/0W9JZRJ9rRTwTi7l53EHGbiJHL5bvGUMwFbaINhbaNyDvUEnpXIsIRRC0rbm0n3GytNB/dK5gCQPLUL6CuiaDEj5qg+HaiAO4b1t5c2L2NMTM7nwU6El2dSKayhY6gQGpHmuVqNytS0yjlMZ6JyPrdh7UUdad+MLWIYJ4qdlY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=PExMpOWM; arc=none smtp.client-ip=203.254.224.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="PExMpOWM" Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20241030181019epoutp04bdc9ad7441d6afd18099e95e846eba79~DTW6QBpbT0312803128epoutp04Y for ; Wed, 30 Oct 2024 18:10:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20241030181019epoutp04bdc9ad7441d6afd18099e95e846eba79~DTW6QBpbT0312803128epoutp04Y DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1730311819; bh=1mlKPMPKFIJBhlmH3o5xGb/9qatIJGaThyCajlxzjfU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PExMpOWMWYHvT5UCN3TUMoRTmBIducyLf+QJvlxHgsTIwTOi2NjgE0ceO4GWa6lup j/tzE8ID/bYQD5vuEHQFFeflLHmseE8dNG/0++tEiQhFIKJIATcEGo6z7v9MMZPRid jvJTKBWLfGUWGgSBCEyOhHpufEvWjK95EDYfSDkE= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20241030181018epcas5p147bd46c689df9a0893db55d290631dc6~DTW5uEoup1452514525epcas5p1G; Wed, 30 Oct 2024 18:10:18 +0000 (GMT) Received: from epsmgec5p1-new.samsung.com (unknown [182.195.38.179]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4XdwCD695wz4x9Pt; Wed, 30 Oct 2024 18:10:16 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmgec5p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id B7.2C.18935.88672276; Thu, 31 Oct 2024 03:10:16 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20241030181016epcas5p3da284aa997e81d9855207584ab4bace3~DTW3ybWDS3027830278epcas5p3D; Wed, 30 Oct 2024 18:10:16 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20241030181016epsmtrp141d51540d875f3db54687f7596e4f268~DTW3xl6V00151201512epsmtrp1-; Wed, 30 Oct 2024 18:10:16 +0000 (GMT) X-AuditID: b6c32a50-cb1f8700000049f7-b5-6722768892c4 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id A2.C6.08227.88672276; Thu, 31 Oct 2024 03:10:16 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20241030181013epsmtip267fc962ebcf5efff16e5a37bbf763948~DTW1USSch0238402384epsmtip2q; Wed, 30 Oct 2024 18:10:13 +0000 (GMT) From: Kanchan Joshi To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com, asml.silence@gmail.com, brauner@kernel.org, viro@zeniv.linux.org.uk, jack@suse.cz Cc: linux-nvme@lists.infradead.org, linux-fsdevel@vger.kernel.org, io-uring@vger.kernel.org, linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, gost.dev@samsung.com, vishak.g@samsung.com, anuj1072538@gmail.com, Anuj Gupta , Kanchan Joshi Subject: [PATCH v6 07/10] block: introduce BIP_CHECK_GUARD/REFTAG/APPTAG bip_flags Date: Wed, 30 Oct 2024 23:31:09 +0530 Message-Id: <20241030180112.4635-8-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241030180112.4635-1-joshi.k@samsung.com> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrHJsWRmVeSWpSXmKPExsWy7bCmlm5HmVK6Qd8ZPYu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wlopnuq/Juy29aarslydIMvO57a1pSaru/fwRcl7mMw+3/BM 7G7k7TCxJ5INO0+muK1f9P/ti7ZrP59XF71dae5RVrHzc+S9d1s8XrGU+C0Q2O+iYzkvIeXb Skmu2IXaKz7rip171X1E4c0F6xcxHivXnCxWqm2ZF9EnZ9ono3zRpKV32XFT6Q/T36r9XpH2 aP/2s8/WC276dHV209oNSizFGYmGWsxFxYkAFlkzZSYDAAA= X-CMS-MailID: 20241030181016epcas5p3da284aa997e81d9855207584ab4bace3 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241030181016epcas5p3da284aa997e81d9855207584ab4bace3 References: <20241030180112.4635-1-joshi.k@samsung.com> From: Anuj Gupta This patch introduces BIP_CHECK_GUARD/REFTAG/APPTAG bip_flags which indicate how the hardware should check the integrity payload. BIP_CHECK_GUARD/REFTAG are conversion of existing semantics, while BIP_CHECK_APPTAG is a new flag. The driver can now just rely on block layer flags, and doesn't need to know the integrity source. Submitter of PI decides which tags to check. This would also give us a unified interface for user and kernel generated integrity. Signed-off-by: Anuj Gupta Signed-off-by: Kanchan Joshi Reviewed-by: Christoph Hellwig Reviewed-by: Keith Busch --- block/bio-integrity.c | 5 +++++ drivers/nvme/host/core.c | 11 +++-------- include/linux/bio-integrity.h | 6 +++++- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index f56d01cec689..3bee43b87001 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -434,6 +434,11 @@ bool bio_integrity_prep(struct bio *bio) if (bi->csum_type == BLK_INTEGRITY_CSUM_IP) bip->bip_flags |= BIP_IP_CHECKSUM; + /* describe what tags to check in payload */ + if (bi->csum_type) + bip->bip_flags |= BIP_CHECK_GUARD; + if (bi->flags & BLK_INTEGRITY_REF_TAG) + bip->bip_flags |= BIP_CHECK_REFTAG; if (bio_integrity_add_page(bio, virt_to_page(buf), len, offset_in_page(buf)) < len) { printk(KERN_ERR "could not attach integrity payload\n"); diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 3de7555a7de7..79bd6b22e88d 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -1004,18 +1004,13 @@ static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns, control |= NVME_RW_PRINFO_PRACT; } - switch (ns->head->pi_type) { - case NVME_NS_DPS_PI_TYPE3: + if (bio_integrity_flagged(req->bio, BIP_CHECK_GUARD)) control |= NVME_RW_PRINFO_PRCHK_GUARD; - break; - case NVME_NS_DPS_PI_TYPE1: - case NVME_NS_DPS_PI_TYPE2: - control |= NVME_RW_PRINFO_PRCHK_GUARD | - NVME_RW_PRINFO_PRCHK_REF; + if (bio_integrity_flagged(req->bio, BIP_CHECK_REFTAG)) { + control |= NVME_RW_PRINFO_PRCHK_REF; if (op == nvme_cmd_zone_append) control |= NVME_RW_APPEND_PIREMAP; nvme_set_ref_tag(ns, cmnd, req); - break; } } diff --git a/include/linux/bio-integrity.h b/include/linux/bio-integrity.h index 58ff9988433a..fe2bfe122db2 100644 --- a/include/linux/bio-integrity.h +++ b/include/linux/bio-integrity.h @@ -11,6 +11,9 @@ enum bip_flags { BIP_DISK_NOCHECK = 1 << 3, /* disable disk integrity checking */ BIP_IP_CHECKSUM = 1 << 4, /* IP checksum */ BIP_COPY_USER = 1 << 5, /* Kernel bounce buffer in use */ + BIP_CHECK_GUARD = 1 << 6, /* guard check */ + BIP_CHECK_REFTAG = 1 << 7, /* reftag check */ + BIP_CHECK_APPTAG = 1 << 8, /* apptag check */ }; struct bio_integrity_payload { @@ -31,7 +34,8 @@ struct bio_integrity_payload { }; #define BIP_CLONE_FLAGS (BIP_MAPPED_INTEGRITY | BIP_CTRL_NOCHECK | \ - BIP_DISK_NOCHECK | BIP_IP_CHECKSUM) + BIP_DISK_NOCHECK | BIP_IP_CHECKSUM | \ + BIP_CHECK_GUARD | BIP_CHECK_REFTAG | BIP_CHECK_APPTAG) #ifdef CONFIG_BLK_DEV_INTEGRITY -- 2.25.1