Usb 20180518 patches
The following changes since commit a4207e3b00e89f934adb231057dcf9a75ac2ae45:
Merge remote-tracking branch 'remotes/cody/tags/block-pull-request' into staging (2018-05-17 11:59:50 +0100)
are available in the git repository at:
git://git.kraxel.org/qemu tags/usb-20180518-pull-request
for you to fetch changes up to 8030dca376fa1bc4d8a6be7628196578f8783ab3:
hw/usb/dev-smartcard-reader: Handle 64 B USB packets (2018-05-18 09:42:16 +0200)
----------------------------------------------------------------
usb: two smartcard reader fixes.
----------------------------------------------------------------
Jakub Jelen (1):
hw/usb/dev-smartcard-reader: Handle 64 B USB packets
Marc-André Lureau (1):
ccid-card-passthru: fix regression in realize()
hw/usb/ccid-card-passthru.c | 2 +- hw/usb/dev-smartcard-reader.c | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-)
Signature · 1 line
2.9.3
[Qemu-devel] [PULL 2/2] hw/usb/dev-smartcard-reader: Handle 64 B USB packets
From: Jakub Jelen <[email protected]>
The current code was not correctly handling 64 B (Max USB 1.1 payload size) packets and therefore preventing some of the messages from smart card to pass through to the guest.
If the smart card in host responded with 34 B of data in APDU layer, the CCID headers added up to 64 B. The packet was send, but not correctly committed per USB specification (8.5.3.2 Variable-length Data Stage):
Quoted 6 lines
When all of the data structure is returned to the host, the function
should indicate that the Data stage is ended by returning a packet that is shorter than the MaxPacketSize for the pipe. If the data structure is an exact multiple of wMaxPacketSize for the pipe, the function will return a zero-length packet to indicate the end of the Data stage.
This lead the guest applications to timeout while waiting for the rest of data (the emulation layer is answering with NAK until the timeout).
This patch is checking the current maximum packet size and if the payload of this size is detected, the message buffer is not yet released. With the next call, the empty buffer is sent and the message buffer is finally released.
Message-id: [email protected]
--- hw/usb/dev-smartcard-reader.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
hw/usb/dev-smartcard-reader.c +9 -5
@@ -1064,7 +1064,8 @@ err:return ; } -static void ccid_bulk_in_copy_to_guest (USBCCIDState *s,USBPacket *p) +static void ccid_bulk_in_copy_to_guest (USBCCIDState *s,USBPacket *p, +unsigned int max_packet_size) {int len =0 ;
@@ -1072,10 +1073,13 @@ static void ccid_bulk_in_copy_to_guest(USBCCIDState *s, USBPacket *p)if (s->current_bulk_in !=NULL ) { len =MIN (s->current_bulk_in->len - s->current_bulk_in->pos, p->iov.size); -usb_packet_copy (p, s->current_bulk_in->data + - s->current_bulk_in->pos, len); +if (len) { +usb_packet_copy (p, s->current_bulk_in->data + + s->current_bulk_in->pos, len); + } s->current_bulk_in->pos += len; -if (s->current_bulk_in->pos == s->current_bulk_in->len) { +if (s->current_bulk_in->pos == s->current_bulk_in->len + && len != max_packet_size) {ccid_bulk_in_release (s); } }else {
@@ -1107,7 +1111,7 @@ static void ccid_handle_data(USBDevice *dev, USBPacket *p)case USB_TOKEN_IN :switch (p->ep->nr) {case CCID_BULK_IN_EP : -ccid_bulk_in_copy_to_guest (s, p); +ccid_bulk_in_copy_to_guest (s, p, dev->ep_ctl.max_packet_size);break ;case CCID_INT_IN_EP :if (s->notify_slot_change) {
Signature · 1 line
2.9.3
[Qemu-devel] [PULL 1/2] ccid-card-passthru: fix regression in realize()
In reply to Gerd HoffmannFrom: Marc-André Lureau <[email protected]>
Since cc847bfd16d894fd8c1a2ce25f31772f6cdbbc74, CCID card-passthru fails to intialize, because it changed a debug line to an error, probably by mistake. Change it back to a DPRINTF debug.
(solves Boxes creating VM with smartcard passthru failing to start)
Message-id: [email protected]
--- hw/usb/ccid-card-passthru.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/usb/ccid-card-passthru.c +1 -1
@@ -345,7 +345,7 @@ static void passthru_realize(CCIDCardState *base, Error **errp) card->vscard_in_pos =0 ; card->vscard_in_hdr =0 ;if (qemu_chr_fe_backend_connected (&card->cs)) { -error_setg (errp,"ccid-card-passthru: initing chardev" ); +DPRINTF (card,D_INFO ,"ccid-card-passthru: initing chardev" ); qemu_chr_fe_set_handlers(&card->cs, ccid_card_vscard_can_read, ccid_card_vscard_read,
Signature · 1 line
2.9.3
Peter Maydell
AppliedQuoted 20 lines · Gerd Hoffmann
The following changes since commit
a4207e3b00e89f934adb231057dcf9a75ac2ae45:Merge remote-tracking branch 'remotes/cody/tags/block-pull-request' into staging (2018-05-17 11:59:50 +0100)
are available in the git repository at:
git://git.kraxel.org/qemutags/usb-20180518-pull-requestfor you to fetch changes up to
8030dca376fa1bc4d8a6be7628196578f8783ab3:hw/usb/dev-smartcard-reader: Handle 64 B USB packets (2018-05-18 09:42:16 +0200)
----------------------------------------------------------------
usb: two smartcard reader fixes.----------------------------------------------------------------
Jakub Jelen (1):
hw/usb/dev-smartcard-reader: Handle 64 B USB packets
Quoted 6 lines
Marc-André Lureau (1):
ccid-card-passthru: fix regression inrealize()hw/usb/ccid-card-passthru.c | 2 +- hw/usb/dev-smartcard-reader.c | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-)
Applied, thanks.
-- PMM