From nobody Sun May 5 02:47:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1605525297; cv=none; d=zohomail.com; s=zohoarc; b=e3oVVcj6VIxcnNagbvQlelM2c4pORz+t21zi8OaYksZwI2new9vTKCO2NFAyW7wJOVmpwjTkSMkLgSa/9TT0af6G+hwjEjtwLENL7sy/6EnKbdRsuCwEAwIt0Y0DYrjCqPAXe8p2vMrI/M1lL9zA/SDjGsEblysww5+XA36FkLc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605525297; 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; bh=R3n3NbysL1CyZFoxfLzlrfQINJJBTQDs6IDvrt+hiPg=; b=XHylPdUUgEK31HoM0Jb+51iCBPaaNj1oNqR6colIX15r22PJx9USHv+a30SDdqnZEim9fnbXdHHStwuErmQVCcrIdMiWwacYfMiA8iktSzX64sAImfo2Tx935H4GcGg5wJtD4GXhlleq4pM2qy7OJlU56DoWuyjxOxyyyebEZbE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=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 16055252972891004.843005511738; Mon, 16 Nov 2020 03:14:57 -0800 (PST) Received: from localhost ([::1]:37766 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kecTG-0007G5-1G for importer@patchew.org; Mon, 16 Nov 2020 06:14:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41964) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kecPI-00023J-LO for qemu-devel@nongnu.org; Mon, 16 Nov 2020 06:10:48 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:44003) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kecPE-00028D-Re for qemu-devel@nongnu.org; Mon, 16 Nov 2020 06:10:48 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-516-zeBfAev9M-iLIiJtVx5nRQ-1; Mon, 16 Nov 2020 06:10:42 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 67687186DD26 for ; Mon, 16 Nov 2020 11:10:41 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-65.ams2.redhat.com [10.36.112.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5C9786EF58; Mon, 16 Nov 2020 11:10:37 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 35691A1EE; Mon, 16 Nov 2020 12:10:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605525044; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=R3n3NbysL1CyZFoxfLzlrfQINJJBTQDs6IDvrt+hiPg=; b=fZ/I4n6zgeZNldPfremxc10GR8vOjMtEdTiBh6qYrnWk4m+5h2GagwkZvbf+X/yztPV0GI 5E5NX5MziC3k+72q9WOkjuvZluskkTGwSQMH/EMxS0cpQZqjm5ICQLZiW9i6/Aq0HZbDXy h/vk0bj4lX1GYIHJhjSTCe7OIEZE7ik= X-MC-Unique: zeBfAev9M-iLIiJtVx5nRQ-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 1/6] usb-storage: switch trace events Date: Mon, 16 Nov 2020 12:10:31 +0100 Message-Id: <20201116111036.12820-2-kraxel@redhat.com> In-Reply-To: <20201116111036.12820-1-kraxel@redhat.com> References: <20201116111036.12820-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=63.128.21.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/16 04:46:27 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=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: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Replace most DPRINTF macros with trace events. Drop some DPRINTF macros. Signed-off-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20201105134112.25119-2-kraxel@redhat.com --- hw/usb/dev-storage.c | 42 +++++++++++++++++------------------------- hw/usb/trace-events | 12 ++++++++++++ 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c index 648340323f68..e317cde8fd48 100644 --- a/hw/usb/dev-storage.c +++ b/hw/usb/dev-storage.c @@ -23,16 +23,10 @@ #include "qapi/visitor.h" #include "qemu/cutils.h" #include "qom/object.h" +#include "trace.h" =20 //#define DEBUG_MSD =20 -#ifdef DEBUG_MSD -#define DPRINTF(fmt, ...) \ -do { printf("usb-msd: " fmt , ## __VA_ARGS__); } while (0) -#else -#define DPRINTF(fmt, ...) do {} while(0) -#endif - /* USB requests. */ #define MassStorageReset 0xff #define GetMaxLun 0xfe @@ -245,8 +239,8 @@ static void usb_msd_send_status(MSDState *s, USBPacket = *p) { int len; =20 - DPRINTF("Command status %d tag 0x%x, len %zd\n", - s->csw.status, le32_to_cpu(s->csw.tag), p->iov.size); + trace_usb_msd_send_status(s->csw.status, le32_to_cpu(s->csw.tag), + p->iov.size); =20 assert(s->csw.sig =3D=3D cpu_to_le32(0x53425355)); len =3D MIN(sizeof(s->csw), p->iov.size); @@ -261,7 +255,7 @@ static void usb_msd_packet_complete(MSDState *s) /* Set s->packet to NULL before calling usb_packet_complete because another request may be issued before usb_packet_complete returns. */ - DPRINTF("Packet complete %p\n", p); + trace_usb_msd_packet_complete(); s->packet =3D NULL; usb_packet_complete(&s->dev, p); } @@ -289,7 +283,7 @@ static void usb_msd_command_complete(SCSIRequest *req, = uint32_t status, size_t r MSDState *s =3D DO_UPCAST(MSDState, dev.qdev, req->bus->qbus.parent); USBPacket *p =3D s->packet; =20 - DPRINTF("Command complete %d tag 0x%x\n", status, req->tag); + trace_usb_msd_cmd_complete(status, req->tag); =20 s->csw.sig =3D cpu_to_le32(0x53425355); s->csw.tag =3D cpu_to_le32(req->tag); @@ -331,6 +325,8 @@ static void usb_msd_request_cancelled(SCSIRequest *req) { MSDState *s =3D DO_UPCAST(MSDState, dev.qdev, req->bus->qbus.parent); =20 + trace_usb_msd_cmd_cancel(req->tag); + if (req =3D=3D s->req) { scsi_req_unref(s->req); s->req =3D NULL; @@ -342,7 +338,7 @@ static void usb_msd_handle_reset(USBDevice *dev) { MSDState *s =3D (MSDState *)dev; =20 - DPRINTF("Reset\n"); + trace_usb_msd_reset(); if (s->req) { scsi_req_cancel(s->req); } @@ -388,7 +384,7 @@ static void usb_msd_handle_control(USBDevice *dev, USBP= acket *p, } maxlun++; } - DPRINTF("MaxLun %d\n", maxlun); + trace_usb_msd_maxlun(maxlun); data[0] =3D maxlun; p->actual_length =3D 1; break; @@ -436,7 +432,6 @@ static void usb_msd_handle_data(USBDevice *dev, USBPack= et *p) le32_to_cpu(cbw.sig)); goto fail; } - DPRINTF("Command on LUN %d\n", cbw.lun); scsi_dev =3D scsi_device_find(&s->bus, 0, 0, cbw.lun); if (scsi_dev =3D=3D NULL) { error_report("usb-msd: Bad LUN %d", cbw.lun); @@ -451,8 +446,8 @@ static void usb_msd_handle_data(USBDevice *dev, USBPack= et *p) } else { s->mode =3D USB_MSDM_DATAOUT; } - DPRINTF("Command tag 0x%x flags %08x len %d data %d\n", - tag, cbw.flags, cbw.cmd_len, s->data_len); + trace_usb_msd_cmd_submit(cbw.lun, tag, cbw.flags, + cbw.cmd_len, s->data_len); assert(le32_to_cpu(s->csw.residue) =3D=3D 0); s->scsi_len =3D 0; s->req =3D scsi_req_new(scsi_dev, tag, cbw.lun, cbw.cmd, NULL); @@ -466,7 +461,7 @@ static void usb_msd_handle_data(USBDevice *dev, USBPack= et *p) break; =20 case USB_MSDM_DATAOUT: - DPRINTF("Data out %zd/%d\n", p->iov.size, s->data_len); + trace_usb_msd_data_out(p->iov.size, s->data_len); if (p->iov.size > s->data_len) { goto fail; } @@ -488,14 +483,13 @@ static void usb_msd_handle_data(USBDevice *dev, USBPa= cket *p) } } if (p->actual_length < p->iov.size) { - DPRINTF("Deferring packet %p [wait data-out]\n", p); + trace_usb_msd_packet_async(); s->packet =3D p; p->status =3D USB_RET_ASYNC; } break; =20 default: - DPRINTF("Unexpected write (len %zd)\n", p->iov.size); goto fail; } break; @@ -510,6 +504,7 @@ static void usb_msd_handle_data(USBDevice *dev, USBPack= et *p) goto fail; } /* Waiting for SCSI write to complete. */ + trace_usb_msd_packet_async(); s->packet =3D p; p->status =3D USB_RET_ASYNC; break; @@ -521,7 +516,7 @@ static void usb_msd_handle_data(USBDevice *dev, USBPack= et *p) =20 if (s->req) { /* still in flight */ - DPRINTF("Deferring packet %p [wait status]\n", p); + trace_usb_msd_packet_async(); s->packet =3D p; p->status =3D USB_RET_ASYNC; } else { @@ -531,8 +526,7 @@ static void usb_msd_handle_data(USBDevice *dev, USBPack= et *p) break; =20 case USB_MSDM_DATAIN: - DPRINTF("Data in %zd/%d, scsi_len %d\n", - p->iov.size, s->data_len, s->scsi_len); + trace_usb_msd_data_in(p->iov.size, s->data_len, s->scsi_len); if (s->scsi_len) { usb_msd_copy_data(s, p); } @@ -550,20 +544,18 @@ static void usb_msd_handle_data(USBDevice *dev, USBPa= cket *p) } } if (p->actual_length < p->iov.size && s->mode =3D=3D USB_MSDM_= DATAIN) { - DPRINTF("Deferring packet %p [wait data-in]\n", p); + trace_usb_msd_packet_async(); s->packet =3D p; p->status =3D USB_RET_ASYNC; } break; =20 default: - DPRINTF("Unexpected read (len %zd)\n", p->iov.size); goto fail; } break; =20 default: - DPRINTF("Bad token\n"); fail: p->status =3D USB_RET_STALL; break; diff --git a/hw/usb/trace-events b/hw/usb/trace-events index a3292d46248f..38e05fc7f4db 100644 --- a/hw/usb/trace-events +++ b/hw/usb/trace-events @@ -252,6 +252,18 @@ usb_hub_attach(int addr, int nr) "dev %d, port %d" usb_hub_detach(int addr, int nr) "dev %d, port %d" usb_hub_status_report(int addr, int status) "dev %d, status 0x%x" =20 +# dev-storage.c +usb_msd_reset(void) "" +usb_msd_maxlun(unsigned maxlun) "%d" +usb_msd_send_status(unsigned status, unsigned tag, size_t size) "status %d= , tag 0x%x, len %zd" +usb_msd_data_in(unsigned packet, unsigned remaining, unsigned total) "%d/%= d (scsi %d)" +usb_msd_data_out(unsigned packet, unsigned remaining) "%d/%d" +usb_msd_packet_async(void) "" +usb_msd_packet_complete(void) "" +usb_msd_cmd_submit(unsigned lun, unsigned tag, unsigned flags, unsigned le= n, unsigned data_len) "lun %u, tag 0x%x, flags 0x%08x, len %d, data-len %d" +usb_msd_cmd_complete(unsigned status, unsigned tag) "status %d, tag 0x%x" +usb_msd_cmd_cancel(unsigned tag) "tag 0x%x" + # dev-uas.c usb_uas_reset(int addr) "dev %d" usb_uas_command(int addr, uint16_t tag, int lun, uint32_t lun64_1, uint32_= t lun64_2) "dev %d, tag 0x%x, lun %d, lun64 0x%08x-0x%08x" --=20 2.27.0 From nobody Sun May 5 02:47:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1605525290; cv=none; d=zohomail.com; s=zohoarc; b=EPeEpgrLHg4xsqcqedZufffiLpxDbToEL4r3AW8RGaYtmM8kpCF29nTlWcUISyh6wHSbZeiCfF2PVhFGUpJlnHWxkwsPCRSD5lSV73c7k+Oo/dJ4OqxWbqVxhUweEImvNa3iH8WWQDiLB2sTUNPCO/JERKs3m1m35C/zUPQSgkc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605525290; 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; bh=xcPSvHa2XajrMBcOiD0WcscKK4RXsKMhdUtHUunZXCg=; b=AkJITFneu1tH90UH7JBedZXEgfxt8oa3rSVZPBxnLwXFL01nmoedgOCdtnPPp1sBF248eebr6v0hU/4A80uizlHPtDtUDt+N6f7hS10SBOJ39iHu00Fo5rpGUgLrvMVtU2NP9P5+wMSVqnX9OnjrjujvkhMJArJ8jLzlBfbqjD0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=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 1605525290717273.98223712036076; Mon, 16 Nov 2020 03:14:50 -0800 (PST) Received: from localhost ([::1]:37350 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kecTA-00074E-OQ for importer@patchew.org; Mon, 16 Nov 2020 06:14:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41960) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kecPI-00021X-3q for qemu-devel@nongnu.org; Mon, 16 Nov 2020 06:10:48 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:34983) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kecPE-000283-Eh for qemu-devel@nongnu.org; Mon, 16 Nov 2020 06:10:47 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-245-8_5o0py-Oty8ifaUJLXtmg-1; Mon, 16 Nov 2020 06:10:41 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B7073873116 for ; Mon, 16 Nov 2020 11:10:40 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-65.ams2.redhat.com [10.36.112.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5CA725C5AF; Mon, 16 Nov 2020 11:10:37 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 3E37DA1FB; Mon, 16 Nov 2020 12:10:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605525043; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xcPSvHa2XajrMBcOiD0WcscKK4RXsKMhdUtHUunZXCg=; b=AXO2wabvepTxAG8aE2tbgDrFEZHkN3N1z5LJHMG/mC7KbNkn5E5/rx35VrHGrWOqZZYdcs 3DfktuxsWQMPKFW1SmR1ZegmwD7okzl0hdyoJNDVFgxKbP9nR6txSoHZoWrS7EyZd9NeZO pMEe8MUXSGQBMeuXIk4V8ywZ9XwU8zs= X-MC-Unique: 8_5o0py-Oty8ifaUJLXtmg-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 2/6] usb-storage: add commandlog property Date: Mon, 16 Nov 2020 12:10:32 +0100 Message-Id: <20201116111036.12820-3-kraxel@redhat.com> In-Reply-To: <20201116111036.12820-1-kraxel@redhat.com> References: <20201116111036.12820-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/15 22:35:17 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=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: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Add property so scsi command logging can be switched at runtime instead of compile time. Signed-off-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20201105134112.25119-3-kraxel@redhat.com --- hw/usb/dev-storage.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c index e317cde8fd48..d5cc6137443c 100644 --- a/hw/usb/dev-storage.c +++ b/hw/usb/dev-storage.c @@ -25,8 +25,6 @@ #include "qom/object.h" #include "trace.h" =20 -//#define DEBUG_MSD - /* USB requests. */ #define MassStorageReset 0xff #define GetMaxLun 0xfe @@ -59,6 +57,7 @@ struct MSDState { /* usb-storage only */ BlockConf conf; uint32_t removable; + bool commandlog; SCSIDevice *scsi_dev; }; typedef struct MSDState MSDState; @@ -451,9 +450,9 @@ static void usb_msd_handle_data(USBDevice *dev, USBPack= et *p) assert(le32_to_cpu(s->csw.residue) =3D=3D 0); s->scsi_len =3D 0; s->req =3D scsi_req_new(scsi_dev, tag, cbw.lun, cbw.cmd, NULL); -#ifdef DEBUG_MSD - scsi_req_print(s->req); -#endif + if (s->commandlog) { + scsi_req_print(s->req); + } len =3D scsi_req_enqueue(s->req); if (len) { scsi_req_continue(s->req); @@ -684,6 +683,7 @@ static Property msd_properties[] =3D { DEFINE_BLOCK_PROPERTIES(MSDState, conf), DEFINE_BLOCK_ERROR_PROPERTIES(MSDState, conf), DEFINE_PROP_BIT("removable", MSDState, removable, 0, false), + DEFINE_PROP_BOOL("commandlog", MSDState, commandlog, false), DEFINE_PROP_END_OF_LIST(), }; =20 --=20 2.27.0 From nobody Sun May 5 02:47:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1605525134; cv=none; d=zohomail.com; s=zohoarc; b=fzUPcBucx8rgv693oLMG4FZEf620AkKrfiHwsHcFYy8D8FO7ezPH+8YRHm5R92KPK0AfTJiYg68AeXs5+TeS24ARWJCnUQr49nK3duoQmBLttBVH353r1DZjHP81Wq1I/7U41QwP4TbMSIe6vS9jhYRDWOnsYwx+c6QFcAS3WK8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605525134; 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; bh=NRtS9CFihx0y6pwEeWEAj5qdTSME9+UquJ7AP5d8s0s=; b=cUZWgnlcH60cWkskElLGi8psB2zhNOIac5oLKdZB54y4AFk3C0wPP+uess7vTWWY1hbGmhpw56cJFyYl1wTLalLw9P7e9R3+dW7wQ4OwQvco8w1ka7HXFlMedx0bjlrWux0PobSJDgsSeS6+dN8XzJ1biKVUz3gLbs2q5Je2Vuo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=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 1605525134434802.7513385008052; Mon, 16 Nov 2020 03:12:14 -0800 (PST) Received: from localhost ([::1]:57182 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kecQf-0003cN-0c for importer@patchew.org; Mon, 16 Nov 2020 06:12:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41932) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kecPG-0001zL-Uf for qemu-devel@nongnu.org; Mon, 16 Nov 2020 06:10:46 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:38325) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kecPE-000285-Ao for qemu-devel@nongnu.org; Mon, 16 Nov 2020 06:10:46 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-515-0cwzP2Y0PkOOhStmU3a8dA-1; Mon, 16 Nov 2020 06:10:41 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E9290186DD25 for ; Mon, 16 Nov 2020 11:10:40 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-65.ams2.redhat.com [10.36.112.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id 45E726EF57; Mon, 16 Nov 2020 11:10:37 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 46FF09D92; Mon, 16 Nov 2020 12:10:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605525043; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NRtS9CFihx0y6pwEeWEAj5qdTSME9+UquJ7AP5d8s0s=; b=fKp/wEvMRnuWD/aR5C8cI0ePkui7RAl+AL/PRIEOxl8Ds0zoVzmpgOG72B45RDla+KJC9w gqWWxuwchxHd82UBpCaKIYeznVvlc5x6UFiMchNYNLH/nwGK5zaN7FRWxrAt8lPFUjfUpF prDwI6R4oKhSe7HZyHY8/8EIxtRwE3E= X-MC-Unique: 0cwzP2Y0PkOOhStmU3a8dA-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 3/6] usb-storage: use bool for removable property Date: Mon, 16 Nov 2020 12:10:33 +0100 Message-Id: <20201116111036.12820-4-kraxel@redhat.com> In-Reply-To: <20201116111036.12820-1-kraxel@redhat.com> References: <20201116111036.12820-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/15 22:35:17 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=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: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Signed-off-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20201105134112.25119-4-kraxel@redhat.com --- hw/usb/dev-storage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c index d5cc6137443c..360e8ca8f2bd 100644 --- a/hw/usb/dev-storage.c +++ b/hw/usb/dev-storage.c @@ -56,7 +56,7 @@ struct MSDState { USBPacket *packet; /* usb-storage only */ BlockConf conf; - uint32_t removable; + bool removable; bool commandlog; SCSIDevice *scsi_dev; }; @@ -682,7 +682,7 @@ static const VMStateDescription vmstate_usb_msd =3D { static Property msd_properties[] =3D { DEFINE_BLOCK_PROPERTIES(MSDState, conf), DEFINE_BLOCK_ERROR_PROPERTIES(MSDState, conf), - DEFINE_PROP_BIT("removable", MSDState, removable, 0, false), + DEFINE_PROP_BOOL("removable", MSDState, removable, false), DEFINE_PROP_BOOL("commandlog", MSDState, commandlog, false), DEFINE_PROP_END_OF_LIST(), }; --=20 2.27.0 From nobody Sun May 5 02:47:34 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1605525158; cv=none; d=zohomail.com; s=zohoarc; b=Eien7dsCI+I7mIXbChqiZCOZN0mBHibpAtgaoDcw9y7d297yGXa9b9STTbd7+fuUloc4aEEKugkfNqd0zoJWc3HD5Wab8crYpGeZ3GoaZFrs2WUIL5aCswh435G0LCEmoIj6qV3kEh8PX3wRB7Gy0C9gWaDKSVIEYM28sbyKsj4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605525158; 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; bh=2wbeC9Kz0dPymbWbmPj+jAGwKtxzC8BoamxYS8e1wy4=; b=F4HpTpCGS9K3f0Shfjjpp6/btwD81it6xa0yc6Va4c987euXek2SAozXtuDySHCqQ8cNEydPgmir259IiqKaRR5HRy3lwLufzjnZtQppVOJs2d3XLCPx5hjzA6HXbOmuKz6tW6cdrZNekfOuSHoSwcT49nUqG6iTI7NCKc2uGyg= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1605525158683337.7316849210699; Mon, 16 Nov 2020 03:12:38 -0800 (PST) Received: from localhost ([::1]:57588 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kecR3-0003mO-9R for importer@patchew.org; Mon, 16 Nov 2020 06:12:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41962) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kecPI-000227-Bz for qemu-devel@nongnu.org; Mon, 16 Nov 2020 06:10:48 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:40155) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kecPG-00029A-31 for qemu-devel@nongnu.org; Mon, 16 Nov 2020 06:10:48 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-226-PESk_AvjPamw0t_rsL7zGA-1; Mon, 16 Nov 2020 06:10:41 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6BE22100855A for ; Mon, 16 Nov 2020 11:10:40 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-65.ams2.redhat.com [10.36.112.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id 45EC85D9CC; Mon, 16 Nov 2020 11:10:37 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 4FE6A9D99; Mon, 16 Nov 2020 12:10:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605525045; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2wbeC9Kz0dPymbWbmPj+jAGwKtxzC8BoamxYS8e1wy4=; b=hK3iiwWuR0X6gaokzPmpYXBx4PiSARH+1r+IcXgalN4d/DrDVADO/HGGoYRtF8bSXI4VDk GAhCdP8h4HXgK+RvhuzJtoWeZZrKQ3Z0OK4GAynN8JQfx1qiXbEoyONMaXTphXajEzhija GCocFuhaBsW/ZbIuFexrPyqZmRbr158= X-MC-Unique: PESk_AvjPamw0t_rsL7zGA-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 4/6] usb-storage: fill csw on cancel Date: Mon, 16 Nov 2020 12:10:34 +0100 Message-Id: <20201116111036.12820-5-kraxel@redhat.com> In-Reply-To: <20201116111036.12820-1-kraxel@redhat.com> References: <20201116111036.12820-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=63.128.21.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/16 04:46:27 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=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: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" When scsi requests are canceled fill the csw (command status word) accordingly. Buglink: https://bugs.launchpad.net/qemu/+bug/1901981 Signed-off-by: Gerd Hoffmann Message-id: 20201105134112.25119-5-kraxel@redhat.com --- hw/usb/dev-storage.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c index 360e8ca8f2bd..f0f005869d25 100644 --- a/hw/usb/dev-storage.c +++ b/hw/usb/dev-storage.c @@ -327,6 +327,10 @@ static void usb_msd_request_cancelled(SCSIRequest *req) trace_usb_msd_cmd_cancel(req->tag); =20 if (req =3D=3D s->req) { + s->csw.sig =3D cpu_to_le32(0x53425355); + s->csw.tag =3D cpu_to_le32(req->tag); + s->csw.status =3D 1; /* error */ + scsi_req_unref(s->req); s->req =3D NULL; s->scsi_len =3D 0; --=20 2.27.0 From nobody Sun May 5 02:47:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1605525294; cv=none; d=zohomail.com; s=zohoarc; b=nD0sirAQjTPIQC3SI9OPIE4a/44Ke4PUbhi71W59t0EpIVJ+VLL8rxKSMam0QmmVUM0smnMQxN7DUCajYArF0PPze0HO007AGjVC7dz5w0Fk/5mrTw2/dnhvZ8Ligbx9JzVb5+9ewskafZnT/DoCAPCHzv/ORpCIHihWRpToW8Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605525294; 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; bh=4T66NZo2MMLrzflLbFU3Wie8LeXLwsYg5rDErYYIn+c=; b=Lay7pnUHvtXGxlUkYqaterv+O4YBYD8PZK23a2EPueIa9OhczvgTJLld+QvQe+pkuWHwMPL1jW1whbzNm8RBtCTv1Pa1NBJo12LdbM5x9E0WyS/yo5MF4KxgoXHOrtrajXlpYT65briaGjVhxvQXmcX3ErZtDgXN1dQSWj59hBc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=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 1605525294412334.7992840800273; Mon, 16 Nov 2020 03:14:54 -0800 (PST) Received: from localhost ([::1]:37692 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kecTF-0007ED-DA for importer@patchew.org; Mon, 16 Nov 2020 06:14:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41978) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kecPM-0002Bh-D4 for qemu-devel@nongnu.org; Mon, 16 Nov 2020 06:10:52 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:33879) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kecPK-0002Ai-M0 for qemu-devel@nongnu.org; Mon, 16 Nov 2020 06:10:52 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-423-3GO4zJnXPcq6hPvRJ8NWnA-1; Mon, 16 Nov 2020 06:10:45 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AB5F85F9C0 for ; Mon, 16 Nov 2020 11:10:44 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-65.ams2.redhat.com [10.36.112.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7D0985B4BF; Mon, 16 Nov 2020 11:10:41 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 58EDA9D9B; Mon, 16 Nov 2020 12:10:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605525050; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4T66NZo2MMLrzflLbFU3Wie8LeXLwsYg5rDErYYIn+c=; b=hHqY1VkdOGOhHvJVO9q8qUEJcsd9Gwzs+98NYFRB8WpJTVkDyoyJYgwvDCznppCgj7yZir VrQ7fF/7nJvjsrsNphBuU7t9PcH/32t8jC5kq0fc2QaLM2rdKdFmRgk2QNOiIJAPTSFE1s XVV9qiVRsWobJrq3KzdFANNUhJ2GLv8= X-MC-Unique: 3GO4zJnXPcq6hPvRJ8NWnA-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 5/6] xhci: fix guest triggerable assert Date: Mon, 16 Nov 2020 12:10:35 +0100 Message-Id: <20201116111036.12820-6-kraxel@redhat.com> In-Reply-To: <20201116111036.12820-1-kraxel@redhat.com> References: <20201116111036.12820-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/15 22:35:17 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=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: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) We didn't start any work yet so we can just return at that point instead of asserting. Buglink: https://bugs.launchpad.net/qemu/+bug/1883732 Signed-off-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20201105134112.25119-6-kraxel@redhat.com --- hw/usb/hcd-xhci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index 79ce5c4be6c4..d00bb0141dac 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -1904,7 +1904,9 @@ static void xhci_kick_epctx(XHCIEPContext *epctx, uns= igned int streamid) streamid =3D 0; xhci_set_ep_state(xhci, epctx, NULL, EP_RUNNING); } - assert(ring->dequeue !=3D 0); + if (!ring->dequeue) { + return; + } =20 epctx->kick_active++; while (1) { --=20 2.27.0 From nobody Sun May 5 02:47:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1605525293; cv=none; d=zohomail.com; s=zohoarc; b=BpJ3U7TasHauMVIpomVKl4bokOyvlck3JAfY/IUTzcoSvDBYulbgIJoqivdRpcWULUop+rU0mcYfyVoviBWBExehrCyYmCnhnYXmBkVTbMC9A7rPd7wKk0uA+zPyj5Pa7N0f6Wiu4skU6LhKGMhE80714xp6jT8aT47VNAAHx+o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605525293; 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; bh=TNbjmQnzAheJCh3tC87MP6ZnzpiktU0EAoN2o++iZzQ=; b=lEfe3sBIDhcHJpqo+xRJGSlPKfKpe7VIvt39gJjXldj9IfeBKk2WnpEkUhWDHqGLoellYfjD6DS/Z0RCRVRF1QXPfXJX/lB1Gwa1Hp7gtlvGOMj8JICIaIim+75MTMgfiFcWk4EZQ9+e/cdCqG4K3kR+avVMGXI7tajYkZgymfA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=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 1605525293127366.605141266799; Mon, 16 Nov 2020 03:14:53 -0800 (PST) Received: from localhost ([::1]:37540 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kecTE-0007A3-11 for importer@patchew.org; Mon, 16 Nov 2020 06:14:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41996) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kecPO-0002GX-8E for qemu-devel@nongnu.org; Mon, 16 Nov 2020 06:10:54 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:34217) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kecPM-0002Bb-Dw for qemu-devel@nongnu.org; Mon, 16 Nov 2020 06:10:53 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-529-hFJwj30pN7iajXN2Ttudvg-1; Mon, 16 Nov 2020 06:10:48 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9B09A1087D60 for ; Mon, 16 Nov 2020 11:10:47 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-65.ams2.redhat.com [10.36.112.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id 775EA1001E73; Mon, 16 Nov 2020 11:10:44 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 61BB29D9C; Mon, 16 Nov 2020 12:10:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605525051; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TNbjmQnzAheJCh3tC87MP6ZnzpiktU0EAoN2o++iZzQ=; b=Y/XX56G//u+Acq6k1y3dJik/GLyO43wx6IPV4MmHVRnZH+P22YtUImPNycK09QSJTYy1dl nTG2Q6mbSajjXD5457SJON52C6dY2mRRLs+k1F0UkOP+075PgRz0PGvxyhrhk13lA2I6Ae VctSLgCOvjahP1smOuzrGEkP8uxFDIc= X-MC-Unique: hFJwj30pN7iajXN2Ttudvg-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 6/6] xhci: move sanity checks Date: Mon, 16 Nov 2020 12:10:36 +0100 Message-Id: <20201116111036.12820-7-kraxel@redhat.com> In-Reply-To: <20201116111036.12820-1-kraxel@redhat.com> References: <20201116111036.12820-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/15 22:35:17 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=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: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) The v variable goes negative for reg < 0x20. Reorder the code to first sanity check then calculate v and assign intr to make sanity checkers happy. Buglink: https://bugs.launchpad.net/qemu/+bug/1902112 Signed-off-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20201105134112.25119-7-kraxel@redhat.com --- hw/usb/hcd-xhci.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index d00bb0141dac..6dfb17cbe915 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -3010,14 +3010,17 @@ static void xhci_runtime_write(void *ptr, hwaddr re= g, uint64_t val, unsigned size) { XHCIState *xhci =3D ptr; - int v =3D (reg - 0x20) / 0x20; - XHCIInterrupter *intr =3D &xhci->intr[v]; + XHCIInterrupter *intr; + int v; + trace_usb_xhci_runtime_write(reg, val); =20 if (reg < 0x20) { trace_usb_xhci_unimplemented("runtime write", reg); return; } + v =3D (reg - 0x20) / 0x20; + intr =3D &xhci->intr[v]; =20 switch (reg & 0x1f) { case 0x00: /* IMAN */ --=20 2.27.0