NJU-ProjectN / nemu

NJU EMUlator, a full system x86/mips32/riscv32/riscv64 emulator for teaching
Other
900 stars 195 forks source link

nemu 支持多核吗? #95

Closed qqli579 closed 6 months ago

qqli579 commented 7 months ago

启动2个core的时候stall在了下面:

[    0.000000] OF: fdt: Ignoring memory range 0x80000000 - 0x80200000

[    0.000000] Linux version 4.18.0-14486-g655055af981b-dirty (hukun@model-1) (gcc version 13.2.0 (gc891d8dc23e)) #190 SMP Tue Apr 16 14:39:20 CST 2024

[    0.000000] bootconsole [early0] enabled

[    0.000000] Initial ramdisk at: 0x(____ptrval____) (3623511 bytes)

[    0.000000] Zone ranges:

[    0.000000]   DMA32    empty

[    0.000000]   Normal   [mem 0x0000000080200000-0x000000047fffffff]

[    0.000000] Movable zone start for each node

[    0.000000] Early memory node ranges

[    0.000000]   node   0: [mem 0x0000000080200000-0x000000047fffffff]

[    0.000000] Initmem setup node 0 [mem 0x0000000080200000-0x000000047fffffff]

[    0.000000] software IO TLB [mem 0x46dffd000-0x471ffd000] (64MB) mapped at [(____ptrval____)-(____ptrval____)]

[    0.000000] elf_hwcap is 0x112d

[    0.000000] percpu: Embedded 17 pages/cpu @(____ptrval____) s30040 r8192 d31400 u69632

[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 4136455

[    0.000000] Kernel command line: root=/dev/mmcblk0 rootfstype=ext4 ro rootwait earlycon

[    0.000000] Dentry cache hash table entries: 2097152 (order: 12, 16777216 bytes)

[    0.000000] Inode-cache hash table entries: 1048576 (order: 11, 8388608 bytes)

[    0.000000] Sorting __ex_table...

[    0.000000] Memory: 16444740K/16775168K available (3551K kernel code, 206K rwdata, 2105K rodata, 3709K init, 778K bss, 330428K reserved, 0K cma-reserved)

[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=2, Nodes=1

[    0.000000] Hierarchical RCU implementation.

[    0.000000] NR_IRQS: 0, nr_irqs: 0, preallocated irqs: 0

[    0.000000] clocksource: riscv_clocksource: mask: 0xffffffffffffffff max_cycles: 0x1d854df40, max_idle_ns: 3526361616960 ns

[    0.000000] Console: colour dummy device 80x25

[    0.000000] console [hvc0] enabled

[    0.000000] console [hvc0] enabled

[    0.000000] bootconsole [early0] disabled

[    0.000000] bootconsole [early0] disabled

[    0.000000] Calibrating delay loop (skipped), value calculated using timer frequency.. 2.00 BogoMIPS (lpj=10000)

[    0.000000] pid_max: default: 32768 minimum: 301

[    0.000000] Mount-cache hash table entries: 32768 (order: 6, 262144 bytes)

[    0.000000] Mountpoint-cache hash table entries: 32768 (order: 6, 262144 bytes)

[    0.010000] Hierarchical SRCU implementation.

[    0.030000] smp: Bringing up secondary CPUs ...

platform.dtsi如下:

/dts-v1/;

/ {
    L18: soc {
        L2: clint@2000000 {
            compatible = "riscv,clint0";
            interrupts-extended = <&L4 3 &L4 7 &L5 3 &L5 7>;
            reg = <0x0 0x38000000 0x0 0x10000>;
            reg-names = "control";
            clock-frequency-mhz = <500>;
        };
        L14: serial@60000000 {
            compatible = "xilinx,uartlite";
            //interrupt-parent = <&L1>;
            interrupts = <3>;
            reg = <0x0 0x40600000 0x0 0x1000>;
            reg-names = "control";
        };
    sdhci: mmc {
      compatible = "nemu-sdhost";
            reg = <0x0 0x40002000 0x0 0x1000>;
    };
    };
  chosen {
    bootargs = "root=/dev/mmcblk0 rootfstype=ext4 ro rootwait earlycon";
  };
    L11: memory@100000000 {
        device_type = "memory";
        reg = <0x0 0x80000000 0x4 0x0000000>;
    };
};

system.dts如下:

/dts-v1/;
/include/ "platform.dtsi"

/ {
    #address-cells = <2>;
    #size-cells = <2>;
    compatible = "freechips,rocketchip-unknown-dev";
    model = "freechips,rocketchip-unknown";
    L19: cpus {
        #address-cells = <1>;
        #size-cells = <0>;
        timebase-frequency = <1000000>;
        L6: cpu@0 {
            clock-frequency = <0>;
            compatible = "UCAS,COOSCA1.0", "riscv";
            d-cache-block-size = <64>;
            d-cache-sets = <64>;
            d-cache-size = <16384>;
            d-tlb-sets = <1>;
            d-tlb-size = <32>;
            device_type = "cpu";
            i-cache-block-size = <64>;
            i-cache-sets = <64>;
            i-cache-size = <16384>;
            i-tlb-sets = <1>;
            i-tlb-size = <32>;
            mmu-type = "riscv,sv39";
            next-level-cache = <&L11>;
            reg = <0x0>;
            riscv,isa = "rv64imafdc";
            status = "okay";
            timebase-frequency = <1000000>;
            tlb-split;
            L4: interrupt-controller {
                #interrupt-cells = <1>;
                compatible = "riscv,cpu-intc";
                interrupt-controller;
            };
        };
        L7: cpu@1 {
            clock-frequency = <0>;
            compatible = "UCAS,COOSCA1.0", "riscv";
            d-cache-block-size = <64>;
            d-cache-sets = <64>;
            d-cache-size = <16384>;
            d-tlb-sets = <1>;
            d-tlb-size = <32>;
            device_type = "cpu";
            i-cache-block-size = <64>;
            i-cache-sets = <64>;
            i-cache-size = <16384>;
            i-tlb-sets = <1>;
            i-tlb-size = <32>;
            mmu-type = "riscv,sv39";
            next-level-cache = <&L11>;
            reg = <0x1>;
            riscv,isa = "rv64imafdc";
            status = "okay";
            timebase-frequency = <1000000>;
            tlb-split;
            L5: interrupt-controller {
                #interrupt-cells = <1>;
                compatible = "riscv,cpu-intc";
                interrupt-controller;
            };
        };
    };
    L18: soc {
        #address-cells = <2>;
        #size-cells = <2>;
        compatible = "freechips,rocketchip-unknown-soc", "simple-bus";
        ranges;
        L3: debug-controller@0 {
            compatible = "sifive,debug-013", "riscv,debug-013";
            interrupts-extended = <&L4 65535 &L5 65535>;
            reg = <0x0 0x0 0x0 0x1000>;
            reg-names = "control";
        };
    };
};

nemu 是否支持多核?

sashimi-yzh commented 7 months ago

这里是教学版本的NEMU, 我们不提供多核的支持, 你可以参考或询问香山团队维护的NEMU