From patchwork Thu Sep 24 20:45:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Jensen X-Patchwork-Id: 1370876 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=irrelevant.dk Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=irrelevant.dk header.i=@irrelevant.dk header.a=rsa-sha256 header.s=fm1 header.b=tKawj+n4; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=FWXKG6k7; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4By6b01d7Dz9sS8 for ; Fri, 25 Sep 2020 06:48:44 +1000 (AEST) Received: from localhost ([::1]:45300 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLYAU-0005Ka-1p for incoming@patchwork.ozlabs.org; Thu, 24 Sep 2020 16:48:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38510) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLY7N-0004Py-3a; Thu, 24 Sep 2020 16:45:29 -0400 Received: from new2-smtp.messagingengine.com ([66.111.4.224]:51605) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLY7J-0007iS-NB; Thu, 24 Sep 2020 16:45:28 -0400 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailnew.nyi.internal (Postfix) with ESMTP id D760C580507; Thu, 24 Sep 2020 16:45:24 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Thu, 24 Sep 2020 16:45:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=WbPXCy/OFaknh L9vreyycHOBgrvUUYu9WIgBvZGZ6+E=; b=tKawj+n4tvXW+Y0Lxx+coHYMzKQEo d3oRKfX1ByweMyxdq5pmi9mf9UdnvqVjwenRz2z3YMd8ewKIcr5pq0yeIu2x//br ik2k7MFZmZq7CNp+SOHXk5NXF/2tU9cFyWJ1DIef0mesRlWt0aavGoQZvTvfv8ct G3hA02JD9bE6itnd4nWdCIfYLWZQTLx7GoWAwmyHEUi//KztPUYiUbY8Y9N0oHS/ 1vFiofgM5rmI6R/2qMGyVba+Rz011T/GpqMAbgby5cjZit1epiSN3OqtPKTjfXD4 OfvTIYhy6PECgJYmOv+C5iwgLv+6NrD/HpUbYEeTDn7oYsC4ssiBKTSeA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=WbPXCy/OFaknhL9vreyycHOBgrvUUYu9WIgBvZGZ6+E=; b=FWXKG6k7 b5R95mDnWHxok2kQopm1BuLS+RKdpNIHKDIvi45lMSLWrNMpDlACowNZ9UJu2wkX n4qQboPgtp9dnx16gze6i1GyEd/PubtRwfJtUzu/LgvCQDFRXbFyDoopxJcZv5Nf 7Y3LPMlWufNoBkJdU/ZnOkMWK3VDB7JkYawmNJd/Vx8IUy1T0y3D/K5fa47pqRUX XosV2X9OrMgExjopyO2tZLjuk42OwdmoePoX/QPzOkzG5dIwG2dlZSgQMOgZKa41 Fwhj6VpfB+aGOm4bOGbz2E/4klzznNBlGZgUIfbLoBAKfFF+NulLq/b1qjpDYXII wyrtfjsBKelQ9g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrudekgdduheduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefmlhgruhhs ucflvghnshgvnhcuoehithhssehirhhrvghlvghvrghnthdrughkqeenucggtffrrghtth gvrhhnpeeuleetgeeiuefhgfekfefgveejiefgteekiedtgfdtieefhfdthfefueffvefg keenucfkphepkedtrdduieejrdelkedrudeltdenucevlhhushhtvghrufhiiigvpedvne curfgrrhgrmhepmhgrihhlfhhrohhmpehithhssehirhhrvghlvghvrghnthdrughk X-ME-Proxy: Received: from apples.local (80-167-98-190-cable.dk.customer.tdc.net [80.167.98.190]) by mail.messagingengine.com (Postfix) with ESMTPA id 5CFFF3064683; Thu, 24 Sep 2020 16:45:23 -0400 (EDT) From: Klaus Jensen To: qemu-devel@nongnu.org Subject: [PATCH 04/16] hw/block/nvme: reject io commands if only admin command set selected Date: Thu, 24 Sep 2020 22:45:04 +0200 Message-Id: <20200924204516.1881843-5-its@irrelevant.dk> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200924204516.1881843-1-its@irrelevant.dk> References: <20200924204516.1881843-1-its@irrelevant.dk> MIME-Version: 1.0 Received-SPF: pass client-ip=66.111.4.224; envelope-from=its@irrelevant.dk; helo=new2-smtp.messagingengine.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/24 14:55:29 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Klaus Jensen , Max Reitz , Keith Busch , Klaus Jensen Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Klaus Jensen If the host sets CC.CSS to 111b, all commands submitted to I/O queues should be completed with status Invalid Command Opcode. Note that this is technically a v1.4 feature, but it does not hurt to implement before we finally bump the reported version implemented. Signed-off-by: Klaus Jensen --- include/block/nvme.h | 5 +++++ hw/block/nvme.c | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/include/block/nvme.h b/include/block/nvme.h index 58647bcdad0b..7a30cf285ae0 100644 --- a/include/block/nvme.h +++ b/include/block/nvme.h @@ -110,6 +110,11 @@ enum NvmeCcMask { #define NVME_CC_IOSQES(cc) ((cc >> CC_IOSQES_SHIFT) & CC_IOSQES_MASK) #define NVME_CC_IOCQES(cc) ((cc >> CC_IOCQES_SHIFT) & CC_IOCQES_MASK) +enum NvmeCcCss { + NVME_CC_CSS_NVM = 0x0, + NVME_CC_CSS_ADMIN_ONLY = 0x7, +}; + enum NvmeCstsShift { CSTS_RDY_SHIFT = 0, CSTS_CFS_SHIFT = 1, diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 758f58c88026..27af2f0b38d5 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -1065,6 +1065,10 @@ static uint16_t nvme_io_cmd(NvmeCtrl *n, NvmeRequest *req) trace_pci_nvme_io_cmd(nvme_cid(req), nsid, nvme_sqid(req), req->cmd.opcode, nvme_io_opc_str(req->cmd.opcode)); + if (NVME_CC_CSS(n->bar.cc) == NVME_CC_CSS_ADMIN_ONLY) { + return NVME_INVALID_OPCODE | NVME_DNR; + } + if (!nvme_nsid_valid(n, nsid)) { return NVME_INVALID_NSID | NVME_DNR; }