ClangBuiltLinux / boot-utils

Collection of files for booting Linux kernels
26 stars 7 forks source link

add s390 buildroot and qemu commands #24

Closed nickdesaulniers closed 4 years ago

nickdesaulniers commented 4 years ago

The SystemZ maintainer in LLVM, Ulrich Weigand, sugguested that buildroot should work if manually switched to use glibc.

Add a buildroot config, and qemu command to boot. Unfortunately, this currently fails to boot; with the output being: $ timeout --foreground 3m unbuffer qemu-system-s390x -M s390-ccw-virtio \ -append '' -display none \ -initrd /android1/boot-utils/images/s390/rootfs.cpio \ -kernel /android0/kernel-all/arch/s390/boot/bzImage -m 512m -nodefaults \ -serial mon:stdio

KASLR disabled: CPU has no PRNG Linux version 5.8.0-10790-g9d4edd164db9-dirty (ndesaulniers@) #213 SMP Thu Aug 13 10:14:52 PDT 2020Kernel fault: interruption code 0005 ilc:2 PSW : 0000200180000000 00000000000177b0 R:0 T:0 IO:0 EX:0 Key:0 M:0 W:0 P:0 AS:0 CC:2 PM:0 RI:0 EA:3 GPRS: 0000000000000001 0000000d00000000 00000003fffffff4 00000000fffffff0 0000000000000000 00000000fffffff4 000000000000000c 00000000fffffff0 00000000fffffffc 0000000000000000 00000000fffffff8 00000000008915a8 0000000000000009 0000000000000002 0000000000000008 000000000000bce0

nathanchance commented 4 years ago

Did you manage to verify this against a GCC built kernel? If not, I can probably do it later tonight when I am back at my computer.

nathanchance commented 4 years ago

This does not appear to work with a GCC built kernel (Linux 5.8)

$ make -skj"$(nproc)" ARCH=s390 CROSS_COMPILE=s390x-linux- O=out/s390 distclean defconfig bzImage

$ ~/cbl/github/boot-utils/boot-qemu.sh -a s390 -k out/s390
...
+ timeout --foreground 3m unbuffer qemu-system-s390x -M s390-ccw-virtio -append '' -display none -initrd /home/nathan/cbl/github/boot-utils/images/s390/rootfs.cpio -kernel /home/nathan/src/linux/out/s390/arch/s390/boot/bzImage -m 512m -nodefaults -serial mon:stdio
KASLR disabled: CPU has no PRNG
[    0.379398] Linux version 5.8.0 (nathan@ubuntu-n2-xlarge-x86) (s390x-linux-gcc (GCC) 10.1.0, GNU ld (GNU Binutils) 2.34) #1 SMP Thu Aug 13 21:59:44 MST 2020
[    0.380485] setup: Linux is running under KVM in 64-bit mode
[    0.391650] setup: The maximum memory size is 512MB
[    0.393149] cpu: 1 configured CPUs, 0 standby CPUs
[    0.416330] Write protected kernel read-only data: 13968k
[    0.438180] Zone ranges:
[    0.439209]   DMA      [mem 0x0000000000000000-0x000000007fffffff]
[    0.439504]   Normal   empty
[    0.439525] Movable zone start for each node
[    0.439555] Early memory node ranges
[    0.439650]   node   0: [mem 0x0000000000000000-0x000000001fffffff]
[    0.440077] Initmem setup node 0 [mem 0x0000000000000000-0x000000001fffffff]
[    0.461886] percpu: Embedded 33 pages/cpu s97536 r8192 d29440 u135168
[    0.463916] Built 1 zonelists, mobility grouping on.  Total pages: 129024
[    0.463938] Policy zone: DMA
[    0.464095] Kernel command line: 
[    0.464721] Dentry cache hash table entries: 65536 (order: 7, 524288 bytes, linear)
[    0.464913] Inode-cache hash table entries: 32768 (order: 6, 262144 bytes, linear)
[    0.466134] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.478955] Memory: 234412K/524288K available (10844K kernel code, 2068K rwdata, 3124K rodata, 4048K init, 872K bss, 37952K reserved, 0K cma-reserved)
[    0.482501] SLUB: HWalign=256, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.483130] ftrace: allocating 33559 entries in 132 pages
[    0.606360] ftrace: allocated 132 pages with 2 groups
[    0.612761] rcu: Hierarchical RCU implementation.
[    0.612788] rcu:     RCU event tracing is enabled.
[    0.612821] rcu:     RCU restricting CPUs from NR_CPUS=512 to nr_cpu_ids=1.
[    0.612906]  Trampoline variant of Tasks RCU enabled.
[    0.612918]  Rude variant of Tasks RCU enabled.
[    0.612932]  Tracing variant of Tasks RCU enabled.
[    0.613003] rcu: RCU calculated value of scheduler-enlistment delay is 10 jiffies.
[    0.613036] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=1
[    0.639657] NR_IRQS: 3, nr_irqs: 3, preallocated irqs: 3
[    0.643782] clocksource: tod: mask: 0xffffffffffffffff max_cycles: 0x3b0a9be803b0a9, max_idle_ns: 1805497147909793 ns
[    0.646938] Console: colour dummy device 80x25
[    0.651471] printk: console [ttyS1] enabled
[    0.652898] pid_max: default: 32768 minimum: 301
[    0.653756] LSM: Security Framework initializing
[    0.656995] SELinux:  Initializing.
[    0.657695] Mount-cache hash table entries: 1024 (order: 1, 8192 bytes, linear)
[    0.657736] Mountpoint-cache hash table entries: 1024 (order: 1, 8192 bytes, linear)
[    0.689964] rcu: Hierarchical SRCU implementation.
[    0.693319] smp: Bringing up secondary CPUs ...
[    0.693438] smp: Brought up 1 node, 1 CPU
[    0.726330] node 0 deferred pages initialised in 30ms
[    0.735619] devtmpfs: initialized
[    0.739976] random: get_random_u32 called from bucket_table_alloc.isra.0+0x82/0x120 with crng_init=0
[    0.743747] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.743871] futex hash table entries: 256 (order: 4, 65536 bytes, linear)
[    0.746687] xor: automatically using best checksumming function   xc        
[    0.749197] NET: Registered protocol family 16
[    0.750937] audit: initializing netlink subsys (disabled)
[    0.754892] Spectre V2 mitigation: execute trampolines
[    0.758655] audit: type=2000 audit(1597381405.526:1): state=initialized audit_enabled=0 res=1
[    1.164362] raid6: vx128x8  gen()   858 MB/s
[    1.334331] raid6: vx128x8  xor()   503 MB/s
[    1.334372] raid6: using algorithm vx128x8 gen() 858 MB/s
[    1.334392] raid6: .... xor() 503 MB/s, rmw enabled
[    1.334450] raid6: using s390xc recovery algorithm
[    1.336393] iommu: Default domain type: Translated 
[    1.338224] SCSI subsystem initialized
[    1.598489] VFS: Disk quotas dquot_6.6.0
[    1.598685] VFS: Dquot-cache hash table entries: 512 (order 0, 4096 bytes)
[    1.599886] hugetlbfs: disabling because there are no supported hugepage sizes
[    1.631352] NET: Registered protocol family 2
[    1.636114] tcp_listen_portaddr_hash hash table entries: 256 (order: 0, 4096 bytes, linear)
[    1.636243] TCP established hash table entries: 4096 (order: 3, 32768 bytes, linear)
[    1.636924] TCP bind hash table entries: 4096 (order: 4, 65536 bytes, linear)
[    1.637060] TCP: Hash tables configured (established 4096 bind 4096)
[    1.639075] UDP hash table entries: 256 (order: 1, 8192 bytes, linear)
[    1.639269] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes, linear)
[    1.640693] NET: Registered protocol family 1
[    1.643377] Trying to unpack rootfs image as initramfs...
[    1.731279] Freeing initrd memory: 6432K
[    1.740311] alg: No test for crc32be (crc32be-vx)
[    1.746319] hypfs: The hardware system does not support hypfs
[    1.747565] hypfs: Initialization of hypfs failed with rc=-61
[    1.750611] Initialise system trusted keyrings
[    1.751863] workingset: timestamp_bits=45 max_order=17 bucket_order=0
[    1.768522] zbud: loaded
[    1.775896] fuse: init (API version 7.31)
[    1.776777] SGI XFS with ACLs, security attributes, realtime, quota, no debug enabled
[    1.880583] Key type asymmetric registered
[    1.880681] Asymmetric key parser 'x509' registered
[    1.880894] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 251)
[    1.881662] io scheduler mq-deadline registered
[    1.881730] io scheduler kyber registered
[    1.882089] io scheduler bfq registered
[    1.883793] atomic64_test: passed
[    1.885389] hvc_iucv: The z/VM IUCV HVC device driver cannot be used without z/VM
[    1.917350] brd: module loaded
[    1.920152] NET: Registered protocol family 10
[    1.926482] Segment Routing with IPv6
[    1.926528] RPL Segment Routing with IPv6
[    1.926850] NET: Registered protocol family 17
[    1.928083] Key type dns_resolver registered
[    1.928700] cio: Channel measurement facility initialized using format extended (mode autodetected)
[    1.931325] Discipline DIAG cannot be used without z/VM
[    1.933621] sclp_sd: Store Data request failed (eq=2, di=3, response=0x40f0, flags=0x00, status=0, rc=-5)
[    1.935395] ap: The hardware system does not support AP instructions
[    1.935445] qeth: loading core functions
[    1.936121] qeth: register layer 2 discipline
[    1.936149] qeth: register layer 3 discipline
[    1.937614] registered taskstats version 1
[    1.937684] Loading compiled-in X.509 certificates
[    2.093671] Loaded X.509 cert 'Build time autogenerated kernel key: 36643ad5e494bc6d11a7da606682facc4293f16b'
[    2.094493] zswap: loaded using pool lzo/zbud
[    2.095927] Key type ._fscrypt registered
[    2.095958] Key type .fscrypt registered
[    2.095978] Key type fscrypt-provisioning registered
[    2.102236] Btrfs loaded, crc32c=crc32c-vx
[    2.103604] ima: No TPM chip found, activating TPM-bypass!
[    2.103758] ima: Allocated hash algorithm: sha256
[    2.104961] ima: No architecture policies found
[    2.118988] Freeing unused kernel memory: 4048K
[    2.134709] Write protected read-only-after-init data: 68k
[    2.134834] Run /init as init process
[    2.201431] request_module: kmod_concurrent_max (0) close to 0 (max_modprobes: 50), for module binfmt-4c46, throttling...
[    7.211356] request_module: modprobe binfmt-4c46 cannot be processed, kmod busy with 50 threads for more than 5 seconds now
[    7.238697] Failed to execute /init (error -8)
[    7.238748] Run /sbin/init as init process
[    7.278568] request_module: kmod_concurrent_max (0) close to 0 (max_modprobes: 50), for module binfmt-4c46, throttling...
[   12.330368] request_module: modprobe binfmt-4c46 cannot be processed, kmod busy with 50 threads for more than 5 seconds now
[   12.355879] Starting init: /sbin/init exists but couldn't execute it (error -8)
[   12.355929] Run /etc/init as init process
[   12.356112] Run /bin/init as init process
[   12.356192] Run /bin/sh as init process
[   12.394869] request_module: kmod_concurrent_max (0) close to 0 (max_modprobes: 50), for module binfmt-4c46, throttling...
[   17.450395] request_module: modprobe binfmt-4c46 cannot be processed, kmod busy with 50 threads for more than 5 seconds now
[   17.475932] Starting init: /bin/sh exists but couldn't execute it (error -8)
[   17.476055] Kernel panic - not syncing: No working init found.  Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance.
[   17.476293] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.8.0 #1
[   17.476317] Hardware name: QEMU 2964 QEMU (KVM/Linux)
[   17.476381] Call Trace:
[   17.476574]  [<0000000000115b9a>] show_stack+0x92/0xd8 
[   17.476650]  [<00000000008354d8>] dump_stack+0x90/0xc0 
[   17.476673]  [<000000000014c21a>] panic+0x112/0x308 
[   17.476695]  [<0000000000b8af64>] kernel_init+0x134/0x148 
[   17.476715]  [<0000000000b93d9c>] ret_from_fork+0x28/0x2c 
+ RET=0
+ set +x

Wonder why /bin/sh cannot be executed...

groeck commented 4 years ago

"request_module: modprobe binfmt-4c46 cannot be processed" suggests a wrong binary format

nickdesaulniers commented 4 years ago

"request_module: modprobe binfmt-4c46 cannot be processed" suggests a wrong binary format

Indeed, rerunning the buildroot build, it looks like it's just building my host's target triple. Looking at the binaries in buildroot/src/output/, they all look x86_64 to me, not s390...

Running make menuconfig in buildroot sources, then going into the list of architectures, s390 is not in the list...let me email Ulrich to see how this could have possibly worked for him.