如何在 Spike (riscv) 中指定内核参数?

How to specify kernel parameters in Spike (riscv)?

我想在启动时预留一部分物理内存Linux。常见的内核参数应该像 "mem=51M memmap=512M2M"。我如何为 Spike 的内核指定这些参数?

我的 Spike 执行命令是:

u@ubuntu14.04:~/riscv$ spike -m2048 +disk=./root.bin bbl ./linux-3.14.33/vmlinux
              vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
                  vvvvvvvvvvvvvvvvvvvvvvvvvvvv
rrrrrrrrrrrrr       vvvvvvvvvvvvvvvvvvvvvvvvvv
rrrrrrrrrrrrrrrr      vvvvvvvvvvvvvvvvvvvvvvvv
rrrrrrrrrrrrrrrrrr    vvvvvvvvvvvvvvvvvvvvvvvv
rrrrrrrrrrrrrrrrrr    vvvvvvvvvvvvvvvvvvvvvvvv
rrrrrrrrrrrrrrrrrr    vvvvvvvvvvvvvvvvvvvvvvvv
rrrrrrrrrrrrrrrr      vvvvvvvvvvvvvvvvvvvvvv  
rrrrrrrrrrrrr       vvvvvvvvvvvvvvvvvvvvvv    
rr                vvvvvvvvvvvvvvvvvvvvvv      
rr            vvvvvvvvvvvvvvvvvvvvvvvv      rr
rrrr      vvvvvvvvvvvvvvvvvvvvvvvvvv      rrrr
rrrrrr      vvvvvvvvvvvvvvvvvvvvvv      rrrrrr
rrrrrrrr      vvvvvvvvvvvvvvvvvv      rrrrrrrr
rrrrrrrrrr      vvvvvvvvvvvvvv      rrrrrrrrrr
rrrrrrrrrrrr      vvvvvvvvvv      rrrrrrrrrrrr
rrrrrrrrrrrrrr      vvvvvv      rrrrrrrrrrrrrr
rrrrrrrrrrrrrrrr      vv      rrrrrrrrrrrrrrrr
rrrrrrrrrrrrrrrrrr          rrrrrrrrrrrrrrrrrr
rrrrrrrrrrrrrrrrrrrr      rrrrrrrrrrrrrrrrrrrr
rrrrrrrrrrrrrrrrrrrrrr  rrrrrrrrrrrrrrrrrrrrrr

       INSTRUCTION SETS WANT TO BE FREE
[    0.000000] Linux version 3.14.33-g043bb5d (guanglin@guanglin-a11-linux) (gcc version 5.2.0 (GCC) ) #2 Sun Aug 23 17:19:49 EDT 2015
[    0.000000] Detected 0x7fc00000 bytes of physical memory
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x00200000-0x7fdfffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x00200000-0x7fdfffff]
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 516110
[    0.000000] Kernel command line: root=/dev/htifblk0
[    0.000000] PID hash table entries: 4096 (order: 3, 32768 bytes)
[    0.000000] Dentry cache hash table entries: 262144 (order: 9, 2097152 bytes)
[    0.000000] Inode-cache hash table entries: 131072 (order: 8, 1048576 bytes)
[    0.000000] Sorting __ex_table...
[    0.000000] Memory: 2058700K/2093056K available (1722K kernel code, 124K rwdata, 356K rodata, 68K init, 211K bss, 34356K reserved)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] NR_IRQS:2
[    0.150000] Calibrating delay using timer specific routine.. 20.01 BogoMIPS (lpj=100050)
[    0.150000] pid_max: default: 32768 minimum: 301
[    0.150000] Mount-cache hash table entries: 4096 (order: 3, 32768 bytes)
[    0.150000] Mountpoint-cache hash table entries: 4096 (order: 3, 32768 bytes)
[    0.150000] devtmpfs: initialized
[    0.150000] NET: Registered protocol family 16
[    0.150000] bio: create slab <bio-0> at 0
[    0.150000] Switched to clocksource riscv_clocksource
[    0.150000] NET: Registered protocol family 2
[    0.150000] TCP established hash table entries: 16384 (order: 5, 131072 bytes)
[    0.150000] TCP bind hash table entries: 16384 (order: 5, 131072 bytes)
[    0.150000] TCP: Hash tables configured (established 16384 bind 16384)
[    0.150000] TCP: reno registered
[    0.150000] UDP hash table entries: 1024 (order: 3, 32768 bytes)
[    0.150000] UDP-Lite hash table entries: 1024 (order: 3, 32768 bytes)
[    0.150000] NET: Registered protocol family 1
[    0.150000] futex hash table entries: 256 (order: 0, 6144 bytes)
[    0.150000] io scheduler noop registered
[    0.150000] io scheduler cfq registered (default)
[    0.150000] htifcon htif1: detected console
[    0.150000] console [htifcon0] enabled
[    0.150000] htifblk htif2: detected disk
[    0.150000] htifblk htif2: added htifblk0
[    0.150000] TCP: cubic registered
[    0.150000] VFS: Mounted root (ext2 filesystem) readonly on device 254:0.
[    0.150000] devtmpfs: mounted
[    0.150000] Freeing unused kernel memory: 68K (ffffffff80000000 - ffffffff80011000)
[    0.160000] EXT2-fs (htifblk0): warning: mounting unchecked fs, running e2fsck is recommended
/ # 

我试过了

spike -m2048 +disk=./root.bin bbl ./linux-3.14.33/vmlinux mem=1G memmap=1GG
spike -m2048 +disk=./root.bin bbl ./linux-3.14.33/vmlinux mem=512M memmap=512M2M

None 有效。

如果我这样做

spike -m2048 +disk=./root.bin bbl "./linux-3.14.33/vmlinux mem=512M memmap=512M2M"

无法打开ELF程序:./linux-3.14.33/vmlinux mem=512M memmap=512M12M!

现在,linux 的参数需要通过 .config 中的 CONFIG_CMDLINE 参数编译成 linux。

可以改进 bbl 的未来版本以支持将参数传递给 linux。