seL4 / camkes-vm-linux

Other
4 stars 13 forks source link

Why can't use Ethernet card in guest linux ? #2

Closed jason416 closed 5 years ago

jason416 commented 5 years ago

I normally follow the instructions in official doc ("Virtualisation on seL4"), and succeed. But no matter how i change the configurations of Ethernet card it does not work fine. I check the status of eth0, like:


image


It seems like the guest linux does not know cable wasn't plugged in, I check the configuration add for vm0 and hardware arguments of this PCIE Ethernet card:

 /*   
 * 03:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection
 *  Interrupt: pin A routed to IRQ 16
 *  Region 0: Memory at df1c0000 (32-bit, non-prefetchable) [size=128K]
 *  Region 1: Memory at df100000 (32-bit, non-prefetchable) [size=512K]
 *  Region 2: I/O ports at e000 [size=32]
 *  Region 3: Memory at df1e0000 (32-bit, non-prefetchable) [size=16K]
*/ 

        vm0_config.pci_devices_iospace = 1;      

        vm0_config.ioports = [
            {"start":0xe000, "end":0xe020, "pci_device":0, "name":"Ethernet5"},// 32B
            //asdas
        ];

        vm0_config.pci_devices = [
            {
                "name":"Ethernet5",
                "bus":3, "dev":0, "fun":0,                                  // bus
                "irq":"Ethernet5",
                "memory":[
                    {"paddr":0xdf1c0000, "size":0x20000, "page_bits":12},   // 128K
                    {"paddr":0xdf100000, "size":0x80000, "page_bits":12},   // 512K
                    {"paddr":0xdf1e0000, "size":0x4000,  "page_bits":12}    // 16K
                ],
            }
        ];

        vm0_config.irqs = [
            {"name":"Ethernet5", "source":10, "level_trig":1, "active_low":1, "dest":16},
        ];

Is the configuration of vm0_config.irqs wrong? How to pass IRQ to guest linux? could you please help me with that , thanks for your time.

jason416 commented 5 years ago

I check vm0_config.irqs again after reading main_continued() in main.c. VMM emulates irq save in irq_badges[16], "source" should be equals 16 from "Interrupt: pin A routed to IRQ 16", "dest" should be in the array named irq_badges. other args should be the same as the message got by lspci -vv. After i set these args correctly, ethernet card works fine in guest Linux! Thanks for your contribution guys !Merry Christmas !