Commit faeba830b086bc9e58748869054e994cb09693cd
Committed by
Rusty Russell
1 parent
7721c494a2
Exists in
master
and in
7 other branches
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>
Showing 4 changed files with 34 additions and 1 deletions Side-by-side Diff
arch/s390/Kconfig
arch/s390/kernel/setup.c
... | ... | @@ -54,6 +54,7 @@ |
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); |
... | ... | @@ -766,7 +767,8 @@ |
766 | 767 | printk("We are running under VM (64 bit mode)\n"); |
767 | 768 | else if (MACHINE_IS_KVM) { |
768 | 769 | printk("We are running under KVM (64 bit mode)\n"); |
769 | - add_preferred_console("ttyS", 1, NULL); | |
770 | + add_preferred_console("hvc", 0, NULL); | |
771 | + s390_virtio_console_init(); | |
770 | 772 | } else |
771 | 773 | printk("We are running native (64 bit mode)\n"); |
772 | 774 | #endif /* CONFIG_64BIT */ |
drivers/s390/kvm/kvm_virtio.c
... | ... | @@ -15,6 +15,7 @@ |
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> |
... | ... | @@ -331,6 +332,25 @@ |
331 | 332 | |
332 | 333 | scan_devices(); |
333 | 334 | return 0; |
335 | +} | |
336 | + | |
337 | +/* code for early console output with virtio_console */ | |
338 | +static __init int early_put_chars(u32 vtermno, const char *buf, int count) | |
339 | +{ | |
340 | + char scratch[17]; | |
341 | + unsigned int len = count; | |
342 | + | |
343 | + if (len > sizeof(scratch) - 1) | |
344 | + len = sizeof(scratch) - 1; | |
345 | + scratch[len] = '\0'; | |
346 | + memcpy(scratch, buf, len); | |
347 | + kvm_hypercall1(KVM_S390_VIRTIO_NOTIFY, __pa(scratch)); | |
348 | + return len; | |
349 | +} | |
350 | + | |
351 | +void s390_virtio_console_init(void) | |
352 | +{ | |
353 | + virtio_cons_early_init(early_put_chars); | |
334 | 354 | } |
335 | 355 | |
336 | 356 | /* |
include/asm-s390/kvm_virtio.h
... | ... | @@ -50,5 +50,15 @@ |
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 |