OSDN Git Service

powerpc/udbg: Reduce the footgun potential of EARLY_DEBUG_LPAR(_HVSI)
authorMichael Ellerman <mpe@ellerman.id.au>
Mon, 24 Jul 2017 14:10:15 +0000 (00:10 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 31 Jul 2017 06:56:45 +0000 (16:56 +1000)
commit9227f0431435c9d664771b112c230e75ca4f9b52
treedb9bdcb00ae0b513b077f2867748fc86b57ad551
parent3603c52f02ee3ad536e4cd08ac08e9c0c4d0c7eb
powerpc/udbg: Reduce the footgun potential of EARLY_DEBUG_LPAR(_HVSI)

For debugging very early boot problems we have CONFIG_PPC_EARLY_DEBUG,
which allows configuring the kernel such that it unconditionally writes
to a particular type of console, regardless of whether that console
exists or not. This is useful sometimes when the kernel crashes before
it can even determine what platform it's on, and therefore what consoles
exist.

However if you boot a kernel built this way on a different platform, it
will generally crash because it writes to a console that doesn't exist.

A particularly nasty instance of this is if you enable the hypervisor
console early debug, and then boot that kernel on bare metal. The result
is that the kernel calls "the hypervisor" very early in boot, but the
kernel *is* the hypervisor, so we jump to the system call handler and
start executing all sorts of code that isn't ready to be run. This may
lead to a machine check or check stop depending on how lucky you are.

Luckily there is an easy way to avoid this particular case. We simply
read the MSR before installing the hooks, and if we see MSR_HV is set
then we are the hypervisor and we definitely should not use the
hypervisor console.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
drivers/tty/hvc/hvc_vio.c