From nobody Thu May 2 12:11:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500541704035251.12332149504937; Thu, 20 Jul 2017 02:08:24 -0700 (PDT) Received: from localhost ([::1]:36796 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dY7RU-0001Vb-VS for importer@patchew.org; Thu, 20 Jul 2017 05:08:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44361) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dY7N9-0006MY-CP for qemu-devel@nongnu.org; Thu, 20 Jul 2017 05:03:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dY7N8-0004Pg-Hb for qemu-devel@nongnu.org; Thu, 20 Jul 2017 05:03:51 -0400 Received: from manul.sfritsch.de ([2a01:4f8:172:195f:112::2]:36994) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dY7N8-0004PG-Bh for qemu-devel@nongnu.org; Thu, 20 Jul 2017 05:03:50 -0400 From: Stefan Fritsch To: Gerd Hoffmann , qemu-devel@nongnu.org Date: Thu, 20 Jul 2017 11:02:44 +0200 Message-Id: <1500541371-24788-2-git-send-email-sf@sfritsch.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1500541371-24788-1-git-send-email-sf@sfritsch.de> References: <1500541371-24788-1-git-send-email-sf@sfritsch.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a01:4f8:172:195f:112::2 Subject: [Qemu-devel] [PATCH v2 1/8] usb-ccid: Add support to dump all USB packets X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Stefan Fritsch The dump can be activated by the debug command line option for the device like this "qemu ... -dev usb,ccid,debug=3D5" While there move the short read debug message to a higher debug level. It triggers very often and makes debug output unreadable. Signed-off-by: Stefan Fritsch Signed-off-by: Christian Ehrhardt --- hw/usb/dev-smartcard-reader.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c index bef1f03c42..624dc2c447 100644 --- a/hw/usb/dev-smartcard-reader.c +++ b/hw/usb/dev-smartcard-reader.c @@ -54,9 +54,25 @@ do { \ #define D_INFO 2 #define D_MORE_INFO 3 #define D_VERBOSE 4 +#define D_TRACE 5 +#define D_REMOTEIO 10 =20 #define CCID_DEV_NAME "usb-ccid" #define USB_CCID_DEV(obj) OBJECT_CHECK(USBCCIDState, (obj), CCID_DEV_NAME) + +static void usb_packet_dump(int lvl, const char *dir, uint8_t *buf, size_t= len) +{ + int i; + if (lvl < D_TRACE) { + return; + } + printf("usb-ccid: usb packet(%s/%zd):", dir, len); + for (i =3D 0; i < len; ++i) { + printf(" %02x", buf[i]); + } + printf("\n"); +} + /* * The two options for variable sized buffers: * make them constant size, for large enough constant, @@ -1007,6 +1023,8 @@ static void ccid_handle_bulk_out(USBCCIDState *s, USB= Packet *p) goto err; } usb_packet_copy(p, s->bulk_out_data + s->bulk_out_pos, p->iov.size); + usb_packet_dump(s->debug, "out", s->bulk_out_data + s->bulk_out_pos, + p->iov.size); s->bulk_out_pos +=3D p->iov.size; if (s->bulk_out_pos < 10) { DPRINTF(s, 1, "%s: header incomplete\n", __func__); @@ -1102,6 +1120,9 @@ static void ccid_bulk_in_copy_to_guest(USBCCIDState *= s, USBPacket *p) p->iov.size); usb_packet_copy(p, s->current_bulk_in->data + s->current_bulk_in->pos, len); + usb_packet_dump(s->debug, " in", + s->current_bulk_in->data + s->current_bulk_in->pos, + len); s->current_bulk_in->pos +=3D len; if (s->current_bulk_in->pos =3D=3D s->current_bulk_in->len) { ccid_bulk_in_release(s); @@ -1116,7 +1137,7 @@ static void ccid_bulk_in_copy_to_guest(USBCCIDState *= s, USBPacket *p) __func__, p->iov.size, len); } if (len < p->iov.size) { - DPRINTF(s, 1, + DPRINTF(s, D_REMOTEIO, "%s: returning short (EREMOTEIO) %d < %zd\n", __func__, len, p->iov.size); } @@ -1143,6 +1164,7 @@ static void ccid_handle_data(USBDevice *dev, USBPacke= t *p) buf[0] =3D CCID_MESSAGE_TYPE_RDR_to_PC_NotifySlotChange; buf[1] =3D s->bmSlotICCState; usb_packet_copy(p, buf, 2); + usb_packet_dump(s->debug, "irq", buf, 2); s->notify_slot_change =3D false; s->bmSlotICCState &=3D ~SLOT_0_CHANGED_MASK; DPRINTF(s, D_INFO, --=20 2.11.0 From nobody Thu May 2 12:11:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500541556875955.007733501862; Thu, 20 Jul 2017 02:05:56 -0700 (PDT) Received: from localhost ([::1]:36786 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dY7P8-00080E-7O for importer@patchew.org; Thu, 20 Jul 2017 05:05:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44368) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dY7N9-0006Me-Gi for qemu-devel@nongnu.org; Thu, 20 Jul 2017 05:03:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dY7N8-0004Pn-KM for qemu-devel@nongnu.org; Thu, 20 Jul 2017 05:03:51 -0400 Received: from manul.sfritsch.de ([2a01:4f8:172:195f:112::2]:36996) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dY7N8-0004PI-F1 for qemu-devel@nongnu.org; Thu, 20 Jul 2017 05:03:50 -0400 From: Stefan Fritsch To: Gerd Hoffmann , qemu-devel@nongnu.org Date: Thu, 20 Jul 2017 11:02:45 +0200 Message-Id: <1500541371-24788-3-git-send-email-sf@sfritsch.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1500541371-24788-1-git-send-email-sf@sfritsch.de> References: <1500541371-24788-1-git-send-email-sf@sfritsch.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a01:4f8:172:195f:112::2 Subject: [Qemu-devel] [PATCH v2 2/8] usb-ccid: Fix USB packet generation for 64-Bytes sized packets. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Stefan Fritsch An USB transfer must be terminated by a packet that is shorter than the maximum USB packet size (usually 64Byte) reported by the device in its descriptor(s). Thus if the last packet of a transfer is exactly 64-Bytes long, we must send an additional zero length packet. Fix this for bulk in transfers. For bulk out transfers this is already ok, for interrupt transfers this is not a problem as the pipe has a maximum packet size of 8 and transfers are only two bytes long. Signed-off-by: Stefan Fritsch Signed-off-by: Christian Ehrhardt --- hw/usb/dev-smartcard-reader.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c index 624dc2c447..49791492ea 100644 --- a/hw/usb/dev-smartcard-reader.c +++ b/hw/usb/dev-smartcard-reader.c @@ -1124,7 +1124,13 @@ static void ccid_bulk_in_copy_to_guest(USBCCIDState = *s, USBPacket *p) s->current_bulk_in->data + s->current_bulk_in->pos, len); s->current_bulk_in->pos +=3D len; - if (s->current_bulk_in->pos =3D=3D s->current_bulk_in->len) { + /* + * The caller assumes that the packet continues if we fill the + * entire iov and the iov length matches the max packet size. + * Add an empty USB packet in this case. + */ + if (s->current_bulk_in->pos =3D=3D s->current_bulk_in->len + && (len < p->iov.size || p->iov.size < CCID_MAX_PACKET_SIZE)) { ccid_bulk_in_release(s); } } else { --=20 2.11.0 From nobody Thu May 2 12:11:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500541912144467.23096999063876; Thu, 20 Jul 2017 02:11:52 -0700 (PDT) Received: from localhost ([::1]:36823 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dY7Ur-0004t9-Py for importer@patchew.org; Thu, 20 Jul 2017 05:11:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44373) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dY7N9-0006Mo-OL for qemu-devel@nongnu.org; Thu, 20 Jul 2017 05:03:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dY7N8-0004Pv-Nb for qemu-devel@nongnu.org; Thu, 20 Jul 2017 05:03:51 -0400 Received: from manul.sfritsch.de ([2a01:4f8:172:195f:112::2]:36998) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dY7N8-0004PM-IV for qemu-devel@nongnu.org; Thu, 20 Jul 2017 05:03:50 -0400 From: Stefan Fritsch To: Gerd Hoffmann , qemu-devel@nongnu.org Date: Thu, 20 Jul 2017 11:02:46 +0200 Message-Id: <1500541371-24788-4-git-send-email-sf@sfritsch.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1500541371-24788-1-git-send-email-sf@sfritsch.de> References: <1500541371-24788-1-git-send-email-sf@sfritsch.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a01:4f8:172:195f:112::2 Subject: [Qemu-devel] [PATCH v2 3/8] usb-ccid: Set protocol parameters based on card ATR X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Stefan Fritsch For the ATR interface bytes encoding see ISO/IEC 7816-3. For the interpretation of the protocol parameter block see the CCID specification. - Values that are not present in the ATR default to zero. - TA_1 is used to fill bmFindexDindex. - The high nibble of bmTCCKST0 must be the protocol (T=3D0 or T=3D1). - For T=3D0 the bWaitingInteger can be found in the global byte TC_2, for T=3D1 the waiting integer is in TB_3 and bIFSC is in TA_3. Signed-off-by: Stefan Fritsch Signed-off-by: Christian Ehrhardt --- hw/usb/dev-smartcard-reader.c | 66 +++++++++++++++++++++++++++++++++++----= ---- 1 file changed, 54 insertions(+), 12 deletions(-) diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c index 49791492ea..769949144b 100644 --- a/hw/usb/dev-smartcard-reader.c +++ b/hw/usb/dev-smartcard-reader.c @@ -801,7 +801,7 @@ static void ccid_write_parameters(USBCCIDState *s, CCID= _Header *recv) return; } h->b.hdr.bMessageType =3D CCID_MESSAGE_TYPE_RDR_to_PC_Parameters; - h->b.hdr.dwLength =3D 0; + h->b.hdr.dwLength =3D (s->bProtocolNum =3D=3D 1) ? 7 : 5; h->b.hdr.bSlot =3D recv->bSlot; h->b.hdr.bSeq =3D recv->bSeq; h->b.bStatus =3D ccid_calc_status(s); @@ -871,6 +871,49 @@ static uint8_t atr_get_protocol_num(const uint8_t *atr= , uint32_t len) return atr[i] & 0x0f; } =20 +/* + * Get a specific interface byte TX_y (X=3D'A'..'D' y=3D1..3) + * See ISO/IEC 7816-3:2006 Chapter 8 for details. + */ +static uint8_t atr_get_TXY(const uint8_t *atr, uint32_t len, char x, int y) +{ + int pos; + uint8_t t0, ti, i; + + if (x < 'A' || x > 'D') { + return 0; + } + x -=3D 'A'; + + if (len < 2) { + return 0; + } + t0 =3D atr[1] >> 4; + pos =3D 2; + ti =3D 1; + /* Skip TA_i..TD_i if present while not at requested index y */ + while (ti < y) { + pos +=3D !!(t0 & 0x01) + !!(t0 & 0x02) + !!(t0 & 0x04); + if (pos >=3D len || !(t0 & 0x08)) { + return 0; + } + t0 =3D atr[pos++] >> 4; + ti++; + } + if (!(t0 & 0x01 << x)) { + return 0; + } + for (i =3D 0; i < x; ++i) { + if (t0 & (1 << i)) { + pos++; + } + } + if (pos >=3D len) { + return 0; + } + return atr[pos]; +} + static void ccid_write_data_block_atr(USBCCIDState *s, CCID_Header *recv) { const uint8_t *atr =3D NULL; @@ -890,21 +933,20 @@ static void ccid_write_data_block_atr(USBCCIDState *s= , CCID_Header *recv) : s->bProtocolNum); switch (atr_protocol_num) { case 0: - /* TODO: unimplemented ATR T0 parameters */ - t0->bmFindexDindex =3D 0; - t0->bmTCCKST0 =3D 0; + t0->bmFindexDindex =3D atr_get_TXY(atr, len, 'A', 1); + t0->bmTCCKST0 =3D 0; /* T0 */ t0->bGuardTimeT0 =3D 0; - t0->bWaitingIntegerT0 =3D 0; + t0->bWaitingIntegerT0 =3D atr_get_TXY(atr, len, 'C', 2); t0->bClockStop =3D 0; break; case 1: - /* TODO: unimplemented ATR T1 parameters */ - t1->bmFindexDindex =3D 0; - t1->bmTCCKST1 =3D 0; - t1->bGuardTimeT1 =3D 0; - t1->bWaitingIntegerT1 =3D 0; - t1->bClockStop =3D 0; - t1->bIFSC =3D 0; + /* NOTE: If present TD2 should specify protocl T=3D1 */ + t1->bmFindexDindex =3D atr_get_TXY(atr, len, 'A', 1); + t1->bmTCCKST1 =3D 0x10; /* T1 */ + t1->bGuardTimeT1 =3D atr_get_TXY(atr, len, 'C', 1); + t1->bWaitingIntegerT1 =3D atr_get_TXY(atr, len, 'B', 3); + t1->bClockStop =3D 0x00; + t1->bIFSC =3D atr_get_TXY(atr, len, 'A', 3); t1->bNadValue =3D 0; break; default: --=20 2.11.0 From nobody Thu May 2 12:11:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500541565786986.8382820216403; Thu, 20 Jul 2017 02:06:05 -0700 (PDT) Received: from localhost ([::1]:36788 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dY7PE-00084N-UR for importer@patchew.org; Thu, 20 Jul 2017 05:06:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44371) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dY7N9-0006Ml-MT for qemu-devel@nongnu.org; Thu, 20 Jul 2017 05:03:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dY7N8-0004Q1-Qm for qemu-devel@nongnu.org; Thu, 20 Jul 2017 05:03:51 -0400 Received: from manul.sfritsch.de ([2a01:4f8:172:195f:112::2]:37000) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dY7N8-0004PP-Le for qemu-devel@nongnu.org; Thu, 20 Jul 2017 05:03:50 -0400 From: Stefan Fritsch To: Gerd Hoffmann , qemu-devel@nongnu.org Date: Thu, 20 Jul 2017 11:02:47 +0200 Message-Id: <1500541371-24788-5-git-send-email-sf@sfritsch.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1500541371-24788-1-git-send-email-sf@sfritsch.de> References: <1500541371-24788-1-git-send-email-sf@sfritsch.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a01:4f8:172:195f:112::2 Subject: [Qemu-devel] [PATCH v2 4/8] usb-ccid: Fix ATR parsing X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Stefan Fritsch - The number of parameter set TA_i...TD_i is unlimited. The list ends if TD_i is not present or the high nibble is zero. - If at least one protocol in any of the TD bytes is non-zero, the ATR must have a checksum. - Add a missing length check before accessing TD. - Fixup a wrong checksum but accept the ATR. Signed-off-by: Stefan Fritsch Signed-off-by: Christian Ehrhardt --- hw/usb/ccid-card-passthru.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/hw/usb/ccid-card-passthru.c b/hw/usb/ccid-card-passthru.c index 45d96b03c6..e2e94ac1ba 100644 --- a/hw/usb/ccid-card-passthru.c +++ b/hw/usb/ccid-card-passthru.c @@ -146,8 +146,7 @@ static void ccid_card_vscard_handle_init( =20 static int check_atr(PassthruState *card, uint8_t *data, int len) { - int historical_length, opt_bytes; - int td_count =3D 0; + int historical_length, opt_bytes, tck =3D 0; int td; =20 if (len < 2) { @@ -160,10 +159,8 @@ static int check_atr(PassthruState *card, uint8_t *dat= a, int len) data[0]); return 0; } - td_count =3D 0; td =3D data[1] >> 4; - while (td && td_count < 2 && opt_bytes + historical_length + 2 < len) { - td_count++; + while (td && opt_bytes + historical_length + 2 < len) { if (td & 0x1) { opt_bytes++; } @@ -175,16 +172,37 @@ static int check_atr(PassthruState *card, uint8_t *da= ta, int len) } if (td & 0x8) { opt_bytes++; - td =3D data[opt_bytes + 2] >> 4; + if (opt_bytes + 1 >=3D len) { + break; + } + /* Checksum byte must be present if T!=3D0 */ + if (data[opt_bytes + 1] & 0xf) { + tck =3D 1; + } + td =3D data[opt_bytes + 1] >> 4; + } else { + td =3D 0; } } - if (len < 2 + historical_length + opt_bytes) { + if (len < 2 + historical_length + opt_bytes + tck) { DPRINTF(card, D_WARN, "atr too short: len %d, but historical_len %d, T1 0x%X\n", len, historical_length, data[1]); return 0; } - if (len > 2 + historical_length + opt_bytes) { + if (tck) { + int i; + uint8_t cksum =3D 0; + for (i =3D 1; i < 2 + historical_length + opt_bytes; ++i) { + cksum ^=3D data[i]; + } + if (cksum !=3D data[i]) { + DPRINTF(card, D_WARN, "atr has bad checksum: " + "real=3D0x%x should be 0x%x (FIXED)\n", cksum, data[i]); + data[i] =3D cksum; + } + } + if (len > 2 + historical_length + opt_bytes + tck) { DPRINTF(card, D_WARN, "atr too long: len %d, but hist/opt %d/%d, T1 0x%X\n", len, historical_length, opt_bytes, data[1]); --=20 2.11.0 From nobody Thu May 2 12:11:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500541844724253.99824966742335; Thu, 20 Jul 2017 02:10:44 -0700 (PDT) Received: from localhost ([::1]:36813 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dY7Tm-0004Bq-If for importer@patchew.org; Thu, 20 Jul 2017 05:10:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44379) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dY7N9-0006Mt-Qq for qemu-devel@nongnu.org; Thu, 20 Jul 2017 05:03:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dY7N8-0004Q7-U2 for qemu-devel@nongnu.org; Thu, 20 Jul 2017 05:03:51 -0400 Received: from manul.sfritsch.de ([2a01:4f8:172:195f:112::2]:37002) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dY7N8-0004PT-PF for qemu-devel@nongnu.org; Thu, 20 Jul 2017 05:03:50 -0400 From: Stefan Fritsch To: Gerd Hoffmann , qemu-devel@nongnu.org Date: Thu, 20 Jul 2017 11:02:48 +0200 Message-Id: <1500541371-24788-6-git-send-email-sf@sfritsch.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1500541371-24788-1-git-send-email-sf@sfritsch.de> References: <1500541371-24788-1-git-send-email-sf@sfritsch.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a01:4f8:172:195f:112::2 Subject: [Qemu-devel] [PATCH v2 5/8] usb-ccid: Fix USB descriptor X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Stefan Fritsch - We want to support both T=3D0 and T=3D1. Additionally, note that all fields in USB descriptors are little endian and the supported protocols are in the lowest byte the of the 32-Bit dwProtocols field. - We want APDU level exchanges. This saves us from PPS exchanges and from APDU reassembly from T=3D1 packets. Signed-off-by: Stefan Fritsch Signed-off-by: Christian Ehrhardt --- hw/usb/dev-smartcard-reader.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c index 769949144b..bc4dc35d3f 100644 --- a/hw/usb/dev-smartcard-reader.c +++ b/hw/usb/dev-smartcard-reader.c @@ -353,8 +353,8 @@ static const uint8_t qemu_ccid_descriptor[] =3D { */ 0x07, /* u8 bVoltageSupport; 01h - 5.0v, 02h - 3.0, 03 - 1.= 8 */ =20 - 0x00, 0x00, /* u32 dwProtocols; RRRR PPPP. RRRR =3D 0000h.*/ - 0x01, 0x00, /* PPPP: 0001h =3D Protocol T=3D0, 0002h =3D Protocol = T=3D1 */ + 0x03, 0x00, /* u32 dwProtocols; RRRR PPPP. RRRR =3D 0000h.*/ + 0x00, 0x00, /* PPPP: 0001h =3D Protocol T=3D0, 0002h =3D Protocol = T=3D1 */ /* u32 dwDefaultClock; in kHZ (0x0fa0 is 4 MHz) */ 0xa0, 0x0f, 0x00, 0x00, /* u32 dwMaximumClock; */ @@ -397,7 +397,7 @@ static const uint8_t qemu_ccid_descriptor[] =3D { * insertion and removal. Must set bit 5 in bmAttribut= es * in Configuration descriptor if 100000 is set. */ - 0xfe, 0x04, 0x01, 0x00, + 0xfe, 0x04, 0x04, 0x00, /* * u32 dwMaxCCIDMessageLength; For extended APDU in * [261 + 10 , 65544 + 10]. Otherwise the minimum is --=20 2.11.0 From nobody Thu May 2 12:11:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15005418132792.1164477279872926; Thu, 20 Jul 2017 02:10:13 -0700 (PDT) Received: from localhost ([::1]:36801 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dY7TH-0003eK-Nm for importer@patchew.org; Thu, 20 Jul 2017 05:10:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44383) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dY7N9-0006Mw-TO for qemu-devel@nongnu.org; Thu, 20 Jul 2017 05:03:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dY7N9-0004QF-1z for qemu-devel@nongnu.org; Thu, 20 Jul 2017 05:03:51 -0400 Received: from manul.sfritsch.de ([2a01:4f8:172:195f:112::2]:37004) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dY7N8-0004PY-ST for qemu-devel@nongnu.org; Thu, 20 Jul 2017 05:03:50 -0400 From: Stefan Fritsch To: Gerd Hoffmann , qemu-devel@nongnu.org Date: Thu, 20 Jul 2017 11:02:49 +0200 Message-Id: <1500541371-24788-7-git-send-email-sf@sfritsch.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1500541371-24788-1-git-send-email-sf@sfritsch.de> References: <1500541371-24788-1-git-send-email-sf@sfritsch.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a01:4f8:172:195f:112::2 Subject: [Qemu-devel] [PATCH v2 6/8] usb-ccid: Fix chaining fields in CCID USB messages X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Stefan Fritsch Incoming packets should never need chaining (bChainParamter =3D> 0). If they ever do we will have to fix this later. Zero is still better than an uninitialized value. Warn if outgoing packets try to use chaining (wLevelParameter !=3D 0). As we are doing APDU level exchanges, the driver should not need to set these bits. Signed-off-by: Stefan Fritsch Signed-off-by: Christian Ehrhardt --- hw/usb/dev-smartcard-reader.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c index bc4dc35d3f..709c65c384 100644 --- a/hw/usb/dev-smartcard-reader.c +++ b/hw/usb/dev-smartcard-reader.c @@ -826,6 +826,7 @@ static void ccid_write_data_block(USBCCIDState *s, uint= 8_t slot, uint8_t seq, p->b.hdr.bSeq =3D seq; p->b.bStatus =3D ccid_calc_status(s); p->b.bError =3D s->bError; + p->bChainParameter =3D 0; if (p->b.bError) { DPRINTF(s, D_VERBOSE, "error %d\n", p->b.bError); } @@ -1027,6 +1028,10 @@ static void ccid_on_apdu_from_guest(USBCCIDState *s,= CCID_XferBlock *recv) len =3D le32_to_cpu(recv->hdr.dwLength); DPRINTF(s, 1, "%s: seq %d, len %d\n", __func__, recv->hdr.bSeq, len); + if (le16_to_cpu(recv->wLevelParameter)) { + DPRINTF(s, D_WARN, "Unsupported non-zero level Parameter %x\n", + le16_to_cpu(recv->wLevelParameter)); + } ccid_add_pending_answer(s, (CCID_Header *)recv); if (s->card && len <=3D BULK_OUT_DATA_SIZE) { ccid_card_apdu_from_guest(s->card, recv->abData, len); --=20 2.11.0 From nobody Thu May 2 12:11:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500541660812215.02220605564594; Thu, 20 Jul 2017 02:07:40 -0700 (PDT) Received: from localhost ([::1]:36793 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dY7Qo-000147-Gg for importer@patchew.org; Thu, 20 Jul 2017 05:07:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44374) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dY7N9-0006Mq-Ot for qemu-devel@nongnu.org; Thu, 20 Jul 2017 05:03:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dY7N9-0004QN-4y for qemu-devel@nongnu.org; Thu, 20 Jul 2017 05:03:51 -0400 Received: from manul.sfritsch.de ([2a01:4f8:172:195f:112::2]:37006) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dY7N8-0004Pa-W4 for qemu-devel@nongnu.org; Thu, 20 Jul 2017 05:03:51 -0400 From: Stefan Fritsch To: Gerd Hoffmann , qemu-devel@nongnu.org Date: Thu, 20 Jul 2017 11:02:50 +0200 Message-Id: <1500541371-24788-8-git-send-email-sf@sfritsch.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1500541371-24788-1-git-send-email-sf@sfritsch.de> References: <1500541371-24788-1-git-send-email-sf@sfritsch.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a01:4f8:172:195f:112::2 Subject: [Qemu-devel] [PATCH v2 7/8] usb-ccid: Increase ccid max APDU size X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Stefan Fritsch The emulated ccid smartcard reader has a fixed limit for APDUs from the card. Increase this to 1024. We have seen software that tries to use 768 byte APDUs. Signed-off-by: Stefan Fritsch --- hw/usb/dev-smartcard-reader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c index 709c65c384..72324e8313 100644 --- a/hw/usb/dev-smartcard-reader.c +++ b/hw/usb/dev-smartcard-reader.c @@ -82,7 +82,7 @@ static void usb_packet_dump(int lvl, const char *dir, uin= t8_t *buf, size_t len) #define BULK_OUT_DATA_SIZE 65536 #define PENDING_ANSWERS_NUM 128 =20 -#define BULK_IN_BUF_SIZE 384 +#define BULK_IN_BUF_SIZE 1024 #define BULK_IN_PENDING_NUM 8 =20 #define CCID_MAX_PACKET_SIZE 64 --=20 2.11.0 From nobody Thu May 2 12:11:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 150054156411380.36628135876708; Thu, 20 Jul 2017 02:06:04 -0700 (PDT) Received: from localhost ([::1]:36787 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dY7PE-00084G-VY for importer@patchew.org; Thu, 20 Jul 2017 05:06:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44412) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dY7NA-0006NO-J5 for qemu-devel@nongnu.org; Thu, 20 Jul 2017 05:03:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dY7N9-0004QV-Bm for qemu-devel@nongnu.org; Thu, 20 Jul 2017 05:03:52 -0400 Received: from manul.sfritsch.de ([2a01:4f8:172:195f:112::2]:37008) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dY7N9-0004Pc-2Z for qemu-devel@nongnu.org; Thu, 20 Jul 2017 05:03:51 -0400 From: Stefan Fritsch To: Gerd Hoffmann , qemu-devel@nongnu.org Date: Thu, 20 Jul 2017 11:02:51 +0200 Message-Id: <1500541371-24788-9-git-send-email-sf@sfritsch.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1500541371-24788-1-git-send-email-sf@sfritsch.de> References: <1500541371-24788-1-git-send-email-sf@sfritsch.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a01:4f8:172:195f:112::2 Subject: [Qemu-devel] [PATCH v2 8/8] usb-ccid: Reduce logging at level WARN X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Stefan Fritsch Change all DPRINTF()s using (1 =3D=3D WARN) to use symbolic constants. Most of these DPRINTFs are now only logging at higher log levels. This allows to use ccid's debug level 1 =3D=3D WARN in normal operation. Signed-off-by: Stefan Fritsch --- hw/usb/dev-smartcard-reader.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c index 72324e8313..fcc3ac1338 100644 --- a/hw/usb/dev-smartcard-reader.c +++ b/hw/usb/dev-smartcard-reader.c @@ -669,7 +669,7 @@ static void ccid_handle_reset(USBDevice *dev) { USBCCIDState *s =3D USB_CCID_DEV(dev); =20 - DPRINTF(s, 1, "Reset\n"); + DPRINTF(s, D_VERBOSE, "Reset\n"); =20 ccid_reset(s); } @@ -713,7 +713,7 @@ static void ccid_handle_control(USBDevice *dev, USBPack= et *p, int request, USBCCIDState *s =3D USB_CCID_DEV(dev); int ret; =20 - DPRINTF(s, 1, "%s: got control %s (%x), value %x\n", __func__, + DPRINTF(s, D_TRACE, "%s: got control %s (%x), value %x\n", __func__, ccid_control_to_str(s, request), request, value); ret =3D usb_desc_handle_control(dev, p, request, value, index, length,= data); if (ret >=3D 0) { @@ -723,19 +723,20 @@ static void ccid_handle_control(USBDevice *dev, USBPa= cket *p, int request, switch (request) { /* Class specific requests. */ case ClassInterfaceOutRequest | CCID_CONTROL_ABORT: - DPRINTF(s, 1, "ccid_control abort UNIMPLEMENTED\n"); + DPRINTF(s, D_INFO, "ccid_control abort UNIMPLEMENTED\n"); p->status =3D USB_RET_STALL; break; case ClassInterfaceRequest | CCID_CONTROL_GET_CLOCK_FREQUENCIES: - DPRINTF(s, 1, "ccid_control get clock frequencies UNIMPLEMENTED\n"= ); + DPRINTF(s, D_INFO, + "ccid_control get clock frequencies UNIMPLEMENTED\n"); p->status =3D USB_RET_STALL; break; case ClassInterfaceRequest | CCID_CONTROL_GET_DATA_RATES: - DPRINTF(s, 1, "ccid_control get data rates UNIMPLEMENTED\n"); + DPRINTF(s, D_INFO, "ccid_control get data rates UNIMPLEMENTED\n"); p->status =3D USB_RET_STALL; break; default: - DPRINTF(s, 1, "got unsupported/bogus control %x, value %x\n", + DPRINTF(s, D_INFO, "got unsupported/bogus control %x, value %x\n", request, value); p->status =3D USB_RET_STALL; break; @@ -1020,13 +1021,13 @@ static void ccid_on_apdu_from_guest(USBCCIDState *s= , CCID_XferBlock *recv) uint32_t len; =20 if (ccid_card_status(s) !=3D ICC_STATUS_PRESENT_ACTIVE) { - DPRINTF(s, 1, + DPRINTF(s, D_INFO, "usb-ccid: not sending apdu to client, no card connected\n= "); ccid_write_data_block_error(s, recv->hdr.bSlot, recv->hdr.bSeq); return; } len =3D le32_to_cpu(recv->hdr.dwLength); - DPRINTF(s, 1, "%s: seq %d, len %d\n", __func__, + DPRINTF(s, D_TRACE, "%s: seq %d, len %d\n", __func__, recv->hdr.bSeq, len); if (le16_to_cpu(recv->wLevelParameter)) { DPRINTF(s, D_WARN, "Unsupported non-zero level Parameter %x\n", @@ -1087,7 +1088,7 @@ static void ccid_handle_bulk_out(USBCCIDState *s, USB= Packet *p) return; } if (s->bulk_out_pos - 10 !=3D ccid_header->dwLength) { - DPRINTF(s, 1, + DPRINTF(s, D_WARN, "usb-ccid: bulk_in: message size mismatch (got %d, expecte= d %d)\n", s->bulk_out_pos - 10, ccid_header->dwLength); goto err; @@ -1101,7 +1102,7 @@ static void ccid_handle_bulk_out(USBCCIDState *s, USB= Packet *p) ccid_write_slot_status(s, ccid_header); break; case CCID_MESSAGE_TYPE_PC_to_RDR_IccPowerOn: - DPRINTF(s, 1, "%s: PowerOn: %d\n", __func__, + DPRINTF(s, D_VERBOSE, "%s: PowerOn: %d\n", __func__, ((CCID_IccPowerOn *)(ccid_header))->bPowerSelect); s->powered =3D true; if (!ccid_card_inserted(s)) { @@ -1137,7 +1138,7 @@ static void ccid_handle_bulk_out(USBCCIDState *s, USB= Packet *p) ccid_write_slot_status(s, ccid_header); break; default: - DPRINTF(s, 1, + DPRINTF(s, D_WARN, "handle_data: ERROR: unhandled message type %Xh\n", ccid_header->bMessageType); /* @@ -1229,13 +1230,13 @@ static void ccid_handle_data(USBDevice *dev, USBPac= ket *p) } break; default: - DPRINTF(s, 1, "Bad endpoint\n"); + DPRINTF(s, D_INFO, "Bad endpoint\n"); p->status =3D USB_RET_STALL; break; } break; default: - DPRINTF(s, 1, "Bad token\n"); + DPRINTF(s, D_INFO, "Bad token\n"); p->status =3D USB_RET_STALL; break; } @@ -1285,7 +1286,7 @@ void ccid_card_send_apdu_to_guest(CCIDCardState *card, Answer *answer; =20 if (!ccid_has_pending_answers(s)) { - DPRINTF(s, 1, "CCID ERROR: got an APDU without pending answers\n"); + DPRINTF(s, D_WARN, "CCID ERROR: got an APDU without pending answer= s\n"); return; } s->bmCommandStatus =3D COMMAND_STATUS_NO_ERROR; @@ -1295,7 +1296,7 @@ void ccid_card_send_apdu_to_guest(CCIDCardState *card, ccid_report_error_failed(s, ERROR_HW_ERROR); return; } - DPRINTF(s, 1, "APDU returned to guest %d (answer seq %d, slot %d)\n", + DPRINTF(s, D_TRACE, "APDU returned to guest %d (answer seq %d, slot %d= )\n", len, answer->seq, answer->slot); ccid_write_data_block_answer(s, apdu, len); } @@ -1317,7 +1318,7 @@ int ccid_card_ccid_attach(CCIDCardState *card) USBDevice *dev =3D USB_DEVICE(qdev->parent_bus->parent); USBCCIDState *s =3D USB_CCID_DEV(dev); =20 - DPRINTF(s, 1, "CCID Attach\n"); + DPRINTF(s, D_VERBOSE, "CCID Attach\n"); if (s->migration_state =3D=3D MIGRATION_MIGRATED) { s->migration_state =3D MIGRATION_NONE; } @@ -1330,7 +1331,7 @@ void ccid_card_ccid_detach(CCIDCardState *card) USBDevice *dev =3D USB_DEVICE(qdev->parent_bus->parent); USBCCIDState *s =3D USB_CCID_DEV(dev); =20 - DPRINTF(s, 1, "CCID Detach\n"); + DPRINTF(s, D_VERBOSE, "CCID Detach\n"); if (ccid_card_inserted(s)) { ccid_on_slot_change(s, false); } @@ -1345,7 +1346,7 @@ void ccid_card_card_error(CCIDCardState *card, uint64= _t error) =20 s->bmCommandStatus =3D COMMAND_STATUS_FAILED; s->last_answer_error =3D error; - DPRINTF(s, 1, "VSC_Error: %" PRIX64 "\n", s->last_answer_error); + DPRINTF(s, D_INFO, "VSC_Error: %" PRIX64 "\n", s->last_answer_error); /* TODO: these errors should be more verbose and propagated to the gue= st.*/ /* * We flush all pending answers on CardRemove message in ccid-card-pas= sthru, --=20 2.11.0