Pablo Greco e6a3ae
From e541592f0c98696276261a7c36afe074a3bdd956 Mon Sep 17 00:00:00 2001
Pablo Greco e6a3ae
From: Maxim Levitsky <mlevitsk@redhat.com>
Pablo Greco e6a3ae
Date: Wed, 18 Sep 2019 18:45:52 +0100
Pablo Greco e6a3ae
Subject: [PATCH 11/22] ccid: Fix dwProtocols advertisement of T=0
Pablo Greco e6a3ae
MIME-Version: 1.0
Pablo Greco e6a3ae
Content-Type: text/plain; charset=UTF-8
Pablo Greco e6a3ae
Content-Transfer-Encoding: 8bit
Pablo Greco e6a3ae
Pablo Greco e6a3ae
RH-Author: Maxim Levitsky <mlevitsk@redhat.com>
Pablo Greco e6a3ae
Message-id: <20190918184552.10820-2-mlevitsk@redhat.com>
Pablo Greco e6a3ae
Patchwork-id: 90769
Pablo Greco e6a3ae
O-Subject: [RHEL-8.2.0 qemu-kvm PATCH 1/1] ccid: Fix dwProtocols advertisement of T=0
Pablo Greco e6a3ae
Bugzilla: 1746361
Pablo Greco e6a3ae
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Pablo Greco e6a3ae
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
Pablo Greco e6a3ae
RH-Acked-by: John Snow <jsnow@redhat.com>
Pablo Greco e6a3ae
Pablo Greco e6a3ae
From: Jason Andryuk <jandryuk@gmail.com>
Pablo Greco e6a3ae
Pablo Greco e6a3ae
Commit d7d218ef02d87c637d20d64da8f575d434ff6f78 attempted to change
Pablo Greco e6a3ae
dwProtocols to only advertise support for T=0 and not T=1.  The change
Pablo Greco e6a3ae
was incorrect as it changed 0x00000003 to 0x00010000.
Pablo Greco e6a3ae
Pablo Greco e6a3ae
lsusb -v in a linux guest shows:
Pablo Greco e6a3ae
"dwProtocols         65536  (Invalid values detected)", though the
Pablo Greco e6a3ae
smart card could still be accessed.  Windows 7 does not detect inserted
Pablo Greco e6a3ae
smart cards and logs the the following Error in the Event Logs:
Pablo Greco e6a3ae
Pablo Greco e6a3ae
    Source: Smart Card Service
Pablo Greco e6a3ae
    Event ID: 610
Pablo Greco e6a3ae
    Smart Card Reader 'QEMU QEMU USB CCID 0' rejected IOCTL SET_PROTOCOL:
Pablo Greco e6a3ae
    Incorrect function. If this error persists, your smart card or reader
Pablo Greco e6a3ae
    may not be functioning correctly
Pablo Greco e6a3ae
Pablo Greco e6a3ae
    Command Header: 03 00 00 00
Pablo Greco e6a3ae
Pablo Greco e6a3ae
Setting to 0x00000001 fixes the Windows issue.
Pablo Greco e6a3ae
Pablo Greco e6a3ae
Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
Pablo Greco e6a3ae
Message-id: 20180420183219.20722-1-jandryuk@gmail.com
Pablo Greco e6a3ae
Cc: qemu-stable@nongnu.org
Pablo Greco e6a3ae
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Pablo Greco e6a3ae
(cherry picked from commit 0ee86bb6c5beb6498488850104f7557c376d0bef)
Pablo Greco e6a3ae
Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
Pablo Greco e6a3ae
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
Pablo Greco e6a3ae
---
Pablo Greco e6a3ae
 hw/usb/dev-smartcard-reader.c | 4 ++--
Pablo Greco e6a3ae
 1 file changed, 2 insertions(+), 2 deletions(-)
Pablo Greco e6a3ae
Pablo Greco e6a3ae
diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c
Pablo Greco e6a3ae
index e646805..cabb564 100644
Pablo Greco e6a3ae
--- a/hw/usb/dev-smartcard-reader.c
Pablo Greco e6a3ae
+++ b/hw/usb/dev-smartcard-reader.c
Pablo Greco e6a3ae
@@ -329,8 +329,8 @@ static const uint8_t qemu_ccid_descriptor[] = {
Pablo Greco e6a3ae
                      */
Pablo Greco e6a3ae
         0x07,       /* u8  bVoltageSupport; 01h - 5.0v, 02h - 3.0, 03 - 1.8 */
Pablo Greco e6a3ae
 
Pablo Greco e6a3ae
-        0x00, 0x00, /* u32 dwProtocols; RRRR PPPP. RRRR = 0000h.*/
Pablo Greco e6a3ae
-        0x01, 0x00, /* PPPP: 0001h = Protocol T=0, 0002h = Protocol T=1 */
Pablo Greco e6a3ae
+        0x01, 0x00, /* u32 dwProtocols; RRRR PPPP. RRRR = 0000h.*/
Pablo Greco e6a3ae
+        0x00, 0x00, /* PPPP: 0001h = Protocol T=0, 0002h = Protocol T=1 */
Pablo Greco e6a3ae
                     /* u32 dwDefaultClock; in kHZ (0x0fa0 is 4 MHz) */
Pablo Greco e6a3ae
         0xa0, 0x0f, 0x00, 0x00,
Pablo Greco e6a3ae
                     /* u32 dwMaximumClock; */
Pablo Greco e6a3ae
-- 
Pablo Greco e6a3ae
1.8.3.1
Pablo Greco e6a3ae