we can really only use 1 serial port with kvmtool, and each serial
port takes quite a bit of boot time.. so default to only exposing 1.
Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Currently we reset the KVM interrupt line on initializing the 8250
serial device emulation.
For ARM this creates a problem where we use the in-kernel IRQ chip
before having fully initialized it. But with the new kernel interface
we cannot finish the GIC initialization before we know the number of
used IRQs, so we have to wait until all devices have been created and
initialized.
Since the in-kernel GIC emulation resets the IRQ line anyway and also
QEMU gets away without resetting it, the easiest solution is to drop
the IRQ line reset.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Both the 16550/8250 UART emulation in kvmtool as well as all the
drivers and DTBs for real hardware use level triggered interrutpts.
But the device tree currently describes them as being edge triggered,
which can lead to hangs in guests.
Use the new IRQ type parameter to properly describe the interrupts.
This goes along the lines of a similar QEMU patch:
http://git.qemu.org/?p=qemu.git;a=commitdiff;h=0be969a2d974971628fc4ed95834d22ecf0fd497
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Currently we describe every interrupt for each device in the FDT
as being edge triggered.
Add a parameter to the irq property generation to allow devices to
specify their interrupts as level triggered if needed.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
The recent introduction of bi-endianness on arm/arm64 had the
odd effect of breaking virtio-pci support on these platforms, as the
device endian field defaults to being VIRTIO_ENDIAN_HOST, which
is the wrong thing to have on a bi-endian capable architecture.
The fix is to check for the endianness on the ioport path the
same way we do it for mmio, which implies passing the vcpu all
the way down. Patch is a bit ugly, but aligns MMIO and ioport nicely.
Tested on arm64 and x86.
Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Currently the only use of the periodic timer tick in kvmtool is to
handle reading from stdin. Though functional, this periodic tick can be
problematic on slow (eg FPGA) platforms and can cause low interactivity or
even stop the execution from progressing at all.
This patch removes the periodic tick in favour of a dedicated thread blocked
waiting for input from the console. In order to reflect the new behaviour,
the old 'kvm__arch_periodic_tick' function is renamed to 'kvm__arch_read_term'.
In making this change it is necessary to actively flush the emulated serial
console's output buffer after the guest writes to it, as otherwise flushing
only happens with terminal input. Similarly, it is no longer necessary to
flush the buffer when we process input.
Signed-off-by: Jonathan Austin <jonathan.austin@arm.com>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Having several uarts with the same name makes the kernel (and dtc)
choke. Add the base address as a qualifier so we get unique names.
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
This patch adds fdt node generation to the 8250 emulation. The
serial8250_device is now stashed inside the ioport priv field, so that
it can be retrieved from the ioport passed back to the generation code.
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
If an architecture other than x86 wants to make use of ioport devices, the
interrupt lines will likely need remapping from their fixed values.
This patch allows an architecture callback, ioport__map_irq, to map
interrupts as appropriate.
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Kvmtool suppresses any output to a console that has not been elected
as *the* console.
While this makes sense on the input side (we want the input to be sent
to one console driver only), it seems to be the wrong thing to do on
the output side, as it effectively prevents the guest from switching
from one console to another (think earlyprintk using 8250 to virtio
console).
After all, the guest *does* poke this device and outputs something
there.
Just remove the kvm->cfg.active_console test from the output paths.
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
We already have something to wrap pthread with mutex_[init,lock,unlock]
calls. This patch creates a new struct mutex abstraction and moves
everything to work with it.
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Switch to using init/exit calls instead of the repeating call blocks in builtin-run.
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
This config option was 'extern'ed between different objects. Clean it up
and move it into struct kvm_config.
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Add support to 'lkvm debug' to inject arbitrary sysrqs using a new
'-s <sysrq>' argument.
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Adding FIFO functionality to the serial emulator to speed up the
console handling.
This also restricts sysrq functionality to the first serial port and
fixes the sysrq injection, which was broken because nothing ever reset
the BI status bit in the LSR.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Sasha reported, that a non RT guest reports "too much work for irq 4"
with the previous serial overhaul.
The reason is, that the new code allows unlimited tx transfers, which
triggers the sanity check in the 8250.c interrupt handler.
Limit the consecutive TX chars to 16 and let the guest kernel escape
from the 8250 interrupt handler. Set the TEMT/THRE bits in the
periodic serial console update.
Reported-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
The interrupt injection of the serial emulation is completely
broken. It's just doing random toggling of the interrupt line, which
can lead to complete console hangs.
The real hardware asserts the interrupt line when a condition
(RX/TX/Status) is met and the corresponding interrupt is enabled in
the IER. It's deasserted when the condition is cleared or the
corresponding interrupt is disabled in the IER.
So the correct emulation just needs to check after each state change
in the LSR or the IER which bits in the IIR need to be set and update
the interrupt line accordingly. To avoid setting the same state over
and over keep an internal state of the last set interrupt line state
and only update via the kvm ioctl when the new state differs.
Rename serial8250__inject_interrupts() to serial8250__update_consoles()
which reflects what the function really is about.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
There is no point to have the same switch case construct for all the
registers, just to take care of the oddball case of DLL/DLM.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
It's nice to align struct initializers, but random tab insertion into
the code flow is a horrible idea.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
The process of probing the 8250 serial port is as follows:
1. Start detecting IRQs
2. Enable the IER register [At this point, the port is supposed to light
the INTR].
3. Stop detecting IRQs [At this point, the driver detects which IRQ
belongs to that port].
4. Disable IER register.
Since we weren't enabling and disabling the IRQ based on IER writes, we
would often fail the probing since the driver couldn't detect which IRQ
is used by the port, and would just default that to 0.
This would cause slowness and may have caused hangs. For me there is a
significant increase in speed of the terminal after this patch.
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
[ penberg@kernel.org: whitspace cleanup ]
Signed-off-by: Pekka Enberg <penberg@kernel.org>
This patch adds the '-tty' option to 'kvm run' which allows the user to
remap a guest TTY into a PTS on the host.
Usage:
'kvm run --tty [id]'
The tty will be mapped to a pts and will be printed on the screen:
' Info: Assigned terminal 1 to pty /dev/pts/X'
At this point, it is possible to communicate with the guest using that pty.
This is useful for debugging guest kernel using KGDB:
1. Run the guest:
'kvm run -k [vmlinuz] -p "kgdboc=ttyS1 kgdbwait" --tty 1'
And see which PTY got assigned to ttyS1.
2. Run GDB on the host:
'gdb [vmlinuz]'
3. Connect to the guest (from within GDB):
'target remote /dev/pty/X'
4. Start debugging! (enter 'continue' to continue boot).
Cc: David Evensky <evensky@dancer.ca.sandia.gov>
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
To make all serials work well, unify value of the last three
serials' registers with the first serial. Otherwise, using ttyS1,
ttyS2, ttyS3 as console will slow the output.
Signed-off-by: Liming Wang <walimisdev@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Allow specifying an optional parameter when registering an
ioport range. The callback functions provided by the registering
module will be called with the same parameter.
This may be used to keep context during callbacks on IO operations.
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
We already register ioports for 0x2f8 and 0x3e8 and mark them as inactive so
mark 0x2e8 ioport as such as well. This is a preparational step to dropping
serial port dummy registrations from ioport__setup_legacy().
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
This patch moves hypervisor native hardware emulation drivers to "hw" directory
like we've done for virtio and disk image code.
Acked-by: Cyrill Gorcunov <gorcunov@gmail.com>
Acked-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Pekka Enberg <penberg@kernel.org>