Skip to contentSkip to conversation

add 1394 bus support

PATCH Superseded [email protected] 4 participants 7 messages Apr 19, 2015 – Apr 20, 2015

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 add 1394 bus support

From: Itamar Tal <[email protected]>

This patch add 1394 (firewire) support to x86_64 and i386 qemu softmmu. It allows one virtual machine to be the server side and the other to be the client side, connected by TCP stream socket (same thing is possible using serial port). This is very useful in for allowing legacy devices to communicate over the firewire channel, but doesn't support USB communication. Especially, it's useful for remote Windows kernel debugging over qemu for malware analysis and so on... The patch was tested on major stable version 2.0.0, 2.2.1 and current master (2.3.0rc?).

Itamar Tal (1):
add 1394 bus support

 default-configs/i386-softmmu.mak   |    1 +
 default-configs/x86_64-softmmu.mak |    1 +
 hw/1394/Makefile.objs              |    1 +
 hw/1394/hcd-ohci.c                 | 1754 ++++++++++++++++++++++++++++++++++++
 hw/1394/hcd-ohci.h                 |  147 +++
 hw/Makefile.objs                   |    1 +
 6 files changed, 1905 insertions(+)
 create mode 100644 hw/1394/Makefile.objs
 create mode 100644 hw/1394/hcd-ohci.c
 create mode 100644 hw/1394/hcd-ohci.h
Signature · 1 line
2.3.4
#1 lore raw

PATCH v2 1/1 add 1394 bus support

From: Itamar Tal <[email protected]>

---
 default-configs/i386-softmmu.mak   |    1 +
 default-configs/x86_64-softmmu.mak |    1 +
 hw/1394/Makefile.objs              |    1 +
 hw/1394/hcd-ohci.c                 | 1754 ++++++++++++++++++++++++++++++++++++
 hw/1394/hcd-ohci.h                 |  147 +++
 hw/Makefile.objs                   |    1 +
 6 files changed, 1905 insertions(+)
 create mode 100644 hw/1394/Makefile.objs
 create mode 100644 hw/1394/hcd-ohci.c
 create mode 100644 hw/1394/hcd-ohci.h
default-configs/i386-softmmu.mak +1 -0
index 6a74e00..8742af9 100644
@@ -45,3 +45,4 @@ CONFIG_MEM_HOTPLUG=y
 CONFIG_XIO3130=y
 CONFIG_IOH3420=y
 CONFIG_I82801B11=y
+CONFIG_1394_OHCI=y
default-configs/x86_64-softmmu.mak +1 -0
index 46b87dd..a47863d 100644
@@ -45,3 +45,4 @@ CONFIG_MEM_HOTPLUG=y
 CONFIG_XIO3130=y
 CONFIG_IOH3420=y
 CONFIG_I82801B11=y
+CONFIG_1394_OHCI=y
hw/1394/Makefile.objs new file +1 -0
new file mode 100644
index 0000000..bddc0e1
@@ -0,0 +1 @@
+common-obj-$(CONFIG_1394_OHCI) += hcd-ohci.o
hw/1394/hcd-ohci.c new file +1754 -0

1,754 lines not on this page · raw message

hw/1394/hcd-ohci.h new file +147 -0

147 lines not on this page · raw message

hw/Makefile.objs +1 -0
index 73afa41..c3baffa 100644
@@ -1,4 +1,5 @@
 devices-dirs-$(call land, $(CONFIG_VIRTIO),$(call land,$(CONFIG_VIRTFS),$(CONFIG_PCI))) += 9pfs/
+devices-dirs-$(CONFIG_SOFTMMU) += 1394/
 devices-dirs-$(CONFIG_ACPI) += acpi/
 devices-dirs-$(CONFIG_SOFTMMU) += audio/
 devices-dirs-$(CONFIG_SOFTMMU) += block/
Signature · 1 line
2.3.4
#2 lore raw

Am 19.04.2015 um 12:52 schrieb [email protected]:

Quoted 3 lines

From: Itamar Tal <[email protected]>

---

Still no Signed-off-by...

Regards,
Andreas

Signature · 3 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Jennifer Guild, Dilip Upmanyu,
Graham Norton; HRB 21284 (AG Nürnberg)
author
#3 lore raw

I've set it just after the subject field in the patch? Should I add it somewhere else and resubmit?

Quoted 15 lines · Andreas Färber

Am 19.04.2015 um 12:52 schrieb [email protected]:

Quoted 3 lines

From: Itamar Tal <[email protected]>

---

Still no Signed-off-by...

Regards,
Andreas

--
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Jennifer Guild, Dilip Upmanyu, Graham Norton; HRB 21284 (AG Nürnberg)

#4 lore raw

Hi,

Am 19.04.2015 um 18:38 schrieb Itamar Tal:

Quoted 2 lines

I've set it just after the subject field in the patch? Should I add it somewhere else and resubmit?

Please compare other QEMU or Linux patches: It needs to go before --- into the commit message. git commit --amend -s will place it correctly.

BTW I'm missing a type_init() and type_register_static() in the bottom of hcd-ohci.c and wonder how you managed to test it without.

Did you copy this code from some other codebase? For one, hcd-ohci.c has "address@hidden", which looks like you copied it from some mailing list archive (then you need to replicate those authors' Signed-off-bys), and for another the Coding Style does not exactly match that of QEMU, in particular you are using a lot of custom _t types whereas QEMU uses CamelCase type names. BTW if you consistently used typedefs for your unions, you could avoid those macros declaring phy etc. unions inline, no?

Please also drop the empty last line in the new files you add. Did you run scripts/checkpatch.pl? Running git-am on a clean branch can also help highlight whitespace errors.

hcd-ohci.h is missing a license/copyright header.

hcd_pci_exit() has commented-out code - please fix or remove. hcd_pci_init() has the opening brace placed wrong.

It looks like a generic PCI device, so why are you placing the config option into i386 and x86_64 configs only rather than pci.mak?

Regards,
Andreas

P.S. Please don't top-post.

Quoted 20 lines

On Apr 19, 2015 6:47 PM, "Andreas Färber" <[email protected] <mailto:[email protected]>> wrote:

Am 19.04.2015 um 12:52 schrieb [email protected] <mailto:[email protected]>:
> From: Itamar Tal <[email protected] <mailto:[email protected]>>
>
> ---

Still no Signed-off-by...

Regards,
Andreas

--
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Jennifer Guild, Dilip Upmanyu, Graham Norton; HRB 21284 (AG Nürnberg)

Signature · 3 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Jennifer Guild, Dilip Upmanyu,
Graham Norton; HRB 21284 (AG Nürnberg)
#5 lore raw
Quoted 9 lines · Andreas Färber

Hi,

Am 19.04.2015 um 18:38 schrieb Itamar Tal:

Quoted 2 lines

I've set it just after the subject field in the patch? Should I add it somewhere else and resubmit?

Please compare other QEMU or Linux patches: It needs to go before --- into the commit message. git commit --amend -s will place it correctly.

OK - I'll do that

Quoted 4 lines

BTW I'm missing a type_init() and type_register_static() in the bottom of hcd-ohci.c and wonder how you managed to test it without.

I test it adding the following commands the command line
-chardev socket,host=127.0.0.1,port=13940,nodelay,id=fw0 -device ohci-1394,chardev=fw0

which creates a new ohci-1394 device which I can work with and connect between machines.

Quoted 9 lines

Did you copy this code from some other codebase? For one, hcd-ohci.c has "address@hidden", which looks like you copied it from some mailing list archive (then you need to replicate those authors' Signed-off-bys), and for another the Coding Style does not exactly match that of QEMU, in particular you are using a lot of custom _t types whereas QEMU uses CamelCase type names. BTW if you consistently used typedefs for your unions, you could avoid those macros declaring phy etc. unions inline, no?

- I've copied the patch from the last reply I've sent to qemu-dev so the address is hidden.
- I ran checkpatch.pl to align the code with the QEMU code before submitting (no errors/warnings). Other than the XXX_t types, anything else? I'll fix it, no problem

Quoted 5 lines

Please also drop the empty last line in the new files you add. Did you run scripts/checkpatch.pl? Running git-am on a clean branch can also help highlight whitespace errors.

- Did checkpatch.pl. I'll also try git-am.

Quoted 3 lines

hcd-ohci.h is missing a license/copyright header.

- OK, I'll add it

Quoted 3 lines

hcd_pci_exit() has commented-out code - please fix or remove.

- no problem

Quoted 2 lines

hcd_pci_init() has the opening brace placed wrong.

- no problem

Quoted 4 lines

It looks like a generic PCI device, so why are you placing the config option into i386 and x86_64 configs only rather than pci.mak?

- I've followed the suggestion by made by Thomas Huth, what do you suggest? When trying to build it with other architectures, sometimes it worked but many times I was missing some qemu dependencies APIs.

Quoted 6 lines

Regards,
Andreas

P.S. Please don't top-post.

- gotcha

Quoted 28 lines
Quoted 13 lines

On Apr 19, 2015 6:47 PM, "Andreas Färber" <[email protected] <mailto:[email protected]>> wrote:

Am 19.04.2015 um 12:52 schrieb [email protected] <mailto:[email protected]>:
> From: Itamar Tal <[email protected] <mailto:[email protected]>>
>
> ---

Still no Signed-off-by...

Quoted 8 lines

Regards,
Andreas

--
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Jennifer Guild, Dilip Upmanyu, Graham Norton; HRB 21284 (AG Nürnberg)

--
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Jennifer Guild, Dilip Upmanyu, Graham Norton; HRB 21284 (AG Nürnberg)

#6 lore raw
In reply to [email protected]
Quoted 36 lines · On 19 April 2015 at 11:52, <[email protected]> wrote:

From: Itamar Tal <[email protected]>

---
 default-configs/i386-softmmu.mak   |    1 +
 default-configs/x86_64-softmmu.mak |    1 +
 hw/1394/Makefile.objs              |    1 +
 hw/1394/hcd-ohci.c                 | 1754 ++++++++++++++++++++++++++++++++++++
 hw/1394/hcd-ohci.h                 |  147 +++
 hw/Makefile.objs                   |    1 +
 6 files changed, 1905 insertions(+)
 create mode 100644 hw/1394/Makefile.objs
 create mode 100644 hw/1394/hcd-ohci.c
 create mode 100644 hw/1394/hcd-ohci.h
hw/1394/hcd-ohci.c new file +21 -0
+typedef union {
+    uint32_t val;
+    struct {
+        uint32_t m:1;         /* = 0 */
+        uint32_t initiated:1; /* = 1 for root node */
+        uint32_t p2:2;        /* = 0 */
+        uint32_t p1:2;        /* = 0 */
+        uint32_t p0:2;        /* = 3, maybe 2 when "child" compared to root */
+        uint32_t pwr:3;       /* = 0 */
+        uint32_t c:1;         /* = 1 when root */
+        uint32_t del:2;       /* = 0? */
+        uint32_t sp:2;        /* = 0? */
+        uint32_t gap_cnt:6;   /* = 0? */
+        uint32_t L:1;         /* = 1? maybe just when connected */
+        uint32_t:1;           /* = 0 */
+        uint32_t node_id:6;
+        uint32_t type:2;      /* = 2 */
+    };
+} self_id_t;
 
+        self_id_t sid;
+

hw/1394/hcd-ohci.c

Quoted 10 lines
hw/1394/hcd-ohci.c new file +10 -0
+        sid.val = 0;
+        sid.initiated = 1;
+        sid.p0 = 2;
+        sid.c = 1;
+        sid.L = 1;
+        sid.node_id = 0;
+        sid.type = 2;
+        dma_memory_write(&address_space_memory,
+                         s->mmio.SelfIDBuffer + 4,
+                         &sid.val, 4);

This assumes that the layout of bitfields is portable -- it is not. You can't use a C bitfield to describe the layout of data in guest memory. You need to get rid of all these structs with bitfields and replace them with explicit AND/OR bit operations on uint32_t types.

thanks
-- PMM