From patchwork Wed Jan 11 07:52:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Jensen X-Patchwork-Id: 1724498 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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: legolas.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=fm2 header.b=V86+RRzZ; 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=Ef8W32T/; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NsKhq0z0hz23f3 for ; Wed, 11 Jan 2023 18:54:51 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pFVug-0004HR-DI; Wed, 11 Jan 2023 02:52:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFVuT-0004EP-CC; Wed, 11 Jan 2023 02:52:34 -0500 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFVuR-0006AY-O5; Wed, 11 Jan 2023 02:52:33 -0500 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 69FA4320093A; Wed, 11 Jan 2023 02:52:28 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Wed, 11 Jan 2023 02:52:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=cc:cc:content-transfer-encoding:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1673423548; x= 1673509948; bh=v+pwZ7Xj3smDj+yWBJfTO38yRtfwHhoOqV+E+YskYOM=; b=V 86+RRzZUFXNNxZDzOtlo6U3wYVgfaF+H5JO2LcTEU68T4tPaChmapFWB+ddYGDdk uqxjgKDKdtDgY0E4lrJ8gLYebas3pI+LZyJgkH42WppBjmHgmDrrV1hwlWvbxDZh pYnm17y/6QxlSU+iVfLp6l17s0p9sn9ocsdSeT1NWnSNco9v6oKXIPA8beCXRetL 0Vfcic9H/bpQMM2OTpWzq+hNGMOvRFDmUyvyIY8iLGshCztjYZQLUtoFTfMDRn0V oA4gV8nm+9JJ21KZu0PUAH+GqfDsFWSRp4Dfy3DLiPO7cud3pA0fmsWEKxyn186W CzPZtsX1+msUEGRkfNFZw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1673423548; x=1673509948; bh=v+pwZ7Xj3smDj +yWBJfTO38yRtfwHhoOqV+E+YskYOM=; b=Ef8W32T/sKtv7Llo142EVPHVWwuNB DSu2dghzm7ILS6kvRStJa6Eu+RGvy0eULTfA8ZV87beBj34Dgh7ibJpUL4nrbeIW LJ3Lt3rZr9ZIsf/HuC0lAoaYa4YLtNuPaM+qhXpP7wTysgDcmMs8DZxn1txLLdaJ lSanDQJqz/CO0I95eqaT0wC5SQ2f485pMgiRMFcIhXGg9EcrC6T6zQyFFkC9MOcy pHOS8Of+VsmNLmc8EGWL233fxkydPqXNyRqdsNLBxyXvjThbBueiTEwdv913MfjM Foy/3RhBz9iVAvu8U0DDdDaCQ8FPvy8/B4KsvmwQHxfc5VP3Kh8Dbbqdw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrleefgdduudefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepmfhlrghu shculfgvnhhsvghnuceoihhtshesihhrrhgvlhgvvhgrnhhtrdgukheqnecuggftrfgrth htvghrnhepjefgieelgfeiveehkeeuveehheekfeevgeeigfehfefgjeejhefffeegudej udegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepih htshesihhrrhgvlhgvvhgrnhhtrdgukh X-ME-Proxy: Feedback-ID: idc91472f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 11 Jan 2023 02:52:26 -0500 (EST) From: Klaus Jensen To: qemu-devel@nongnu.org, Peter Maydell Cc: Klaus Jensen , qemu-block@nongnu.org, Keith Busch , Klaus Jensen , qemu-stable@nongnu.org, Guenter Roeck Subject: [PULL 3/6] hw/nvme: fix missing endian conversions for doorbell buffers Date: Wed, 11 Jan 2023 08:52:10 +0100 Message-Id: <20230111075213.70404-4-its@irrelevant.dk> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230111075213.70404-1-its@irrelevant.dk> References: <20230111075213.70404-1-its@irrelevant.dk> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1817; i=k.jensen@samsung.com; h=from:subject; bh=X14mTLElADuOBbLWP/86wawuglEhbJ8qpNIESqKJWFQ=; b=owJ4nAFtAZL+kA0DAAoBTeGvMW1PDekByyZiAGO+aqxljUACEbfXwlH42GNC3uq0bDKo7lwUFLV5 ELJcP0EhpokBMwQAAQoAHRYhBFIoM6p14tzmokdmwE3hrzFtTw3pBQJjvmqsAAoJEE3hrzFtTw3pE9 sH/ii66XFPM65x18vTrvjItmY5ak+Z0wI5hc7fypt+C26TM2VcbtpiSWjHQJl0RHL8d5J7c8Rq9nWq CrxJsd7qM9iU87s/9s0/9rGbExOm/TQzrqZF4wnfYYH3VA53Q5h2QPSyIDyCM5cuTu7RMupA1PJiGV hAJ3LeUFzaGReEHJt2BYyrv0YOKv1On/5ShmBwAc5yKLyvt41VGlAfTBS7rOJ6mrx0P7MjFDWslxgN Z1bPxDYTn1Tn9Pm+S8n392jVPTqxKYGRD18UdOFNeG/XDYguaAUTIbdp4GM4BKIxpR9+cWiPCOzopn NoQPoe2mehAaExeXzGLNOTvSRW1Guo2ICYT6hB X-Developer-Key: i=k.jensen@samsung.com; a=openpgp; fpr=DDCA4D9C9EF931CC3468427263D56FC5E55DA838 Received-SPF: pass client-ip=64.147.123.19; envelope-from=its@irrelevant.dk; helo=wout3-smtp.messagingengine.com 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Klaus Jensen The eventidx and doorbell value are not handling endianness correctly. Fix this. Fixes: 3f7fe8de3d49 ("hw/nvme: Implement shadow doorbell buffer support") Cc: qemu-stable@nongnu.org Reported-by: Guenter Roeck Reviewed-by: Keith Busch Signed-off-by: Klaus Jensen --- hw/nvme/ctrl.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index cfe16476f0a4..28e02ec7baa6 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -1336,8 +1336,11 @@ static inline void nvme_blk_write(BlockBackend *blk, int64_t offset, static void nvme_update_cq_head(NvmeCQueue *cq) { - pci_dma_read(PCI_DEVICE(cq->ctrl), cq->db_addr, &cq->head, - sizeof(cq->head)); + uint32_t v; + + pci_dma_read(PCI_DEVICE(cq->ctrl), cq->db_addr, &v, sizeof(v)); + + cq->head = le32_to_cpu(v); trace_pci_nvme_update_cq_head(cq->cqid, cq->head); } @@ -6148,16 +6151,20 @@ static uint16_t nvme_admin_cmd(NvmeCtrl *n, NvmeRequest *req) static void nvme_update_sq_eventidx(const NvmeSQueue *sq) { + uint32_t v = cpu_to_le32(sq->tail); + trace_pci_nvme_update_sq_eventidx(sq->sqid, sq->tail); - pci_dma_write(PCI_DEVICE(sq->ctrl), sq->ei_addr, &sq->tail, - sizeof(sq->tail)); + pci_dma_write(PCI_DEVICE(sq->ctrl), sq->ei_addr, &v, sizeof(v)); } static void nvme_update_sq_tail(NvmeSQueue *sq) { - pci_dma_read(PCI_DEVICE(sq->ctrl), sq->db_addr, &sq->tail, - sizeof(sq->tail)); + uint32_t v; + + pci_dma_read(PCI_DEVICE(sq->ctrl), sq->db_addr, &v, sizeof(v)); + + sq->tail = le32_to_cpu(v); trace_pci_nvme_update_sq_tail(sq->sqid, sq->tail); }