keystone-enclave / keystone

Keystone Enclave (QEMU + HiFive Unleashed)
Other
466 stars 134 forks source link

keystone CVA6's runing : about network error #409

Open JefferryDengCJ opened 10 months ago

JefferryDengCJ commented 10 months ago

............................................................................. done!

OpenSBI v1.1


/ \ / __ _ _ __ (___ _) ' \ / \ '_ \ ___ \ _ < __ _) __/ ____) _) _ ____/ ./ _ _ _ _____/ __/___
_

[SM] Initializing ... hart [0] [SM] Keystone security monitor has been initialized! 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 Platform Name : ARIANE RISC-V Platform Features : medeleg Platform HART Count : 1 Platform IPI Device : aclint-mswi Platform Timer Device : aclint-mtimer @ 1000000Hz Platform Console Device : uart8250 Platform HSM Device : --- Platform Reboot Device : --- Platform Shutdown Device : --- Firmware Base : 0x80000000 Firmware Size : 364 KB Runtime SBI Version : 1.0

Domain0 Name : root Domain0 Boot HART : 0 Domain0 HARTs : 0* Domain0 Region00 : 0x0000000002008000-0x000000000200bfff (I) Domain0 Region01 : 0x0000000002000000-0x0000000002007fff (I) Domain0 Region02 : 0x0000000080000000-0x000000008007ffff () Domain0 Region03 : 0x0000000000000000-0xffffffffffffffff (R,W,X) Domain0 Next Address : 0x0000000080200000 Domain0 Next Arg1 : 0x0000000082200000 Domain0 Next Mode : S-mode Domain0 SysReset : yes

Boot HART ID : 0 Boot HART Domain : root Boot HART Priv Version : v1.12 Boot HART Base ISA : rv64imafdc Boot HART ISA Extensions : none Boot HART PMP Count : 8 Boot HART PMP Granularity : 8 Boot HART PMP Address Bits: 54 Boot HART MHPM Count : 0 Boot HART MIDELEG : 0x0000000000000222 Boot HART MEDELEG : 0x000000000000b109 [ 0.000000] Linux version 6.1.32 (jefferry@localhost-centos7) (riscv64-buildroot-linux-gnu-gcc.br_real (Buildroot 2023.02.2) 11.4.0, GNU ld (GNU Binutils) 2.38) #4 SMP Thu Jan 11 22:26:17 CST 2024 [ 0.000000] OF: fdt: Ignoring memory range 0x80000000 - 0x80200000 [ 0.000000] Machine model: eth,ariane-bare [ 0.000000] efi: UEFI not found. [ 0.000000] Zone ranges: [ 0.000000] DMA32 [mem 0x0000000080200000-0x00000000bfffffff] [ 0.000000] Normal empty [ 0.000000] Movable zone start for each node [ 0.000000] Early memory node ranges [ 0.000000] node 0: [mem 0x0000000080200000-0x00000000bfffffff] [ 0.000000] Initmem setup node 0 [mem 0x0000000080200000-0x00000000bfffffff] [ 0.000000] SBI specification v1.0 detected [ 0.000000] SBI implementation ID=0x1 Version=0x10001 [ 0.000000] SBI TIME extension detected [ 0.000000] SBI IPI extension detected [ 0.000000] SBI RFENCE extension detected [ 0.000000] SBI HSM extension detected [ 0.000000] riscv: base ISA extensions acdfim [ 0.000000] riscv: ELF capabilities acdfim [ 0.000000] percpu: Embedded 15 pages/cpu s22376 r8192 d30872 u61440 [ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 258055 [ 0.000000] Kernel command line: earlyprintk initcall_debug [ 0.000000] Unknown kernel command line parameters "earlyprintk", will be passed to user space. [ 0.000000] Dentry cache hash table entries: 131072 (order: 8, 1048576 bytes, linear) [ 0.000000] Inode-cache hash table entries: 65536 (order: 7, 524288 bytes, linear) [ 0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off [ 0.000000] Memory: 1005984K/1046528K available (4947K kernel code, 4212K rwdata, 2048K rodata, 10855K init, 388K bss, 40544K reserved, 0K cma-reserved) [ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1 [ 0.000000] rcu: Hierarchical RCU implementation. [ 0.000000] rcu: RCU event tracing is enabled. [ 0.000000] rcu: RCU restricting CPUs from NR_CPUS=64 to nr_cpu_ids=1. [ 0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 10 jiffies. [ 0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=1 [ 0.000000] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0 [ 0.000000] riscv-intc: 64 local interrupts mapped [ 0.000000] plic: interrupt-controller@c000000: mapped 30 interrupts with 1 handlers for 2 contexts. [ 0.000000] rcu: srcu_init: Setting srcu_struct sizes based on contention. [ 0.000000] riscv-timer: riscv_timer_init_dt: Registering clocksource cpuid [0] hartid [0] [ 0.000000] clocksource: riscv_clocksource: mask: 0xffffffffffffffff max_cycles: 0x5c40939b5, max_idle_ns: 440795202646 ns [ 0.000145] sched_clock: 64 bits at 25MHz, resolution 40ns, wraps every 4398046511100ns [ 0.005682] Calibrating delay loop (skipped), value calculated using timer frequency.. 50.00 BogoMIPS (lpj=250000) [ 0.006779] pid_max: default: 32768 minimum: 301 [ 0.021548] Mount-cache hash table entries: 2048 (order: 2, 16384 bytes, linear) [ 0.024296] Mountpoint-cache hash table entries: 2048 (order: 2, 16384 bytes, linear) [ 0.163872] riscv: ELF compat mode unsupported [ 0.167025] ASID allocator using 16 bits (65536 entries) [ 0.187795] rcu: Hierarchical SRCU implementation. [ 0.188100] rcu: Max phase no-delay instances is 1000. [ 0.236347] EFI services will not be available. [ 0.256073] smp: Bringing up secondary CPUs ... [ 0.256547] smp: Brought up 1 node, 1 CPU [ 0.285274] devtmpfs: initialized [ 0.366286] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns [ 0.370278] futex hash table entries: 256 (order: 2, 16384 bytes, linear) [ 0.497519] NET: Registered PF_NETLINK/PF_ROUTE protocol family [ 1.219325] usbcore: registered new interface driver usbfs [ 1.223624] usbcore: registered new interface driver hub [ 1.226336] usbcore: registered new device driver usb [ 1.243176] pps_core: LinuxPPS API ver. 1 registered [ 1.243663] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti giometti@linux.it [ 1.247583] PTP clock support registered [ 1.343301] clocksource: Switched to clocksource riscv_clocksource [ 1.525649] NET: Registered PF_INET protocol family [ 1.548307] IP idents hash table entries: 16384 (order: 5, 131072 bytes, linear) [ 1.656815] tcp_listen_portaddr_hash hash table entries: 512 (order: 1, 8192 bytes, linear) [ 1.658397] Table-perturb hash table entries: 65536 (order: 6, 262144 bytes, linear) [ 1.659601] TCP established hash table entries: 8192 (order: 4, 65536 bytes, linear) [ 1.664956] TCP bind hash table entries: 8192 (order: 6, 262144 bytes, linear) [ 1.679161] TCP: Hash tables configured (established 8192 bind 8192) [ 1.689263] UDP hash table entries: 512 (order: 2, 16384 bytes, linear) [ 1.692743] UDP-Lite hash table entries: 512 (order: 2, 16384 bytes, linear) [ 1.708364] NET: Registered PF_UNIX/PF_LOCAL protocol family [ 1.756098] RPC: Registered named UNIX socket transport module. [ 1.756624] RPC: Registered udp transport module. [ 1.756990] RPC: Registered tcp transport module. [ 1.757325] RPC: Registered tcp NFSv4.1 backchannel transport module. [ 1.976746] workingset: timestamp_bits=62 max_order=18 bucket_order=0 [ 3.060889] NFS: Registering the id_resolver key type [ 3.066330] Key type id_resolver registered [ 3.066845] Key type id_legacy registered [ 3.076540] nfs4filelayout_init: NFSv4 File Layout Driver Registering... [ 3.078820] nfs4flexfilelayout_init: NFSv4 Flexfile Layout Driver Registering... [ 5.283129] io scheduler mq-deadline registered [ 5.286349] io scheduler kyber registered [ 14.488519] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled [ 14.608399] printk: console [ttyS0] disabled [ 14.613583] 10000000.uart: ttyS0 at MMIO 0x10000000 (irq = 1, base_baud = 3125000) is a 16550A [ 16.006163] printk: console [ttyS0] enabled [ 16.238915] xilinx_spi 20000000.xps-spi: at [mem 0x20000000-0x20000fff], irq=2 [ 16.368621] lowrisc-digilent-ethernet: Lowrisc ethernet platform (30000000-30007FFF) mapped to ffffffc804100000 [ 28.658531] Probing lowrisc-0:01 (address 1) [ 28.699025] Generic PHY lowrisc-0:01: attached PHY driver (mii_bus:phy_addr=lowrisc-0:01, irq=POLL) [ 28.737849] lowrisc-eth 30000000.lowrisc-eth: Lowrisc Ether100MHz registered [ 28.855720] mmc_spi spi0.0: SD/MMC host mmc0, no WP, no poweroff, cd polling [ 28.903717] usbcore: registered new interface driver usbhid [ 28.910323] usbhid: USB HID core driver [ 29.014254] NET: Registered PF_INET6 protocol family [ 29.134205] Segment Routing with IPv6 [ 29.145148] In-situ OAM (IOAM) with IPv6 [ 29.157931] sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver [ 29.207756] NET: Registered PF_PACKET protocol family [ 29.259959] mmc0: host does not support reading read-only switch, assuming write-enable [ 29.270870] mmc0: new SDXC card on SPI [ 29.327782] mmcblk0: mmc0:0000 SDABC 58.6 GiB [ 29.387600] Key type dns_resolver registered [ 30.247573] mmcblk0: p1 p2 [ 31.316606] Freeing unused kernel image (initmem) memory: 10852K [ 31.343724] Run /init as init process Starting syslogd: OK Starting klogd: OK Running sysctl: OK Saving 256 bits of non-creditable seed for next boot Starting network: [ 54.008558] lowrisc-eth 30000000.lowrisc-eth eth0: Current addr: 23 01 00 89 07 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 54.026282] lowrisc-eth 30000000.lowrisc-eth eth0: Expected addr: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 54.043742] ------------[ cut here ]------------ [ 54.049332] netdevice: eth0: Incorrect netdev->dev_addr [ 54.058912] WARNING: CPU: 0 PID: 99 at net/core/dev_addr_lists.c:519 dev_addr_check+0xa4/0x100 [ 54.069690] Modules linked in: [ 54.073921] CPU: 0 PID: 99 Comm: ip Not tainted 6.1.32 #4 [ 54.080492] Hardware name: eth,ariane-bare (DT) [ 54.085860] epc : dev_addr_check+0xa4/0x100 [ 54.091685] ra : dev_addr_check+0xa4/0x100 [ 54.097494] epc : ffffffff8038241a ra : ffffffff8038241a sp : ffffffc8041c3b70 [ 54.105725] gp : ffffffff816b68f8 tp : ffffffd802854280 t0 : 636976656474656e [ 54.113916] t1 : 000000000000006e t2 : 6563697665647465 s0 : ffffffc8041c3ba0 [ 54.122089] s1 : ffffffd801abe000 a0 : 000000000000002b a1 : ffffffff81684108 [ 54.130255] a2 : 0000000000000010 a3 : fffffffffffffffe a4 : 0000000000000000 [ 54.138423] a5 : 0000000000000000 a6 : 0000000000000008 a7 : 0000000000000038 [ 54.146547] s2 : ffffffd801abe000 s3 : ffffffd801bc3b28 s4 : 0000000000000000 [ 54.154732] s5 : 0000000000000000 s6 : ffffffd801abe240 s7 : 0000000000000000 [ 54.162859] s8 : ffffffd80269cc00 s9 : 0000000000000000 s10: 0000003fcbb2bd20 [ 54.171019] s11: 0000000000000008 t3 : ffffffff816c7217 t4 : ffffffff816c7217 [ 54.179169] t5 : ffffffff816c7218 t6 : ffffffc8041c3948 [ 54.185342] status: 0000000200000120 badaddr: 0000000000009002 cause: 0000000000000003 [ 54.194182] [] dev_addr_check+0xa4/0x100 [ 54.201256] [] __dev_open+0x2c/0x134 [ 54.207824] [] __dev_change_flags+0x178/0x1e4 [ 54.215182] [] dev_change_flags+0x1e/0x52 [ 54.222149] [] devinet_ioctl+0x1cc/0x5b2 [ 54.228999] [] inet_ioctl+0xc4/0x13c [ 54.235486] [] sock_do_ioctl+0x2c/0xac [ 54.242330] [] sock_ioctl+0x12e/0x2bc [ 54.248979] [] sys_ioctl+0x76/0x88 [ 54.255397] [] ret_from_syscall+0x0/0x2 [ 54.262139] ---[ end trace 0000000000000000 ]--- [ 54.288589] Open device, request interrupt 3 udhcpc: started, v1.36.0 udhcpc: broadcasting discover udhcpc: no lease, forking to background OK Starting dropbear sshd: OK

Welcome to Buildroot buildroot login: root
Password:

does it look like network configuration error?

grg-haas commented 10 months ago

does it look like network configuration error?

It does indeed, although things do look like they stabilize after a bit -- i.e. I see that udhcpc and sshd both start successfully, which they wouldn't do if the network interface stayed down. I'd attempt to debug this like a regular Linux networking issue -- start by running ip a to see if the interfaces you expect exist, and then go from there.

I do see that udhcpc fails to get a lease -- maybe the cause of the networking issues is a lack of a DHCP server?

acaldaya commented 10 months ago

I got a similar error recently, see my notes on it below, they could hint you where to look. You are using a kernel > 5.10 so, they should apply.


For some reason the platform is not getting the MAC address in the DTS. Instead it is using the HW core default: 23:01:00:89:97:02 on Linux 5.19 this issue causes a kernel warning because of this check introduced after v5.10. In that commit it is suggested to use dev_addr_set() to change the MAC address.

The MAC address is updated in function lowrisc_100MHz_probe @ lowrisc_100MHz.c.

...
printk("lowrisc-digilent-ethernet: Lowrisc ethernet platform (%llX-%llX) mapped to %lx\n",
               lowrisc_ethernet[0].start,
               lowrisc_ethernet[0].end,
               (size_t)(priv->ioaddr));

priv->irq = platform_get_irq(ofdev, 0);

/* get the MAC address set by the boot loader */
lowrisc_read_mac_address(priv, mac_address);
memcpy(ndev->dev_addr, mac_address, ETH_ALEN);
...

Replacing the memcpy by dev_addr_set(ndev, mac_address); prevents the warning.

IMO, this change is better (copied from xilinx_emaclite.c):

- /* get the MAC address set by the boot loader */
- lowrisc_read_mac_address(priv, mac_address);
- memcpy(ndev->dev_addr, mac_address, ETH_ALEN);

+  rc = of_get_ethdev_address(ofdev->dev.of_node, ndev);
+  if (rc) {
+       dev_warn(dev, "No MAC address found, using random\n");
+       eth_hw_addr_random(ndev);
+   }
JefferryDengCJ commented 10 months ago

I got a similar error recently, see my notes on it below, they could hint you where to look. You are using a kernel > 5.10 so, they should apply.

For some reason the platform is not getting the MAC address in the DTS. Instead it is using the HW core default: 23:01:00:89:97:02 on Linux 5.19 this issue causes a kernel warning because of this check introduced after v5.10. In that commit it is suggested to use dev_addr_set() to change the MAC address.

The MAC address is updated in function lowrisc_100MHz_probe @ lowrisc_100MHz.c.

...
printk("lowrisc-digilent-ethernet: Lowrisc ethernet platform (%llX-%llX) mapped to %lx\n",
               lowrisc_ethernet[0].start,
               lowrisc_ethernet[0].end,
               (size_t)(priv->ioaddr));

priv->irq = platform_get_irq(ofdev, 0);

/* get the MAC address set by the boot loader */
lowrisc_read_mac_address(priv, mac_address);
memcpy(ndev->dev_addr, mac_address, ETH_ALEN);
...

Replacing the memcpy by dev_addr_set(ndev, mac_address); prevents the warning.

IMO, this change is better (copied from xilinx_emaclite.c):

- /* get the MAC address set by the boot loader */
- lowrisc_read_mac_address(priv, mac_address);
- memcpy(ndev->dev_addr, mac_address, ETH_ALEN);

+  rc = of_get_ethdev_address(ofdev->dev.of_node, ndev);
+  if (rc) {
+     dev_warn(dev, "No MAC address found, using random\n");
+     eth_hw_addr_random(ndev);
+ }

Thank you very much.

asyarifstudio commented 10 months ago

Hi @JefferryDengCJ

I've seen similar issue in the past but running the udhcpc after user logged in will allow the device to connect to the network again.