All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ankit Kumar <ankit.kumar@samsung.com>
To: kbusch@kernel.org, its@irrelevant.dk
Cc: qemu-devel@nongnu.org, Ankit Kumar <ankit.kumar@samsung.com>
Subject: [PATCH 2/3] hw/nvme: fix disable pi checks for Type 3 protection
Date: Tue,  8 Aug 2023 02:57:44 +0530	[thread overview]
Message-ID: <20230807212745.70151-3-ankit.kumar@samsung.com> (raw)
In-Reply-To: <20230807212745.70151-1-ankit.kumar@samsung.com>

As per the NVM command set specification, the protection information
checks for Type 3 protection are disabled, only when both application
and reference tag have all bits set to 1.

Signed-off-by: Ankit Kumar <ankit.kumar@samsung.com>
---
 hw/nvme/dif.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/hw/nvme/dif.c b/hw/nvme/dif.c
index 01b19c3373..f9bd29a2a6 100644
--- a/hw/nvme/dif.c
+++ b/hw/nvme/dif.c
@@ -157,7 +157,8 @@ static uint16_t nvme_dif_prchk_crc16(NvmeNamespace *ns, NvmeDifTuple *dif,
 {
     switch (NVME_ID_NS_DPS_TYPE(ns->id_ns.dps)) {
     case NVME_ID_NS_DPS_TYPE_3:
-        if (be32_to_cpu(dif->g16.reftag) != 0xffffffff) {
+        if ((be32_to_cpu(dif->g16.reftag) != 0xffffffff) ||
+            (be16_to_cpu(dif->g16.apptag) != 0xffff)) {
             break;
         }
 
@@ -225,7 +226,7 @@ static uint16_t nvme_dif_prchk_crc64(NvmeNamespace *ns, NvmeDifTuple *dif,
 
     switch (NVME_ID_NS_DPS_TYPE(ns->id_ns.dps)) {
     case NVME_ID_NS_DPS_TYPE_3:
-        if (r != 0xffffffffffff) {
+        if (r != 0xffffffffffff || (be16_to_cpu(dif->g64.apptag) != 0xffff)) {
             break;
         }
 
-- 
2.25.1



  parent reply	other threads:[~2023-08-08  1:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20230807160836epcas5p34398954fecd7388469012404b09b78f9@epcas5p3.samsung.com>
2023-08-07 21:27 ` [PATCH 0/3] hw/nvme: bug fixes and doc update Ankit Kumar
2023-08-07 21:27   ` [PATCH 1/3] hw/nvme: fix CRC64 for guard tag Ankit Kumar
2023-08-08  5:58     ` Klaus Jensen
2023-08-07 21:27   ` Ankit Kumar [this message]
2023-08-08  5:57     ` [PATCH 2/3] hw/nvme: fix disable pi checks for Type 3 protection Klaus Jensen
2023-08-07 21:27   ` [PATCH 3/3] docs: update hw/nvme documentation for protection information Ankit Kumar
2023-08-08  5:59     ` Klaus Jensen
2023-08-08  6:04   ` [PATCH 0/3] hw/nvme: bug fixes and doc update Michael Tokarev
2023-08-08  6:06     ` Klaus Jensen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230807212745.70151-3-ankit.kumar@samsung.com \
    --to=ankit.kumar@samsung.com \
    --cc=its@irrelevant.dk \
    --cc=kbusch@kernel.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.