powerpc: Don't Oops when accessing /proc/powerpc/lparcfg without hypervisor
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>
Tue, 27 Aug 2013 06:38:33 +0000 (16:38 +1000)
committerBen Hutchings <ben@decadent.org.uk>
Tue, 10 Sep 2013 00:57:33 +0000 (01:57 +0100)
commitc349bf07d6c05e89c967327af0f334604826d0e4
treedeae8ee0beeb79297b01a38838acea3d169d5627
parent83537f7467eb1f42014cd48cbd615c101cfc4d98
powerpc: Don't Oops when accessing /proc/powerpc/lparcfg without hypervisor

commit f5f6cbb61610b7bf9d9d96db9c3979d62a424bab upstream.

/proc/powerpc/lparcfg is an ancient facility (though still actively used)
which allows access to some informations relative to the partition when
running underneath a PAPR compliant hypervisor.

It makes no sense on non-pseries machines. However, currently, not only
can it be created on these if the kernel has pseries support, but accessing
it on such a machine will crash due to trying to do hypervisor calls.

In fact, it should also not do HV calls on older pseries that didn't have
an hypervisor either.

Finally, it has the plumbing to be a module but is a "bool" Kconfig option.

This fixes the whole lot by turning it into a machine_device_initcall
that is only created on pseries, and adding the necessary hypervisor
check before calling the H_GET_EM_PARMS hypercall

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
[bwh: Backported to 3.2: lparcfg_cleanup() was a bit different]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
arch/powerpc/kernel/lparcfg.c