1 | The following changes since commit 2e02083438962d26ef9dcc7100f3b378104183db: | 1 | The following changes since commit fff3159900d2b95613a9cb75fc3703e67a674729: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2017-11-17 19:08:07 +0000) | 3 | Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20190726' into staging (2019-07-26 16:23:07 +0100) |
4 | 4 | ||
5 | are available in the git repository at: | 5 | are available in the git repository at: |
6 | 6 | ||
7 | https://github.com/jasowang/qemu.git tags/net-pull-request | 7 | https://github.com/jasowang/qemu.git tags/net-pull-request |
8 | 8 | ||
9 | for you to fetch changes up to c527e0afcd7d719abc3a5ca5e4c8ac2fe48b999f: | 9 | for you to fetch changes up to f77bed14f01557596727c4eea042e9818c242049: |
10 | 10 | ||
11 | hw/net/vmxnet3: Fix code to work on big endian hosts, too (2017-11-20 11:08:00 +0800) | 11 | net/colo-compare.c: Fix memory leak and code style issue. (2019-07-29 16:29:30 +0800) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | 14 | ||
15 | ---------------------------------------------------------------- | 15 | ---------------------------------------------------------------- |
16 | Ed Swierk (1): | 16 | Jason Wang (1): |
17 | net: Transmit zero UDP checksum as 0xFFFF | 17 | e1000: don't raise interrupt in pre_save() |
18 | 18 | ||
19 | Jason Wang (1): | 19 | Prasad J Pandit (3): |
20 | Revert "Add new PCI ID for i82559a" | 20 | qemu-bridge-helper: restrict interface name to IFNAMSIZ |
21 | qemu-bridge-helper: move repeating code in parse_acl_file | ||
22 | net: tap: replace snprintf with g_strdup_printf calls | ||
21 | 23 | ||
22 | Mao Zhongyi (1): | 24 | Zhang Chen (1): |
23 | colo-compare: fix the dangerous assignment | 25 | net/colo-compare.c: Fix memory leak and code style issue. |
24 | 26 | ||
25 | Stefan Weil (1): | 27 | hw/net/e1000.c | 8 ++------ |
26 | MAINTAINERS: Add missing entry for eepro100 emulation | 28 | net/colo-compare.c | 27 ++++++++++++++++++++------- |
27 | 29 | net/tap.c | 19 +++++++++++-------- | |
28 | Thomas Huth (2): | 30 | qemu-bridge-helper.c | 24 +++++++++++++++++------- |
29 | hw/net/eepro100: Fix endianness problem on big endian hosts | 31 | 4 files changed, 50 insertions(+), 28 deletions(-) |
30 | hw/net/vmxnet3: Fix code to work on big endian hosts, too | ||
31 | |||
32 | MAINTAINERS | 5 ++ | ||
33 | hw/net/e1000.c | 2 +- | ||
34 | hw/net/eepro100.c | 17 +--- | ||
35 | hw/net/net_rx_pkt.c | 2 +- | ||
36 | hw/net/net_tx_pkt.c | 2 +- | ||
37 | hw/net/vmware_utils.h | 6 ++ | ||
38 | hw/net/vmxnet3.c | 49 ++++++++--- | ||
39 | hw/net/vmxnet3.h | 230 ++++++++++++++++++++++++++++++------------------- | ||
40 | include/hw/compat.h | 4 - | ||
41 | include/hw/pci/pci.h | 1 - | ||
42 | include/net/checksum.h | 6 ++ | ||
43 | net/colo-compare.c | 2 +- | ||
44 | qemu-options.hx | 2 +- | ||
45 | 13 files changed, 201 insertions(+), 127 deletions(-) | ||
46 | 32 | ||
47 | 33 | diff view generated by jsdifflib |
1 | From: Ed Swierk <eswierk@skyportsystems.com> | 1 | We should not raise any interrupt after VM has been stopped but this |
---|---|---|---|
2 | is what e1000 currently did when mit timer is active in | ||
3 | pre_save(). Fixing this by scheduling a timer in post_load() which can | ||
4 | make sure the interrupt was raised when VM is running. | ||
2 | 5 | ||
3 | The checksum algorithm used by IPv4, TCP and UDP allows a zero value | 6 | Reported-and-tested-by: Longpeng <longpeng2@huawei.com> |
4 | to be represented by either 0x0000 and 0xFFFF. But per RFC 768, a zero | ||
5 | UDP checksum must be transmitted as 0xFFFF because 0x0000 is a special | ||
6 | value meaning no checksum. | ||
7 | |||
8 | Substitute 0xFFFF whenever a checksum is computed as zero when | ||
9 | modifying a UDP datagram header. Doing this on IPv4 and TCP checksums | ||
10 | is unnecessary but legal. Add a wrapper for net_checksum_finish() that | ||
11 | makes the substitution. | ||
12 | |||
13 | (We can't just change net_checksum_finish(), as that function is also | ||
14 | used by receivers to verify checksums, and in that case the expected | ||
15 | value is always 0x0000.) | ||
16 | |||
17 | Signed-off-by: Ed Swierk <eswierk@skyportsystems.com> | ||
18 | Signed-off-by: Jason Wang <jasowang@redhat.com> | 7 | Signed-off-by: Jason Wang <jasowang@redhat.com> |
19 | --- | 8 | --- |
20 | hw/net/e1000.c | 2 +- | 9 | hw/net/e1000.c | 8 ++------ |
21 | hw/net/net_rx_pkt.c | 2 +- | 10 | 1 file changed, 2 insertions(+), 6 deletions(-) |
22 | hw/net/net_tx_pkt.c | 2 +- | ||
23 | hw/net/vmxnet3.c | 3 ++- | ||
24 | include/net/checksum.h | 6 ++++++ | ||
25 | 5 files changed, 11 insertions(+), 4 deletions(-) | ||
26 | 11 | ||
27 | diff --git a/hw/net/e1000.c b/hw/net/e1000.c | 12 | diff --git a/hw/net/e1000.c b/hw/net/e1000.c |
28 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
29 | --- a/hw/net/e1000.c | 14 | --- a/hw/net/e1000.c |
30 | +++ b/hw/net/e1000.c | 15 | +++ b/hw/net/e1000.c |
31 | @@ -XXX,XX +XXX,XX @@ putsum(uint8_t *data, uint32_t n, uint32_t sloc, uint32_t css, uint32_t cse) | 16 | @@ -XXX,XX +XXX,XX @@ static int e1000_pre_save(void *opaque) |
32 | n = cse + 1; | 17 | E1000State *s = opaque; |
33 | if (sloc < n-1) { | 18 | NetClientState *nc = qemu_get_queue(s->nic); |
34 | sum = net_checksum_add(n-css, data+css); | 19 | |
35 | - stw_be_p(data + sloc, net_checksum_finish(sum)); | 20 | - /* If the mitigation timer is active, emulate a timeout now. */ |
36 | + stw_be_p(data + sloc, net_checksum_finish_nozero(sum)); | 21 | - if (s->mit_timer_on) { |
22 | - e1000_mit_timer(s); | ||
23 | - } | ||
24 | - | ||
25 | /* | ||
26 | * If link is down and auto-negotiation is supported and ongoing, | ||
27 | * complete auto-negotiation immediately. This allows us to look | ||
28 | @@ -XXX,XX +XXX,XX @@ static int e1000_post_load(void *opaque, int version_id) | ||
29 | s->mit_irq_level = false; | ||
37 | } | 30 | } |
38 | } | 31 | s->mit_ide = 0; |
39 | 32 | - s->mit_timer_on = false; | |
40 | diff --git a/hw/net/net_rx_pkt.c b/hw/net/net_rx_pkt.c | 33 | + s->mit_timer_on = true; |
41 | index XXXXXXX..XXXXXXX 100644 | 34 | + timer_mod(s->mit_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + 1); |
42 | --- a/hw/net/net_rx_pkt.c | 35 | |
43 | +++ b/hw/net/net_rx_pkt.c | 36 | /* nc.link_down can't be migrated, so infer link_down according |
44 | @@ -XXX,XX +XXX,XX @@ _net_rx_pkt_calc_l4_csum(struct NetRxPkt *pkt) | 37 | * to link status bit in mac_reg[STATUS]. |
45 | cntr += net_checksum_add_iov(pkt->vec, pkt->vec_len, | ||
46 | pkt->l4hdr_off, csl, cso); | ||
47 | |||
48 | - csum = net_checksum_finish(cntr); | ||
49 | + csum = net_checksum_finish_nozero(cntr); | ||
50 | |||
51 | trace_net_rx_pkt_l4_csum_calc_csum(pkt->l4hdr_off, csl, cntr, csum); | ||
52 | |||
53 | diff --git a/hw/net/net_tx_pkt.c b/hw/net/net_tx_pkt.c | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/hw/net/net_tx_pkt.c | ||
56 | +++ b/hw/net/net_tx_pkt.c | ||
57 | @@ -XXX,XX +XXX,XX @@ static void net_tx_pkt_do_sw_csum(struct NetTxPkt *pkt) | ||
58 | net_checksum_add_iov(iov, iov_len, pkt->virt_hdr.csum_start, csl, cso); | ||
59 | |||
60 | /* Put the checksum obtained into the packet */ | ||
61 | - csum = cpu_to_be16(net_checksum_finish(csum_cntr)); | ||
62 | + csum = cpu_to_be16(net_checksum_finish_nozero(csum_cntr)); | ||
63 | iov_from_buf(iov, iov_len, csum_offset, &csum, sizeof csum); | ||
64 | } | ||
65 | |||
66 | diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c | ||
67 | index XXXXXXX..XXXXXXX 100644 | ||
68 | --- a/hw/net/vmxnet3.c | ||
69 | +++ b/hw/net/vmxnet3.c | ||
70 | @@ -XXX,XX +XXX,XX @@ static void vmxnet3_rx_need_csum_calculate(struct NetRxPkt *pkt, | ||
71 | data = (uint8_t *)pkt_data + vhdr->csum_start; | ||
72 | len = pkt_len - vhdr->csum_start; | ||
73 | /* Put the checksum obtained into the packet */ | ||
74 | - stw_be_p(data + vhdr->csum_offset, net_raw_checksum(data, len)); | ||
75 | + stw_be_p(data + vhdr->csum_offset, | ||
76 | + net_checksum_finish_nozero(net_checksum_add(len, data))); | ||
77 | |||
78 | vhdr->flags &= ~VIRTIO_NET_HDR_F_NEEDS_CSUM; | ||
79 | vhdr->flags |= VIRTIO_NET_HDR_F_DATA_VALID; | ||
80 | diff --git a/include/net/checksum.h b/include/net/checksum.h | ||
81 | index XXXXXXX..XXXXXXX 100644 | ||
82 | --- a/include/net/checksum.h | ||
83 | +++ b/include/net/checksum.h | ||
84 | @@ -XXX,XX +XXX,XX @@ net_checksum_add(int len, uint8_t *buf) | ||
85 | } | ||
86 | |||
87 | static inline uint16_t | ||
88 | +net_checksum_finish_nozero(uint32_t sum) | ||
89 | +{ | ||
90 | + return net_checksum_finish(sum) ?: 0xFFFF; | ||
91 | +} | ||
92 | + | ||
93 | +static inline uint16_t | ||
94 | net_raw_checksum(uint8_t *data, int length) | ||
95 | { | ||
96 | return net_checksum_finish(net_checksum_add(length, data)); | ||
97 | -- | 38 | -- |
98 | 2.7.4 | 39 | 2.5.0 |
99 | 40 | ||
100 | 41 | diff view generated by jsdifflib |
1 | From: Stefan Weil <sw@weilnetz.de> | 1 | From: Prasad J Pandit <pjp@fedoraproject.org> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Stefan Weil <sw@weilnetz.de> | 3 | The network interface name in Linux is defined to be of size |
4 | IFNAMSIZ(=16), including the terminating null('\0') byte. | ||
5 | The same is applied to interface names read from 'bridge.conf' | ||
6 | file to form ACL rules. If user supplied '--br=bridge' name | ||
7 | is not restricted to the same length, it could lead to ACL bypass | ||
8 | issue. Restrict interface name to IFNAMSIZ, including null byte. | ||
9 | |||
10 | Reported-by: Riccardo Schirone <rschiron@redhat.com> | ||
11 | Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org> | ||
12 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
13 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> | ||
14 | Reviewed-by: Li Qiang <liq3ea@gmail.com> | ||
4 | Signed-off-by: Jason Wang <jasowang@redhat.com> | 15 | Signed-off-by: Jason Wang <jasowang@redhat.com> |
5 | --- | 16 | --- |
6 | MAINTAINERS | 5 +++++ | 17 | qemu-bridge-helper.c | 11 +++++++++++ |
7 | 1 file changed, 5 insertions(+) | 18 | 1 file changed, 11 insertions(+) |
8 | 19 | ||
9 | diff --git a/MAINTAINERS b/MAINTAINERS | 20 | diff --git a/qemu-bridge-helper.c b/qemu-bridge-helper.c |
10 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
11 | --- a/MAINTAINERS | 22 | --- a/qemu-bridge-helper.c |
12 | +++ b/MAINTAINERS | 23 | +++ b/qemu-bridge-helper.c |
13 | @@ -XXX,XX +XXX,XX @@ M: Dmitry Fleytman <dmitry@daynix.com> | 24 | @@ -XXX,XX +XXX,XX @@ static int parse_acl_file(const char *filename, ACLList *acl_list) |
14 | S: Maintained | 25 | } |
15 | F: hw/net/e1000e* | 26 | *argend = 0; |
16 | 27 | ||
17 | +eepro100 | 28 | + if (!g_str_equal(cmd, "include") && strlen(arg) >= IFNAMSIZ) { |
18 | +M: Stefan Weil <sw@weilnetz.de> | 29 | + fprintf(stderr, "name `%s' too long: %zu\n", arg, strlen(arg)); |
19 | +S: Maintained | 30 | + fclose(f); |
20 | +F: hw/net/eepro100.c | 31 | + errno = EINVAL; |
32 | + return -1; | ||
33 | + } | ||
21 | + | 34 | + |
22 | Generic Loader | 35 | if (strcmp(cmd, "deny") == 0) { |
23 | M: Alistair Francis <alistair.francis@xilinx.com> | 36 | acl_rule = g_malloc(sizeof(*acl_rule)); |
24 | S: Maintained | 37 | if (strcmp(arg, "all") == 0) { |
38 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv) | ||
39 | usage(); | ||
40 | return EXIT_FAILURE; | ||
41 | } | ||
42 | + if (strlen(bridge) >= IFNAMSIZ) { | ||
43 | + fprintf(stderr, "name `%s' too long: %zu\n", bridge, strlen(bridge)); | ||
44 | + return EXIT_FAILURE; | ||
45 | + } | ||
46 | |||
47 | /* parse default acl file */ | ||
48 | QSIMPLEQ_INIT(&acl_list); | ||
25 | -- | 49 | -- |
26 | 2.7.4 | 50 | 2.5.0 |
27 | 51 | ||
28 | 52 | diff view generated by jsdifflib |
1 | From: Thomas Huth <thuth@redhat.com> | 1 | From: Prasad J Pandit <pjp@fedoraproject.org> |
---|---|---|---|
2 | 2 | ||
3 | Since commit 1865e288a823c764cd4344d ("Fix eepro100 simple transmission | 3 | Move repeating error handling sequence in parse_acl_file routine |
4 | mode"), the test/pxe-test is broken for the eepro100 device on big | 4 | to an 'err' label. |
5 | endian hosts. However, it seems like that commit did not introduce the | ||
6 | problem, but just uncovered it: The EEPRO100State->tx.tbd_array_addr and | ||
7 | EEPRO100State->tx.tcb_bytes fields are already in host byte order, since | ||
8 | they have already been byte-swapped in the read_cb() function. | ||
9 | Thus byte-swapping them in tx_command() again results in the wrong | ||
10 | endianness. Removing the byte-swapping here fixes the pxe-test. | ||
11 | 5 | ||
12 | Signed-off-by: Thomas Huth <thuth@redhat.com> | 6 | Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org> |
7 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
8 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> | ||
9 | Reviewed-by: Li Qiang <liq3ea@gmail.com> | ||
13 | Signed-off-by: Jason Wang <jasowang@redhat.com> | 10 | Signed-off-by: Jason Wang <jasowang@redhat.com> |
14 | --- | 11 | --- |
15 | hw/net/eepro100.c | 4 ++-- | 12 | qemu-bridge-helper.c | 19 +++++++++---------- |
16 | 1 file changed, 2 insertions(+), 2 deletions(-) | 13 | 1 file changed, 9 insertions(+), 10 deletions(-) |
17 | 14 | ||
18 | diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c | 15 | diff --git a/qemu-bridge-helper.c b/qemu-bridge-helper.c |
19 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/hw/net/eepro100.c | 17 | --- a/qemu-bridge-helper.c |
21 | +++ b/hw/net/eepro100.c | 18 | +++ b/qemu-bridge-helper.c |
22 | @@ -XXX,XX +XXX,XX @@ static void read_cb(EEPRO100State *s) | 19 | @@ -XXX,XX +XXX,XX @@ static int parse_acl_file(const char *filename, ACLList *acl_list) |
23 | 20 | ||
24 | static void tx_command(EEPRO100State *s) | 21 | if (arg == NULL) { |
25 | { | 22 | fprintf(stderr, "Invalid config line:\n %s\n", line); |
26 | - uint32_t tbd_array = le32_to_cpu(s->tx.tbd_array_addr); | 23 | - fclose(f); |
27 | - uint16_t tcb_bytes = (le16_to_cpu(s->tx.tcb_bytes) & 0x3fff); | 24 | - errno = EINVAL; |
28 | + uint32_t tbd_array = s->tx.tbd_array_addr; | 25 | - return -1; |
29 | + uint16_t tcb_bytes = s->tx.tcb_bytes & 0x3fff; | 26 | + goto err; |
30 | /* Sends larger than MAX_ETH_FRAME_SIZE are allowed, up to 2600 bytes. */ | 27 | } |
31 | uint8_t buf[2600]; | 28 | |
32 | uint16_t size = 0; | 29 | *arg = 0; |
30 | @@ -XXX,XX +XXX,XX @@ static int parse_acl_file(const char *filename, ACLList *acl_list) | ||
31 | |||
32 | if (!g_str_equal(cmd, "include") && strlen(arg) >= IFNAMSIZ) { | ||
33 | fprintf(stderr, "name `%s' too long: %zu\n", arg, strlen(arg)); | ||
34 | - fclose(f); | ||
35 | - errno = EINVAL; | ||
36 | - return -1; | ||
37 | + goto err; | ||
38 | } | ||
39 | |||
40 | if (strcmp(cmd, "deny") == 0) { | ||
41 | @@ -XXX,XX +XXX,XX @@ static int parse_acl_file(const char *filename, ACLList *acl_list) | ||
42 | parse_acl_file(arg, acl_list); | ||
43 | } else { | ||
44 | fprintf(stderr, "Unknown command `%s'\n", cmd); | ||
45 | - fclose(f); | ||
46 | - errno = EINVAL; | ||
47 | - return -1; | ||
48 | + goto err; | ||
49 | } | ||
50 | } | ||
51 | |||
52 | fclose(f); | ||
53 | - | ||
54 | return 0; | ||
55 | + | ||
56 | +err: | ||
57 | + fclose(f); | ||
58 | + errno = EINVAL; | ||
59 | + return -1; | ||
60 | + | ||
61 | } | ||
62 | |||
63 | static bool has_vnet_hdr(int fd) | ||
33 | -- | 64 | -- |
34 | 2.7.4 | 65 | 2.5.0 |
35 | 66 | ||
36 | 67 | diff view generated by jsdifflib |
1 | From: Thomas Huth <thuth@redhat.com> | 1 | From: Prasad J Pandit <pjp@fedoraproject.org> |
---|---|---|---|
2 | 2 | ||
3 | Since commit ab06ec43577177a442e8 we test the vmxnet3 device in the | 3 | When invoking qemu-bridge-helper in 'net_bridge_run_helper', |
4 | pxe-tester, too (when running "make check SPEED=slow"). This now | 4 | instead of using fixed sized buffers, use dynamically allocated |
5 | revealed that the code is not working there if the host is a big | 5 | ones initialised and returned by g_strdup_printf(). |
6 | endian machine (for example ppc64 or s390x) - "make check SPEED=slow" | ||
7 | is now failing on such hosts. | ||
8 | 6 | ||
9 | The vmxnet3 code lacks endianness conversions in a couple of places. | 7 | Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org> |
10 | Interestingly, the bitfields in the structs in vmxnet3.h already tried to | 8 | Reviewed-by: Li Qiang <liq3ea@gmail.com> |
11 | take care of the *bit* endianness of the C compilers - but the code missed | 9 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> |
12 | to change the *byte* endianness when reading or writing the corresponding | ||
13 | structs. So the bitfields are now wrapped into unions which allow to change | ||
14 | the byte endianness during runtime with the non-bitfield member of the union. | ||
15 | With these changes, "make check SPEED=slow" now properly works on big endian | ||
16 | hosts, too. | ||
17 | |||
18 | Reported-by: David Gibson <dgibson@redhat.com> | ||
19 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
20 | Reviewed-by: David Gibson <dgibson@redhat.com> | ||
21 | Signed-off-by: Thomas Huth <thuth@redhat.com> | ||
22 | Signed-off-by: Jason Wang <jasowang@redhat.com> | 10 | Signed-off-by: Jason Wang <jasowang@redhat.com> |
23 | --- | 11 | --- |
24 | hw/net/vmware_utils.h | 6 ++ | 12 | net/tap.c | 19 +++++++++++-------- |
25 | hw/net/vmxnet3.c | 46 +++++++--- | 13 | 1 file changed, 11 insertions(+), 8 deletions(-) |
26 | hw/net/vmxnet3.h | 230 ++++++++++++++++++++++++++++++-------------------- | ||
27 | 3 files changed, 181 insertions(+), 101 deletions(-) | ||
28 | 14 | ||
29 | diff --git a/hw/net/vmware_utils.h b/hw/net/vmware_utils.h | 15 | diff --git a/net/tap.c b/net/tap.c |
30 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
31 | --- a/hw/net/vmware_utils.h | 17 | --- a/net/tap.c |
32 | +++ b/hw/net/vmware_utils.h | 18 | +++ b/net/tap.c |
33 | @@ -XXX,XX +XXX,XX @@ vmw_shmem_ld16(PCIDevice *d, hwaddr addr) | 19 | @@ -XXX,XX +XXX,XX @@ static int net_bridge_run_helper(const char *helper, const char *bridge, |
34 | { | ||
35 | uint16_t res; | ||
36 | pci_dma_read(d, addr, &res, 2); | ||
37 | + res = le16_to_cpu(res); | ||
38 | VMW_SHPRN("SHMEM load16: %" PRIx64 " (value 0x%X)", addr, res); | ||
39 | return res; | ||
40 | } | ||
41 | @@ -XXX,XX +XXX,XX @@ static inline void | ||
42 | vmw_shmem_st16(PCIDevice *d, hwaddr addr, uint16_t value) | ||
43 | { | ||
44 | VMW_SHPRN("SHMEM store16: %" PRIx64 " (value 0x%X)", addr, value); | ||
45 | + value = cpu_to_le16(value); | ||
46 | pci_dma_write(d, addr, &value, 2); | ||
47 | } | ||
48 | |||
49 | @@ -XXX,XX +XXX,XX @@ vmw_shmem_ld32(PCIDevice *d, hwaddr addr) | ||
50 | { | ||
51 | uint32_t res; | ||
52 | pci_dma_read(d, addr, &res, 4); | ||
53 | + res = le32_to_cpu(res); | ||
54 | VMW_SHPRN("SHMEM load32: %" PRIx64 " (value 0x%X)", addr, res); | ||
55 | return res; | ||
56 | } | ||
57 | @@ -XXX,XX +XXX,XX @@ static inline void | ||
58 | vmw_shmem_st32(PCIDevice *d, hwaddr addr, uint32_t value) | ||
59 | { | ||
60 | VMW_SHPRN("SHMEM store32: %" PRIx64 " (value 0x%X)", addr, value); | ||
61 | + value = cpu_to_le32(value); | ||
62 | pci_dma_write(d, addr, &value, 4); | ||
63 | } | ||
64 | |||
65 | @@ -XXX,XX +XXX,XX @@ vmw_shmem_ld64(PCIDevice *d, hwaddr addr) | ||
66 | { | ||
67 | uint64_t res; | ||
68 | pci_dma_read(d, addr, &res, 8); | ||
69 | + res = le64_to_cpu(res); | ||
70 | VMW_SHPRN("SHMEM load64: %" PRIx64 " (value %" PRIx64 ")", addr, res); | ||
71 | return res; | ||
72 | } | ||
73 | @@ -XXX,XX +XXX,XX @@ static inline void | ||
74 | vmw_shmem_st64(PCIDevice *d, hwaddr addr, uint64_t value) | ||
75 | { | ||
76 | VMW_SHPRN("SHMEM store64: %" PRIx64 " (value %" PRIx64 ")", addr, value); | ||
77 | + value = cpu_to_le64(value); | ||
78 | pci_dma_write(d, addr, &value, 8); | ||
79 | } | ||
80 | |||
81 | diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c | ||
82 | index XXXXXXX..XXXXXXX 100644 | ||
83 | --- a/hw/net/vmxnet3.c | ||
84 | +++ b/hw/net/vmxnet3.c | ||
85 | @@ -XXX,XX +XXX,XX @@ vmxnet3_dump_tx_descr(struct Vmxnet3_TxDesc *descr) | ||
86 | "addr %" PRIx64 ", len: %d, gen: %d, rsvd: %d, " | ||
87 | "dtype: %d, ext1: %d, msscof: %d, hlen: %d, om: %d, " | ||
88 | "eop: %d, cq: %d, ext2: %d, ti: %d, tci: %d", | ||
89 | - le64_to_cpu(descr->addr), descr->len, descr->gen, descr->rsvd, | ||
90 | + descr->addr, descr->len, descr->gen, descr->rsvd, | ||
91 | descr->dtype, descr->ext1, descr->msscof, descr->hlen, descr->om, | ||
92 | descr->eop, descr->cq, descr->ext2, descr->ti, descr->tci); | ||
93 | } | ||
94 | @@ -XXX,XX +XXX,XX @@ vmxnet3_dump_rx_descr(struct Vmxnet3_RxDesc *descr) | ||
95 | { | ||
96 | VMW_PKPRN("RX DESCR: addr %" PRIx64 ", len: %d, gen: %d, rsvd: %d, " | ||
97 | "dtype: %d, ext1: %d, btype: %d", | ||
98 | - le64_to_cpu(descr->addr), descr->len, descr->gen, | ||
99 | + descr->addr, descr->len, descr->gen, | ||
100 | descr->rsvd, descr->dtype, descr->ext1, descr->btype); | ||
101 | } | ||
102 | |||
103 | @@ -XXX,XX +XXX,XX @@ static void vmxnet3_complete_packet(VMXNET3State *s, int qidx, uint32_t tx_ridx) | ||
104 | memset(&txcq_descr, 0, sizeof(txcq_descr)); | ||
105 | txcq_descr.txdIdx = tx_ridx; | ||
106 | txcq_descr.gen = vmxnet3_ring_curr_gen(&s->txq_descr[qidx].comp_ring); | ||
107 | - | ||
108 | + txcq_descr.val1 = cpu_to_le32(txcq_descr.val1); | ||
109 | + txcq_descr.val2 = cpu_to_le32(txcq_descr.val2); | ||
110 | vmxnet3_ring_write_curr_cell(d, &s->txq_descr[qidx].comp_ring, &txcq_descr); | ||
111 | |||
112 | /* Flush changes in TX descriptor before changing the counter value */ | ||
113 | @@ -XXX,XX +XXX,XX @@ vmxnet3_on_rx_done_update_stats(VMXNET3State *s, | ||
114 | } | 20 | } |
115 | } | 21 | if (pid == 0) { |
116 | 22 | int open_max = sysconf(_SC_OPEN_MAX), i; | |
117 | +static inline void | 23 | - char fd_buf[6+10]; |
118 | +vmxnet3_ring_read_curr_txdesc(PCIDevice *pcidev, Vmxnet3Ring *ring, | 24 | - char br_buf[6+IFNAMSIZ] = {0}; |
119 | + struct Vmxnet3_TxDesc *txd) | 25 | - char helper_cmd[PATH_MAX + sizeof(fd_buf) + sizeof(br_buf) + 15]; |
120 | +{ | 26 | + char *fd_buf = NULL; |
121 | + vmxnet3_ring_read_curr_cell(pcidev, ring, txd); | 27 | + char *br_buf = NULL; |
122 | + txd->addr = le64_to_cpu(txd->addr); | 28 | + char *helper_cmd = NULL; |
123 | + txd->val1 = le32_to_cpu(txd->val1); | 29 | |
124 | + txd->val2 = le32_to_cpu(txd->val2); | 30 | for (i = 3; i < open_max; i++) { |
125 | +} | 31 | if (i != sv[1]) { |
126 | + | 32 | @@ -XXX,XX +XXX,XX @@ static int net_bridge_run_helper(const char *helper, const char *bridge, |
127 | static inline bool | 33 | } |
128 | vmxnet3_pop_next_tx_descr(VMXNET3State *s, | ||
129 | int qidx, | ||
130 | @@ -XXX,XX +XXX,XX @@ vmxnet3_pop_next_tx_descr(VMXNET3State *s, | ||
131 | Vmxnet3Ring *ring = &s->txq_descr[qidx].tx_ring; | ||
132 | PCIDevice *d = PCI_DEVICE(s); | ||
133 | |||
134 | - vmxnet3_ring_read_curr_cell(d, ring, txd); | ||
135 | + vmxnet3_ring_read_curr_txdesc(d, ring, txd); | ||
136 | if (txd->gen == vmxnet3_ring_curr_gen(ring)) { | ||
137 | /* Only read after generation field verification */ | ||
138 | smp_rmb(); | ||
139 | /* Re-read to be sure we got the latest version */ | ||
140 | - vmxnet3_ring_read_curr_cell(d, ring, txd); | ||
141 | + vmxnet3_ring_read_curr_txdesc(d, ring, txd); | ||
142 | VMXNET3_RING_DUMP(VMW_RIPRN, "TX", qidx, ring); | ||
143 | *descr_idx = vmxnet3_ring_curr_cell_idx(ring); | ||
144 | vmxnet3_inc_tx_consumption_counter(s, qidx); | ||
145 | @@ -XXX,XX +XXX,XX @@ static void vmxnet3_process_tx_queue(VMXNET3State *s, int qidx) | ||
146 | |||
147 | if (!s->skip_current_tx_pkt) { | ||
148 | data_len = (txd.len > 0) ? txd.len : VMXNET3_MAX_TX_BUF_SIZE; | ||
149 | - data_pa = le64_to_cpu(txd.addr); | ||
150 | + data_pa = txd.addr; | ||
151 | |||
152 | if (!net_tx_pkt_add_raw_fragment(s->tx_pkt, | ||
153 | data_pa, | ||
154 | @@ -XXX,XX +XXX,XX @@ vmxnet3_read_next_rx_descr(VMXNET3State *s, int qidx, int ridx, | ||
155 | Vmxnet3Ring *ring = &s->rxq_descr[qidx].rx_ring[ridx]; | ||
156 | *didx = vmxnet3_ring_curr_cell_idx(ring); | ||
157 | vmxnet3_ring_read_curr_cell(d, ring, dbuf); | ||
158 | + dbuf->addr = le64_to_cpu(dbuf->addr); | ||
159 | + dbuf->val1 = le32_to_cpu(dbuf->val1); | ||
160 | + dbuf->ext1 = le32_to_cpu(dbuf->ext1); | ||
161 | } | ||
162 | |||
163 | static inline uint8_t | ||
164 | @@ -XXX,XX +XXX,XX @@ vmxnet3_pop_rxc_descr(VMXNET3State *s, int qidx, uint32_t *descr_gen) | ||
165 | |||
166 | pci_dma_read(PCI_DEVICE(s), | ||
167 | daddr, &rxcd, sizeof(struct Vmxnet3_RxCompDesc)); | ||
168 | + rxcd.val1 = le32_to_cpu(rxcd.val1); | ||
169 | + rxcd.val2 = le32_to_cpu(rxcd.val2); | ||
170 | + rxcd.val3 = le32_to_cpu(rxcd.val3); | ||
171 | ring_gen = vmxnet3_ring_curr_gen(&s->rxq_descr[qidx].comp_ring); | ||
172 | |||
173 | if (rxcd.gen != ring_gen) { | ||
174 | @@ -XXX,XX +XXX,XX @@ vmxnet3_pci_dma_writev(PCIDevice *pci_dev, | ||
175 | } | ||
176 | } | ||
177 | |||
178 | +static void | ||
179 | +vmxnet3_pci_dma_write_rxcd(PCIDevice *pcidev, dma_addr_t pa, | ||
180 | + struct Vmxnet3_RxCompDesc *rxcd) | ||
181 | +{ | ||
182 | + rxcd->val1 = cpu_to_le32(rxcd->val1); | ||
183 | + rxcd->val2 = cpu_to_le32(rxcd->val2); | ||
184 | + rxcd->val3 = cpu_to_le32(rxcd->val3); | ||
185 | + pci_dma_write(pcidev, pa, rxcd, sizeof(*rxcd)); | ||
186 | +} | ||
187 | + | ||
188 | static bool | ||
189 | vmxnet3_indicate_packet(VMXNET3State *s) | ||
190 | { | ||
191 | @@ -XXX,XX +XXX,XX @@ vmxnet3_indicate_packet(VMXNET3State *s) | ||
192 | } | 34 | } |
193 | 35 | ||
194 | chunk_size = MIN(bytes_left, rxd.len); | 36 | - snprintf(fd_buf, sizeof(fd_buf), "%s%d", "--fd=", sv[1]); |
195 | - vmxnet3_pci_dma_writev(d, data, bytes_copied, | 37 | + fd_buf = g_strdup_printf("%s%d", "--fd=", sv[1]); |
196 | - le64_to_cpu(rxd.addr), chunk_size); | 38 | |
197 | + vmxnet3_pci_dma_writev(d, data, bytes_copied, rxd.addr, chunk_size); | 39 | if (strrchr(helper, ' ') || strrchr(helper, '\t')) { |
198 | bytes_copied += chunk_size; | 40 | /* assume helper is a command */ |
199 | bytes_left -= chunk_size; | 41 | |
200 | 42 | if (strstr(helper, "--br=") == NULL) { | |
201 | vmxnet3_dump_rx_descr(&rxd); | 43 | - snprintf(br_buf, sizeof(br_buf), "%s%s", "--br=", bridge); |
202 | 44 | + br_buf = g_strdup_printf("%s%s", "--br=", bridge); | |
203 | if (ready_rxcd_pa != 0) { | 45 | } |
204 | - pci_dma_write(d, ready_rxcd_pa, &rxcd, sizeof(rxcd)); | 46 | |
205 | + vmxnet3_pci_dma_write_rxcd(d, ready_rxcd_pa, &rxcd); | 47 | - snprintf(helper_cmd, sizeof(helper_cmd), "%s %s %s %s", |
48 | - helper, "--use-vnet", fd_buf, br_buf); | ||
49 | + helper_cmd = g_strdup_printf("%s %s %s %s", helper, | ||
50 | + "--use-vnet", fd_buf, br_buf ? br_buf : ""); | ||
51 | |||
52 | parg = args; | ||
53 | *parg++ = (char *)"sh"; | ||
54 | @@ -XXX,XX +XXX,XX @@ static int net_bridge_run_helper(const char *helper, const char *bridge, | ||
55 | *parg++ = NULL; | ||
56 | |||
57 | execv("/bin/sh", args); | ||
58 | + g_free(helper_cmd); | ||
59 | } else { | ||
60 | /* assume helper is just the executable path name */ | ||
61 | |||
62 | - snprintf(br_buf, sizeof(br_buf), "%s%s", "--br=", bridge); | ||
63 | + br_buf = g_strdup_printf("%s%s", "--br=", bridge); | ||
64 | |||
65 | parg = args; | ||
66 | *parg++ = (char *)helper; | ||
67 | @@ -XXX,XX +XXX,XX @@ static int net_bridge_run_helper(const char *helper, const char *bridge, | ||
68 | |||
69 | execv(helper, args); | ||
206 | } | 70 | } |
207 | 71 | + g_free(fd_buf); | |
208 | memset(&rxcd, 0, sizeof(struct Vmxnet3_RxCompDesc)); | 72 | + g_free(br_buf); |
209 | @@ -XXX,XX +XXX,XX @@ vmxnet3_indicate_packet(VMXNET3State *s) | 73 | _exit(1); |
210 | rxcd.eop = 1; | 74 | |
211 | rxcd.err = (bytes_left != 0); | 75 | } else { |
212 | |||
213 | - pci_dma_write(d, ready_rxcd_pa, &rxcd, sizeof(rxcd)); | ||
214 | + vmxnet3_pci_dma_write_rxcd(d, ready_rxcd_pa, &rxcd); | ||
215 | |||
216 | /* Flush RX descriptor changes */ | ||
217 | smp_wmb(); | ||
218 | diff --git a/hw/net/vmxnet3.h b/hw/net/vmxnet3.h | ||
219 | index XXXXXXX..XXXXXXX 100644 | ||
220 | --- a/hw/net/vmxnet3.h | ||
221 | +++ b/hw/net/vmxnet3.h | ||
222 | @@ -XXX,XX +XXX,XX @@ enum { | ||
223 | struct Vmxnet3_TxDesc { | ||
224 | __le64 addr; | ||
225 | |||
226 | + union { | ||
227 | + struct { | ||
228 | #ifdef __BIG_ENDIAN_BITFIELD | ||
229 | - u32 msscof:14; /* MSS, checksum offset, flags */ | ||
230 | - u32 ext1:1; | ||
231 | - u32 dtype:1; /* descriptor type */ | ||
232 | - u32 rsvd:1; | ||
233 | - u32 gen:1; /* generation bit */ | ||
234 | - u32 len:14; | ||
235 | + u32 msscof:14; /* MSS, checksum offset, flags */ | ||
236 | + u32 ext1:1; | ||
237 | + u32 dtype:1; /* descriptor type */ | ||
238 | + u32 rsvd:1; | ||
239 | + u32 gen:1; /* generation bit */ | ||
240 | + u32 len:14; | ||
241 | #else | ||
242 | - u32 len:14; | ||
243 | - u32 gen:1; /* generation bit */ | ||
244 | - u32 rsvd:1; | ||
245 | - u32 dtype:1; /* descriptor type */ | ||
246 | - u32 ext1:1; | ||
247 | - u32 msscof:14; /* MSS, checksum offset, flags */ | ||
248 | + u32 len:14; | ||
249 | + u32 gen:1; /* generation bit */ | ||
250 | + u32 rsvd:1; | ||
251 | + u32 dtype:1; /* descriptor type */ | ||
252 | + u32 ext1:1; | ||
253 | + u32 msscof:14; /* MSS, checksum offset, flags */ | ||
254 | #endif /* __BIG_ENDIAN_BITFIELD */ | ||
255 | - | ||
256 | + }; | ||
257 | + u32 val1; | ||
258 | + }; | ||
259 | + | ||
260 | + union { | ||
261 | + struct { | ||
262 | #ifdef __BIG_ENDIAN_BITFIELD | ||
263 | - u32 tci:16; /* Tag to Insert */ | ||
264 | - u32 ti:1; /* VLAN Tag Insertion */ | ||
265 | - u32 ext2:1; | ||
266 | - u32 cq:1; /* completion request */ | ||
267 | - u32 eop:1; /* End Of Packet */ | ||
268 | - u32 om:2; /* offload mode */ | ||
269 | - u32 hlen:10; /* header len */ | ||
270 | + u32 tci:16; /* Tag to Insert */ | ||
271 | + u32 ti:1; /* VLAN Tag Insertion */ | ||
272 | + u32 ext2:1; | ||
273 | + u32 cq:1; /* completion request */ | ||
274 | + u32 eop:1; /* End Of Packet */ | ||
275 | + u32 om:2; /* offload mode */ | ||
276 | + u32 hlen:10; /* header len */ | ||
277 | #else | ||
278 | - u32 hlen:10; /* header len */ | ||
279 | - u32 om:2; /* offload mode */ | ||
280 | - u32 eop:1; /* End Of Packet */ | ||
281 | - u32 cq:1; /* completion request */ | ||
282 | - u32 ext2:1; | ||
283 | - u32 ti:1; /* VLAN Tag Insertion */ | ||
284 | - u32 tci:16; /* Tag to Insert */ | ||
285 | + u32 hlen:10; /* header len */ | ||
286 | + u32 om:2; /* offload mode */ | ||
287 | + u32 eop:1; /* End Of Packet */ | ||
288 | + u32 cq:1; /* completion request */ | ||
289 | + u32 ext2:1; | ||
290 | + u32 ti:1; /* VLAN Tag Insertion */ | ||
291 | + u32 tci:16; /* Tag to Insert */ | ||
292 | #endif /* __BIG_ENDIAN_BITFIELD */ | ||
293 | + }; | ||
294 | + u32 val2; | ||
295 | + }; | ||
296 | }; | ||
297 | |||
298 | /* TxDesc.OM values */ | ||
299 | @@ -XXX,XX +XXX,XX @@ struct Vmxnet3_TxDataDesc { | ||
300 | #define VMXNET3_TCD_GEN_DWORD_SHIFT 3 | ||
301 | |||
302 | struct Vmxnet3_TxCompDesc { | ||
303 | - u32 txdIdx:12; /* Index of the EOP TxDesc */ | ||
304 | - u32 ext1:20; | ||
305 | - | ||
306 | + union { | ||
307 | + struct { | ||
308 | +#ifdef __BIG_ENDIAN_BITFIELD | ||
309 | + u32 ext1:20; | ||
310 | + u32 txdIdx:12; /* Index of the EOP TxDesc */ | ||
311 | +#else | ||
312 | + u32 txdIdx:12; /* Index of the EOP TxDesc */ | ||
313 | + u32 ext1:20; | ||
314 | +#endif | ||
315 | + }; | ||
316 | + u32 val1; | ||
317 | + }; | ||
318 | __le32 ext2; | ||
319 | __le32 ext3; | ||
320 | |||
321 | - u32 rsvd:24; | ||
322 | - u32 type:7; /* completion type */ | ||
323 | - u32 gen:1; /* generation bit */ | ||
324 | + union { | ||
325 | + struct { | ||
326 | +#ifdef __BIG_ENDIAN_BITFIELD | ||
327 | + u32 gen:1; /* generation bit */ | ||
328 | + u32 type:7; /* completion type */ | ||
329 | + u32 rsvd:24; | ||
330 | +#else | ||
331 | + u32 rsvd:24; | ||
332 | + u32 type:7; /* completion type */ | ||
333 | + u32 gen:1; /* generation bit */ | ||
334 | +#endif | ||
335 | + }; | ||
336 | + u32 val2; | ||
337 | + }; | ||
338 | }; | ||
339 | |||
340 | struct Vmxnet3_RxDesc { | ||
341 | __le64 addr; | ||
342 | - | ||
343 | + union { | ||
344 | + struct { | ||
345 | #ifdef __BIG_ENDIAN_BITFIELD | ||
346 | - u32 gen:1; /* Generation bit */ | ||
347 | - u32 rsvd:15; | ||
348 | - u32 dtype:1; /* Descriptor type */ | ||
349 | - u32 btype:1; /* Buffer Type */ | ||
350 | - u32 len:14; | ||
351 | + u32 gen:1; /* Generation bit */ | ||
352 | + u32 rsvd:15; | ||
353 | + u32 dtype:1; /* Descriptor type */ | ||
354 | + u32 btype:1; /* Buffer Type */ | ||
355 | + u32 len:14; | ||
356 | #else | ||
357 | - u32 len:14; | ||
358 | - u32 btype:1; /* Buffer Type */ | ||
359 | - u32 dtype:1; /* Descriptor type */ | ||
360 | - u32 rsvd:15; | ||
361 | - u32 gen:1; /* Generation bit */ | ||
362 | + u32 len:14; | ||
363 | + u32 btype:1; /* Buffer Type */ | ||
364 | + u32 dtype:1; /* Descriptor type */ | ||
365 | + u32 rsvd:15; | ||
366 | + u32 gen:1; /* Generation bit */ | ||
367 | #endif | ||
368 | + }; | ||
369 | + u32 val1; | ||
370 | + }; | ||
371 | u32 ext1; | ||
372 | }; | ||
373 | |||
374 | @@ -XXX,XX +XXX,XX @@ struct Vmxnet3_RxDesc { | ||
375 | #define VMXNET3_RXD_GEN_SHIFT 31 | ||
376 | |||
377 | struct Vmxnet3_RxCompDesc { | ||
378 | + union { | ||
379 | + struct { | ||
380 | #ifdef __BIG_ENDIAN_BITFIELD | ||
381 | - u32 ext2:1; | ||
382 | - u32 cnc:1; /* Checksum Not Calculated */ | ||
383 | - u32 rssType:4; /* RSS hash type used */ | ||
384 | - u32 rqID:10; /* rx queue/ring ID */ | ||
385 | - u32 sop:1; /* Start of Packet */ | ||
386 | - u32 eop:1; /* End of Packet */ | ||
387 | - u32 ext1:2; | ||
388 | - u32 rxdIdx:12; /* Index of the RxDesc */ | ||
389 | + u32 ext2:1; | ||
390 | + u32 cnc:1; /* Checksum Not Calculated */ | ||
391 | + u32 rssType:4; /* RSS hash type used */ | ||
392 | + u32 rqID:10; /* rx queue/ring ID */ | ||
393 | + u32 sop:1; /* Start of Packet */ | ||
394 | + u32 eop:1; /* End of Packet */ | ||
395 | + u32 ext1:2; | ||
396 | + u32 rxdIdx:12; /* Index of the RxDesc */ | ||
397 | #else | ||
398 | - u32 rxdIdx:12; /* Index of the RxDesc */ | ||
399 | - u32 ext1:2; | ||
400 | - u32 eop:1; /* End of Packet */ | ||
401 | - u32 sop:1; /* Start of Packet */ | ||
402 | - u32 rqID:10; /* rx queue/ring ID */ | ||
403 | - u32 rssType:4; /* RSS hash type used */ | ||
404 | - u32 cnc:1; /* Checksum Not Calculated */ | ||
405 | - u32 ext2:1; | ||
406 | + u32 rxdIdx:12; /* Index of the RxDesc */ | ||
407 | + u32 ext1:2; | ||
408 | + u32 eop:1; /* End of Packet */ | ||
409 | + u32 sop:1; /* Start of Packet */ | ||
410 | + u32 rqID:10; /* rx queue/ring ID */ | ||
411 | + u32 rssType:4; /* RSS hash type used */ | ||
412 | + u32 cnc:1; /* Checksum Not Calculated */ | ||
413 | + u32 ext2:1; | ||
414 | #endif /* __BIG_ENDIAN_BITFIELD */ | ||
415 | + }; | ||
416 | + u32 val1; | ||
417 | + }; | ||
418 | |||
419 | __le32 rssHash; /* RSS hash value */ | ||
420 | |||
421 | + union { | ||
422 | + struct { | ||
423 | #ifdef __BIG_ENDIAN_BITFIELD | ||
424 | - u32 tci:16; /* Tag stripped */ | ||
425 | - u32 ts:1; /* Tag is stripped */ | ||
426 | - u32 err:1; /* Error */ | ||
427 | - u32 len:14; /* data length */ | ||
428 | + u32 tci:16; /* Tag stripped */ | ||
429 | + u32 ts:1; /* Tag is stripped */ | ||
430 | + u32 err:1; /* Error */ | ||
431 | + u32 len:14; /* data length */ | ||
432 | #else | ||
433 | - u32 len:14; /* data length */ | ||
434 | - u32 err:1; /* Error */ | ||
435 | - u32 ts:1; /* Tag is stripped */ | ||
436 | - u32 tci:16; /* Tag stripped */ | ||
437 | + u32 len:14; /* data length */ | ||
438 | + u32 err:1; /* Error */ | ||
439 | + u32 ts:1; /* Tag is stripped */ | ||
440 | + u32 tci:16; /* Tag stripped */ | ||
441 | #endif /* __BIG_ENDIAN_BITFIELD */ | ||
442 | + }; | ||
443 | + u32 val2; | ||
444 | + }; | ||
445 | |||
446 | - | ||
447 | + union { | ||
448 | + struct { | ||
449 | #ifdef __BIG_ENDIAN_BITFIELD | ||
450 | - u32 gen:1; /* generation bit */ | ||
451 | - u32 type:7; /* completion type */ | ||
452 | - u32 fcs:1; /* Frame CRC correct */ | ||
453 | - u32 frg:1; /* IP Fragment */ | ||
454 | - u32 v4:1; /* IPv4 */ | ||
455 | - u32 v6:1; /* IPv6 */ | ||
456 | - u32 ipc:1; /* IP Checksum Correct */ | ||
457 | - u32 tcp:1; /* TCP packet */ | ||
458 | - u32 udp:1; /* UDP packet */ | ||
459 | - u32 tuc:1; /* TCP/UDP Checksum Correct */ | ||
460 | - u32 csum:16; | ||
461 | + u32 gen:1; /* generation bit */ | ||
462 | + u32 type:7; /* completion type */ | ||
463 | + u32 fcs:1; /* Frame CRC correct */ | ||
464 | + u32 frg:1; /* IP Fragment */ | ||
465 | + u32 v4:1; /* IPv4 */ | ||
466 | + u32 v6:1; /* IPv6 */ | ||
467 | + u32 ipc:1; /* IP Checksum Correct */ | ||
468 | + u32 tcp:1; /* TCP packet */ | ||
469 | + u32 udp:1; /* UDP packet */ | ||
470 | + u32 tuc:1; /* TCP/UDP Checksum Correct */ | ||
471 | + u32 csum:16; | ||
472 | #else | ||
473 | - u32 csum:16; | ||
474 | - u32 tuc:1; /* TCP/UDP Checksum Correct */ | ||
475 | - u32 udp:1; /* UDP packet */ | ||
476 | - u32 tcp:1; /* TCP packet */ | ||
477 | - u32 ipc:1; /* IP Checksum Correct */ | ||
478 | - u32 v6:1; /* IPv6 */ | ||
479 | - u32 v4:1; /* IPv4 */ | ||
480 | - u32 frg:1; /* IP Fragment */ | ||
481 | - u32 fcs:1; /* Frame CRC correct */ | ||
482 | - u32 type:7; /* completion type */ | ||
483 | - u32 gen:1; /* generation bit */ | ||
484 | + u32 csum:16; | ||
485 | + u32 tuc:1; /* TCP/UDP Checksum Correct */ | ||
486 | + u32 udp:1; /* UDP packet */ | ||
487 | + u32 tcp:1; /* TCP packet */ | ||
488 | + u32 ipc:1; /* IP Checksum Correct */ | ||
489 | + u32 v6:1; /* IPv6 */ | ||
490 | + u32 v4:1; /* IPv4 */ | ||
491 | + u32 frg:1; /* IP Fragment */ | ||
492 | + u32 fcs:1; /* Frame CRC correct */ | ||
493 | + u32 type:7; /* completion type */ | ||
494 | + u32 gen:1; /* generation bit */ | ||
495 | #endif /* __BIG_ENDIAN_BITFIELD */ | ||
496 | + }; | ||
497 | + u32 val3; | ||
498 | + }; | ||
499 | }; | ||
500 | |||
501 | /* fields in RxCompDesc we access via Vmxnet3_GenericDesc.dword[3] */ | ||
502 | -- | 76 | -- |
503 | 2.7.4 | 77 | 2.5.0 |
504 | 78 | ||
505 | 79 | diff view generated by jsdifflib |
1 | From: Mao Zhongyi <maozy.fnst@cn.fujitsu.com> | 1 | From: Zhang Chen <chen.zhang@intel.com> |
---|---|---|---|
2 | 2 | ||
3 | Cc: Peter Maydell <peter.maydell@linaro.org> | 3 | This patch to fix the origin "char *data" memory leak, code style issue |
4 | Cc: Jason Wang <jasowang@redhat.com> | 4 | and add necessary check here. |
5 | Cc: Zhang Chen <zhangckid@gmail.com> | 5 | Reported-by: Coverity (CID 1402785) |
6 | Cc: Li Zhijian <lizhijian@cn.fujitsu.com> | 6 | |
7 | Cc: Paolo Bonzini <pbonzini@redhat.com> | 7 | Signed-off-by: Zhang Chen <chen.zhang@intel.com> |
8 | Fixes: 8ec14402029d783720f4312ed8a925548e1dad61 | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reported-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Reported-by: Paolo Bonzini <pbonzini@redhat.com> | ||
11 | Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com> | ||
12 | Reviewed-by: Darren Kenny <darren.kenny@oracle.com> | ||
13 | Signed-off-by: Jason Wang <jasowang@redhat.com> | 9 | Signed-off-by: Jason Wang <jasowang@redhat.com> |
14 | --- | 10 | --- |
15 | net/colo-compare.c | 2 +- | 11 | net/colo-compare.c | 27 ++++++++++++++++++++------- |
16 | 1 file changed, 1 insertion(+), 1 deletion(-) | 12 | 1 file changed, 20 insertions(+), 7 deletions(-) |
17 | 13 | ||
18 | diff --git a/net/colo-compare.c b/net/colo-compare.c | 14 | diff --git a/net/colo-compare.c b/net/colo-compare.c |
19 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/net/colo-compare.c | 16 | --- a/net/colo-compare.c |
21 | +++ b/net/colo-compare.c | 17 | +++ b/net/colo-compare.c |
22 | @@ -XXX,XX +XXX,XX @@ static int packet_enqueue(CompareState *s, int mode, Connection **con) | 18 | @@ -XXX,XX +XXX,XX @@ static int compare_chr_send(CompareState *s, |
23 | "drop packet"); | 19 | uint32_t vnet_hdr_len, |
20 | bool notify_remote_frame); | ||
21 | |||
22 | +static bool packet_matches_str(const char *str, | ||
23 | + const uint8_t *buf, | ||
24 | + uint32_t packet_len) | ||
25 | +{ | ||
26 | + if (packet_len != strlen(str)) { | ||
27 | + return false; | ||
28 | + } | ||
29 | + | ||
30 | + return !memcmp(str, buf, strlen(str)); | ||
31 | +} | ||
32 | + | ||
33 | static void notify_remote_frame(CompareState *s) | ||
34 | { | ||
35 | char msg[] = "DO_CHECKPOINT"; | ||
36 | @@ -XXX,XX +XXX,XX @@ static void compare_notify_rs_finalize(SocketReadState *notify_rs) | ||
37 | { | ||
38 | CompareState *s = container_of(notify_rs, CompareState, notify_rs); | ||
39 | |||
40 | - /* Get Xen colo-frame's notify and handle the message */ | ||
41 | - char *data = g_memdup(notify_rs->buf, notify_rs->packet_len); | ||
42 | - char msg[] = "COLO_COMPARE_GET_XEN_INIT"; | ||
43 | + const char msg[] = "COLO_COMPARE_GET_XEN_INIT"; | ||
44 | int ret; | ||
45 | |||
46 | - if (!strcmp(data, "COLO_USERSPACE_PROXY_INIT")) { | ||
47 | + if (packet_matches_str("COLO_USERSPACE_PROXY_INIT", | ||
48 | + notify_rs->buf, | ||
49 | + notify_rs->packet_len)) { | ||
50 | ret = compare_chr_send(s, (uint8_t *)msg, strlen(msg), 0, true); | ||
51 | if (ret < 0) { | ||
52 | error_report("Notify Xen COLO-frame INIT failed"); | ||
24 | } | 53 | } |
54 | - } | ||
55 | - | ||
56 | - if (!strcmp(data, "COLO_CHECKPOINT")) { | ||
57 | + } else if (packet_matches_str("COLO_CHECKPOINT", | ||
58 | + notify_rs->buf, | ||
59 | + notify_rs->packet_len)) { | ||
60 | /* colo-compare do checkpoint, flush pri packet and remove sec packet */ | ||
61 | g_queue_foreach(&s->conn_list, colo_flush_packets, s); | ||
62 | + } else { | ||
63 | + error_report("COLO compare got unsupported instruction"); | ||
25 | } | 64 | } |
26 | - con = &conn; | ||
27 | + *con = conn; | ||
28 | |||
29 | return 0; | ||
30 | } | 65 | } |
66 | |||
31 | -- | 67 | -- |
32 | 2.7.4 | 68 | 2.5.0 |
33 | 69 | ||
34 | 70 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | This reverts commit 5e89dc01133f8f5e621f6b66b356c6f37d31dafb since: | ||
2 | 1 | ||
3 | - we should use ID in the spec instead the one used by OEM | ||
4 | - in the future, we should allow changing id through either property | ||
5 | or EEPROM file. | ||
6 | |||
7 | Cc: Stefan Weil <sw@weilnetz.de> | ||
8 | Cc: Michael Nawrocki <michael.nawrocki@gtri.gatech.edu> | ||
9 | Cc: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Cc: Michael S. Tsirkin <mst@redhat.com> | ||
11 | Reviewed-by: Stefan Weil <sw@weilnetz.de> | ||
12 | Signed-off-by: Jason Wang <jasowang@redhat.com> | ||
13 | --- | ||
14 | hw/net/eepro100.c | 13 ------------- | ||
15 | include/hw/compat.h | 4 ---- | ||
16 | include/hw/pci/pci.h | 1 - | ||
17 | qemu-options.hx | 2 +- | ||
18 | 4 files changed, 1 insertion(+), 19 deletions(-) | ||
19 | |||
20 | diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/hw/net/eepro100.c | ||
23 | +++ b/hw/net/eepro100.c | ||
24 | @@ -XXX,XX +XXX,XX @@ typedef struct { | ||
25 | const char *name; | ||
26 | const char *desc; | ||
27 | uint16_t device_id; | ||
28 | - uint16_t alt_device_id; | ||
29 | uint8_t revision; | ||
30 | uint16_t subsystem_vendor_id; | ||
31 | uint16_t subsystem_id; | ||
32 | @@ -XXX,XX +XXX,XX @@ typedef struct { | ||
33 | /* Quasi static device properties (no need to save them). */ | ||
34 | uint16_t stats_size; | ||
35 | bool has_extended_tcb_support; | ||
36 | - bool use_alt_device_id; | ||
37 | } EEPRO100State; | ||
38 | |||
39 | /* Word indices in EEPROM. */ | ||
40 | @@ -XXX,XX +XXX,XX @@ static void e100_nic_realize(PCIDevice *pci_dev, Error **errp) | ||
41 | |||
42 | TRACE(OTHER, logout("\n")); | ||
43 | |||
44 | - /* By default, the i82559a adapter uses the legacy PCI ID (for the | ||
45 | - * i82557). This allows the PCI ID to be changed to the alternate | ||
46 | - * i82559 ID if needed. | ||
47 | - */ | ||
48 | - if (s->use_alt_device_id && strcmp(info->name, "i82559a") == 0) { | ||
49 | - pci_config_set_device_id(s->dev.config, info->alt_device_id); | ||
50 | - } | ||
51 | - | ||
52 | s->device = info->device; | ||
53 | |||
54 | e100_pci_reset(s, &local_err); | ||
55 | @@ -XXX,XX +XXX,XX @@ static E100PCIDeviceInfo e100_devices[] = { | ||
56 | .desc = "Intel i82559A Ethernet", | ||
57 | .device = i82559A, | ||
58 | .device_id = PCI_DEVICE_ID_INTEL_82557, | ||
59 | - .alt_device_id = PCI_DEVICE_ID_INTEL_82559, | ||
60 | .revision = 0x06, | ||
61 | .stats_size = 80, | ||
62 | .has_extended_tcb_support = true, | ||
63 | @@ -XXX,XX +XXX,XX @@ static E100PCIDeviceInfo *eepro100_get_class(EEPRO100State *s) | ||
64 | |||
65 | static Property e100_properties[] = { | ||
66 | DEFINE_NIC_PROPERTIES(EEPRO100State, conf), | ||
67 | - DEFINE_PROP_BOOL("x-use-alt-device-id", EEPRO100State, use_alt_device_id, | ||
68 | - true), | ||
69 | DEFINE_PROP_END_OF_LIST(), | ||
70 | }; | ||
71 | |||
72 | diff --git a/include/hw/compat.h b/include/hw/compat.h | ||
73 | index XXXXXXX..XXXXXXX 100644 | ||
74 | --- a/include/hw/compat.h | ||
75 | +++ b/include/hw/compat.h | ||
76 | @@ -XXX,XX +XXX,XX @@ | ||
77 | .driver = "virtio-tablet-device",\ | ||
78 | .property = "wheel-axis",\ | ||
79 | .value = "false",\ | ||
80 | - },{\ | ||
81 | - .driver = "i82559a",\ | ||
82 | - .property = "x-use-alt-device-id",\ | ||
83 | - .value = "false",\ | ||
84 | }, | ||
85 | |||
86 | #define HW_COMPAT_2_9 \ | ||
87 | diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h | ||
88 | index XXXXXXX..XXXXXXX 100644 | ||
89 | --- a/include/hw/pci/pci.h | ||
90 | +++ b/include/hw/pci/pci.h | ||
91 | @@ -XXX,XX +XXX,XX @@ extern bool pci_available; | ||
92 | /* Intel (0x8086) */ | ||
93 | #define PCI_DEVICE_ID_INTEL_82551IT 0x1209 | ||
94 | #define PCI_DEVICE_ID_INTEL_82557 0x1229 | ||
95 | -#define PCI_DEVICE_ID_INTEL_82559 0x1030 | ||
96 | #define PCI_DEVICE_ID_INTEL_82801IR 0x2922 | ||
97 | |||
98 | /* Red Hat / Qumranet (for QEMU) -- see pci-ids.txt */ | ||
99 | diff --git a/qemu-options.hx b/qemu-options.hx | ||
100 | index XXXXXXX..XXXXXXX 100644 | ||
101 | --- a/qemu-options.hx | ||
102 | +++ b/qemu-options.hx | ||
103 | @@ -XXX,XX +XXX,XX @@ that the card should have; this option currently only affects virtio cards; set | ||
104 | @var{v} = 0 to disable MSI-X. If no @option{-net} option is specified, a single | ||
105 | NIC is created. QEMU can emulate several different models of network card. | ||
106 | Valid values for @var{type} are | ||
107 | -@code{virtio}, @code{i82551}, @code{i82557b}, @code{i82559a}, @code{i82559er}, | ||
108 | +@code{virtio}, @code{i82551}, @code{i82557b}, @code{i82559er}, | ||
109 | @code{ne2k_pci}, @code{ne2k_isa}, @code{pcnet}, @code{rtl8139}, | ||
110 | @code{e1000}, @code{smc91c111}, @code{lance} and @code{mcf_fec}. | ||
111 | Not all devices are supported on all targets. Use @code{-net nic,model=help} | ||
112 | -- | ||
113 | 2.7.4 | ||
114 | |||
115 | diff view generated by jsdifflib |