From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) (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 2FA89187877 for ; Fri, 23 Aug 2024 10:48:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.25 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724410113; cv=none; b=oSoattB3sAkMHrQ0rGKxuZQUkXWfMrCWBXluOrvZQ1m0QyE/AyOepHwGyl4TwWYVgdc0VKibmXJGTZWVdIBKJXq5hQsPibRndWuFiTejdrjJ8sD/qmNjRmikI3/2FqjiT+oAG4l/De2LShFcDqwzqxbME3OM3J2eykMZEz9saj0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724410113; c=relaxed/simple; bh=kmTSdUT+bP9tsddpB6eT+RYHgy7lddAPgpddvcZdAGA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=HA+NAkzZRq8DAfOiuaLcFzH+vj2PL2bAkMghwTa2GvHet+L69Ixq/A/k8lDRchJMHsXlFeIzLkePly6wkDV8+J17v+CsNdcOITIdtbR3ja5UWdjlFb91XyjK4Z4V7IyjHWCm1889bYfWGORK7Yt+bg9EC8HDi3rpGQsbZJZKsTs= 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=IaH3U1m0; arc=none smtp.client-ip=203.254.224.25 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="IaH3U1m0" Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20240823104830epoutp02a65b88ebfe30fb6b832dbd23f1c13ff5~uVdv4Lzvu1185511855epoutp02U for ; Fri, 23 Aug 2024 10:48:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20240823104830epoutp02a65b88ebfe30fb6b832dbd23f1c13ff5~uVdv4Lzvu1185511855epoutp02U DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1724410110; bh=fdfNA1BhNobCcdbbPzAPNJ/9rXGRREf8RhQ25IpYD8c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IaH3U1m05Yq56Z7hn3yIih+AQk+KehLWxeJp1gGJ34wrKxTb3vFMnkr0+e2m27HBj sNQtTIKYVa9CbCR7Y7hboZXtiQMihPnR/YNn3mpOB5Ht2DQeht+oyseuZ5P/e9uL6Y bD1nFR16J2gRb4QsvXxhFL25Jx69fLczp8zbXdWo= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20240823104830epcas5p4826c24b394f3cb5b21217d069f39561b~uVdvg2IsV1745317453epcas5p4t; Fri, 23 Aug 2024 10:48:30 +0000 (GMT) Received: from epsmgec5p1-new.samsung.com (unknown [182.195.38.175]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4Wqxcr3YY8z4x9Q1; Fri, 23 Aug 2024 10:48:28 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmgec5p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id 5D.8A.19863.CF868C66; Fri, 23 Aug 2024 19:48:28 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20240823104629epcas5p3fea0cb7e66b0446ddacf7648c08c3ba8~uVb-MALz22095320953epcas5p3W; Fri, 23 Aug 2024 10:46:29 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240823104629epsmtrp132972e540270c63d4dfd7abdd7d847fe~uVb-LNNz00257302573epsmtrp1N; Fri, 23 Aug 2024 10:46:29 +0000 (GMT) X-AuditID: b6c32a50-ef5fe70000004d97-1e-66c868fc3e24 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 03.6F.07567.58868C66; Fri, 23 Aug 2024 19:46:29 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240823104627epsmtip2ec3a72087ba73c78ad139cde0b1e31dc~uVb9G5eM91384313843epsmtip2T; Fri, 23 Aug 2024 10:46:27 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com, asml.silence@gmail.com, krisman@suse.de Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, linux-scsi@vger.kernel.org, Anuj Gupta , Kanchan Joshi Subject: [PATCH v3 07/10] block: introduce BIP_CHECK_GUARD/REFTAG/APPTAG bip_flags Date: Fri, 23 Aug 2024 16:08:07 +0530 Message-Id: <20240823103811.2421-8-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240823103811.2421-1-anuj20.g@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+NgFtrPJsWRmVeSWpSXmKPExsWy7bCmpu6fjBNpBj/XiVs0TfjLbDFn1TZG i9V3+9ksbh7YyWSxcvVRJot3redYLI7+f8t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prz3Yf iVFpeyyy//Dj1pJndqwX9E3CvW/a7rKqmiuxepOGEktxRqKhFnNRcSIAQo2TTwgDAAA= X-CMS-MailID: 20240823104629epcas5p3fea0cb7e66b0446ddacf7648c08c3ba8 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240823104629epcas5p3fea0cb7e66b0446ddacf7648c08c3ba8 References: <20240823103811.2421-1-anuj20.g@samsung.com> This patch introduces BIP_CHECK_GUARD/REFTAG/APPTAG bip_flags which indicate how the hardware should check the integrity payload. 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 --- block/bio-integrity.c | 5 +++++ drivers/nvme/host/core.c | 12 +++--------- include/linux/bio-integrity.h | 6 +++++- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index aaf67eb427ab..7fbf8c307a36 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -444,6 +444,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 33fa01c599ad..d4c366df8f12 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -1002,19 +1002,13 @@ static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns, return BLK_STS_NOTSUPP; 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 a1a9031a5985..c7c0121689e1 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, + BIP_CHECK_REFTAG = 1 << 7, + BIP_CHECK_APPTAG = 1 << 8, }; struct bio_integrity_payload { @@ -40,7 +43,8 @@ struct uio_meta { }; #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