qemu-trivial
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-trivial] [PATCH] hw/net/opencores_eth: Allocating Large sized arra


From: Zhou Jie
Subject: [Qemu-trivial] [PATCH] hw/net/opencores_eth: Allocating Large sized arrays to heap
Date: Tue, 26 Apr 2016 11:35:13 +0800

open_eth_start_xmit has a huge stack usage of 65536 bytes approx.
Moving large arrays to heap to reduce stack usage.

Signed-off-by: Zhou Jie <address@hidden>
---
 hw/net/opencores_eth.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/hw/net/opencores_eth.c b/hw/net/opencores_eth.c
index c6094fb..ba23922 100644
--- a/hw/net/opencores_eth.c
+++ b/hw/net/opencores_eth.c
@@ -483,7 +483,7 @@ static NetClientInfo net_open_eth_info = {
 
 static void open_eth_start_xmit(OpenEthState *s, desc *tx)
 {
-    uint8_t buf[65536];
+    uint8_t *buf = NULL;
     unsigned len = GET_FIELD(tx->len_flags, TXD_LEN);
     unsigned tx_len = len;
 
@@ -498,6 +498,7 @@ static void open_eth_start_xmit(OpenEthState *s, desc *tx)
 
     trace_open_eth_start_xmit(tx->buf_ptr, len, tx_len);
 
+    buf = g_new(uint8_t, tx_len);
     if (len > tx_len) {
         len = tx_len;
     }
@@ -506,6 +507,7 @@ static void open_eth_start_xmit(OpenEthState *s, desc *tx)
         memset(buf + len, 0, tx_len - len);
     }
     qemu_send_packet(qemu_get_queue(s->nic), buf, tx_len);
+    g_free(buf);
 
     if (tx->len_flags & TXD_WR) {
         s->tx_desc = 0;
-- 
2.5.5






reply via email to

[Prev in Thread] Current Thread [Next in Thread]