All of lore.kernel.org
 help / color / mirror / Atom feed
* [PULL 0/8] Kraxel 20220704 patches
@ 2022-07-04  7:59 Gerd Hoffmann
  2022-07-04  7:59 ` [PULL 1/8] Rename docs/specs/fw_cfg.txt to .rst Gerd Hoffmann
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Gerd Hoffmann @ 2022-07-04  7:59 UTC (permalink / raw)
  To: qemu-devel
  Cc: Akihiko Odaki, Canokeys.org, Gerd Hoffmann, Peter Maydell,
	Philippe Mathieu-Daudé,
	Hongren (Zenithal) Zheng

The following changes since commit d495e432c04a6394126c35cf96517749708b410f:

  Merge tag 'pull-aspeed-20220630' of https://github.com/legoater/qemu into staging (2022-06-30 22:04:12 +0530)

are available in the Git repository at:

  https://gitlab.com/kraxel/qemu.git tags/kraxel-20220704-pull-request

for you to fetch changes up to 927b968d1bc7c0a25edad8161608223b1122a253:

  hw: canokey: Remove HS support as not compliant to the spec (2022-07-01 12:39:51 +0200)

----------------------------------------------------------------
usb: canokey fixes.
ui: better tab labels, cocoa fix,
docs: convert fw_cfg to rst.

----------------------------------------------------------------

Akihiko Odaki (1):
  ui/cocoa: Fix clipboard text release

Hongren (Zenithal) Zheng (3):
  hw/usb/canokey: Fix CCID ZLP
  hw/usb/canokey: fix compatibility of qemu-xhci
  docs/system/devices/usb/canokey: remove limitations on qemu-xhci

MkfsSion (1):
  hw: canokey: Remove HS support as not compliant to the spec

Simon Sapin (2):
  Rename docs/specs/fw_cfg.txt to .rst
  Convert fw_cfg.rst to reStructuredText syntax

Wen, Jianxian (1):
  ui/console: allow display device to be labeled with given id

 include/ui/console.h                  |   1 +
 hw/usb/canokey.c                      |  31 +++-
 ui/console.c                          |  41 ++++-
 docs/specs/{fw_cfg.txt => fw_cfg.rst} | 211 ++++++++++++++------------
 docs/specs/index.rst                  |   1 +
 docs/system/devices/canokey.rst       |  10 --
 ui/cocoa.m                            |   4 +-
 7 files changed, 189 insertions(+), 110 deletions(-)
 rename docs/specs/{fw_cfg.txt => fw_cfg.rst} (58%)

-- 
2.36.1



^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PULL 1/8] Rename docs/specs/fw_cfg.txt to .rst
  2022-07-04  7:59 [PULL 0/8] Kraxel 20220704 patches Gerd Hoffmann
@ 2022-07-04  7:59 ` Gerd Hoffmann
  2022-07-04  7:59 ` [PULL 2/8] Convert fw_cfg.rst to reStructuredText syntax Gerd Hoffmann
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Gerd Hoffmann @ 2022-07-04  7:59 UTC (permalink / raw)
  To: qemu-devel
  Cc: Akihiko Odaki, Canokeys.org, Gerd Hoffmann, Peter Maydell,
	Philippe Mathieu-Daudé,
	Hongren (Zenithal) Zheng, Simon Sapin

From: Simon Sapin <simon.sapin@exyr.org>

This is a separate commit in order to make reviewing the next one easier.

Signed-off-by: Simon Sapin <simon.sapin@exyr.org>
Message-Id: <20220625161455.1232954-1-simon.sapin@exyr.org>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 docs/specs/{fw_cfg.txt => fw_cfg.rst} | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename docs/specs/{fw_cfg.txt => fw_cfg.rst} (100%)

diff --git a/docs/specs/fw_cfg.txt b/docs/specs/fw_cfg.rst
similarity index 100%
rename from docs/specs/fw_cfg.txt
rename to docs/specs/fw_cfg.rst
-- 
2.36.1



^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PULL 2/8] Convert fw_cfg.rst to reStructuredText syntax
  2022-07-04  7:59 [PULL 0/8] Kraxel 20220704 patches Gerd Hoffmann
  2022-07-04  7:59 ` [PULL 1/8] Rename docs/specs/fw_cfg.txt to .rst Gerd Hoffmann
@ 2022-07-04  7:59 ` Gerd Hoffmann
  2022-07-04  7:59 ` [PULL 3/8] ui/console: allow display device to be labeled with given id Gerd Hoffmann
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Gerd Hoffmann @ 2022-07-04  7:59 UTC (permalink / raw)
  To: qemu-devel
  Cc: Akihiko Odaki, Canokeys.org, Gerd Hoffmann, Peter Maydell,
	Philippe Mathieu-Daudé,
	Hongren (Zenithal) Zheng, Simon Sapin

From: Simon Sapin <simon.sapin@exyr.org>

And add it to specs/index.rst

Signed-off-by: Simon Sapin <simon.sapin@exyr.org>
Message-Id: <20220625161455.1232954-2-simon.sapin@exyr.org>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 docs/specs/fw_cfg.rst | 211 +++++++++++++++++++++++-------------------
 docs/specs/index.rst  |   1 +
 2 files changed, 119 insertions(+), 93 deletions(-)

diff --git a/docs/specs/fw_cfg.rst b/docs/specs/fw_cfg.rst
index 3e6d586f66bf..5ad47a901c9f 100644
--- a/docs/specs/fw_cfg.rst
+++ b/docs/specs/fw_cfg.rst
@@ -1,7 +1,9 @@
+===========================================
 QEMU Firmware Configuration (fw_cfg) Device
 ===========================================
 
-= Guest-side Hardware Interface =
+Guest-side Hardware Interface
+=============================
 
 This hardware interface allows the guest to retrieve various data items
 (blobs) that can influence how the firmware configures itself, or may
@@ -9,7 +11,8 @@ contain tables to be installed for the guest OS. Examples include device
 boot order, ACPI and SMBIOS tables, virtual machine UUID, SMP and NUMA
 information, kernel/initrd images for direct (Linux) kernel booting, etc.
 
-== Selector (Control) Register ==
+Selector (Control) Register
+---------------------------
 
 * Write only
 * Location: platform dependent (IOport or MMIO)
@@ -30,10 +33,12 @@ of 1 means the item's data can be overwritten by writes to the data
 register. In other words, configuration write mode is enabled when
 the selector value is between 0x4000-0x7fff or 0xc000-0xffff.
 
-NOTE: As of QEMU v2.4, writes to the fw_cfg data register are no
+.. NOTE::
+      As of QEMU v2.4, writes to the fw_cfg data register are no
       longer supported, and will be ignored (treated as no-ops)!
 
-NOTE: As of QEMU v2.9, writes are reinstated, but only through the DMA
+.. NOTE::
+      As of QEMU v2.9, writes are reinstated, but only through the DMA
       interface (see below). Furthermore, writeability of any specific item is
       governed independently of Bit14 in the selector key value.
 
@@ -45,17 +50,19 @@ items are accessed with a selector value between 0x0000-0x7fff, and
 architecture specific configuration items are accessed with a selector
 value between 0x8000-0xffff.
 
-== Data Register ==
+Data Register
+-------------
 
 * Read/Write (writes ignored as of QEMU v2.4, but see the DMA interface)
-* Location: platform dependent (IOport [*] or MMIO)
+* Location: platform dependent (IOport [#]_ or MMIO)
 * Width: 8-bit (if IOport), 8/16/32/64-bit (if MMIO)
 * Endianness: string-preserving
 
-[*] On platforms where the data register is exposed as an IOport, its
-port number will always be one greater than the port number of the
-selector register. In other words, the two ports overlap, and can not
-be mapped separately.
+.. [#]
+    On platforms where the data register is exposed as an IOport, its
+    port number will always be one greater than the port number of the
+    selector register. In other words, the two ports overlap, and can not
+    be mapped separately.
 
 The data register allows access to an array of bytes for each firmware
 configuration data item. The specific item is selected by writing to
@@ -74,91 +81,103 @@ An N-byte wide read of the data register will return the next available
 N bytes of the selected firmware configuration item, as a substring, in
 increasing address order, similar to memcpy().
 
-== Register Locations ==
+Register Locations
+------------------
 
-=== x86, x86_64 Register Locations ===
+x86, x86_64
+    * Selector Register IOport: 0x510
+    * Data Register IOport:     0x511
+    * DMA Address IOport:       0x514
 
-Selector Register IOport: 0x510
-Data Register IOport:     0x511
-DMA Address IOport:       0x514
+Arm
+    * Selector Register address: Base + 8 (2 bytes)
+    * Data Register address:     Base + 0 (8 bytes)
+    * DMA Address address:       Base + 16 (8 bytes)
 
-=== Arm Register Locations ===
+ACPI Interface
+--------------
 
-Selector Register address: Base + 8 (2 bytes)
-Data Register address:     Base + 0 (8 bytes)
-DMA Address address:       Base + 16 (8 bytes)
-
-== ACPI Interface ==
-
-The fw_cfg device is defined with ACPI ID "QEMU0002". Since we expect
+The fw_cfg device is defined with ACPI ID ``QEMU0002``. Since we expect
 ACPI tables to be passed into the guest through the fw_cfg device itself,
 the guest-side firmware can not use ACPI to find fw_cfg. However, once the
 firmware is finished setting up ACPI tables and hands control over to the
 guest kernel, the latter can use the fw_cfg ACPI node for a more accurate
 inventory of in-use IOport or MMIO regions.
 
-== Firmware Configuration Items ==
+Firmware Configuration Items
+----------------------------
 
-=== Signature (Key 0x0000, FW_CFG_SIGNATURE) ===
+Signature (Key 0x0000, ``FW_CFG_SIGNATURE``)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 The presence of the fw_cfg selector and data registers can be verified
-by selecting the "signature" item using key 0x0000 (FW_CFG_SIGNATURE),
+by selecting the "signature" item using key 0x0000 (``FW_CFG_SIGNATURE``),
 and reading four bytes from the data register. If the fw_cfg device is
-present, the four bytes read will contain the characters "QEMU".
+present, the four bytes read will contain the characters ``QEMU``.
 
 If the DMA interface is available, then reading the DMA Address
-Register returns 0x51454d5520434647 ("QEMU CFG" in big-endian format).
+Register returns 0x51454d5520434647 (``QEMU CFG`` in big-endian format).
 
-=== Revision / feature bitmap (Key 0x0001, FW_CFG_ID) ===
+Revision / feature bitmap (Key 0x0001, ``FW_CFG_ID``)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 A 32-bit little-endian unsigned int, this item is used to check for enabled
 features.
- - Bit 0: traditional interface. Always set.
- - Bit 1: DMA interface.
 
-=== File Directory (Key 0x0019, FW_CFG_FILE_DIR) ===
+- Bit 0: traditional interface. Always set.
+- Bit 1: DMA interface.
+
+File Directory (Key 0x0019, ``FW_CFG_FILE_DIR``)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. highlight:: c
 
 Firmware configuration items stored at selector keys 0x0020 or higher
-(FW_CFG_FILE_FIRST or higher) have an associated entry in a directory
+(``FW_CFG_FILE_FIRST`` or higher) have an associated entry in a directory
 structure, which makes it easier for guest-side firmware to identify
-and retrieve them. The format of this file directory (from fw_cfg.h in
-the QEMU source tree) is shown here, slightly annotated for clarity:
+and retrieve them. The format of this file directory (from ``fw_cfg.h`` in
+the QEMU source tree) is shown here, slightly annotated for clarity::
 
-struct FWCfgFiles {		/* the entire file directory fw_cfg item */
-    uint32_t count;		/* number of entries, in big-endian format */
-    struct FWCfgFile f[];	/* array of file entries, see below */
-};
+    struct FWCfgFiles {		/* the entire file directory fw_cfg item */
+        uint32_t count;		/* number of entries, in big-endian format */
+        struct FWCfgFile f[];	/* array of file entries, see below */
+    };
 
-struct FWCfgFile {		/* an individual file entry, 64 bytes total */
-    uint32_t size;		/* size of referenced fw_cfg item, big-endian */
-    uint16_t select;		/* selector key of fw_cfg item, big-endian */
-    uint16_t reserved;
-    char name[56];		/* fw_cfg item name, NUL-terminated ascii */
-};
+    struct FWCfgFile {		/* an individual file entry, 64 bytes total */
+        uint32_t size;		/* size of referenced fw_cfg item, big-endian */
+        uint16_t select;	/* selector key of fw_cfg item, big-endian */
+        uint16_t reserved;
+        char name[56];		/* fw_cfg item name, NUL-terminated ascii */
+    };
 
-=== All Other Data Items ===
+All Other Data Items
+~~~~~~~~~~~~~~~~~~~~
 
 Please consult the QEMU source for the most up-to-date and authoritative list
 of selector keys and their respective items' purpose, format and writeability.
 
-=== Ranges ===
+Ranges
+~~~~~~
 
 Theoretically, there may be up to 0x4000 generic firmware configuration
 items, and up to 0x4000 architecturally specific ones.
 
+===============  ===========
 Selector Reg.    Range Usage
----------------  -----------
+===============  ===========
 0x0000 - 0x3fff  Generic (0x0000 - 0x3fff, generally RO, possibly RW through
-                          the DMA interface in QEMU v2.9+)
+                 the DMA interface in QEMU v2.9+)
 0x4000 - 0x7fff  Generic (0x0000 - 0x3fff, RW, ignored in QEMU v2.4+)
 0x8000 - 0xbfff  Arch. Specific (0x0000 - 0x3fff, generally RO, possibly RW
-                                 through the DMA interface in QEMU v2.9+)
+                 through the DMA interface in QEMU v2.9+)
 0xc000 - 0xffff  Arch. Specific (0x0000 - 0x3fff, RW, ignored in v2.4+)
+===============  ===========
 
 In practice, the number of allowed firmware configuration items depends on the
 machine type/version.
 
-= Guest-side DMA Interface =
+Guest-side DMA Interface
+========================
 
 If bit 1 of the feature bitmap is set, the DMA interface is present. This does
 not replace the existing fw_cfg interface, it is an add-on. This interface
@@ -171,68 +190,74 @@ addresses can be triggered with just one write, whereas operations with
 64-bit addresses can be triggered with one 64-bit write or two 32-bit writes,
 starting with the most significant half (at offset 0).
 
-In this register, the physical address of a FWCfgDmaAccess structure in RAM
-should be written. This is the format of the FWCfgDmaAccess structure:
+In this register, the physical address of a ``FWCfgDmaAccess`` structure in RAM
+should be written. This is the format of the ``FWCfgDmaAccess`` structure::
 
-typedef struct FWCfgDmaAccess {
-    uint32_t control;
-    uint32_t length;
-    uint64_t address;
-} FWCfgDmaAccess;
+    typedef struct FWCfgDmaAccess {
+        uint32_t control;
+        uint32_t length;
+        uint64_t address;
+    } FWCfgDmaAccess;
 
 The fields of the structure are in big endian mode, and the field at the lowest
-address is the "control" field.
+address is the ``control`` field.
 
-The "control" field has the following bits:
- - Bit 0: Error
- - Bit 1: Read
- - Bit 2: Skip
- - Bit 3: Select. The upper 16 bits are the selected index.
- - Bit 4: Write
+The ``control`` field has the following bits:
 
-When an operation is triggered, if the "control" field has bit 3 set, the
+- Bit 0: Error
+- Bit 1: Read
+- Bit 2: Skip
+- Bit 3: Select. The upper 16 bits are the selected index.
+- Bit 4: Write
+
+When an operation is triggered, if the ``control`` field has bit 3 set, the
 upper 16 bits are interpreted as an index of a firmware configuration item.
 This has the same effect as writing the selector register.
 
-If the "control" field has bit 1 set, a read operation will be performed.
-"length" bytes for the current selector and offset will be copied into the
-physical RAM address specified by the "address" field.
+If the ``control`` field has bit 1 set, a read operation will be performed.
+``length`` bytes for the current selector and offset will be copied into the
+physical RAM address specified by the ``address`` field.
 
-If the "control" field has bit 4 set (and not bit 1), a write operation will be
-performed. "length" bytes will be copied from the physical RAM address
-specified by the "address" field to the current selector and offset. QEMU
+If the ``control`` field has bit 4 set (and not bit 1), a write operation will be
+performed. ``length`` bytes will be copied from the physical RAM address
+specified by the ``address`` field to the current selector and offset. QEMU
 prevents starting or finishing the write beyond the end of the item associated
 with the current selector (i.e., the item cannot be resized). Truncated writes
 are dropped entirely. Writes to read-only items are also rejected. All of these
-write errors set bit 0 (the error bit) in the "control" field.
+write errors set bit 0 (the error bit) in the ``control`` field.
 
-If the "control" field has bit 2 set (and neither bit 1 nor bit 4), a skip
+If the ``control`` field has bit 2 set (and neither bit 1 nor bit 4), a skip
 operation will be performed. The offset for the current selector will be
-advanced "length" bytes.
+advanced ``length`` bytes.
 
-To check the result, read the "control" field:
-   error bit set        ->  something went wrong.
-   all bits cleared     ->  transfer finished successfully.
-   otherwise            ->  transfer still in progress (doesn't happen
-                            today due to implementation not being async,
-                            but may in the future).
+To check the result, read the ``control`` field:
 
-= Externally Provided Items =
+Error bit set
+    Something went wrong.
+All bits cleared
+    Transfer finished successfully.
+Otherwise
+    Transfer still in progress
+    (doesn't happen today due to implementation not being async,
+    but may in the future).
+
+Externally Provided Items
+=========================
 
 Since v2.4, "file" fw_cfg items (i.e., items with selector keys above
-FW_CFG_FILE_FIRST, and with a corresponding entry in the fw_cfg file
+``FW_CFG_FILE_FIRST``, and with a corresponding entry in the fw_cfg file
 directory structure) may be inserted via the QEMU command line, using
-the following syntax:
+the following syntax::
 
     -fw_cfg [name=]<item_name>,file=<path>
 
-Or
+Or::
 
     -fw_cfg [name=]<item_name>,string=<string>
 
 Since v5.1, QEMU allows some objects to generate fw_cfg-specific content,
 the content is then associated with a "file" item using the 'gen_id' option
-in the command line, using the following syntax:
+in the command line, using the following syntax::
 
     -object <generator-type>,id=<generated_id>,[generator-specific-options] \
     -fw_cfg [name=]<item_name>,gen_id=<generated_id>
@@ -241,24 +266,24 @@ See QEMU man page for more documentation.
 
 Using item_name with plain ASCII characters only is recommended.
 
-Item names beginning with "opt/" are reserved for users.  QEMU will
+Item names beginning with ``opt/`` are reserved for users.  QEMU will
 never create entries with such names unless explicitly ordered by the
 user.
 
 To avoid clashes among different users, it is strongly recommended
-that you use names beginning with opt/RFQDN/, where RFQDN is a reverse
+that you use names beginning with ``opt/RFQDN/``, where RFQDN is a reverse
 fully qualified domain name you control.  For instance, if SeaBIOS
-wanted to define additional names, the prefix "opt/org.seabios/" would
+wanted to define additional names, the prefix ``opt/org.seabios/`` would
 be appropriate.
 
-For historical reasons, "opt/ovmf/" is reserved for OVMF firmware.
+For historical reasons, ``opt/ovmf/`` is reserved for OVMF firmware.
 
-Prefix "opt/org.qemu/" is reserved for QEMU itself.
+Prefix ``opt/org.qemu/`` is reserved for QEMU itself.
 
-Use of names not beginning with "opt/" is potentially dangerous and
+Use of names not beginning with ``opt/`` is potentially dangerous and
 entirely unsupported.  QEMU will warn if you try.
 
-Use of names not beginning with "opt/" is tolerated with 'gen_id' (that
+Use of names not beginning with ``opt/`` is tolerated with 'gen_id' (that
 is, the warning is suppressed), but you must know exactly what you're
 doing.
 
diff --git a/docs/specs/index.rst b/docs/specs/index.rst
index e10684bf5353..a58d9311cb36 100644
--- a/docs/specs/index.rst
+++ b/docs/specs/index.rst
@@ -20,3 +20,4 @@ guest hardware that is specific to QEMU.
    acpi_nvdimm
    acpi_erst
    sev-guest-firmware
+   fw_cfg
-- 
2.36.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PULL 3/8] ui/console: allow display device to be labeled with given id
  2022-07-04  7:59 [PULL 0/8] Kraxel 20220704 patches Gerd Hoffmann
  2022-07-04  7:59 ` [PULL 1/8] Rename docs/specs/fw_cfg.txt to .rst Gerd Hoffmann
  2022-07-04  7:59 ` [PULL 2/8] Convert fw_cfg.rst to reStructuredText syntax Gerd Hoffmann
@ 2022-07-04  7:59 ` Gerd Hoffmann
  2022-07-04  7:59 ` [PULL 4/8] ui/cocoa: Fix clipboard text release Gerd Hoffmann
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Gerd Hoffmann @ 2022-07-04  7:59 UTC (permalink / raw)
  To: qemu-devel
  Cc: Akihiko Odaki, Canokeys.org, Gerd Hoffmann, Peter Maydell,
	Philippe Mathieu-Daudé,
	Hongren (Zenithal) Zheng, Wen, Jianxian, Jianxian Wen, Lu Gao

From: "Wen, Jianxian" <Jianxian.Wen@verisilicon.com>

The update makes it easier to find and specify devices.
They can only be found by device type name without the id field,
for example, devices of the same type have the same label.
The update also adds a head field,
which is useful for devices that support multiple heads,
such as virtio-gpu.

Signed-off-by: Jianxian Wen <jianxian.wen@verisilicon.com>
Signed-off-by: Lu Gao <lu.gao@verisilicon.com>
Message-Id: <4C23C17B8E87E74E906A25A3254A03F4018FC045B0@SHASXM06.verisilicon.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/ui/console.h |  1 +
 ui/console.c         | 41 ++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/include/ui/console.h b/include/ui/console.h
index b64d82436097..c0520c694c23 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -463,6 +463,7 @@ bool qemu_console_is_visible(QemuConsole *con);
 bool qemu_console_is_graphic(QemuConsole *con);
 bool qemu_console_is_fixedsize(QemuConsole *con);
 bool qemu_console_is_gl_blocked(QemuConsole *con);
+bool qemu_console_is_multihead(DeviceState *dev);
 char *qemu_console_get_label(QemuConsole *con);
 int qemu_console_get_index(QemuConsole *con);
 uint32_t qemu_console_get_head(QemuConsole *con);
diff --git a/ui/console.c b/ui/console.c
index 9331b85203a0..e139f7115e1f 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -2313,11 +2313,50 @@ bool qemu_console_is_gl_blocked(QemuConsole *con)
     return con->gl_block;
 }
 
+bool qemu_console_is_multihead(DeviceState *dev)
+{
+    QemuConsole *con;
+    Object *obj;
+    uint32_t f = 0xffffffff;
+    uint32_t h;
+
+    QTAILQ_FOREACH(con, &consoles, next) {
+        obj = object_property_get_link(OBJECT(con),
+                                       "device", &error_abort);
+        if (DEVICE(obj) != dev) {
+            continue;
+        }
+
+        h = object_property_get_uint(OBJECT(con),
+                                     "head", &error_abort);
+        if (f == 0xffffffff) {
+            f = h;
+        } else if (h != f) {
+            return true;
+        }
+    }
+    return false;
+}
+
 char *qemu_console_get_label(QemuConsole *con)
 {
     if (con->console_type == GRAPHIC_CONSOLE) {
         if (con->device) {
-            return g_strdup(object_get_typename(con->device));
+            DeviceState *dev;
+            bool multihead;
+
+            dev = DEVICE(con->device);
+            multihead = qemu_console_is_multihead(dev);
+            if (multihead) {
+                return g_strdup_printf("%s.%d", dev->id ?
+                                       dev->id :
+                                       object_get_typename(con->device),
+                                       con->head);
+            } else {
+                return g_strdup_printf("%s", dev->id ?
+                                       dev->id :
+                                       object_get_typename(con->device));
+            }
         }
         return g_strdup("VGA");
     } else {
-- 
2.36.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PULL 4/8] ui/cocoa: Fix clipboard text release
  2022-07-04  7:59 [PULL 0/8] Kraxel 20220704 patches Gerd Hoffmann
                   ` (2 preceding siblings ...)
  2022-07-04  7:59 ` [PULL 3/8] ui/console: allow display device to be labeled with given id Gerd Hoffmann
@ 2022-07-04  7:59 ` Gerd Hoffmann
  2022-07-04  7:59 ` [PULL 5/8] hw/usb/canokey: Fix CCID ZLP Gerd Hoffmann
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Gerd Hoffmann @ 2022-07-04  7:59 UTC (permalink / raw)
  To: qemu-devel
  Cc: Akihiko Odaki, Canokeys.org, Gerd Hoffmann, Peter Maydell,
	Philippe Mathieu-Daudé,
	Hongren (Zenithal) Zheng

From: Akihiko Odaki <akihiko.odaki@gmail.com>

[-NSPasteboard dataForType:] returns an autoreleased NSString,
and callings its release method will result in double-free when
the global autorelease pool is released. Use NSAutoreleasePool to
release it properly.

Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <20220614212131.94696-1-akihiko.odaki@gmail.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/cocoa.m | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ui/cocoa.m b/ui/cocoa.m
index 84c84e98fc5e..6a4dccff7f02 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -1894,16 +1894,18 @@ static void cocoa_clipboard_notify(Notifier *notifier, void *data)
 static void cocoa_clipboard_request(QemuClipboardInfo *info,
                                     QemuClipboardType type)
 {
+    NSAutoreleasePool *pool;
     NSData *text;
 
     switch (type) {
     case QEMU_CLIPBOARD_TYPE_TEXT:
+        pool = [[NSAutoreleasePool alloc] init];
         text = [[NSPasteboard generalPasteboard] dataForType:NSPasteboardTypeString];
         if (text) {
             qemu_clipboard_set_data(&cbpeer, info, type,
                                     [text length], [text bytes], true);
-            [text release];
         }
+        [pool release];
         break;
     default:
         break;
-- 
2.36.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PULL 5/8] hw/usb/canokey: Fix CCID ZLP
  2022-07-04  7:59 [PULL 0/8] Kraxel 20220704 patches Gerd Hoffmann
                   ` (3 preceding siblings ...)
  2022-07-04  7:59 ` [PULL 4/8] ui/cocoa: Fix clipboard text release Gerd Hoffmann
@ 2022-07-04  7:59 ` Gerd Hoffmann
  2022-07-04  7:59 ` [PULL 6/8] hw/usb/canokey: fix compatibility of qemu-xhci Gerd Hoffmann
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Gerd Hoffmann @ 2022-07-04  7:59 UTC (permalink / raw)
  To: qemu-devel
  Cc: Akihiko Odaki, Canokeys.org, Gerd Hoffmann, Peter Maydell,
	Philippe Mathieu-Daudé,
	Hongren (Zenithal) Zheng, MkfsSion

From: "Hongren (Zenithal) Zheng" <i@zenithal.me>

CCID could send zero-length packet (ZLP)
if we invoke two data_in, two packets would be concated
and we could not distinguish them.

The CANOKEY_EMU_EP_CTAPHID is imported from canokey-qemu.h

Reported-by: MkfsSion <myychina28759@gmail.com>
Signed-off-by: Hongren (Zenithal) Zheng <i@zenithal.me>
Message-Id: <YqcqGz0s3+LE42ms@Sun>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb/canokey.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/hw/usb/canokey.c b/hw/usb/canokey.c
index 4a08b1cbd776..86548923eb16 100644
--- a/hw/usb/canokey.c
+++ b/hw/usb/canokey.c
@@ -109,11 +109,10 @@ int canokey_emu_transmit(
      * Note: this is a quirk for CanoKey CTAPHID
      * because it calls multiple emu_transmit in one device_loop
      * but w/o data_in it would stuck in device_loop
-     * This has no side effect for CCID as it is strictly
-     * OUT then IN transfer
-     * However it has side effect for Control transfer
+     * This has side effect for CCID since CCID can send ZLP
+     * This also has side effect for Control transfer
      */
-    if (ep_in != 0) {
+    if (ep_in == CANOKEY_EMU_EP_CTAPHID) {
         canokey_emu_data_in(ep_in);
     }
     return 0;
-- 
2.36.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PULL 6/8] hw/usb/canokey: fix compatibility of qemu-xhci
  2022-07-04  7:59 [PULL 0/8] Kraxel 20220704 patches Gerd Hoffmann
                   ` (4 preceding siblings ...)
  2022-07-04  7:59 ` [PULL 5/8] hw/usb/canokey: Fix CCID ZLP Gerd Hoffmann
@ 2022-07-04  7:59 ` Gerd Hoffmann
  2022-07-04  7:59 ` [PULL 7/8] docs/system/devices/usb/canokey: remove limitations on qemu-xhci Gerd Hoffmann
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Gerd Hoffmann @ 2022-07-04  7:59 UTC (permalink / raw)
  To: qemu-devel
  Cc: Akihiko Odaki, Canokeys.org, Gerd Hoffmann, Peter Maydell,
	Philippe Mathieu-Daudé,
	Hongren (Zenithal) Zheng

From: "Hongren (Zenithal) Zheng" <i@zenithal.me>

XHCI wont poll interrupt IN endpoint if NAKed, and needs wakeup

Suggested-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Hongren (Zenithal) Zheng <i@zenithal.me>
Message-Id: <YqcqSHNpI7sXRNpZ@Sun>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb/canokey.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/hw/usb/canokey.c b/hw/usb/canokey.c
index 86548923eb16..8da0d65556af 100644
--- a/hw/usb/canokey.c
+++ b/hw/usb/canokey.c
@@ -103,6 +103,13 @@ int canokey_emu_transmit(
             pbuf, size);
     key->ep_in_size[ep_in] += size;
     key->ep_in_state[ep_in] = CANOKEY_EP_IN_READY;
+    /*
+     * wake up controller if we NAKed IN token before
+     * Note: this is a quirk for CanoKey CTAPHID
+     */
+    if (ep_in == CANOKEY_EMU_EP_CTAPHID) {
+        usb_wakeup(usb_ep_get(&key->dev, USB_TOKEN_IN, ep_in), 0);
+    }
     /*
      * ready for more data in device loop
      *
@@ -208,6 +215,22 @@ static void canokey_handle_data(USBDevice *dev, USBPacket *p)
             key->ep_out_size[ep_out] = out_len;
             canokey_emu_data_out(ep_out, NULL);
         }
+        /*
+         * Note: this is a quirk for CanoKey CTAPHID
+         *
+         * There is one code path that uses this device loop
+         * INTR IN -> useful data_in and useless device_loop -> NAKed
+         * INTR OUT -> useful device loop -> transmit -> wakeup
+         *   (useful thanks to both data_in and data_out having been called)
+         * the next INTR IN -> actual data to guest
+         *
+         * if there is no such device loop, there would be no further
+         * INTR IN, no device loop, no transmit hence no usb_wakeup
+         * then qemu would hang
+         */
+        if (ep_in == CANOKEY_EMU_EP_CTAPHID) {
+            canokey_emu_device_loop(); /* may call transmit multiple times */
+        }
         break;
     case USB_TOKEN_IN:
         if (key->ep_in_pos[ep_in] == 0) { /* first time IN */
-- 
2.36.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PULL 7/8] docs/system/devices/usb/canokey: remove limitations on qemu-xhci
  2022-07-04  7:59 [PULL 0/8] Kraxel 20220704 patches Gerd Hoffmann
                   ` (5 preceding siblings ...)
  2022-07-04  7:59 ` [PULL 6/8] hw/usb/canokey: fix compatibility of qemu-xhci Gerd Hoffmann
@ 2022-07-04  7:59 ` Gerd Hoffmann
  2022-07-04  7:59 ` [PULL 8/8] hw: canokey: Remove HS support as not compliant to the spec Gerd Hoffmann
  2022-07-04 11:06 ` [PULL 0/8] Kraxel 20220704 patches Richard Henderson
  8 siblings, 0 replies; 10+ messages in thread
From: Gerd Hoffmann @ 2022-07-04  7:59 UTC (permalink / raw)
  To: qemu-devel
  Cc: Akihiko Odaki, Canokeys.org, Gerd Hoffmann, Peter Maydell,
	Philippe Mathieu-Daudé,
	Hongren (Zenithal) Zheng

From: "Hongren (Zenithal) Zheng" <i@zenithal.me>

Signed-off-by: Hongren (Zenithal) Zheng <i@zenithal.me>
Message-Id: <YqcqeIpY4h7ZQPWH@Sun>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 docs/system/devices/canokey.rst | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/docs/system/devices/canokey.rst b/docs/system/devices/canokey.rst
index 169f99b8eb82..c2c58ae3e7cb 100644
--- a/docs/system/devices/canokey.rst
+++ b/docs/system/devices/canokey.rst
@@ -146,16 +146,6 @@ multiple CanoKey QEMU running, namely you can not
 Also, there is no lock on canokey-file, thus two CanoKey QEMU instance
 can not read one canokey-file at the same time.
 
-Another limitation is that this device is not compatible with ``qemu-xhci``,
-in that this device would hang when there are FIDO2 packets (traffic on
-interrupt endpoints). If you do not use FIDO2 then it works as intended,
-but for full functionality you should use old uhci/ehci bus and attach canokey
-to it, for example
-
-.. parsed-literal::
-
-   |qemu_system| -device piix3-usb-uhci,id=uhci -device canokey,bus=uhci.0
-
 References
 ==========
 
-- 
2.36.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PULL 8/8] hw: canokey: Remove HS support as not compliant to the spec
  2022-07-04  7:59 [PULL 0/8] Kraxel 20220704 patches Gerd Hoffmann
                   ` (6 preceding siblings ...)
  2022-07-04  7:59 ` [PULL 7/8] docs/system/devices/usb/canokey: remove limitations on qemu-xhci Gerd Hoffmann
@ 2022-07-04  7:59 ` Gerd Hoffmann
  2022-07-04 11:06 ` [PULL 0/8] Kraxel 20220704 patches Richard Henderson
  8 siblings, 0 replies; 10+ messages in thread
From: Gerd Hoffmann @ 2022-07-04  7:59 UTC (permalink / raw)
  To: qemu-devel
  Cc: Akihiko Odaki, Canokeys.org, Gerd Hoffmann, Peter Maydell,
	Philippe Mathieu-Daudé,
	Hongren (Zenithal) Zheng, MkfsSion

From: MkfsSion <mkfssion@mkfssion.com>

Canokey core currently using 16 bytes as maximum packet size for
control endpoint, but to run the device in high-speed a 64 bytes
maximum packet size is required according to USB 2.0 specification.
Since we don't acutally need to run the device in high-speed, simply
don't assign high member in USBDesc.

When canokey-qemu is used with xhci, xhci would drive canokey
in high speed mode, since the bcdUSB in canokey-core is 2.1,
yet canokey-core set bMaxPacketSize0 to be 16, this is out
of the spec as the spec said that ``The allowable maximum
control transfer data payload sizes...for high-speed devices,
it is 64 bytes''.

In this case, usb device validation in Windows 10 LTSC 2021
as the guest would fail. It would complain
USB\DEVICE_DESCRIPTOR_VALIDATION_FAILURE.

Note that bcdUSB only identifies the spec version the device
complies, but it has no indication of its speed. So it is
allowed for the device to run in FS but comply the 2.1 spec.

To solve the issue we decided to just drop the high
speed support. This only affects usb-ehci as usb-ehci would
complain speed mismatch when FS device is attached to a HS port.
That's why the .high member was initialized in the first place.
Meanwhile, xhci is not affected as it works well with FS device.
Since everyone is now using xhci, it does no harm to most users.

Suggested-by: Hongren (Zenithal) Zheng <i@zenithal.me>
Signed-off-by: YuanYang Meng <mkfssion@mkfssion.com>
Reviewed-by: Hongren (Zenithal) Zheng <i@zenithal.me>
Message-Id: <20220625142138.19363-1-mkfssion@mkfssion.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb/canokey.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/usb/canokey.c b/hw/usb/canokey.c
index 8da0d65556af..bbc5da07b58f 100644
--- a/hw/usb/canokey.c
+++ b/hw/usb/canokey.c
@@ -56,7 +56,6 @@ static const USBDesc desc_canokey = {
         .iSerialNumber     = STR_SERIALNUMBER,
     },
     .full = &desc_device_canokey,
-    .high = &desc_device_canokey,
     .str  = desc_strings,
 };
 
-- 
2.36.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PULL 0/8] Kraxel 20220704 patches
  2022-07-04  7:59 [PULL 0/8] Kraxel 20220704 patches Gerd Hoffmann
                   ` (7 preceding siblings ...)
  2022-07-04  7:59 ` [PULL 8/8] hw: canokey: Remove HS support as not compliant to the spec Gerd Hoffmann
@ 2022-07-04 11:06 ` Richard Henderson
  8 siblings, 0 replies; 10+ messages in thread
From: Richard Henderson @ 2022-07-04 11:06 UTC (permalink / raw)
  To: Gerd Hoffmann, qemu-devel
  Cc: Akihiko Odaki, Canokeys.org, Peter Maydell,
	Philippe Mathieu-Daudé,
	Hongren (Zenithal) Zheng

On 7/4/22 13:29, Gerd Hoffmann wrote:
> The following changes since commit d495e432c04a6394126c35cf96517749708b410f:
> 
>    Merge tag 'pull-aspeed-20220630' of https://github.com/legoater/qemu into staging (2022-06-30 22:04:12 +0530)
> 
> are available in the Git repository at:
> 
>    https://gitlab.com/kraxel/qemu.git tags/kraxel-20220704-pull-request
> 
> for you to fetch changes up to 927b968d1bc7c0a25edad8161608223b1122a253:
> 
>    hw: canokey: Remove HS support as not compliant to the spec (2022-07-01 12:39:51 +0200)
> 
> ----------------------------------------------------------------
> usb: canokey fixes.
> ui: better tab labels, cocoa fix,
> docs: convert fw_cfg to rst.

Applied, thanks.  Please update https://wiki.qemu.org/ChangeLog/7.1 as appropriate.


r~


> 
> ----------------------------------------------------------------
> 
> Akihiko Odaki (1):
>    ui/cocoa: Fix clipboard text release
> 
> Hongren (Zenithal) Zheng (3):
>    hw/usb/canokey: Fix CCID ZLP
>    hw/usb/canokey: fix compatibility of qemu-xhci
>    docs/system/devices/usb/canokey: remove limitations on qemu-xhci
> 
> MkfsSion (1):
>    hw: canokey: Remove HS support as not compliant to the spec
> 
> Simon Sapin (2):
>    Rename docs/specs/fw_cfg.txt to .rst
>    Convert fw_cfg.rst to reStructuredText syntax
> 
> Wen, Jianxian (1):
>    ui/console: allow display device to be labeled with given id
> 
>   include/ui/console.h                  |   1 +
>   hw/usb/canokey.c                      |  31 +++-
>   ui/console.c                          |  41 ++++-
>   docs/specs/{fw_cfg.txt => fw_cfg.rst} | 211 ++++++++++++++------------
>   docs/specs/index.rst                  |   1 +
>   docs/system/devices/canokey.rst       |  10 --
>   ui/cocoa.m                            |   4 +-
>   7 files changed, 189 insertions(+), 110 deletions(-)
>   rename docs/specs/{fw_cfg.txt => fw_cfg.rst} (58%)
> 



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-07-04 11:08 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-04  7:59 [PULL 0/8] Kraxel 20220704 patches Gerd Hoffmann
2022-07-04  7:59 ` [PULL 1/8] Rename docs/specs/fw_cfg.txt to .rst Gerd Hoffmann
2022-07-04  7:59 ` [PULL 2/8] Convert fw_cfg.rst to reStructuredText syntax Gerd Hoffmann
2022-07-04  7:59 ` [PULL 3/8] ui/console: allow display device to be labeled with given id Gerd Hoffmann
2022-07-04  7:59 ` [PULL 4/8] ui/cocoa: Fix clipboard text release Gerd Hoffmann
2022-07-04  7:59 ` [PULL 5/8] hw/usb/canokey: Fix CCID ZLP Gerd Hoffmann
2022-07-04  7:59 ` [PULL 6/8] hw/usb/canokey: fix compatibility of qemu-xhci Gerd Hoffmann
2022-07-04  7:59 ` [PULL 7/8] docs/system/devices/usb/canokey: remove limitations on qemu-xhci Gerd Hoffmann
2022-07-04  7:59 ` [PULL 8/8] hw: canokey: Remove HS support as not compliant to the spec Gerd Hoffmann
2022-07-04 11:06 ` [PULL 0/8] Kraxel 20220704 patches Richard Henderson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.