From nobody Sun Feb 8 10:44:11 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565998935; cv=none; d=zoho.com; s=zohoarc; b=IzrpN07BhZcaM6sSq4eQSzPyD2Fyiv7YN0O390c4EdjMPDDkZdqX/Lj0MijSAIpMu1yTHrEFokpa5213fxbwjGt3/PAWP2U6lZ6TKthVbAAWC77OirDIxBpIS68ox6Oy896VjgRwFORmGnmOchyZa0IiWq27v+jSYLApQEhHnbk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565998935; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=DWUoGoDHvi6TzwqE+rTc3W/fH+bX6cIOTHteh5ZPNj8=; b=F555ki2I92X1dkpUOJZYCxBChTgjQzquF7XS3wsnbr7NDwQHsWGTvxa/Gdf8T+Zo852cxU80iU8vrAxu3dVn0AaV9z5q+K3zwnSuViFZCoFYMlmudaDM8kI27PYM8RKmS4fVdTxgouPd9xnSJq0kKaiMaxTecDkW0VlZRuZJmIU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1565998935708541.1703293078623; Fri, 16 Aug 2019 16:42:15 -0700 (PDT) Received: from localhost ([::1]:33450 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hylrK-00018r-EM for importer@patchew.org; Fri, 16 Aug 2019 19:42:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47610) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hylSB-0001aX-2W for qemu-devel@nongnu.org; Fri, 16 Aug 2019 19:16:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hylS9-0007q8-Rd for qemu-devel@nongnu.org; Fri, 16 Aug 2019 19:16:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51846) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hylS9-0007pf-MN; Fri, 16 Aug 2019 19:16:13 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 07BCD306F4A9; Fri, 16 Aug 2019 23:16:13 +0000 (UTC) Received: from probe.bos.redhat.com (dhcp-17-187.bos.redhat.com [10.18.17.187]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5FBF417BB9; Fri, 16 Aug 2019 23:16:12 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Date: Fri, 16 Aug 2019 19:16:07 -0400 Message-Id: <20190816231609.9521-2-jsnow@redhat.com> In-Reply-To: <20190816231609.9521-1-jsnow@redhat.com> References: <20190816231609.9521-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Fri, 16 Aug 2019 23:16:13 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 1/3] dma-helpers: ensure AIO callback is invoked after cancellation 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: peter.maydell@linaro.org, jsnow@redhat.com, qemu-stable@nongnu.org, Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini dma_aio_cancel unschedules the BH if there is one, which corresponds to the reschedule_dma case of dma_blk_cb. This can stall the DMA permanently, because dma_complete will never get invoked and therefore nobody will ever invoke the original AIO callback in dbs->common.cb. Fix this by invoking the callback (which is ensured to happen after a bdrv_aio_cancel_async, or done manually in the dbs->bh case), and add assertions to check that the DMA state machine is indeed waiting for dma_complete or reschedule_dma, but never both. Reported-by: John Snow Signed-off-by: Paolo Bonzini Message-id: 20190729213416.1972-1-pbonzini@redhat.com Signed-off-by: John Snow --- dma-helpers.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/dma-helpers.c b/dma-helpers.c index 2d7e02d35e5..d3871dc61ea 100644 --- a/dma-helpers.c +++ b/dma-helpers.c @@ -90,6 +90,7 @@ static void reschedule_dma(void *opaque) { DMAAIOCB *dbs =3D (DMAAIOCB *)opaque; =20 + assert(!dbs->acb && dbs->bh); qemu_bh_delete(dbs->bh); dbs->bh =3D NULL; dma_blk_cb(dbs, 0); @@ -111,15 +112,12 @@ static void dma_complete(DMAAIOCB *dbs, int ret) { trace_dma_complete(dbs, ret, dbs->common.cb); =20 + assert(!dbs->acb && !dbs->bh); dma_blk_unmap(dbs); if (dbs->common.cb) { dbs->common.cb(dbs->common.opaque, ret); } qemu_iovec_destroy(&dbs->iov); - if (dbs->bh) { - qemu_bh_delete(dbs->bh); - dbs->bh =3D NULL; - } qemu_aio_unref(dbs); } =20 @@ -179,14 +177,21 @@ static void dma_aio_cancel(BlockAIOCB *acb) =20 trace_dma_aio_cancel(dbs); =20 + assert(!(dbs->acb && dbs->bh)); if (dbs->acb) { + /* This will invoke dma_blk_cb. */ blk_aio_cancel_async(dbs->acb); + return; } + if (dbs->bh) { cpu_unregister_map_client(dbs->bh); qemu_bh_delete(dbs->bh); dbs->bh =3D NULL; } + if (dbs->common.cb) { + dbs->common.cb(dbs->common.opaque, -ECANCELED); + } } =20 static AioContext *dma_get_aio_context(BlockAIOCB *acb) --=20 2.21.0 From nobody Sun Feb 8 10:44:11 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565999240; cv=none; d=zoho.com; s=zohoarc; b=HPeGlHcJN7wAJH/+hzak20yZEkkeo3gKozMPOSrc5d8sXgCA7nQH4KAz4CbJ83i3B9DcFhjkKsJtCA4MBzhDBdLQQa6SB41vqvXlReu7eSzczoXJoJlmVqKpoJwiGjmNZQusQ2oLGbWI6eE/0YLWO0PYmGDYEM2Qca5nmaCL8ao= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565999240; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=c1VEK0T9RiMPlW++zcIXXvlRLi7qsB7LN1+Fwf2719E=; b=XEABFCf4geZ6zMdqzy/G9wGZT+0opRVAug7K17ydzPmwRqKOW/d9ztEo36+fdXX7h+2WbQ94naNwYPc+nO1mcPlTENNaveTbMayES1iKPDr5vKDjLmQAV3RTmZ1ydAB+cl0acdmE3VM+4fk+htrUiRzWEcf7KKs694RbxlrQ04I= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1565999240564394.28974593786245; Fri, 16 Aug 2019 16:47:20 -0700 (PDT) Received: from localhost ([::1]:33526 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hylwF-0007bB-D9 for importer@patchew.org; Fri, 16 Aug 2019 19:47:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47620) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hylSB-0001bO-Nt for qemu-devel@nongnu.org; Fri, 16 Aug 2019 19:16:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hylSA-0007qi-Jn for qemu-devel@nongnu.org; Fri, 16 Aug 2019 19:16:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55404) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hylSA-0007qF-Ei; Fri, 16 Aug 2019 19:16:14 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BDDEF30A5686; Fri, 16 Aug 2019 23:16:13 +0000 (UTC) Received: from probe.bos.redhat.com (dhcp-17-187.bos.redhat.com [10.18.17.187]) by smtp.corp.redhat.com (Postfix) with ESMTP id 26ED917BB9; Fri, 16 Aug 2019 23:16:13 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Date: Fri, 16 Aug 2019 19:16:08 -0400 Message-Id: <20190816231609.9521-3-jsnow@redhat.com> In-Reply-To: <20190816231609.9521-1-jsnow@redhat.com> References: <20190816231609.9521-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Fri, 16 Aug 2019 23:16:13 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 2/3] Revert "ide/ahci: Check for -ECANCELED in aio callbacks" 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: peter.maydell@linaro.org, Shaju Abraham , jsnow@redhat.com, qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" This reverts commit 0d910cfeaf2076b116b4517166d5deb0fea76394. It's not correct to just ignore an error code in a callback; we need to handle that error and possible report failure to the guest so that they don't wait indefinitely for an operation that will now never finish. This ought to help cases reported by Nutanix where iSCSI returns a legitimate -ECANCELED for certain operations which should be propagated normally. Reported-by: Shaju Abraham Signed-off-by: John Snow Message-id: 20190729223605.7163-1-jsnow@redhat.com Signed-off-by: John Snow --- hw/ide/ahci.c | 3 --- hw/ide/core.c | 14 -------------- 2 files changed, 17 deletions(-) diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index d72da85605a..d45393c019d 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -1025,9 +1025,6 @@ static void ncq_cb(void *opaque, int ret) IDEState *ide_state =3D &ncq_tfs->drive->port.ifs[0]; =20 ncq_tfs->aiocb =3D NULL; - if (ret =3D=3D -ECANCELED) { - return; - } =20 if (ret < 0) { bool is_read =3D ncq_tfs->cmd =3D=3D READ_FPDMA_QUEUED; diff --git a/hw/ide/core.c b/hw/ide/core.c index 38b6cdac87b..e6e54c6c9a2 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -723,9 +723,6 @@ static void ide_sector_read_cb(void *opaque, int ret) s->pio_aiocb =3D NULL; s->status &=3D ~BUSY_STAT; =20 - if (ret =3D=3D -ECANCELED) { - return; - } if (ret !=3D 0) { if (ide_handle_rw_error(s, -ret, IDE_RETRY_PIO | IDE_RETRY_READ)) { @@ -841,10 +838,6 @@ static void ide_dma_cb(void *opaque, int ret) uint64_t offset; bool stay_active =3D false; =20 - if (ret =3D=3D -ECANCELED) { - return; - } - if (ret =3D=3D -EINVAL) { ide_dma_error(s); return; @@ -976,10 +969,6 @@ static void ide_sector_write_cb(void *opaque, int ret) IDEState *s =3D opaque; int n; =20 - if (ret =3D=3D -ECANCELED) { - return; - } - s->pio_aiocb =3D NULL; s->status &=3D ~BUSY_STAT; =20 @@ -1059,9 +1048,6 @@ static void ide_flush_cb(void *opaque, int ret) =20 s->pio_aiocb =3D NULL; =20 - if (ret =3D=3D -ECANCELED) { - return; - } if (ret < 0) { /* XXX: What sector number to set here? */ if (ide_handle_rw_error(s, -ret, IDE_RETRY_FLUSH)) { --=20 2.21.0 From nobody Sun Feb 8 10:44:11 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565999444; cv=none; d=zoho.com; s=zohoarc; b=VN2vVQri4jgc1TPLhXTQNqNB8qw6eDEvJhhZiMgCyjS07DMtAMjP5nxZbPPZmWp9CQ6I8/TxzcucWbUwGh+RLtdFRn0MXKgdvweLbhpmNJ0VRxutshBxSGY1z6V8TAfw4Ui3K+UZIli7YtlwLA2v8oP+7QrMaMrrW29Uj7xZdNM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565999444; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=SU6aXVLRLB589QM6ptBkePMv99jxI//umurY0lW/+G4=; b=MqMN/XTj6Mj+GfT+9LVQDLYFSHF4m4tCKyR2reD1TIOLX6lgsD9lF0QUdhbQ2Vb7V5SRooMxcDfQ1S0B/rS2E1gsv56ORv/v8FxpztW8rb0W2D6/iTaHhg90YCtz4ngBLvo/DTt2sbet2cypWMReiOBNR/6ZzBwq0ziDayLx3cA= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1565999444031403.15006481452247; Fri, 16 Aug 2019 16:50:44 -0700 (PDT) Received: from localhost ([::1]:33588 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hylzU-0003e0-3N for importer@patchew.org; Fri, 16 Aug 2019 19:50:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47665) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hylSG-0001hk-JZ for qemu-devel@nongnu.org; Fri, 16 Aug 2019 19:16:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hylSE-0007sx-Q5 for qemu-devel@nongnu.org; Fri, 16 Aug 2019 19:16:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44118) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hylSE-0007sc-Ix; Fri, 16 Aug 2019 19:16:18 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E453F307D844; Fri, 16 Aug 2019 23:16:17 +0000 (UTC) Received: from probe.bos.redhat.com (dhcp-17-187.bos.redhat.com [10.18.17.187]) by smtp.corp.redhat.com (Postfix) with ESMTP id E013F17BB9; Fri, 16 Aug 2019 23:16:13 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Date: Fri, 16 Aug 2019 19:16:09 -0400 Message-Id: <20190816231609.9521-4-jsnow@redhat.com> In-Reply-To: <20190816231609.9521-1-jsnow@redhat.com> References: <20190816231609.9521-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Fri, 16 Aug 2019 23:16:17 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 3/3] hw/ide/atapi: Use the ldst API 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: peter.maydell@linaro.org, jsnow@redhat.com, qemu-stable@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Philippe Mathieu-Daud=C3=A9 The big-endian load/store functions are already provided by "qemu/bswap.h". Avoid code duplication, use the generic API. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20190808130454.9930-1-philmd@redhat.com Signed-off-by: John Snow --- hw/ide/atapi.c | 80 ++++++++++++++++++-------------------------------- 1 file changed, 28 insertions(+), 52 deletions(-) diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c index 1b0f66cc089..17a9d635d84 100644 --- a/hw/ide/atapi.c +++ b/hw/ide/atapi.c @@ -45,30 +45,6 @@ static void padstr8(uint8_t *buf, int buf_size, const ch= ar *src) } } =20 -static inline void cpu_to_ube16(uint8_t *buf, int val) -{ - buf[0] =3D val >> 8; - buf[1] =3D val & 0xff; -} - -static inline void cpu_to_ube32(uint8_t *buf, unsigned int val) -{ - buf[0] =3D val >> 24; - buf[1] =3D val >> 16; - buf[2] =3D val >> 8; - buf[3] =3D val & 0xff; -} - -static inline int ube16_to_cpu(const uint8_t *buf) -{ - return (buf[0] << 8) | buf[1]; -} - -static inline int ube32_to_cpu(const uint8_t *buf) -{ - return (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]; -} - static void lba_to_msf(uint8_t *buf, int lba) { lba +=3D 150; @@ -485,7 +461,7 @@ static inline uint8_t ide_atapi_set_profile(uint8_t *bu= f, uint8_t *index, uint8_t *buf_profile =3D buf + 12; /* start of profiles */ =20 buf_profile +=3D ((*index) * 4); /* start of indexed profile */ - cpu_to_ube16 (buf_profile, profile); + stw_be_p(buf_profile, profile); buf_profile[2] =3D ((buf_profile[0] =3D=3D buf[6]) && (buf_profile[1] = =3D=3D buf[7])); =20 /* each profile adds 4 bytes to the response */ @@ -518,9 +494,9 @@ static int ide_dvd_read_structure(IDEState *s, int form= at, buf[7] =3D 0; /* default densities */ =20 /* FIXME: 0x30000 per spec? */ - cpu_to_ube32(buf + 8, 0); /* start sector */ - cpu_to_ube32(buf + 12, total_sectors - 1); /* end sector */ - cpu_to_ube32(buf + 16, total_sectors - 1); /* l0 end secto= r */ + stl_be_p(buf + 8, 0); /* start sector */ + stl_be_p(buf + 12, total_sectors - 1); /* end sector */ + stl_be_p(buf + 16, total_sectors - 1); /* l0 end sector */ =20 /* Size of buffer, not including 2 byte size field */ stw_be_p(buf, 2048 + 2); @@ -839,7 +815,7 @@ static void cmd_get_configuration(IDEState *s, uint8_t = *buf) } =20 /* XXX: could result in alignment problems in some architectures */ - max_len =3D ube16_to_cpu(buf + 7); + max_len =3D lduw_be_p(buf + 7); =20 /* * XXX: avoid overflow for io_buffer if max_len is bigger than @@ -859,16 +835,16 @@ static void cmd_get_configuration(IDEState *s, uint8_= t *buf) * to use as current. 0 means there is no media */ if (media_is_dvd(s)) { - cpu_to_ube16(buf + 6, MMC_PROFILE_DVD_ROM); + stw_be_p(buf + 6, MMC_PROFILE_DVD_ROM); } else if (media_is_cd(s)) { - cpu_to_ube16(buf + 6, MMC_PROFILE_CD_ROM); + stw_be_p(buf + 6, MMC_PROFILE_CD_ROM); } =20 buf[10] =3D 0x02 | 0x01; /* persistent and current */ len =3D 12; /* headers: 8 + 4 */ len +=3D ide_atapi_set_profile(buf, &index, MMC_PROFILE_DVD_ROM); len +=3D ide_atapi_set_profile(buf, &index, MMC_PROFILE_CD_ROM); - cpu_to_ube32(buf, len - 4); /* data length */ + stl_be_p(buf, len - 4); /* data length */ =20 ide_atapi_cmd_reply(s, len, max_len); } @@ -878,7 +854,7 @@ static void cmd_mode_sense(IDEState *s, uint8_t *buf) int action, code; int max_len; =20 - max_len =3D ube16_to_cpu(buf + 7); + max_len =3D lduw_be_p(buf + 7); action =3D buf[2] >> 6; code =3D buf[2] & 0x3f; =20 @@ -886,7 +862,7 @@ static void cmd_mode_sense(IDEState *s, uint8_t *buf) case 0: /* current values */ switch(code) { case MODE_PAGE_R_W_ERROR: /* error recovery */ - cpu_to_ube16(&buf[0], 16 - 2); + stw_be_p(&buf[0], 16 - 2); buf[2] =3D 0x70; buf[3] =3D 0; buf[4] =3D 0; @@ -905,7 +881,7 @@ static void cmd_mode_sense(IDEState *s, uint8_t *buf) ide_atapi_cmd_reply(s, 16, max_len); break; case MODE_PAGE_AUDIO_CTL: - cpu_to_ube16(&buf[0], 24 - 2); + stw_be_p(&buf[0], 24 - 2); buf[2] =3D 0x70; buf[3] =3D 0; buf[4] =3D 0; @@ -924,7 +900,7 @@ static void cmd_mode_sense(IDEState *s, uint8_t *buf) ide_atapi_cmd_reply(s, 24, max_len); break; case MODE_PAGE_CAPABILITIES: - cpu_to_ube16(&buf[0], 30 - 2); + stw_be_p(&buf[0], 30 - 2); buf[2] =3D 0x70; buf[3] =3D 0; buf[4] =3D 0; @@ -946,11 +922,11 @@ static void cmd_mode_sense(IDEState *s, uint8_t *buf) buf[14] |=3D 1 << 1; } buf[15] =3D 0x00; /* No volume & mute control, no changer */ - cpu_to_ube16(&buf[16], 704); /* 4x read speed */ + stw_be_p(&buf[16], 704); /* 4x read speed */ buf[18] =3D 0; /* Two volume levels */ buf[19] =3D 2; - cpu_to_ube16(&buf[20], 512); /* 512k buffer */ - cpu_to_ube16(&buf[22], 704); /* 4x read speed current */ + stw_be_p(&buf[20], 512); /* 512k buffer */ + stw_be_p(&buf[22], 704); /* 4x read speed current */ buf[24] =3D 0; buf[25] =3D 0; buf[26] =3D 0; @@ -998,12 +974,12 @@ static void cmd_read(IDEState *s, uint8_t* buf) int nb_sectors, lba; =20 if (buf[0] =3D=3D GPCMD_READ_10) { - nb_sectors =3D ube16_to_cpu(buf + 7); + nb_sectors =3D lduw_be_p(buf + 7); } else { - nb_sectors =3D ube32_to_cpu(buf + 6); + nb_sectors =3D ldl_be_p(buf + 6); } =20 - lba =3D ube32_to_cpu(buf + 2); + lba =3D ldl_be_p(buf + 2); if (nb_sectors =3D=3D 0) { ide_atapi_cmd_ok(s); return; @@ -1017,7 +993,7 @@ static void cmd_read_cd(IDEState *s, uint8_t* buf) int nb_sectors, lba, transfer_request; =20 nb_sectors =3D (buf[6] << 16) | (buf[7] << 8) | buf[8]; - lba =3D ube32_to_cpu(buf + 2); + lba =3D ldl_be_p(buf + 2); =20 if (nb_sectors =3D=3D 0) { ide_atapi_cmd_ok(s); @@ -1057,7 +1033,7 @@ static void cmd_seek(IDEState *s, uint8_t* buf) unsigned int lba; uint64_t total_sectors =3D s->nb_sectors >> 2; =20 - lba =3D ube32_to_cpu(buf + 2); + lba =3D ldl_be_p(buf + 2); if (lba >=3D total_sectors) { ide_atapi_cmd_error(s, ILLEGAL_REQUEST, ASC_LOGICAL_BLOCK_OOR); return; @@ -1098,15 +1074,15 @@ static void cmd_start_stop_unit(IDEState *s, uint8_= t* buf) =20 static void cmd_mechanism_status(IDEState *s, uint8_t* buf) { - int max_len =3D ube16_to_cpu(buf + 8); + int max_len =3D lduw_be_p(buf + 8); =20 - cpu_to_ube16(buf, 0); + stw_be_p(buf, 0); /* no current LBA */ buf[2] =3D 0; buf[3] =3D 0; buf[4] =3D 0; buf[5] =3D 1; - cpu_to_ube16(buf + 6, 0); + stw_be_p(buf + 6, 0); ide_atapi_cmd_reply(s, 8, max_len); } =20 @@ -1116,7 +1092,7 @@ static void cmd_read_toc_pma_atip(IDEState *s, uint8_= t* buf) int max_len; uint64_t total_sectors =3D s->nb_sectors >> 2; =20 - max_len =3D ube16_to_cpu(buf + 7); + max_len =3D lduw_be_p(buf + 7); format =3D buf[9] >> 6; msf =3D (buf[1] >> 1) & 1; start_track =3D buf[6]; @@ -1154,15 +1130,15 @@ static void cmd_read_cdvd_capacity(IDEState *s, uin= t8_t* buf) uint64_t total_sectors =3D s->nb_sectors >> 2; =20 /* NOTE: it is really the number of sectors minus 1 */ - cpu_to_ube32(buf, total_sectors - 1); - cpu_to_ube32(buf + 4, 2048); + stl_be_p(buf, total_sectors - 1); + stl_be_p(buf + 4, 2048); ide_atapi_cmd_reply(s, 8, 8); } =20 static void cmd_read_disc_information(IDEState *s, uint8_t* buf) { uint8_t type =3D buf[1] & 7; - uint32_t max_len =3D ube16_to_cpu(buf + 7); + uint32_t max_len =3D lduw_be_p(buf + 7); =20 /* Types 1/2 are only defined for Blu-Ray. */ if (type !=3D 0) { @@ -1196,7 +1172,7 @@ static void cmd_read_dvd_structure(IDEState *s, uint8= _t* buf) int format =3D buf[7]; int ret; =20 - max_len =3D ube16_to_cpu(buf + 8); + max_len =3D lduw_be_p(buf + 8); =20 if (format < 0xff) { if (media_is_cd(s)) { --=20 2.21.0