Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

s390: use virtio_console for KVM on s390

This patch enables virtio_console as the default console on kvm for
s390. We currently use the same notify hack as lguest for early
console output. I will try to address this for lguest and s390 later.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

authored by

Christian Borntraeger and committed by
Rusty Russell
faeba830 7721c494

+34 -1
+1
arch/s390/Kconfig
··· 565 565 depends on 64BIT && EXPERIMENTAL 566 566 select VIRTIO 567 567 select VIRTIO_RING 568 + select VIRTIO_CONSOLE 568 569 help 569 570 Select this option if you want to run the kernel under s390 linux 570 571 endmenu
+3 -1
arch/s390/kernel/setup.c
··· 54 54 #include <asm/sections.h> 55 55 #include <asm/ebcdic.h> 56 56 #include <asm/compat.h> 57 + #include <asm/kvm_virtio.h> 57 58 58 59 long psw_kernel_bits = (PSW_BASE_BITS | PSW_MASK_DAT | PSW_ASC_PRIMARY | 59 60 PSW_MASK_MCHECK | PSW_DEFAULT_KEY); ··· 767 766 printk("We are running under VM (64 bit mode)\n"); 768 767 else if (MACHINE_IS_KVM) { 769 768 printk("We are running under KVM (64 bit mode)\n"); 770 - add_preferred_console("ttyS", 1, NULL); 769 + add_preferred_console("hvc", 0, NULL); 770 + s390_virtio_console_init(); 771 771 } else 772 772 printk("We are running native (64 bit mode)\n"); 773 773 #endif /* CONFIG_64BIT */
+20
drivers/s390/kvm/kvm_virtio.c
··· 15 15 #include <linux/err.h> 16 16 #include <linux/virtio.h> 17 17 #include <linux/virtio_config.h> 18 + #include <linux/virtio_console.h> 18 19 #include <linux/interrupt.h> 19 20 #include <linux/virtio_ring.h> 20 21 #include <linux/pfn.h> ··· 332 331 333 332 scan_devices(); 334 333 return 0; 334 + } 335 + 336 + /* code for early console output with virtio_console */ 337 + static __init int early_put_chars(u32 vtermno, const char *buf, int count) 338 + { 339 + char scratch[17]; 340 + unsigned int len = count; 341 + 342 + if (len > sizeof(scratch) - 1) 343 + len = sizeof(scratch) - 1; 344 + scratch[len] = '\0'; 345 + memcpy(scratch, buf, len); 346 + kvm_hypercall1(KVM_S390_VIRTIO_NOTIFY, __pa(scratch)); 347 + return len; 348 + } 349 + 350 + void s390_virtio_console_init(void) 351 + { 352 + virtio_cons_early_init(early_put_chars); 335 353 } 336 354 337 355 /*
+10
include/asm-s390/kvm_virtio.h
··· 50 50 #define KVM_S390_VIRTIO_RESET 1 51 51 #define KVM_S390_VIRTIO_SET_STATUS 2 52 52 53 + #ifdef __KERNEL__ 54 + /* early virtio console setup */ 55 + #ifdef CONFIG_VIRTIO_CONSOLE 56 + extern void s390_virtio_console_init(void); 57 + #else 58 + static inline void s390_virtio_console_init(void) 59 + { 60 + } 61 + #endif /* CONFIG_VIRTIO_CONSOLE */ 62 + #endif /* __KERNEL__ */ 53 63 #endif