1407a6883SThomas Huth#!/usr/bin/env python3 2407a6883SThomas Huth# 32bef5b94SNicholas Piggin# Test that Linux kernel boots on ppc powernv machines and check the console 42bef5b94SNicholas Piggin# 52bef5b94SNicholas Piggin# Copyright (c) 2018, 2020 Red Hat, Inc. 62bef5b94SNicholas Piggin# 72bef5b94SNicholas Piggin# This work is licensed under the terms of the GNU GPL, version 2 or 82bef5b94SNicholas Piggin# later. See the COPYING file in the top-level directory. 92bef5b94SNicholas Piggin 10*4f37abffSThomas Huthfrom qemu_test import LinuxKernelTest, Asset 11407a6883SThomas Huthfrom qemu_test import wait_for_console_pattern 122bef5b94SNicholas Piggin 13*4f37abffSThomas Huthclass powernvMachine(LinuxKernelTest): 142bef5b94SNicholas Piggin 152bef5b94SNicholas Piggin timeout = 90 168d07a8aeSNicholas Piggin KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 console=hvc0 ' 172bef5b94SNicholas Piggin panic_message = 'Kernel panic - not syncing' 182bef5b94SNicholas Piggin good_message = 'VFS: Cannot open root device' 192bef5b94SNicholas Piggin 20407a6883SThomas Huth ASSET_KERNEL = Asset( 21407a6883SThomas Huth ('https://archives.fedoraproject.org/pub/archive/fedora-secondary/' 22407a6883SThomas Huth 'releases/29/Everything/ppc64le/os/ppc/ppc64/vmlinuz'), 23407a6883SThomas Huth '383c2f5c23bc0d9d32680c3924d3fd7ee25cc5ef97091ac1aa5e1d853422fc5f') 24407a6883SThomas Huth 258d07a8aeSNicholas Piggin def do_test_linux_boot(self, command_line = KERNEL_COMMON_COMMAND_LINE): 262bef5b94SNicholas Piggin self.require_accelerator("tcg") 27407a6883SThomas Huth kernel_path = self.ASSET_KERNEL.fetch() 282bef5b94SNicholas Piggin 292bef5b94SNicholas Piggin self.vm.set_console() 302bef5b94SNicholas Piggin self.vm.add_args('-kernel', kernel_path, 318d07a8aeSNicholas Piggin '-append', command_line) 322bef5b94SNicholas Piggin self.vm.launch() 332bef5b94SNicholas Piggin 342bef5b94SNicholas Piggin def test_linux_boot(self): 35407a6883SThomas Huth self.set_machine('powernv') 362bef5b94SNicholas Piggin self.do_test_linux_boot() 372bef5b94SNicholas Piggin console_pattern = 'VFS: Cannot open root device' 382bef5b94SNicholas Piggin wait_for_console_pattern(self, console_pattern, self.panic_message) 392bef5b94SNicholas Piggin 402bef5b94SNicholas Piggin def test_linux_smp_boot(self): 41407a6883SThomas Huth self.set_machine('powernv') 422bef5b94SNicholas Piggin self.vm.add_args('-smp', '4') 432bef5b94SNicholas Piggin self.do_test_linux_boot() 442bef5b94SNicholas Piggin console_pattern = 'smp: Brought up 1 node, 4 CPUs' 452bef5b94SNicholas Piggin wait_for_console_pattern(self, console_pattern, self.panic_message) 462bef5b94SNicholas Piggin wait_for_console_pattern(self, self.good_message, self.panic_message) 472bef5b94SNicholas Piggin 488d07a8aeSNicholas Piggin def test_linux_smp_hpt_boot(self): 49407a6883SThomas Huth self.set_machine('powernv') 508d07a8aeSNicholas Piggin self.vm.add_args('-smp', '4') 518d07a8aeSNicholas Piggin self.do_test_linux_boot(self.KERNEL_COMMON_COMMAND_LINE + 528d07a8aeSNicholas Piggin 'disable_radix') 538d07a8aeSNicholas Piggin console_pattern = 'smp: Brought up 1 node, 4 CPUs' 548d07a8aeSNicholas Piggin wait_for_console_pattern(self, 'hash-mmu: Initializing hash mmu', 558d07a8aeSNicholas Piggin self.panic_message) 568d07a8aeSNicholas Piggin wait_for_console_pattern(self, console_pattern, self.panic_message) 578d07a8aeSNicholas Piggin wait_for_console_pattern(self, self.good_message, self.panic_message) 588d07a8aeSNicholas Piggin 592bef5b94SNicholas Piggin def test_linux_smt_boot(self): 60407a6883SThomas Huth self.set_machine('powernv') 612bef5b94SNicholas Piggin self.vm.add_args('-smp', '4,threads=4') 622bef5b94SNicholas Piggin self.do_test_linux_boot() 632bef5b94SNicholas Piggin console_pattern = 'CPU maps initialized for 4 threads per core' 642bef5b94SNicholas Piggin wait_for_console_pattern(self, console_pattern, self.panic_message) 652bef5b94SNicholas Piggin console_pattern = 'smp: Brought up 1 node, 4 CPUs' 662bef5b94SNicholas Piggin wait_for_console_pattern(self, console_pattern, self.panic_message) 672bef5b94SNicholas Piggin wait_for_console_pattern(self, self.good_message, self.panic_message) 682bef5b94SNicholas Piggin 692bef5b94SNicholas Piggin def test_linux_big_boot(self): 70407a6883SThomas Huth self.set_machine('powernv') 712bef5b94SNicholas Piggin self.vm.add_args('-smp', '16,threads=4,cores=2,sockets=2') 722bef5b94SNicholas Piggin 732bef5b94SNicholas Piggin # powernv does not support NUMA 742bef5b94SNicholas Piggin self.do_test_linux_boot() 752bef5b94SNicholas Piggin console_pattern = 'CPU maps initialized for 4 threads per core' 762bef5b94SNicholas Piggin wait_for_console_pattern(self, console_pattern, self.panic_message) 772bef5b94SNicholas Piggin console_pattern = 'smp: Brought up 2 nodes, 16 CPUs' 782bef5b94SNicholas Piggin wait_for_console_pattern(self, console_pattern, self.panic_message) 792bef5b94SNicholas Piggin wait_for_console_pattern(self, self.good_message, self.panic_message) 80407a6883SThomas Huth 81*4f37abffSThomas Huth 82*4f37abffSThomas Huth ASSET_EPAPR_KERNEL = Asset( 83*4f37abffSThomas Huth ('https://github.com/open-power/op-build/releases/download/v2.7/' 84*4f37abffSThomas Huth 'zImage.epapr'), 85*4f37abffSThomas Huth '0ab237df661727e5392cee97460e8674057a883c5f74381a128fa772588d45cd') 86*4f37abffSThomas Huth 87*4f37abffSThomas Huth def do_test_ppc64_powernv(self, proc): 88*4f37abffSThomas Huth self.require_accelerator("tcg") 89*4f37abffSThomas Huth kernel_path = self.ASSET_EPAPR_KERNEL.fetch() 90*4f37abffSThomas Huth self.vm.set_console() 91*4f37abffSThomas Huth self.vm.add_args('-kernel', kernel_path, 92*4f37abffSThomas Huth '-append', 'console=tty0 console=hvc0', 93*4f37abffSThomas Huth '-device', 'pcie-pci-bridge,id=bridge1,bus=pcie.1,addr=0x0', 94*4f37abffSThomas Huth '-device', 'nvme,bus=pcie.2,addr=0x0,serial=1234', 95*4f37abffSThomas Huth '-device', 'e1000e,bus=bridge1,addr=0x3', 96*4f37abffSThomas Huth '-device', 'nec-usb-xhci,bus=bridge1,addr=0x2') 97*4f37abffSThomas Huth self.vm.launch() 98*4f37abffSThomas Huth 99*4f37abffSThomas Huth self.wait_for_console_pattern("CPU: " + proc + " generation processor") 100*4f37abffSThomas Huth self.wait_for_console_pattern("zImage starting: loaded") 101*4f37abffSThomas Huth self.wait_for_console_pattern("Run /init as init process") 102*4f37abffSThomas Huth # Device detection output driven by udev probing is sometimes cut off 103*4f37abffSThomas Huth # from console output, suspect S14silence-console init script. 104*4f37abffSThomas Huth 105*4f37abffSThomas Huth def test_powernv8(self): 106*4f37abffSThomas Huth self.set_machine('powernv8') 107*4f37abffSThomas Huth self.do_test_ppc64_powernv('P8') 108*4f37abffSThomas Huth 109*4f37abffSThomas Huth def test_powernv9(self): 110*4f37abffSThomas Huth self.set_machine('powernv9') 111*4f37abffSThomas Huth self.do_test_ppc64_powernv('P9') 112*4f37abffSThomas Huth 113*4f37abffSThomas Huth def test_powernv10(self): 114*4f37abffSThomas Huth self.set_machine('powernv10') 115*4f37abffSThomas Huth self.do_test_ppc64_powernv('P10') 116*4f37abffSThomas Huth 117407a6883SThomas Huthif __name__ == '__main__': 118*4f37abffSThomas Huth LinuxKernelTest.main() 119