From nobody Tue May 21 06:27:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=yadro.com ARC-Seal: i=1; a=rsa-sha256; t=1650538593; cv=none; d=zohomail.com; s=zohoarc; b=n68EyK8FDV5sA/MQtbzPS6FxZPcvPKbYy0KgrSp7eP7JQ0jvoV9fH+6PHunzjPoB3CQNmr4tVl5TyNE+64tCoMivgsrdhOxhZFIa/mOsN8uIol6AcyGi9GOEJjMcvGYhg8e+hJt6JZvwcf09Pb/bziV8/HIsNjVza+nym/oxPrU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650538593; h=Content-Type:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=lLHBujjxE82j4NCvQrcrvQEqsTO4HczbxpUQTSfRVzU=; b=L3KOxiIsyI1yYrYRlGSiiIyRK0LeeCpoat9TF0/xF2naSz1TX/TeHbBjuVkvPKT9qwN8HqCkZ2JP3mEy5y6vwfQ6V/9NTQnK4curMK8HzgKNQrORvT5yw0XycK76bmVIDe0Rx2jlxxhlV6a3awEbsapvcSL2ju0mSE81NR/R1M8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1650538593234130.51734432271724; Thu, 21 Apr 2022 03:56:33 -0700 (PDT) Received: from localhost ([::1]:50602 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhUUB-0007Qg-3u for importer@patchew.org; Thu, 21 Apr 2022 06:56:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52606) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhUPw-00048A-Du; Thu, 21 Apr 2022 06:52:08 -0400 Received: from mta-02.yadro.com ([89.207.88.252]:44140 helo=mta-01.yadro.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhUPu-0006S2-JI; Thu, 21 Apr 2022 06:52:07 -0400 Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id 6B09943AC2; Thu, 21 Apr 2022 10:52:02 +0000 (UTC) Received: from mta-01.yadro.com ([127.0.0.1]) by localhost (mta-01.yadro.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tjrAFQjctvJx; Thu, 21 Apr 2022 13:52:01 +0300 (MSK) Received: from T-EXCH-04.corp.yadro.com (t-exch-04.corp.yadro.com [172.17.100.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mta-01.yadro.com (Postfix) with ESMTPS id 0BABD42A76; Thu, 21 Apr 2022 13:52:01 +0300 (MSK) Received: from localhost.localdomain (10.178.113.54) by T-EXCH-04.corp.yadro.com (172.17.100.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.32; Thu, 21 Apr 2022 13:51:59 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yadro.com; h= content-disposition:content-type:content-type:mime-version :message-id:subject:subject:from:from:date:date:received :received:received; s=mta-01; t=1650538321; x=1652352722; bh=tSd GUMRbMRQrX8T/WiS7EqDhiBuqZH2WUSozgmuRUDE=; b=MyNZ8ppdbJqvQhuGsJ8 QasGkmlo1r+1DRpssJMljZbhU4gmLoWZYsqqTjKCLMwH48l3tqSok4xyR7ldvfQR 7a1jfJPgXBDbLoXXMinzo393oBWKgMgZJ7t7bzg9DBCDpqQ59EtTwNNaY3ljqUF7 4MPp6JNVEGUjuaHxlVd3FLtk= X-Virus-Scanned: amavisd-new at yadro.com Date: Thu, 21 Apr 2022 13:51:58 +0300 From: Dmitry Tikhov To: Subject: [PATCH v2] hw/nvme: fix copy cmd for pi enabled namespaces Message-ID: <20220421105158.ufd3wzivaougxokx@localhost.localdomain> MIME-Version: 1.0 Content-Disposition: inline X-Originating-IP: [10.178.113.54] X-ClientProxiedBy: T-EXCH-01.corp.yadro.com (172.17.10.101) To T-EXCH-04.corp.yadro.com (172.17.100.104) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=89.207.88.252; envelope-from=d.tihov@yadro.com; helo=mta-01.yadro.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kbusch@kernel.org, its@irrelevant.dk, ddtikhov@gmail.com, qemu-block@nongnu.org, linux@yadro.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @yadro.com) X-ZM-MESSAGEID: 1650538594701100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Current implementation have problem in the read part of copy command. Because there is no metadata mangling before nvme_dif_check invocation, reftag error could be thrown for blocks of namespace that have not been previously written to. Signed-off-by: Dmitry Tikhov --- v2: * remove refactoring * remove write part fix --- hw/nvme/ctrl.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index 74540a03d5..08574c4dcb 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -2787,6 +2787,10 @@ static void nvme_copy_in_completed_cb(void *opaque, = int ret) size_t mlen =3D nvme_m2b(ns, nlb); uint8_t *mbounce =3D iocb->bounce + nvme_l2b(ns, nlb); =20 + status =3D nvme_dif_mangle_mdata(ns, mbounce, mlen, slba); + if (status) { + goto invalid; + } status =3D nvme_dif_check(ns, iocb->bounce, len, mbounce, mlen, pr= infor, slba, apptag, appmask, &reftag); if (status) { --=20 2.35.1