diff options
author | Zhou Jie <zhoujie2011@cn.fujitsu.com> | 2016-04-27 10:07:48 +0800 |
---|---|---|
committer | Max Filippov <jcmvbkbc@gmail.com> | 2016-05-23 22:10:16 +0300 |
commit | ea4d824168ce2a309ccf26fa20c6e4f9e3d47c82 (patch) | |
tree | bcd9a6d20787db195db178931db7758dc9b761fa /hw | |
parent | aa8e0ab975e8c83c114ed8071be94dce232f75eb (diff) | |
download | qemu-ea4d824168ce2a309ccf26fa20c6e4f9e3d47c82.tar.gz qemu-ea4d824168ce2a309ccf26fa20c6e4f9e3d47c82.tar.bz2 qemu-ea4d824168ce2a309ccf26fa20c6e4f9e3d47c82.zip |
hw/net/opencores_eth: Allocating Large sized arrays to heap
open_eth_start_xmit has a huge stack usage of 65536 bytes approx.
Moving large arrays to heap to reduce stack usage.
Reduce size of a buffer allocated on stack to 0x600 bytes, which is the
maximal frame length when HUGEN bit is not set in MODER, only allocate
buffer on heap when that is too small. Thus heap is not used in typical
use case.
Signed-off-by: Zhou Jie <zhoujie2011@cn.fujitsu.com>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/net/opencores_eth.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/hw/net/opencores_eth.c b/hw/net/opencores_eth.c index c2699922e6..484d113eb6 100644 --- a/hw/net/opencores_eth.c +++ b/hw/net/opencores_eth.c @@ -482,7 +482,8 @@ static NetClientInfo net_open_eth_info = { static void open_eth_start_xmit(OpenEthState *s, desc *tx) { - uint8_t buf[65536]; + uint8_t *buf = NULL; + uint8_t buffer[0x600]; unsigned len = GET_FIELD(tx->len_flags, TXD_LEN); unsigned tx_len = len; @@ -497,6 +498,11 @@ static void open_eth_start_xmit(OpenEthState *s, desc *tx) trace_open_eth_start_xmit(tx->buf_ptr, len, tx_len); + if (tx_len > sizeof(buffer)) { + buf = g_new(uint8_t, tx_len); + } else { + buf = buffer; + } if (len > tx_len) { len = tx_len; } @@ -505,6 +511,9 @@ 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); + if (tx_len > sizeof(buffer)) { + g_free(buf); + } if (tx->len_flags & TXD_WR) { s->tx_desc = 0; |