OP-TEE / optee_os

Trusted side of the TEE
Other
1.57k stars 1.06k forks source link

QEMU only have LO network interface #3949

Closed geneva1 closed 4 years ago

geneva1 commented 4 years ago

Why QEMU only have lo network interface ? What about eth0that gives the qemu session internet capability ?

Starting syslogd: OK
Starting klogd: OK
Initializing random number generator... [    3.367620] random: dd: uninitialized urandom read (512 bytes read)
done.
Set permissions on /dev/tee*: OK
Create/set permissions on /data/tee: OK
Starting tee-supplicant: OK
Starting network: OK
Starting network (udhcpc): FAIL

Welcome to Buildroot, type root or test to login
buildroot login: root
# ifconfig
lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

# 
rog@rog-GL502VMK:~/Documents/optee-qemu/build$ cat common.mk | grep network -C 10
ifeq ($(QEMU_VIRTFS_ENABLE),y)
QEMU_CONFIGURE_PARAMS_COMMON +=  --enable-virtfs
QEMU_EXTRA_ARGS +=\
    -fsdev local,id=fsdev0,path=$(QEMU_VIRTFS_HOST_DIR),security_model=none \
    -device virtio-9p-device,fsdev=fsdev0,mount_tag=host
endif

ifeq ($(GDBSERVER),y)
HOSTFWD := ,hostfwd=tcp::12345-:12345
endif
# Enable QEMU SLiRP user networking
QEMU_EXTRA_ARGS +=\
    -netdev user,id=vmnic$(HOSTFWD) -device virtio-net-device,netdev=vmnic

define run-help
    @echo
    @echo \* QEMU is now waiting to start the execution
    @echo \* Start execution with either a \'c\' followed by \<enter\> in the QEMU console or
    @echo \* attach a debugger and continue from there.
    @echo \*
    @echo \* To run OP-TEE tests, use the xtest command in the \'Normal World\' terminal
rog@rog-GL502VMK:~/Documents/optee-qemu/build$ cat kconfigs/qemu.conf | grep 1000
# CONFIG_HZ_1000 is not set
CONFIG_PHYSICAL_START=0x1000000
CONFIG_CAN_SJA1000=m
CONFIG_CAN_SJA1000_ISA=m
CONFIG_CAN_SJA1000_PLATFORM=m
CONFIG_PATA_RZ1000=m
CONFIG_E1000=m
CONFIG_E1000E=m
CONFIG_E1000E_HWTS=y
CONFIG_NET_SB1000=m
CONFIG_REGULATOR_SLG51000=m
CONFIG_DVB_TUNER_ITD1000=m
CONFIG_WILC1000=m
CONFIG_WILC1000_SDIO=m
CONFIG_WILC1000_SPI=m
CONFIG_WILC1000_HW_OOB_INTR=y
CONFIG_CC10001_ADC=m
CONFIG_LMP91000=m
rog@rog-GL502VMK:~/Documents/optee-qemu/build$ 

I tried to re-compile the kernel with CONFIG_E1000=y and CONFIG_E1000E=y , but lsmod returns nothing, and eth0 interface still does not show up

geneva1 commented 4 years ago

I have re-compiled QEMU with QEMU_USERNET_ENABLE ?=y , but eth0 interface still does not show up in ifconfig. Why ?

rog@rog-GL502VMK:~/Documents/optee-qemu/build$ cat common.mk | grep -C 10 USERNET

CCACHE ?= $(shell which ccache) # Don't remove this comment (space is needed)

# Accessing a shared folder on the host from QEMU:
# # Set QEMU_VIRTFS_ENABLE to 'y' and adjust QEMU_VIRTFS_HOST_DIR
# # Then in QEMU, run:
# # $ mount -t 9p -o trans=virtio host <mount_point>
QEMU_VIRTFS_ENABLE      ?= y
QEMU_VIRTFS_HOST_DIR    ?= $(ROOT)

QEMU_USERNET_ENABLE     ?= y

################################################################################
# Mandatory for autotools (for specifying --host)
################################################################################
ifeq ($(COMPILE_NS_USER),64)
MULTIARCH           := aarch64-linux-gnu
else
MULTIARCH           := arm-linux-gnueabihf
endif

rog@rog-GL502VMK:~/Documents/optee-qemu/build$ 
etienne-lms commented 4 years ago

sorry, i can't tell.

geneva1 commented 4 years ago

Starting network (udhcpc): FAIL

Why the kernel start-up log showed failure in starting udcpc network ?

I also tried to use -device e1000,netdev=vmnic instead of -device virtio-net-device,netdev=vmnic in common.mk , but eth0 interface still does not show up.

geneva1 commented 4 years ago

@etienne-lms I had added CONFIG_IP_PNP_DHCP=y and CONFIG_IP_PNP=y to kernel config file, kconfigs/qemu.conf, but kernel start-up log still show Starting network (udhcpc): FAIL

geneva1 commented 4 years ago

@etienne-lms For dhcp installation, http://www.linuxfromscratch.org/blfs/view/svn/basicnet/dhcp.html shows more than just kernel config modifications (which I had already done).

Besides, I only have the following dhcp-related files inside QEMU session.

# find / -name "*dhcp*"
/tmp/udhcpc.log
/sbin/udhcpc
/usr/share/udhcpc
/etc/init.d/S50udhcpc
# 
# cat /etc/init.d/S50udhcpc
#!/bin/sh
case "$1" in
  start)
    printf "Starting network (udhcpc): "
    udhcpc >> /var/log/udhcpc.log 2>&1
    [ $? = 0 ] && echo "OK" || echo "FAIL"
    ;;
  stop)
    printf "Stopping network (udhcpc): "
    killall udhcpc
    [ $? = 0 ] && echo "OK" || echo "FAIL"
    ;;
  restart|reload)
    "$0" stop
    "$0" start
    ;;
  *)
    echo "Usage: $0 {start|stop|restart}"
    exit 1
esac

exit $?

#
# /etc/init.d/S50udhcpc start
Starting network (udhcpc): FAIL
# 

Could you advise ?

etienne-lms commented 4 years ago

Sorry. I never used that on Qemu. Maybe Qemu the not the most handy setup with testing network stuff. I can't tell. I would recommend you start from an unmodified OP-TEE setup (qemu_v8 for example) and change configuration step by step.

geneva1 commented 4 years ago

@etienne-lms I had actually tried to rebuild everything for the netfilter and netfilter_queue issue that I had earlier. And it actually worked well only for qemu_v7, not qemu_v8. I do not know why.

Now, I am adding dhcp feature on top of the successful build of qemu bundled with netfilter and netfilter_queue

geneva1 commented 4 years ago

@msa2 @igoropaniuk Do you have any idea about this dhcp issue ?

github-actions[bot] commented 4 years ago

This issue has been marked as a stale issue because it has been open (more than) 30 days with no activity. Remove the stale label or add a comment, otherwise this issue will automatically be closed in 5 days. Note, that you can always re-open a closed issue at any time.

rezamarzban commented 3 years ago

I have this problem also, And i had deep research about this problem for one day completely ... . I tested all ways, but still the problem is exist. I have headache ... .

Only dsl.iso (damn small linux iso cd that use KNOPPIX) can bring up network in qemu network user mode, So it is needed to having deep research that how it can bring up this network?