]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/log
mirror_ubuntu-bionic-kernel.git
6 years agopowerpc: Set regs->dar if memory access fails in emulate_step()
Paul Mackerras [Wed, 30 Aug 2017 04:12:37 +0000 (14:12 +1000)]
powerpc: Set regs->dar if memory access fails in emulate_step()

This adds code to the instruction emulation code to set regs->dar
to the address of any memory access that fails.  This address is
not necessarily the same as the effective address of the instruction,
because if the memory access is unaligned, it might cross a page
boundary and fault on the second page.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc: Emulate the dcbz instruction
Paul Mackerras [Wed, 30 Aug 2017 04:12:36 +0000 (14:12 +1000)]
powerpc: Emulate the dcbz instruction

This adds code to analyse_instr() and emulate_step() to understand the
dcbz (data cache block zero) instruction.  The emulate_dcbz() function
is made public so it can be used by the alignment handler in future.
(The apparently unnecessary cropping of the address to 32 bits is
there because it will be needed in that situation.)

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc: Emulate load/store floating double pair instructions
Paul Mackerras [Wed, 30 Aug 2017 04:12:35 +0000 (14:12 +1000)]
powerpc: Emulate load/store floating double pair instructions

This adds lfdp[x] and stfdp[x] to the set of instructions that
analyse_instr() and emulate_step() understand.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc: Emulate vector element load/store instructions
Paul Mackerras [Wed, 30 Aug 2017 04:12:34 +0000 (14:12 +1000)]
powerpc: Emulate vector element load/store instructions

This adds code to analyse_instr() and emulate_step() to handle the
vector element loads and stores:

lvebx, lvehx, lvewx, stvebx, stvehx, stvewx.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc: Emulate FP/vector/VSX loads/stores correctly when regs not live
Paul Mackerras [Wed, 30 Aug 2017 04:12:33 +0000 (14:12 +1000)]
powerpc: Emulate FP/vector/VSX loads/stores correctly when regs not live

At present, the analyse_instr/emulate_step code checks for the
relevant MSR_FP/VEC/VSX bit being set when a FP/VMX/VSX load
or store is decoded, but doesn't recheck the bit before reading or
writing the relevant FP/VMX/VSX register in emulate_step().

Since we don't have preemption disabled, it is possible that we get
preempted between checking the MSR bit and doing the register access.
If that happened, then the registers would have been saved to the
thread_struct for the current process.  Accesses to the CPU registers
would then potentially read stale values, or write values that would
never be seen by the user process.

Another way that the registers can become non-live is if a page
fault occurs when accessing user memory, and the page fault code
calls a copy routine that wants to use the VMX or VSX registers.

To fix this, the code for all the FP/VMX/VSX loads gets restructured
so that it forms an image in a local variable of the desired register
contents, then disables preemption, checks the MSR bit and either
sets the CPU register or writes the value to the thread struct.
Similarly, the code for stores checks the MSR bit, copies either the
CPU register or the thread struct to a local variable, then reenables
preemption and then copies the register image to memory.

If the instruction being emulated is in the kernel, then we must not
use the register values in the thread_struct.  In this case, if the
relevant MSR enable bit is not set, then emulate_step refuses to
emulate the instruction.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc: Make load/store emulation use larger memory accesses
Paul Mackerras [Wed, 30 Aug 2017 04:12:32 +0000 (14:12 +1000)]
powerpc: Make load/store emulation use larger memory accesses

At the moment, emulation of loads and stores of up to 8 bytes to
unaligned addresses on a little-endian system uses a sequence of
single-byte loads or stores to memory.  This is rather inefficient,
and the code is hard to follow because it has many ifdefs.
In addition, the Power ISA has requirements on how unaligned accesses
are performed, which are not met by doing all accesses as
sequences of single-byte accesses.

Emulation of VSX loads and stores uses __copy_{to,from}_user,
which means the emulation code has no control on the size of
accesses.

To simplify this, we add new copy_mem_in() and copy_mem_out()
functions for accessing memory.  These use a sequence of the largest
possible aligned accesses, up to 8 bytes (or 4 on 32-bit systems),
to copy memory between a local buffer and user memory.  We then
rewrite {read,write}_mem_unaligned and the VSX load/store
emulation using these new functions.

These new functions also simplify the code in do_fp_load() and
do_fp_store() for the unaligned cases.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc: Add emulation for the addpcis instruction
Paul Mackerras [Wed, 30 Aug 2017 04:12:31 +0000 (14:12 +1000)]
powerpc: Add emulation for the addpcis instruction

The addpcis instruction puts the sum of the next instruction address
plus a constant into a register.  Since the result depends on the
address of the instruction, it will give an incorrect result if it
is single-stepped out of line, which is what the *probes subsystem
will currently do if a probe is placed on an addpcis instruction.
This fixes the problem by adding emulation of it to analyse_instr().

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc: Don't update CR0 in emulation of popcnt, prty, bpermd instructions
Paul Mackerras [Wed, 30 Aug 2017 04:12:30 +0000 (14:12 +1000)]
powerpc: Don't update CR0 in emulation of popcnt, prty, bpermd instructions

The architecture shows the least-significant bit of the instruction
word as reserved for the popcnt[bwd], prty[wd] and bpermd
instructions, that is, these instructions never update CR0.
Therefore this changes the emulation of these instructions to
skip the CR0 update.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc: Fix emulation of the isel instruction
Paul Mackerras [Wed, 30 Aug 2017 04:12:29 +0000 (14:12 +1000)]
powerpc: Fix emulation of the isel instruction

The case added for the isel instruction was added inside a switch
statement which uses the 10-bit minor opcode field in the 0x7fe
bits of the instruction word.  However, for the isel instruction,
the minor opcode field is only the 0x3e bits, and the 0x7c0 bits
are used for the "BC" field, which indicates which CR bit to use
to select the result.

Therefore, for the isel emulation to work correctly when BC != 0,
we need to match on ((instr >> 1) & 0x1f) == 15).  To do this, we
pull the isel case out of the switch statement and put it in an
if statement of its own.

Fixes: e27f71e5ff3c ("powerpc/lib/sstep: Add isel instruction emulation")
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/64: Fix update forms of loads and stores to write 64-bit EA
Paul Mackerras [Wed, 30 Aug 2017 04:12:28 +0000 (14:12 +1000)]
powerpc/64: Fix update forms of loads and stores to write 64-bit EA

When a 64-bit processor is executing in 32-bit mode, the update forms
of load and store instructions are required by the architecture to
write the full 64-bit effective address into the RA register, though
only the bottom 32 bits are used to address memory.  Currently,
the instruction emulation code writes the truncated address to the
RA register.  This fixes it by keeping the full 64-bit EA in the
instruction_op structure, truncating the address in emulate_step()
where it is used to address memory, rather than in the address
computations in analyse_instr().

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc: Handle most loads and stores in instruction emulation code
Paul Mackerras [Wed, 30 Aug 2017 04:12:27 +0000 (14:12 +1000)]
powerpc: Handle most loads and stores in instruction emulation code

This extends the instruction emulation infrastructure in sstep.c to
handle all the load and store instructions defined in the Power ISA
v3.0, except for the atomic memory operations, ldmx (which was never
implemented), lfdp/stfdp, and the vector element load/stores.

The instructions added are:

Integer loads and stores: lbarx, lharx, lqarx, stbcx., sthcx., stqcx.,
lq, stq.

VSX loads and stores: lxsiwzx, lxsiwax, stxsiwx, lxvx, lxvl, lxvll,
lxvdsx, lxvwsx, stxvx, stxvl, stxvll, lxsspx, lxsdx, stxsspx, stxsdx,
lxvw4x, lxsibzx, lxvh8x, lxsihzx, lxvb16x, stxvw4x, stxsibx, stxvh8x,
stxsihx, stxvb16x, lxsd, lxssp, lxv, stxsd, stxssp, stxv.

These instructions are handled both in the analyse_instr phase and in
the emulate_step phase.

The code for lxvd2ux and stxvd2ux has been taken out, as those
instructions were never implemented in any processor and have been
taken out of the architecture, and their opcodes have been reused for
other instructions in POWER9 (lxvb16x and stxvb16x).

The emulation for the VSX loads and stores uses helper functions
which don't access registers or memory directly, which can hopefully
be reused by KVM later.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc: Don't check MSR FP/VMX/VSX enable bits in analyse_instr()
Paul Mackerras [Wed, 30 Aug 2017 04:12:26 +0000 (14:12 +1000)]
powerpc: Don't check MSR FP/VMX/VSX enable bits in analyse_instr()

This removes the checks for the FP/VMX/VSX enable bits in the MSR
from analyse_instr() and adds them to emulate_step() instead.

The reason for this is that we may want to use analyse_instr() in
a situation where the FP/VMX/VSX register values are stored in the
current thread_struct and the FP/VMX/VSX enable bits in the MSR
image in the pt_regs are zero.  Since analyse_instr() doesn't make
any changes to register state, it is reasonable for it to indicate
what the effect of an instruction would be even though the relevant
enable bit is off.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc: Change analyse_instr so it doesn't modify *regs
Paul Mackerras [Wed, 30 Aug 2017 04:12:25 +0000 (14:12 +1000)]
powerpc: Change analyse_instr so it doesn't modify *regs

The analyse_instr function currently doesn't just work out what an
instruction does, it also executes those instructions whose effect
is only to update CPU registers that are stored in struct pt_regs.
This is undesirable because optprobes uses analyse_instr to work out
if an instruction could be successfully emulated in future.

This changes analyse_instr so it doesn't modify *regs; instead it
stores information in the instruction_op structure to indicate what
registers (GPRs, CR, XER, LR) would be set and what value they would
be set to.  A companion function called emulate_update_regs() can
then use that information to update a pt_regs struct appropriately.

As a minor cleanup, this replaces inline asm using the cntlzw and
cntlzd instructions with calls to __builtin_clz() and __builtin_clzl().

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc: Correct instruction code for xxlor instruction
Paul Mackerras [Wed, 30 Aug 2017 04:12:24 +0000 (14:12 +1000)]
powerpc: Correct instruction code for xxlor instruction

The instruction code for xxlor that commit 0016a4cf5582 ("powerpc:
Emulate most Book I instructions in emulate_step()", 2010-06-15)
added is actually the code for xxlnor.  It is used in get_vsr()
and put_vsr() and the effect of the error is that if emulate_step
is used to emulate a VSX load or store from any register other
than vsr0, the bitwise complement of the correct value will be
loaded or stored.  This corrects the error.

Fixes: 0016a4cf5582 ("powerpc: Emulate most Book I instructions in emulate_step()")
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc: Fix DAR reporting when alignment handler faults
Michael Ellerman [Thu, 24 Aug 2017 10:49:57 +0000 (20:49 +1000)]
powerpc: Fix DAR reporting when alignment handler faults

Anton noticed that if we fault part way through emulating an unaligned
instruction, we don't update the DAR to reflect that.

The DAR value is eventually reported back to userspace as the address
in the SEGV signal, and if userspace is using that value to demand
fault then it can be confused by us not setting the value correctly.

This patch is ugly as hell, but is intended to be the minimal fix and
back ports easily.

Cc: stable@vger.kernel.org
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Reviewed-by: Paul Mackerras <paulus@ozlabs.org>
6 years agopowerpc/pseries: Don't attempt to acquire drc during memory hot add for assigned...
John Allen [Wed, 23 Aug 2017 17:18:43 +0000 (12:18 -0500)]
powerpc/pseries: Don't attempt to acquire drc during memory hot add for assigned lmbs

Check if an LMB is assigned before attempting to call dlpar_acquire_drc
in order to avoid any unnecessary rtas calls. This substantially
reduces the running time of memory hot add on lpars with large amounts
of memory.

[mpe: We need to explicitly set rc to 0 in the success case, otherwise
 the compiler might think we use rc without initialising it.]

Fixes: c21f515c7436 ("powerpc/pseries: Make the acquire/release of the drc for memory a seperate step")
Cc: stable@vger.kernel.org # v4.11+
Signed-off-by: John Allen <jallen@linux.vnet.ibm.com>
Reviewed-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/4xx: Constify cpm_suspend_ops
Arvind Yadav [Wed, 30 Aug 2017 16:48:20 +0000 (22:18 +0530)]
powerpc/4xx: Constify cpm_suspend_ops

struct platform_suspend_ops are not supposed to change at runtime.
Functions suspend_set_ops working with const platform_suspend_ops. So
mark the non-const structs as const.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/smp: Add Power9 scheduler topology
Oliver O'Halloran [Thu, 29 Jun 2017 07:12:56 +0000 (17:12 +1000)]
powerpc/smp: Add Power9 scheduler topology

In previous generations of Power processors each core had a private L2
cache. The Power 9 processor has a slightly different design where the
L2 cache is shared among pairs of cores rather than being completely
private.

Making the scheduler aware of this cache sharing allows the scheduler to
make better migration decisions. For example, if two CPU heavy tasks
share a core then one task can be migrated to the paired core to improve
throughput. Under the existing three level topology the task could be
migrated to any core on the same chip, while with the new topology it
would be preferentially migrated to the paired core so it remains
cache-hot.

Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/smp: Add cpu_l2_cache_map
Oliver O'Halloran [Thu, 29 Jun 2017 07:12:55 +0000 (17:12 +1000)]
powerpc/smp: Add cpu_l2_cache_map

We want to add an extra level to the CPU scheduler topology to account
for cores which share a cache. To do this we need to build a cpumask
for each CPU that indicates which CPUs share this cache to use as an
input to the scheduler.

Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/smp: Rework CPU topology construction
Oliver O'Halloran [Thu, 29 Jun 2017 07:12:54 +0000 (17:12 +1000)]
powerpc/smp: Rework CPU topology construction

The CPU scheduler topology is constructed from a number of per-cpu
cpumasks which describe which sets of logical CPUs are related in some
fashion. Current code that handles constructing these masks when CPUs
are hot(un)plugged can be simplified a bit by exploiting the fact that
the scheduler requires higher levels of the toplogy (e.g package level
groupings) to be supersets of the lower levels (e.g.  threas in a core).
This patch reworks the cpumask construction to be simpler and easier to
extend with extra topology levels.

Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
[mpe: Fix CONFIG_HOTPLUG_CPU=n build]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/smp: Use cpu_to_chip_id() to find core siblings
Oliver O'Halloran [Thu, 29 Jun 2017 07:12:53 +0000 (17:12 +1000)]
powerpc/smp: Use cpu_to_chip_id() to find core siblings

When building the CPU scheduler topology the kernel uses the ibm,chipid
property from the devicetree to group logical CPUs. Currently the DT
search for this property is open-coded in smp.c and this functionality
is a duplication of what's in cpu_to_chip_id() already. This patch
removes the existing search in favor of that.

It's worth mentioning that the semantics of the search are different
in cpu_to_chip_id(). When there is no ibm,chipid in the CPUs node it
will also search /cpus and / for the property, but this should not
effect the output topology.

Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agocxl: Fix driver use count
Frederic Barrat [Wed, 30 Aug 2017 10:15:49 +0000 (12:15 +0200)]
cxl: Fix driver use count

cxl keeps a driver use count, which is used with the hash memory model
on p8 to know when to upgrade local TLBIs to global and to trigger
callbacks to manage the MMU for PSL8.

If a process opens a context and closes without attaching or fails the
attachment, the driver use count is never decremented. As a
consequence, TLB invalidations remain global, even if there are no
active cxl contexts.

We should increment the driver use count when the process is attaching
to the cxl adapter, and not on open. It's not needed before the
adapter starts using the context and the use count is decremented on
the detach path, so it makes more sense.

It affects only the user api. The kernel api is already doing The
Right Thing.

Signed-off-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Cc: stable@vger.kernel.org # v4.2+
Fixes: 7bb5d91a4dda ("cxl: Rework context lifetimes")
Acked-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agoselftests/powerpc: Force ptrace tests to build -fno-pie
Michael Neuling [Wed, 30 Aug 2017 10:45:12 +0000 (20:45 +1000)]
selftests/powerpc: Force ptrace tests to build -fno-pie

Currently these tests won't build with a `--enable-default-pie`
compiler as they require r30 to be clobbered. This gives
an error:
  ptrace-tm-spd-gpr.c:41:2: error: PIC register clobbered by 'r30' in 'asm'

This forces these tests to be built no-pie.

Signed-off-by: Michael Neuling <mikey@neuling.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc: conditionally compile platform-specific serial drivers
Hannes Reinecke [Tue, 27 Jun 2017 14:29:51 +0000 (16:29 +0200)]
powerpc: conditionally compile platform-specific serial drivers

mpsc.c and mpc52xx-psc.c are platform-specific serial drivers, and
should be compiled for the respective platforms only.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Torsten Duwe <duwe@suse.de>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/asm: Convert .llong directives to .8byte
Tobin C. Harding [Thu, 9 Mar 2017 05:42:12 +0000 (16:42 +1100)]
powerpc/asm: Convert .llong directives to .8byte

.llong is an undocumented PPC specific directive. The generic
equivalent is .quad, but even better (because it's self describing) is
.8byte.

Convert all .llong directives to .8byte.

Signed-off-by: Tobin C. Harding <me@tobin.cc>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/configs: Enable THP and 64K for ppc64(le)_defconfig
Balbir Singh [Thu, 13 Apr 2017 07:20:45 +0000 (17:20 +1000)]
powerpc/configs: Enable THP and 64K for ppc64(le)_defconfig

Enable 64K page size and THP. I use ppc64le_defconfig when I need
a single config across guest and host, but having 4K page size
as default is not what I expect. I could move these over to
server.config and merge if ppc64_defconfig is meant for systems
that use 4k pages by default.

Signed-off-by: Balbir Singh <bsingharora@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agoMAINTAINERS: Add drivers/watchdog/wdrtas.c to powerpc section
Murilo Opsfelder Araujo [Thu, 1 Jun 2017 16:05:41 +0000 (13:05 -0300)]
MAINTAINERS: Add drivers/watchdog/wdrtas.c to powerpc section

drivers/watchdog/wdrtas.c is of interest of linuxppc maintainers.

Signed-off-by: Murilo Opsfelder Araujo <mopsfelder@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/configs: Enable function trace by default
Balbir Singh [Thu, 13 Apr 2017 07:03:09 +0000 (17:03 +1000)]
powerpc/configs: Enable function trace by default

Most (all?) distros turn these on, so it makes sense to enable them
for testing coverage, and they're also useful for developers.

Signed-off-by: Balbir Singh <bsingharora@gmail.com>
Acked-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
[mpe: Reword change log]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/xmon: Add ISA v3.0 SPRs to SPR dump
Balbir Singh [Wed, 30 Aug 2017 11:45:09 +0000 (21:45 +1000)]
powerpc/xmon: Add ISA v3.0 SPRs to SPR dump

Add support for printing the PIDR/TIDR for ISA 300 and PSSCR and PTCR
in ISA 3.0 hypervisor mode.

SPRN_PSSCR_PR is the privileged mode access and is used when we are
not in hypervisor mode.

Signed-off-by: Balbir Singh <bsingharora@gmail.com>
[mpe: Split out of larger patch]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/xmon: Add AMR, UAMOR, AMOR, IAMR to SPR dump
Balbir Singh [Wed, 30 Aug 2017 11:43:34 +0000 (21:43 +1000)]
powerpc/xmon: Add AMR, UAMOR, AMOR, IAMR to SPR dump

This patch adds support to xmon for dumping the AMR, UAMOR, AMOR and
IAMR SPRs based on their supported ISA revisions.

Signed-off-by: Balbir Singh <bsingharora@gmail.com>
[mpe: Split out of larger patch]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/xmon: Dump all 64 bits of HDEC
Balbir Singh [Wed, 30 Aug 2017 00:27:44 +0000 (10:27 +1000)]
powerpc/xmon: Dump all 64 bits of HDEC

ISA 3.0 defines hypervisor decrementer to be 64 bits in length.
This patch extends the print format for to be 64 bits.

Signed-off-by: Balbir Singh <bsingharora@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc: Squash lines for simple wrapper functions
Masahiro Yamada [Tue, 6 Sep 2016 11:21:50 +0000 (20:21 +0900)]
powerpc: Squash lines for simple wrapper functions

Remove unneeded variables and assignments.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/mm/radix: Prettify mapped memory range print out
Michael Ellerman [Wed, 30 Aug 2017 07:41:17 +0000 (17:41 +1000)]
powerpc/mm/radix: Prettify mapped memory range print out

When we map memory at boot we print out the ranges of real addresses
that we mapped and the page size that was used.

Currently it's a bit ugly:

  Mapped range 0x0 - 0x2000000000 with 0x40000000
  Mapped range 0x200000000000 - 0x202000000000 with 0x40000000

Pad the addresses so they line up, and print the page size using
actual units, eg:

  Mapped 0x0000000000000000-0x0000000001200000 with 64.0 KiB pages
  Mapped 0x0000000001200000-0x0000000040000000 with 2.00 MiB pages
  Mapped 0x0000000040000000-0x0000000100000000 with 1.00 GiB pages

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/mm/radix: Add pr_fmt() to pgtable-radix.c
Michael Ellerman [Wed, 30 Aug 2017 07:41:29 +0000 (17:41 +1000)]
powerpc/mm/radix: Add pr_fmt() to pgtable-radix.c

Make the printks look a bit nicer by adding a prefix.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/kernel: Change retrieval of pci_dn
Bryant G. Ly [Tue, 29 Aug 2017 13:11:51 +0000 (08:11 -0500)]
powerpc/kernel: Change retrieval of pci_dn

For a PCI device it's pci_dn can be retrieved from
pdev->dev.archdata.firmware_data, PCI_DN(devnode), or parent's list.
Thus, we should just use the existing function pci_get_pdn_by_devfn
to get the pci_dn.

Signed-off-by: Bryant G. Ly <bryantly@linux.vnet.ibm.com>
Reviewed-by: Sam Bobroff <sam.bobroff@au1.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/mm/cxl: Add barrier when setting mm cpumask
Aneesh Kumar K.V [Mon, 28 Aug 2017 08:35:44 +0000 (14:05 +0530)]
powerpc/mm/cxl: Add barrier when setting mm cpumask

We need to add memory barrier so that the page table walk doesn't happen
before the cpumask is set and made visible to the other cpus. We need
to use a sync here instead of lwsync because lwsync is not sufficient for
store/load ordering.

We also need to add an if (mm) check so that we do the right thing when called
with a kernel context. For kernel context, we have mm = NULL. W.r.t kernel
address we can skip setting the mm cpumask.

Fixes: 0f4bc0932e ("powerpc/mm/cxl: Add the fault handling cpu to mm cpumask")
Cc: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Reported-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Acked-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/powernv/vas: Define copy/paste interfaces
Sukadev Bhattiprolu [Tue, 29 Aug 2017 06:23:40 +0000 (23:23 -0700)]
powerpc/powernv/vas: Define copy/paste interfaces

Define interfaces (wrappers) to the 'copy' and 'paste'
instructions (which are new in PowerISA 3.0). These are intended to be
used to by NX driver(s) to submit Coprocessor Request Blocks (CRBs) to
the NX hardware engines.

Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/powernv/vas: Define vas_tx_win_open()
Sukadev Bhattiprolu [Tue, 29 Aug 2017 06:23:39 +0000 (23:23 -0700)]
powerpc/powernv/vas: Define vas_tx_win_open()

Define an interface to open a VAS send window. This interface is
intended to be used the Nest Accelerator (NX) driver(s) to open
a send window and use it to submit compression/encryption requests
to a VAS receive window.

The receive window, identified by the [vasid, cop] parameters, must
already be open in VAS (i.e connected to an NX engine).

Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/powernv/vas: Define vas_win_close() interface
Sukadev Bhattiprolu [Tue, 29 Aug 2017 06:23:38 +0000 (23:23 -0700)]
powerpc/powernv/vas: Define vas_win_close() interface

Define the vas_win_close() interface which should be used to close a
send or receive windows.

While the hardware configurations required to open send and receive
windows differ, the configuration to close a window is the same for
both. So we use a single interface to close the window.

Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/powernv/vas: Define vas_rx_win_open() interface
Sukadev Bhattiprolu [Tue, 29 Aug 2017 06:23:37 +0000 (23:23 -0700)]
powerpc/powernv/vas: Define vas_rx_win_open() interface

Define the vas_rx_win_open() interface. This interface is intended to
be used by the Nest Accelerator (NX) driver(s) to setup receive
windows for one or more NX engines (which implement compression &
encryption algorithms in the hardware).

Follow-on patches will provide an interface to close the window and to
open a send window that kernel subsystems can use to access the NX
engines.

The interface to open a receive window is expected to be invoked for
each instance of VAS in the system.

Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/powernv/vas: Define helpers to alloc/free windows
Sukadev Bhattiprolu [Tue, 29 Aug 2017 06:23:36 +0000 (23:23 -0700)]
powerpc/powernv/vas: Define helpers to alloc/free windows

Define helpers to allocate/free VAS window objects. These will be used
in follow-on patches when opening/closing windows.

Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/powernv/vas: Define helpers to init window context
Sukadev Bhattiprolu [Tue, 29 Aug 2017 06:23:35 +0000 (23:23 -0700)]
powerpc/powernv/vas: Define helpers to init window context

Define helpers to initialize window context registers of the VAS
hardware. These will be used in follow-on patches when opening/closing
VAS windows.

Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/powernv/vas: Define helpers to access MMIO regions
Sukadev Bhattiprolu [Tue, 29 Aug 2017 06:23:34 +0000 (23:23 -0700)]
powerpc/powernv/vas: Define helpers to access MMIO regions

Define some helper functions to access the MMIO regions. We use these
in follow-on patches to read/write VAS hardware registers. They are
also used to later issue 'paste' instructions to submit requests to
the NX hardware engines.

Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/powernv/vas: Define vas_init() and vas_exit()
Sukadev Bhattiprolu [Tue, 29 Aug 2017 06:23:33 +0000 (23:23 -0700)]
powerpc/powernv/vas: Define vas_init() and vas_exit()

Implement vas_init() and vas_exit() functions for a new VAS module.
This VAS module is essentially a library for other device drivers
and kernel users of the NX coprocessors like NX-842 and NX-GZIP.
In the future this will be extended to add support for user space
to access the NX coprocessors.

VAS is currently only supported with 64K page size.

Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/powernv: Move GET_FIELD/SET_FIELD to vas.h
Sukadev Bhattiprolu [Tue, 29 Aug 2017 06:23:32 +0000 (23:23 -0700)]
powerpc/powernv: Move GET_FIELD/SET_FIELD to vas.h

Move the GET_FIELD and SET_FIELD macros to vas.h as VAS and other
users of VAS, including NX-842 can use those macros.

There is a lot of related code between the VAS/NX kernel drivers
and skiboot. For consistency, switch the order of parameters in
SET_FIELD to match the order in skiboot.

Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Reviewed-by: Dan Streetman <ddstreet@ieee.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/powernv/vas: Define macros, register fields and structures
Sukadev Bhattiprolu [Tue, 29 Aug 2017 06:23:31 +0000 (23:23 -0700)]
powerpc/powernv/vas: Define macros, register fields and structures

Define macros for the VAS hardware registers and bit-fields as well
as couple of data structures needed by the VAS driver.

Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
[mpe: Fixup include guard to use _ASM_POWERPC_VAS_H]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/xmon: Fix display of SPRs
Balbir Singh [Tue, 29 Aug 2017 07:22:36 +0000 (17:22 +1000)]
powerpc/xmon: Fix display of SPRs

Convert 0.16x to 0.16lx. Otherwise we lose the top 8 nibbles and
effectively print only the last 32 bits.

Fixes: 1846193b178d ("powerpc/xmon: Dump ISA 2.06 SPRs")
Signed-off-by: Balbir Singh <bsingharora@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/pci: Remove OF node back pointer from pci_dn
Alexey Kardashevskiy [Tue, 29 Aug 2017 07:34:04 +0000 (17:34 +1000)]
powerpc/pci: Remove OF node back pointer from pci_dn

The check_req() helper uses pci_get_pdn() to get an OF node pointer.
pci_get_pdn() returns a pci_dn pointer which either:
1) from the OF node returned by pci_device_to_OF_node();
2) from the parent child_list where entries don't have OF node pointers.
Since check_req() does not care about 2), it can call
pci_device_to_OF_node() directly, hence the change.

The find_pe_dn() helper uses embedded pci_dn to get an OF node which is
also stored in edev->pdev so let's take a shortcut and call
pci_device_to_OF_node() directly.

With these 2 changes, we can finally get rid of the OF node back pointer.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/eeh: Reduce use of pci_dn::node
Alexey Kardashevskiy [Tue, 29 Aug 2017 07:34:03 +0000 (17:34 +1000)]
powerpc/eeh: Reduce use of pci_dn::node

The pci_dn struct caches a OF device node pointer in order to access
the "ibm,loc-code" property when EEH is recovering.

However, when this happens in eeh_dev_check_failure(), we also have
a pci_dev pointer which should have a valid pointer to the device node
when pci_dn has one (both pointers are not NULL for physical functions
and are NULL for virtual functions).

This changes pci_remove_device_node_info() to look for a parent of
the node being removed, just like pci_add_device_node_info() does when it
references the parent node.

This is the first step to get rid of pci_dn::node.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/eeh: Remove unnecessary config_addr from eeh_dev
Alexey Kardashevskiy [Tue, 29 Aug 2017 07:34:02 +0000 (17:34 +1000)]
powerpc/eeh: Remove unnecessary config_addr from eeh_dev

The eeh_dev struct hold a config space address of an associated node
and the very same address is also stored in the pci_dn struct which
is always present during the eeh_dev lifetime.

This uses bus:devfn directly from pci_dn instead of cached and packed
config_addr.

Since config_addr is made from device's bus:dev.fn, there is no point
in keeping it in the debugfs either so remove that too.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/eeh: Remove unnecessary pointer to phb from eeh_dev
Alexey Kardashevskiy [Tue, 29 Aug 2017 07:34:01 +0000 (17:34 +1000)]
powerpc/eeh: Remove unnecessary pointer to phb from eeh_dev

The eeh_dev struct already holds a pointer to pci_dn which it does not
exist without and pci_dn itself holds the very same pointer so just
use it.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/eeh: Reduce to one the number of places where edev is allocated
Alexey Kardashevskiy [Tue, 29 Aug 2017 07:34:00 +0000 (17:34 +1000)]
powerpc/eeh: Reduce to one the number of places where edev is allocated

arch/powerpc/kernel/eeh_dev.c:57 is the only legit place where edev
is allocated; other 2 places allocate it on stack and in the heap for
a very short period of time to use eeh_pe_get() as takes edev.

This changes eeh_pe_get() to receive required parameters explicitly.

This removes unnecessary temporary allocation of edev.

This uses the "pe_no" name instead of the "pe_config_addr" name as
it actually is a PE number and not a config space address as it seemed.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Acked-by: Russell Currey <ruscur@russell.cc>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/pci: Remove unused parameter from add_one_dev_pci_data()
Alexey Kardashevskiy [Tue, 29 Aug 2017 07:33:59 +0000 (17:33 +1000)]
powerpc/pci: Remove unused parameter from add_one_dev_pci_data()

pdev is always NULL, remove it.

To make checkpatch.pl happy, this also removes the "out of memory"
message.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Acked-by: Russell Currey <ruscur@russell.cc>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/512x: Constify clk_div_tables
Arvind Yadav [Mon, 28 Aug 2017 06:05:15 +0000 (11:35 +0530)]
powerpc/512x: Constify clk_div_tables

clk_div_tables are not supposed to change at runtime.
mpc512x_clk_divtable function working with const clk_div_table. So
mark the non-const structs as const.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/44x: Fix mask and shift to zero bug
Dan Carpenter [Fri, 25 Aug 2017 10:33:40 +0000 (13:33 +0300)]
powerpc/44x: Fix mask and shift to zero bug

My static checker complains that 0x00001800 >> 13 is zero. Looking at
the context, it seems like a copy and paste bug from the line below
and probably 0x3 << 13 or 0x00006000 was intended.

Fixes: 2af59f7d5c3e ("[POWERPC] 4xx: Add 405GPr and 405EP support in boot wrapper")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/83xx: Use sizeof correct type when ioremapping
Dan Carpenter [Wed, 28 Jun 2017 11:49:07 +0000 (14:49 +0300)]
powerpc/83xx: Use sizeof correct type when ioremapping

There is a cut and paste error here so we use sizeof(struct mpc83xx_pmc)
to remap the memory for "clock_regs". That sizeof() is 20 bytes and we
only need to remap 12 bytes. It presumably doesn't affect run time too
much...

I changed them to both use sizeof(*variable_name) because that's the
preferred kernel style these days.

Fixes: d49747bdfb2d ("powerpc/mpc83xx: Power Management support")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
[mpe: It will map at least one page anyway, but still a good cleanup]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc: Machine check interrupt is a non-maskable interrupt
Nicholas Piggin [Wed, 19 Jul 2017 06:59:12 +0000 (16:59 +1000)]
powerpc: Machine check interrupt is a non-maskable interrupt

Use nmi_enter similarly to system reset interrupts. This uses NMI
printk NMI buffers and turns off various debugging facilities that
helps avoid tripping on ourselves or other CPUs.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/powernv: Use kernel crash path for machine checks
Nicholas Piggin [Wed, 19 Jul 2017 06:59:11 +0000 (16:59 +1000)]
powerpc/powernv: Use kernel crash path for machine checks

There are quite a few machine check exceptions that can be caused by
kernel bugs. To make debugging easier, use the kernel crash path in
cases of synchronous machine checks that occur in kernel mode, if that
would not result in the machine going straight to panic or crash dump.

There is a downside here that die()ing the process in kernel mode can
still leave the system unstable. panic_on_oops will always force the
system to fail-stop, so systems where that behaviour is important will
still do the right thing.

As a test, when triggering an i-side 0111b error (ifetch from foreign
address) in kernel mode process context on POWER9, the kernel currently
dies quickly like this:

  Severe Machine check interrupt [Not recovered]
    NIP [ffff000000000000]: 0xffff000000000000
    Initiator: CPU
    Error type: Real address [Instruction fetch (foreign)]
  [  127.426651616,0] OPAL: Reboot requested due to Platform error.
      Effective[  127.426693712,3] OPAL: Reboot requested due to Platform error. address: ffff000000000000
  opal: Reboot type 1 not supported
  Kernel panic - not syncing: PowerNV Unrecovered Machine Check
  CPU: 56 PID: 4425 Comm: syscall Tainted: G   M            4.12.0-rc1-13857-ga4700a261072-dirty #35
  Call Trace:
  [  128.017988928,4] IPMI: BUG: Dropping ESEL on the floor due to
    buggy/mising code in OPAL for this BMC
    Rebooting in 10 seconds..
  Trying to free IRQ 496 from IRQ context!

After this patch, the process is killed and the kernel continues with
this message, which gives enough information to identify the offending
branch (i.e., with CFAR):

  Severe Machine check interrupt [Not recovered]
    NIP [ffff000000000000]: 0xffff000000000000
    Initiator: CPU
    Error type: Real address [Instruction fetch (foreign)]
      Effective address: ffff000000000000
  Oops: Machine check, sig: 7 [#1]
  SMP NR_CPUS=2048
  NUMA
  PowerNV
  Modules linked in: iptable_mangle ipt_MASQUERADE nf_nat_masquerade_ipv4 ...
  CPU: 22 PID: 4436 Comm: syscall Tainted: G   M            4.12.0-rc1-13857-ga4700a261072-dirty #36
  task: c000000932300000 task.stack: c000000932380000
  NIP: ffff000000000000 LR: 00000000217706a4 CTR: ffff000000000000
  REGS: c00000000fc8fd80 TRAP: 0200   Tainted: G   M             (4.12.0-rc1-13857-ga4700a261072-dirty)
  MSR: 90000000001c1003 <SF,HV,ME,RI,LE>
    CR: 24000484  XER: 20000000
  CFAR: c000000000004c80 DAR: 0000000021770a90 DSISR: 0a000000 SOFTE: 1
  GPR00: 0000000000001ebe 00007fffce4818b0 0000000021797f00 0000000000000000
  GPR04: 00007fff8007ac24 0000000044000484 0000000000004000 00007fff801405e8
  GPR08: 900000000280f033 0000000024000484 0000000000000000 0000000000000030
  GPR12: 9000000000001003 00007fff801bc370 0000000000000000 0000000000000000
  GPR16: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
  GPR20: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
  GPR24: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
  GPR28: 00007fff801b0000 0000000000000000 00000000217707a0 00007fffce481918
  NIP [ffff000000000000] 0xffff000000000000
  LR [00000000217706a4] 0x217706a4
  Call Trace:
  Instruction dump:
  XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
  XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/powernv: Flush console before platform error reboot
Nicholas Piggin [Wed, 19 Jul 2017 06:59:10 +0000 (16:59 +1000)]
powerpc/powernv: Flush console before platform error reboot

Unrecovered MCE and HMI errors are sent through a special restart OPAL
call to log the platform error. The downside is that they don't go
through normal Linux crash paths, so they don't give much information
to the Linux console.

Change this by providing a special crash function which does some of
the console flushing from the panic() path before calling firmware to
reboot.

The downside of this is a little more code to execute before reaching
the firmware reboot. However in practice, it's critical to get the
Linux console messages output in order to debug a problem. So this is
a desirable tradeoff.

Note on the implementation: It is difficult to plumb a custom reboot
handler into the panic path, because panic does a little bit too much
work. For example, it will try to delay with the timebase, but that
may be corrupted in some cases resulting in a hang without reaching
the platform reboot. Another problem is that panic can invoke the
crash dump code which is not what we want in the case of a hardware
platform error. Long-term the best solution will be to rework the
panic path so it can be suitable for this kind of panic, but for now
we just duplicate a bit of the code.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc: Do not send system reset request through the oops path
Nicholas Piggin [Wed, 5 Jul 2017 03:56:27 +0000 (13:56 +1000)]
powerpc: Do not send system reset request through the oops path

A system reset is a request to crash / debug the system rather than
necessarily caused by encountering a BUG. So there is no need to
serialize all CPUs behind the die lock, adding taints to all
subsequent traces beyond the first, breaking console locks, etc.

The system reset is NMI context which has its own printk buffers to
prevent output being interleaved. Then it's better to have all
secondaries print out their debug as quickly as possible and the
primary will flush out all printk buffers during panic().

So remove the 0x100 path from die, and move it into system_reset. Name
the crash/dump reasons "System Reset".

This gives "not tained" traces when crashing an untainted kernel. It
also gives the panic reason as "System Reset" as opposed to "Fatal
exception in interrupt" (or "die oops" for fadump).

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/pseries/le: Work around a firmware quirk
Nicholas Piggin [Wed, 5 Jul 2017 03:56:26 +0000 (13:56 +1000)]
powerpc/pseries/le: Work around a firmware quirk

Some PowerVM firmware when delivering a system reset interrupt to a
little endian OS will mess up SRR registers. They are byteswapped, and
SRR1 is incorrect. An example from a crash:

  NIP: 14dd0900000000c0
  MSR: 1000000200000080

It's possible to detect this pattern in SRR1 (that would never happen
in normal operation), and at least fix the NIP. After this patch, the
same interrupt reports NIP properly:

  NIP [c00000000009dd14] plpar_hcall_norets+0x1c/0x28

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc: Do not call ppc_md.panic in fadump panic notifier
Nicholas Piggin [Wed, 5 Jul 2017 03:56:25 +0000 (13:56 +1000)]
powerpc: Do not call ppc_md.panic in fadump panic notifier

If fadump is not registered, and no other crash or debug handlers are
registered, the powerpc panic handler stops the guest before the
generic panic code can push out debug information to the console.

Currently, system reset injection causes the guest to silently stop.

Stop calling ppc_md.panic in the panic notifier. crash_fadump already
does rtas_os_term() to terminate the guest if fadump is registered.

Remove ppc_md.panic. Move fadump panic notifier into fadump code.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/64: Fix watchdog configuration regressions
Nicholas Piggin [Mon, 28 Aug 2017 04:27:19 +0000 (14:27 +1000)]
powerpc/64: Fix watchdog configuration regressions

This fixes a couple more bits of fallout from the new hard lockup watchdog
patch.

It restores the required hw_nmi_get_sample_period() function for the
perf watchdog, and removes some function declarations on 64e that are only
defined for 64s. This fixes the 64e build when the hardlockup detector is
enabled.

It restores the default behaviour of disabling the perf watchdog, and also
fixes disabling the 64s watchdog when running as a guest.

Fixes: 2104180a53 ("powerpc/64s: implement arch-specific hardlockup watchdog")
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/64s/radix: Do not allocate SLB shadow structures
Nicholas Piggin [Sun, 13 Aug 2017 01:33:43 +0000 (11:33 +1000)]
powerpc/64s/radix: Do not allocate SLB shadow structures

These are unused in radix mode.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/64s/radix: Remove bolted-SLB address limit for per-cpu stacks
Nicholas Piggin [Sun, 13 Aug 2017 01:33:41 +0000 (11:33 +1000)]
powerpc/64s/radix: Remove bolted-SLB address limit for per-cpu stacks

Radix MMU does not take SLB or TLB interrupts when accessing kernel
linear address. Remove this restriction for radix mode.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/powernv: powernv platform is not constrained by RMA
Nicholas Piggin [Sun, 13 Aug 2017 01:33:39 +0000 (11:33 +1000)]
powerpc/powernv: powernv platform is not constrained by RMA

Remove incorrect comment about real mode address restrictions on
powernv (bare metal), and unnecessary clamping to ppc64_rma_size.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/64s: idle POWER9 can execute stop in virtual mode
Nicholas Piggin [Fri, 25 Aug 2017 04:30:35 +0000 (14:30 +1000)]
powerpc/64s: idle POWER9 can execute stop in virtual mode

The hardware can execute stop in any context, and KVM does not
require real mode because siblings do not share MMU state. This
saves a switch to real-mode when going idle.

Acked-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/64s: Drop no longer used IDLE_STATE_ENTER_SEQ
Nicholas Piggin [Tue, 29 Aug 2017 11:40:35 +0000 (21:40 +1000)]
powerpc/64s: Drop no longer used IDLE_STATE_ENTER_SEQ

There are no longer any callers of IDLE_STATE_ENTER_SEQ, all callers
use IDLE_STATE_ENTER_SEQ_NORET. So drop the former.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
[mpe: Split out of larger patch, write change log]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/64s: POWER9 can execute stop without a sync sequence
Nicholas Piggin [Tue, 29 Aug 2017 11:34:40 +0000 (21:34 +1000)]
powerpc/64s: POWER9 can execute stop without a sync sequence

We don't need to use IDLE_STATE_ENTER_SEQ_NORET on Power9.

Reviewed-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
[mpe: Split out of larger patch]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/64s: Move IDLE_STATE_ENTER_SEQ[_NORET] into idle_book3s.S
Nicholas Piggin [Tue, 29 Aug 2017 11:36:35 +0000 (21:36 +1000)]
powerpc/64s: Move IDLE_STATE_ENTER_SEQ[_NORET] into idle_book3s.S

This macro is only used in idle_book3s.S, move it in there and add a
more descriptive comment.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
[mpe: Split out of larger patch and write change log]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agoMerge branch 'topic/ppc-kvm' into next
Michael Ellerman [Tue, 29 Aug 2017 11:26:30 +0000 (21:26 +1000)]
Merge branch 'topic/ppc-kvm' into next

Merge Nicks commit to rework the KVM thread management, shared with the
KVM tree via the ppc-kvm topic branch.

6 years agoKVM: PPC: Book3S HV: POWER9 does not require secondary thread management
Nicholas Piggin [Fri, 25 Aug 2017 04:30:33 +0000 (14:30 +1000)]
KVM: PPC: Book3S HV: POWER9 does not require secondary thread management

POWER9 CPUs have independent MMU contexts per thread, so KVM does not
need to quiesce secondary threads, so the hwthread_req/hwthread_state
protocol does not have to be used. So patch it away on POWER9, and patch
away the branch from the Linux idle wakeup to kvm_start_guest that is
never used.

Add a warning and error out of kvmppc_grab_hwthread in case it is ever
called on POWER9.

This avoids a hwsync in the idle wakeup path on POWER9.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Acked-by: Paul Mackerras <paulus@ozlabs.org>
[mpe: Use WARN(...) instead of WARN_ON()/pr_err(...)]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/configs/6xx: Drop removed CONFIG_USB_LED
Michael Ellerman [Wed, 23 Aug 2017 05:38:06 +0000 (15:38 +1000)]
powerpc/configs/6xx: Drop removed CONFIG_USB_LED

In commit a335aaf3125c ("usb: misc: remove outdated USB LED driver")
CONFIG_USB_LED was removed, so drop it from our defconfigs.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/configs/6xx: Drop no longer selectable CONFIG_BT_HCIUART_LL
Michael Ellerman [Wed, 23 Aug 2017 05:38:05 +0000 (15:38 +1000)]
powerpc/configs/6xx: Drop no longer selectable CONFIG_BT_HCIUART_LL

Since commit 76c4969fecb1 ("Bluetooth: hci_uart: fix kconfig
dependency") we can no longer select CONFIG_BT_HCIUART_LL.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/configs/c2k: Switch CONFIG_GEN_RTC from =m to =y
Michael Ellerman [Wed, 23 Aug 2017 05:38:04 +0000 (15:38 +1000)]
powerpc/configs/c2k: Switch CONFIG_GEN_RTC from =m to =y

In commit 835ea93e9d26 ("char/genrtc: remove powerpc support"),
CONFIG_GEN_RTC switch from tristate to bool, update the defconfig to
match.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/configs/6xx: Switch CONFIG_USB_EHCI_FSL to =m
Michael Ellerman [Wed, 23 Aug 2017 05:38:03 +0000 (15:38 +1000)]
powerpc/configs/6xx: Switch CONFIG_USB_EHCI_FSL to =m

In commit ca07e1c1e4a6 ("drivers:usb:fsl:Make fsl ehci drv an
independent driver module"), CONFIG_USB_EHCI_FSL was switched from
built-in to modular. Update the defconfig.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/configs/6xx: Drop no longer needed CONFIG_BT_HCIUART_H4
Michael Ellerman [Wed, 23 Aug 2017 05:38:02 +0000 (15:38 +1000)]
powerpc/configs/6xx: Drop no longer needed CONFIG_BT_HCIUART_H4

Since commit 943cc592195e ("Bluetooth: bpa10x: Use h4_recv_buf helper
for frame reassembly") we no longer need to set CONFIG_BT_HCIUART_H4
in our defconfigs.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/configs/6xx: Drop no longer needed CONFIG_NETFILTER_XT_MATCH_SOCKET
Michael Ellerman [Wed, 23 Aug 2017 05:38:01 +0000 (15:38 +1000)]
powerpc/configs/6xx: Drop no longer needed CONFIG_NETFILTER_XT_MATCH_SOCKET

Since commit 8db4c5be88f6 ("netfilter: move socket lookup
infrastructure to nf_socket_ipv{4,6}.c") we no longer need to set
CONFIG_NETFILTER_XT_MATCH_SOCKET in our defconfigs.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/configs/6xx: Reinstate CONFIG_CPU_FREQ_STAT
Michael Ellerman [Wed, 23 Aug 2017 05:38:00 +0000 (15:38 +1000)]
powerpc/configs/6xx: Reinstate CONFIG_CPU_FREQ_STAT

In commit 1aefc75b2449 ("cpufreq: stats: Make the stats code
non-modular"), the CPU_FREQ_STAT code was made non-modular. Our
defconfig still said =m though, which meant we no longer got the
code at all. Switch the defconfig to =y.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/configs/6xx: Drop no longer needed CONFIG_NF_CONNTRACK_PROC_COMPAT
Michael Ellerman [Wed, 23 Aug 2017 05:37:59 +0000 (15:37 +1000)]
powerpc/configs/6xx: Drop no longer needed CONFIG_NF_CONNTRACK_PROC_COMPAT

Since commit adf0516845bc ("netfilter: remove ip_conntrack* sysctl
compat code") we no longer need to set CONFIG_NF_CONNTRACK_PROC_COMPAT
in our defconfigs.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/configs/6xx: Drop removed CONFIG_BLK_DEV_HD
Michael Ellerman [Wed, 23 Aug 2017 05:37:58 +0000 (15:37 +1000)]
powerpc/configs/6xx: Drop removed CONFIG_BLK_DEV_HD

In commit 8e14be53f470 ("remove the obsolete hd driver") the
CONFIG_BLK_DEV_HD symbol was removed, so drop it from the defconfig.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/configs/6xx: Clean up duplicate CONFIG_EXT4 values
Michael Ellerman [Wed, 23 Aug 2017 05:37:57 +0000 (15:37 +1000)]
powerpc/configs/6xx: Clean up duplicate CONFIG_EXT4 values

We had two values for CONFIG_EXT4, =m and =y, just use =y.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/configs/6xx: Drop no longer needed CONFIG_TIMER_STATS
Michael Ellerman [Wed, 23 Aug 2017 05:37:56 +0000 (15:37 +1000)]
powerpc/configs/6xx: Drop no longer needed CONFIG_TIMER_STATS

Since commit dfb4357da6dd ("time: Remove CONFIG_TIMER_STATS") we no
longer need to set CONFIG_TIMER_STATS in our defconfigs.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/configs/6xx: Turn CONFIG_DRM_RADEON back on
Michael Ellerman [Wed, 23 Aug 2017 05:37:55 +0000 (15:37 +1000)]
powerpc/configs/6xx: Turn CONFIG_DRM_RADEON back on

In commit d92d9c3a1448 ("drm: hide legacy drivers with CONFIG_DRM_LEGACY")
CONFIG_DRM_RADEON was moved behind CONFIG_DRM_LEGACY meaning it
stopped being enabled by ppc6xx_defconfig. Although no one has
noticed, given this is basically a legacy platform, it seems anyone
who is using it probably still wants this driver. So turn it back on
for now.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/configs/mpc5200: Drop no longer needed CONFIG_FB
Michael Ellerman [Wed, 23 Aug 2017 05:37:54 +0000 (15:37 +1000)]
powerpc/configs/mpc5200: Drop no longer needed CONFIG_FB

Since commit a03fdcb18632 ("drm: Add top level Kconfig option for DRM
fbdev emulation") we no longer need to set CONFIG_FB in our
defconfigs.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/configs: Update for CONFIG_INPUT_MOUSEDEV=n
Michael Ellerman [Wed, 23 Aug 2017 05:37:52 +0000 (15:37 +1000)]
powerpc/configs: Update for CONFIG_INPUT_MOUSEDEV=n

In commit 73d8ef76006b ("Input: mousedev - stop offering PS/2 to
userspace by default") the symbol INPUT_MOUSEDEV went from being
'default y' to 'default n' (implied).

That means we no longer need to explicitly disable it in our
defconfigs.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/configs: Drop removed CONFIG_LOGFS
Michael Ellerman [Wed, 23 Aug 2017 05:37:51 +0000 (15:37 +1000)]
powerpc/configs: Drop removed CONFIG_LOGFS

In commit 1d0fd57a50aa ("logfs: remove from tree"), logfs was removed
from the tree, so we can drop it from our defconfigs.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/configs: Turn CONFIG_R128 back in pmac32_defconfig
Michael Ellerman [Wed, 23 Aug 2017 05:37:50 +0000 (15:37 +1000)]
powerpc/configs: Turn CONFIG_R128 back in pmac32_defconfig

In commit d92d9c3a1448 ("drm: hide legacy drivers with
CONFIG_DRM_LEGACY") CONFIG_R128 was moved behind CONFIG_DRM_LEGACY
meaning it stopped being enabled by pmac32_defconfig. Although no one
has noticed, given this is basically a legacy platform, it seems
anyone who is using it probably still wants this driver. So turn it
back on for now.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/configs: Drop no longer needed CONFIG_LIBCRC32C
Michael Ellerman [Wed, 23 Aug 2017 05:37:49 +0000 (15:37 +1000)]
powerpc/configs: Drop no longer needed CONFIG_LIBCRC32C

Since commit 300ae149468f ("netfilter: select LIBCRC32C together with
SCTP conntrack") we no longer need to set CONFIG_LIBCRC32C in our
defconfigs.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/configs: Drop unnecessary CONFIG_EDAC from ppc64e
Michael Ellerman [Wed, 23 Aug 2017 05:37:48 +0000 (15:37 +1000)]
powerpc/configs: Drop unnecessary CONFIG_EDAC from ppc64e

There are no EDAC drivers for ppc64e.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/configs: Drop no longer needed CONFIG_SCSI
Michael Ellerman [Wed, 23 Aug 2017 05:37:47 +0000 (15:37 +1000)]
powerpc/configs: Drop no longer needed CONFIG_SCSI

Since commit 67f6d6655993 ("powerpc: convert amigaone_defconfig to use
libata PATA drivers") we no longer need to set CONFIG_SCSI in our
defconfigs.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/configs: Drop no longer needed CONFIG_IPV6
Michael Ellerman [Wed, 23 Aug 2017 05:37:46 +0000 (15:37 +1000)]
powerpc/configs: Drop no longer needed CONFIG_IPV6

Since commit de551f2eb22a ("net: Build IPv6 into kernel by default")
we no longer need to set CONFIG_IPV6 in our defconfigs.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/configs: Add CONFIG_RAS now required for CONFIG_EDAC
Michael Ellerman [Wed, 23 Aug 2017 05:37:45 +0000 (15:37 +1000)]
powerpc/configs: Add CONFIG_RAS now required for CONFIG_EDAC

In commit e3c4ff6d8c94 ("EDAC: Remove EDAC_MM_EDAC") CONFIG_EDAC grew
a dependency on CONFIG_RAS. Some of our defconfigs don't have the
latter, which means we lose CONFIG_EDAC, so add CONFIG_RAS to fix
that.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/configs: Drop no longer needed CONFIG_AUDITSYSCALL
Michael Ellerman [Wed, 23 Aug 2017 05:37:44 +0000 (15:37 +1000)]
powerpc/configs: Drop no longer needed CONFIG_AUDITSYSCALL

Since commit cb74ed278f80 ("audit: always enable syscall auditing when
supported and audit is enabled") we no longer need to set
CONFIG_AUDITSYSCALL in our defconfigs.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/configs: Drop CONFIG_SERIAL_TXX9_* from cell/ppc64
Michael Ellerman [Wed, 23 Aug 2017 05:37:43 +0000 (15:37 +1000)]
powerpc/configs: Drop CONFIG_SERIAL_TXX9_* from cell/ppc64

In commit bf4981a00636 ("powerpc: Remove the celleb support") we
dropped the celleb support, which made these symbols unselectable
because we no longer select HAS_TX99_SERIAL. So drop them from the
defconfigs.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/configs: Drop MEMORY_HOTREMOVE from ppc64/cell
Michael Ellerman [Wed, 23 Aug 2017 05:37:42 +0000 (15:37 +1000)]
powerpc/configs: Drop MEMORY_HOTREMOVE from ppc64/cell

xxxx

In commit 577ec789a79e ("powerpc/cell: Drop select of MEMORY_HOTPLUG")
we removed the last traces of any dependency between

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/configs: Drop unnecessary CONFIG_POWERNV_OP_PANEL
Michael Ellerman [Wed, 23 Aug 2017 05:37:41 +0000 (15:37 +1000)]
powerpc/configs: Drop unnecessary CONFIG_POWERNV_OP_PANEL

In commit 43a1dd9b5fc6 ("powerpc/powernv: Add driver for operator
panel on FSP machines") we added CONFIG_POWERNV_OP_PANEL=m to the
powernv defconfig, but it's default m so that's no necessary.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/configs: Drop no longer needed PCI_MSI on powernv
Michael Ellerman [Wed, 23 Aug 2017 05:37:40 +0000 (15:37 +1000)]
powerpc/configs: Drop no longer needed PCI_MSI on powernv

In commit a311e738b6d8 ("powerpc/powernv: Make PCI non-optional") we
made PCI (and therefore PCI_MSI) non-optional on powernv, so it
doesn't need to be in the defconfig anymore.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/configs: Drop no longer needed CONFIG_SMP for pseries/ppc64/powernv
Michael Ellerman [Wed, 23 Aug 2017 05:37:39 +0000 (15:37 +1000)]
powerpc/configs: Drop no longer needed CONFIG_SMP for pseries/ppc64/powernv

In commit 40e275653e2c ("powerpc/powernv: Always enable SMP when
building powernv") and 270e2dc9b803 ("powerpc/pseries: Always enable
SMP when building pseries") we forced CONFIG_SMP on for some configs.
Therefore we don't need to set it in those configs anymore.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
6 years agopowerpc/configs: Drop unnecessary CONFIG_UPROBE_EVENT
Michael Ellerman [Wed, 23 Aug 2017 05:37:38 +0000 (15:37 +1000)]
powerpc/configs: Drop unnecessary CONFIG_UPROBE_EVENT

In commit 6b0b7551428e ("perf/core: Rename CONFIG_[UK]PROBE_EVENT to
CONFIG_[UK]PROBE_EVENTS") it was renamed to CONFIG_UPROBE_EVENTS.

Additionally it's default y, and we have the prerequisites enabled, so
we don't need it in our defconfigs.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>