Re: [PATCH v2] cxl: Flush PSL cache before resetting the adapter

2016-10-04 Thread Andrew Donnellan

On 04/10/16 22:00, Frederic Barrat wrote:

If the capi link is going down while the PSL owns a dirty cache line,
any access from the host for that data could lead to an Uncorrectable
Error.
So when resetting the capi adapter through sysfs, make sure the PSL
cache is flushed. It won't help if there are any active Process
Elements on the card, as the cache would likely get new dirty cache
lines immediately, but if resetting an idle adapter, it should avoid
any bad surprises from data left over from terminated Process Elements.

Signed-off-by: Frederic Barrat 


Reviewed-by: Andrew Donnellan 

...but not that it matters because V1 of this just got merged...

--
Andrew Donnellan  OzLabs, ADL Canberra
andrew.donnel...@au1.ibm.com  IBM Australia Limited



[PATCH] selftests/powerpc: Fix build break caused by EXPORT_SYMBOL changes

2016-10-04 Thread Michael Ellerman
The changes to make EXPORT_SYMBOL work in asm, specifically commit
9445aa1a3062 ("ppc: move exports to definitions"), in the kbuild tree,
breaks some of our selftests.

That is because we symlink the kernel code into the selftest, and shim
the required headers, and we are now missing asm/export.h

So create a minimal export.h to keep the tests building once powerpc and
the kbuild trees are merged.

Signed-off-by: Michael Ellerman 
---
 tools/testing/selftests/powerpc/copyloops/asm/export.h   | 1 +
 tools/testing/selftests/powerpc/stringloops/asm/export.h | 1 +
 2 files changed, 2 insertions(+)
 create mode 100644 tools/testing/selftests/powerpc/copyloops/asm/export.h
 create mode 100644 tools/testing/selftests/powerpc/stringloops/asm/export.h

diff --git a/tools/testing/selftests/powerpc/copyloops/asm/export.h 
b/tools/testing/selftests/powerpc/copyloops/asm/export.h
new file mode 100644
index ..2d14a9b4248c
--- /dev/null
+++ b/tools/testing/selftests/powerpc/copyloops/asm/export.h
@@ -0,0 +1 @@
+#define EXPORT_SYMBOL(x)
diff --git a/tools/testing/selftests/powerpc/stringloops/asm/export.h 
b/tools/testing/selftests/powerpc/stringloops/asm/export.h
new file mode 100644
index ..2d14a9b4248c
--- /dev/null
+++ b/tools/testing/selftests/powerpc/stringloops/asm/export.h
@@ -0,0 +1 @@
+#define EXPORT_SYMBOL(x)
-- 
2.7.4



[PATCH] MAINTAINERS: Update powerpc website & add selftests

2016-10-04 Thread Michael Ellerman
The selftests under tools/testing/selftests/powerpc are maintained by
us, so add a file pattern for them.

Also drop the www.penguinppc.org link, it's not dead, but the site is
dead (database error). Instead link to the wiki attached to our github,
there is some info there which may be useful, which is better than none.

Signed-off-by: Michael Ellerman 
---
 MAINTAINERS | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index e3cfae014209..b27a26b16740 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7033,7 +7033,7 @@ LINUX FOR POWERPC (32-BIT AND 64-BIT)
 M: Benjamin Herrenschmidt 
 M: Paul Mackerras 
 M: Michael Ellerman 
-W: http://www.penguinppc.org/
+W: https://github.com/linuxppc/linux/wiki
 L: linuxppc-dev@lists.ozlabs.org
 Q: http://patchwork.ozlabs.org/project/linuxppc-dev/list/
 T: git git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git
@@ -7048,6 +7048,7 @@ F:drivers/net/ethernet/ibm/ibmvnic.*
 F: drivers/pci/hotplug/pnv_php.c
 F: drivers/pci/hotplug/rpa*
 F: drivers/scsi/ibmvscsi/
+F: tools/testing/selftests/powerpc
 N: opal
 N: /pmac
 N: powermac
-- 
2.7.4



[PATCH] MAINTAINERS: Drop separate pseries entry

2016-10-04 Thread Michael Ellerman
Paul is no longer acting as a separate maintainer for pseries, it is
handled along with the rest of powerpc. The URL no longer links anywhere
meaningful, so drop it also.

Signed-off-by: Michael Ellerman 
---
 MAINTAINERS | 6 --
 1 file changed, 6 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index f593300e310b..e3cfae014209 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7029,12 +7029,6 @@ F:   drivers/lightnvm/
 F: include/linux/lightnvm.h
 F: include/uapi/linux/lightnvm.h
 
-LINUX FOR IBM pSERIES (RS/6000)
-M: Paul Mackerras 
-W: http://www.ibm.com/linux/ltc/projects/ppc
-S: Supported
-F: arch/powerpc/boot/rs6000.h
-
 LINUX FOR POWERPC (32-BIT AND 64-BIT)
 M: Benjamin Herrenschmidt 
 M: Paul Mackerras 
-- 
2.7.4



Re: [PATCH v2] cxl: Flush PSL cache before resetting the adapter

2016-10-04 Thread Ian Munsie
Acked-by: Ian Munsie 



Re: powerpc/eeh: Quieten EEH message when no adapters are found

2016-10-04 Thread Michael Ellerman
On Sun, 2016-02-10 at 00:09:38 UTC, Anton Blanchard wrote:
> From: Anton Blanchard 
> 
> No real need for this to be pr_warn(), reduce it to pr_info().
> 
> Signed-off-by: Anton Blanchard 
> Acked-by: Gavin Shan 

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/91ac730b8b1d7c5e71e7ed2d785a61

cheers


Re: powerpc: Remove static branch prediction in atomic{, 64}_add_unless

2016-10-04 Thread Michael Ellerman
On Mon, 2016-03-10 at 06:03:03 UTC, Anton Blanchard wrote:
> From: Anton Blanchard 
> 
> I see quite a lot of static branch mispredictions on a simple
> web serving workload. The issue is in __atomic_add_unless(), called
> from _atomic_dec_and_lock(). There is no obvious common case, so it
> is better to let the hardware predict the branch.
> 
> Signed-off-by: Anton Blanchard 

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/61e98ebff3ba3d3b17e999dc483c26

cheers


Re: powerpc: Align hot loops of memset() and backwards_memcpy()

2016-10-04 Thread Michael Ellerman
On Thu, 2016-04-08 at 06:53:22 UTC, Anton Blanchard wrote:
> From: Anton Blanchard 
> 
> Align the hot loops in our assembly implementation of memset()
> and backwards_memcpy().
> 
> backwards_memcpy() is called from tcp_v4_rcv(), so we might
> want to optimise this a little more.
> 
> Signed-off-by: Anton Blanchard 

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/12ab11a2c09b30c1938c8e82e53908

cheers


Re: powerpc: During context switch, check before setting mm_cpumask

2016-10-04 Thread Michael Ellerman
On Mon, 2016-03-10 at 06:40:29 UTC, Anton Blanchard wrote:
> From: Anton Blanchard 
> 
> During context switch, switch_mm() sets our current CPU in mm_cpumask.
> We can avoid this atomic sequence in most cases by checking before
> setting the bit.
> 
> Testing on a POWER8 using our context switch microbenchmark:
> 
> tools/testing/selftests/powerpc/benchmarks/context_switch \
>   --process --no-fp --no-altivec --no-vector
> 
> Performance improves 2%.
> 
> Signed-off-by: Anton Blanchard 
> Acked-by: Balbir Singh 

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/bb85fb5803270c52863b983596c2a0

cheers


Re: cxl: replace loop with for_each_child_of_node(), remove unneeded of_node_put()

2016-10-04 Thread Michael Ellerman
On Fri, 2016-29-07 at 03:55:34 UTC, Andrew Donnellan wrote:
> Rewrite the cxl_guest_init_afu() loop in cxl_of_probe() to use
> for_each_child_of_node() rather than a hand-coded for loop.
> 
> Remove the useless of_node_put(afu_np) call after the loop, where it's
> guaranteed that afu_np == NULL.
> 
> Reported-by: SF Markus Elfring 
> Reported-by: Julia Lawall 
> Signed-off-by: Andrew Donnellan 
> Reviewed-by: Frederic Barrat 

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/735840b44bcc998e2574faf63d1aaa

cheers


Re: powerpc/fadump: Fix build break when CONFIG_PROC_VMCORE=n

2016-10-04 Thread Michael Ellerman
On Fri, 2016-30-09 at 00:51:46 UTC, Michael Ellerman wrote:
> The fadump code calls vmcore_cleanup() which only exists if
> CONFIG_PROC_VMCORE=y. We don't want to depend on CONFIG_PROC_VMCORE,
> because it's user selectable, so just wrap the call in an #ifdef.
> 
> Signed-off-by: Michael Ellerman 

Applied to powerpc next.

https://git.kernel.org/powerpc/c/2685f826e5ffd1ab73b26fd5ac4e1f

cheers


Re: cxl: Flush PSL cache before resetting the adapter

2016-10-04 Thread Michael Ellerman
On Mon, 2016-03-10 at 19:36:02 UTC, Frederic Barrat wrote:
> If the capi link is going down while the PSL owns a dirty cache line,
> any access from the host for that data could lead to an Unrecoverable
> Error.
> So when resetting the capi adapter through sysfs, make sure the PSL
> cache is flushed. It won't help if there are any active Process
> Elements on the card, as the cache would likely get new dirty cache
> lines immediately, but if resetting an idle adapter, it should avoid
> any bad surprises from data left over from terminated Process Elements.
> 
> Signed-off-by: Frederic Barrat 
> Reviewed-by: Andrew Donnellan 
> Acked-by: Ian Munsie 

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/aaa2245ed836824f21f8e42e0ab63b

cheers


Re: [7/9] powerpc/powernv: Fix data type for @r in pnv_ioda_parse_m64_window()

2016-10-04 Thread Michael Ellerman
On Tue, 2016-02-08 at 04:10:35 UTC, Gavin Shan wrote:
> This fixes warning reported from sparse:
> 
>   gwshan@gwshan:~/sandbox/l$ make C=2 CF=-D__CHECK_ENDIAN__ \
>  arch/powerpc/platforms/powernv/pci-ioda.o
> :
>   arch/powerpc/platforms/powernv/pci-ioda.c:451:49: \
>   warning: incorrect type in argument 2 (different base types)
>   arch/powerpc/platforms/powernv/pci-ioda.c:451:49: \
>   expected restricted __be32 const [usertype] *addr
>   arch/powerpc/platforms/powernv/pci-ioda.c:451:49: \
>   got unsigned int const [usertype] *
>   arch/powerpc/platforms/powernv/pci-ioda.c:452:50: \
>   warning: incorrect type in argument 1 (different base types)
>   arch/powerpc/platforms/powernv/pci-ioda.c:452:50: \
>   expected restricted __be32 const [usertype] *cell
>   arch/powerpc/platforms/powernv/pci-ioda.c:452:50: \
>   got unsigned int const [usertype] *
>   arch/powerpc/platforms/powernv/pci-ioda.c:454:35: \
>   warning: incorrect type in argument 1 (different base types)
>   arch/powerpc/platforms/powernv/pci-ioda.c:454:35: \
>   expected restricted __be32 const [usertype] *cell
>   arch/powerpc/platforms/powernv/pci-ioda.c:454:35: \
>   got unsigned int const [usertype] *[assigned] r
> 
> Fixes: 262af557dd75 ("powerpc/powernv: Enable M64 aperatus for PHB3")
> Signed-off-by: Gavin Shan 

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/0e7736c6b806b24c693367196a076c

cheers


Re: [4/9] powerpc/powernv: Use CPU-endian PEST in pnv_pci_dump_p7ioc_diag_data()

2016-10-04 Thread Michael Ellerman
On Tue, 2016-02-08 at 04:10:32 UTC, Gavin Shan wrote:
> This fixes the warnings reported from sparse:
> 
>   gwshan@gwshan:~/sandbox/l$ make C=2 CF=-D__CHECK_ENDIAN__ \
>  arch/powerpc/platforms/powernv/pci.o
> :
>   arch/powerpc/platforms/powernv/pci.c:312:33: \
>   warning: restricted __be64 degrades to integer
>   arch/powerpc/platforms/powernv/pci.c:313:33: \
>   warning: restricted __be64 degrades to integer
> 
> Fixes: cee72d5bb489 ("powerpc/powernv: Display diag data on p7ioc EEH errors")
> Cc: sta...@vger.kernel.org # v3.3+
> Signed-off-by: Gavin Shan 

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/5adaf8629b193f185ca5a1665b9e77

cheers


Re: [v4, 6/7] drivers/pci/hotplug: Use of_property_read_u32() in powernv driver

2016-10-04 Thread Michael Ellerman
On Thu, 2016-29-09 at 05:52:04 UTC, Gavin Shan wrote:
> This replaces of_get_property() with of_property_read_u32() or
> of_property_read_string() so that we needn't consider the endian
> issue, the returned value always is in CPU-endian.
> 
> Signed-off-by: Gavin Shan 

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/39f0d6fbdc3f205d0c61a9c530c682

cheers


Re: [3/9] powerpc/powernv: Specify proper data type for PCI_SLOT_ID_PREFIX

2016-10-04 Thread Michael Ellerman
On Tue, 2016-02-08 at 04:10:31 UTC, Gavin Shan wrote:
> This fixes the warning reported from sparse:
> 
>   gwshan@gwshan:~/sandbox/l$ make C=2 CF=-D__CHECK_ENDIAN__ \
>  arch/powerpc/platforms/powernv/eeh-powernv.o
> :
>   arch/powerpc/platforms/powernv/eeh-powernv.c:875:23: \
>   warning: constant 0x8000 is so big it is unsigned long
> 
> Fixes: ebe225312739 ("powerpc/powernv: Support PCI slot ID")
> Suggested-by: Michael Ellerman 
> Signed-off-by: Gavin Shan 

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/066bcd785aac9c10e5f9b873f9bd2e

cheers


Re: [2/9] powerpc/powernv: Use CPU-endian hub diag-data type in pnv_eeh_get_and_dump_hub_diag()

2016-10-04 Thread Michael Ellerman
On Tue, 2016-02-08 at 04:10:30 UTC, Gavin Shan wrote:
> The hub diag-data type is filled with big-endian data by OPAL call
> opal_pci_get_hub_diag_data(). We need convert it to CPU-endian value
> before using it. The issue is reported by sparse as pointed by Michael
> Ellerman:
> 
>   gwshan@gwshan:~/sandbox/l$ make C=2 CF=-D__CHECK_ENDIAN__ \
> arch/powerpc/platforms/powernv/eeh-powernv.o
>:
>   arch/powerpc/platforms/powernv/eeh-powernv.c:1309:21: \
>   warning: restricted __be16 degrades to integer
>   arch/powerpc/platforms/powernv/eeh-powernv.c:1309:21: \
>   warning: restricted __be16 degrades to integer
>   arch/powerpc/platforms/powernv/eeh-powernv.c:1309:21: \
>   warning: restricted __be16 degrades to integer
>   arch/powerpc/platforms/powernv/eeh-powernv.c:1309:21: \
>   warning: restricted __be16 degrades to integer
>   arch/powerpc/platforms/powernv/eeh-powernv.c:1309:21: \
>   warning: restricted __be16 degrades to integer
> 
> This converts hub diag-data type to CPU-endian before using it in
> pnv_eeh_get_and_dump_hub_diag().
> 
> Fixes: 2a485ad7c88d ("powerpc/powernv: Drop PHB operation next_error()")
> Cc: sta...@vger.kernel.org # v4.1+
> Suggested-by: Michael Ellerman 
> Signed-off-by: Gavin Shan 
> Reviewed-by: Russell Currey 

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/a7032132d7560a8434e1f54b71efd7

cheers


Re: [1/9] powerpc/powernv: Pass CPU-endian PE number to opal_pci_eeh_freeze_clear()

2016-10-04 Thread Michael Ellerman
On Tue, 2016-02-08 at 04:10:29 UTC, Gavin Shan wrote:
> The PE number (@frozen_pe_no), filled by opal_pci_next_error() is in
> big-endian format. It should be converted to CPU-dian before it is
> passed to opal_pci_eeh_freeze_clear() when clearing the frozen state
> if the PE is invalid one. As Michael Ellerman pointed out, the issue
> is also detected by sparse:
> 
>   gwshan@gwshan:~/sandbox/l$ make C=2 CF=-D__CHECK_ENDIAN__ \
> arch/powerpc/platforms/powernv/eeh-powernv.o
>   :
>   arch/powerpc/platforms/powernv/eeh-powernv.c:1541:41: \
>   warning: incorrect type in argument 2 (different base types)
>   arch/powerpc/platforms/powernv/eeh-powernv.c:1541:41: \
>   expected unsigned long long [unsigned] [usertype] pe_number
>   arch/powerpc/platforms/powernv/eeh-powernv.c:1541:41: \
>   got restricted __be64 [addressable] [usertype] frozen_pe_no
> 
> This passes CPU-endian PE number to opal_pci_eeh_freeze_clear() and
> it should be part of commit <0f36db77643b> ("powerpc/eeh: Fix wrong
> printed PE number"), which was merged to 4.3 kernel.
> 
> Fixes: 71b540adffd9 ("powerpc/powernv: Don't escalate non-existing frozen PE")
> Cc: sta...@vger.kernel.org # v4.3+
> Suggested-by: Paul Mackerras 
> Signed-off-by: Gavin Shan 
> Reviewed-by: Russell Currey 

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/d63e51b31e0b655ed0f581b8a8fd4c

cheers


Re: [1/4] powerpc/configs: Enable VMX crypto

2016-10-04 Thread Michael Ellerman
On Fri, 2016-30-09 at 10:39:50 UTC, Anton Blanchard wrote:
> From: Anton Blanchard 
> 
> We see big improvements with the VMX crypto functions (often 10x or more),
> so enable it as a module.
> 
> Signed-off-by: Anton Blanchard 

Series applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/43c2394fc15028c6d846633d21ebdd

cheers


Re: [1/3] bpf powerpc: introduce accessors for using the tmp local stack space

2016-10-04 Thread Michael Ellerman
On Fri, 2016-23-09 at 20:35:00 UTC, "Naveen N. Rao" wrote:
> While at it, ensure that the location of the local save area is
> consistent whether or not we setup our own stackframe. This property is
> utilised in the next patch that adds support for tail calls.
> 
> Signed-off-by: Naveen N. Rao 

Series applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/7b847f523fe07b4ad73a01cec49a4d

cheers


Re: [1/2] powerpc: tm: Add TM Unavailable Exception

2016-10-04 Thread Michael Ellerman
On Wed, 2016-14-09 at 08:02:15 UTC, Cyril Bur wrote:
> If the kernel disables transactional memory (TM) and userspace still
> tries TM related actions (TM instructions or TM SPR accesses) TM aware
> hardware will cause the kernel to take a facility unavailable
> exception.
> 
> Add checks for the exception being caused by illegal TM access in
> userspace.
> 
> Signed-off-by: Cyril Bur 

Series applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/172f7aaa75d0eaae167edde25c08aa

cheers


Re: [1/2] powerpc: Only disable HAVE_EFFICIENT_UNALIGNED_ACCESS on POWER7 little endian

2016-10-04 Thread Michael Ellerman
On Sun, 2016-25-09 at 12:35:40 UTC, Anton Blanchard wrote:
> From: Anton Blanchard 
> 
> POWER8 handles unaligned accesses in little endian mode, but commit
> 0b5e6661ac69 ("powerpc: Don't set HAVE_EFFICIENT_UNALIGNED_ACCESS on
> little endian builds") disabled it for all.
> 
> The issue with unaligned little endian accesses is specific to POWER7,
> so update the Kconfig check to match. Using the stat() testcase from
> commit a75c380c7129 ("powerpc: Enable DCACHE_WORD_ACCESS on ppc64le"),
> performance improves 15% on POWER8.
> 
> Signed-off-by: Anton Blanchard 

Series applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/8a18cc0c2c36ee49d70a620ac0190d

cheers


Re: [v5, 02/20] powerpc: Always restore FPU/VEC/VSX if hardware transactional memory in use

2016-10-04 Thread Michael Ellerman
On Fri, 2016-23-09 at 06:18:08 UTC, Cyril Bur wrote:
> Comment from arch/powerpc/kernel/process.c:967:
>  If userspace is inside a transaction (whether active or
>  suspended) and FP/VMX/VSX instructions have ever been enabled
>  inside that transaction, then we have to keep them enabled
>  and keep the FP/VMX/VSX state loaded while ever the transaction
>  continues.  The reason is that if we didn't, and subsequently
>  got a FP/VMX/VSX unavailable interrupt inside a transaction,
>  we don't know whether it's the same transaction, and thus we
>  don't know which of the checkpointed state and the ransactional
>  state to use.
> 
> restore_math() restore_fp() and restore_altivec() currently may not
> restore the registers. It doesn't appear that this is more serious
> than a performance penalty. If the math registers aren't restored the
> userspace thread will still be run with the facility disabled.
> Userspace will not be able to read invalid values. On the first access
> it will take an facility unavailable exception and the kernel will
> detected an active transaction, at which point it will abort the
> transaction. There is the possibility for a pathological case
> preventing any progress by transactions, however, transactions
> are never guaranteed to make progress.
> 
> Fixes: 70fe3d9 ("powerpc: Restore FPU/VEC/VSX if previously used")
> Signed-off-by: Cyril Bur 

Series applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/dc16b553c949e81f37555777dc7bab

cheers


Re: [v3,01/42] powerpc/64s: Add new exception vector macros

2016-10-04 Thread Michael Ellerman
On Wed, 2016-05-10 at 00:22:23 UTC, Michael Ellerman wrote:
> Create arch/powerpc/include/asm/head-64.h with macros that specify
> an exception vector (name, type, location), which will be used to
> label and lay out exceptions into the object file.
> 
> Naming is moved out of exception-64s.h, which is used to specify the
> implementation of exception handlers.
> 
> objdump of generated code in exception vectors is unchanged except for
> names. Alignment directives scattered around are annoying, but done
> this way so that disassembly can verify identical instruction
> generation before and after patch. These get cleaned up in future
> patch.
> 
> We change the way KVMTEST works, explicitly passing EXC_HV or EXC_STD
> rather than overloading the trap number. This removes the need to have
> SOFTEN values for the overloaded trap numbers, eg. 0x502.
> 
> Signed-off-by: Nicholas Piggin 
> Signed-off-by: Michael Ellerman 

Series applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/da2bc4644c75d992427c45c5ade3bd

cheers


Re: [RFC] fs: add userspace critical mounts event support

2016-10-04 Thread Linus Torvalds
On Tue, Oct 4, 2016 at 6:48 PM, Josh Triplett  wrote:
>
>I definitely don't think it
> should be a system-wide "mount event"; it should be a per-device "go
> direct-load your firmware" poke from userspace.

I don't disagree with that kind of interface. We already have things
like "rescan" for PCI bus devices to force a bus rescan. Iit's a
simple device attribute. Having a similar thing to trigger firmware
reload for a driver sounds entirely sane.

  Linus


Re: [RFC] fs: add userspace critical mounts event support

2016-10-04 Thread Josh Triplett
On Tue, Oct 04, 2016 at 05:12:58PM -0700, Linus Torvalds wrote:
> On Tue, Oct 4, 2016 at 5:00 PM, Luis R. Rodriguez  wrote:
> > I am not sure how/why a firmware loading daemon would be a better
> > idea now. What Marc describes that Josh proposed with signals for
> > userspcae seems more aligned with what we likely need
> 
> Quite frankly, I doubt you want a signal.
> 
> You will want to have some way to specify where the firmware files
> are. Right now we have "fw_path[]" which is hardcoded except for the
> first entry that can be set as a module parameter. But you'd probably
> want to expand on that, which implies some /sys or /proc interface.
> 
> And once you do that, wouldn't it make more sense to just make the
> "update the firmware path /proc/sys/kernel/fw_path file" make things
> re-search for firmware?

That could work, but it seems like overkill to allow changing the path,
rather than the simpler interface of just telling the one driver "go
ahead and direct-load your firmware now".  I definitely don't think it
should be a system-wide "mount event"; it should be a per-device "go
direct-load your firmware" poke from userspace.  That would solve the
"build-in the driver so it can start waking up slow monitors, but wait
to load the firmware until you have a filesystem" problem.  (And it
would avoid creating some unusual driver-specific late-firmware-load
mechanism.)

That said, the Chrome OS folks apparently have some mechanism where they
mount a tmpfs over /lib/firmware to let userspace choose firmware at
runtime, so perhaps the path-changing mechanism would help there.  Kees?


Re: [RFC] fs: add userspace critical mounts event support

2016-10-04 Thread Linus Torvalds
On Tue, Oct 4, 2016 at 5:24 PM, Luis R. Rodriguez  wrote:
>
> Note that the races are beyond firmware, so all
> kernel_read_file_from_path() users, as such re-using such old /sys/
> interafeces for firmware will not suffice to cover all ground now for
> the same race for other possible users.

Blah blah blah.

The reason I've hated this whole discussion is that it's full of
"let's re-architect everything", and then it has these horribly warty
interfaces. It's classic second-system syndrome.

Just do *one* thing, and do it well. Don't change anything else. Don't
force existign drivers to use new interfaces. Don't over-architect,
and don't do stupid interfaces.

If user-space mounts a new filesystem (or just unpacks files from a
tar-file that has firmware images in it, for chissake), that is not
some magical "critical mount event". The whole concept is just stupid.
Is it a "mount event" when the user downloads a new firmware image
from the internet?

HELL NO.

But what is equally stupid is to then dismiss simple models because
some totally unrelated "beyond firmware" issue.

Anything that is "beyond firmware" shouldn't even be discussed, for
chrissake! It has nothing what-so-ever to do with firmware loading. If
there ends up being some common helper functions, and shared code,
that *still* doesn't make it so.

Basic rules of thumb:

 (a) don't over-design

 (b) don't have stupid illogical interfaces

 (c) don't conflate different issues just because you think they may
have shared code.

 (4) be consistent. Don't make up new interfaces, and most certainly
do *NOT* dismiss something just because it's what we have done before.

That's it.

Linus


Re: [RFC] fs: add userspace critical mounts event support

2016-10-04 Thread Luis R. Rodriguez
On Tue, Oct 4, 2016 at 5:12 PM, Linus Torvalds
 wrote:
> On Tue, Oct 4, 2016 at 5:00 PM, Luis R. Rodriguez  wrote:
>>
>> I am not sure how/why a firmware loading daemon would be a better
>> idea now. What Marc describes that Josh proposed with signals for
>> userspcae seems more aligned with what we likely need
>
> Quite frankly, I doubt you want a signal.
>
> You will want to have some way to specify where the firmware files
> are. Right now we have "fw_path[]" which is hardcoded except for the
> first entry that can be set as a module parameter. But you'd probably
> want to expand on that, which implies some /sys or /proc interface.
>
> And once you do that, wouldn't it make more sense to just make the
> "update the firmware path /proc/sys/kernel/fw_path file" make things
> re-search for firmware?

We can, but re-searching for firmware assumes we cache pending
firmware, we currently don't, we just either process sync or async
firmware requests.

> In other words, the interface has to be something *sensible*. Not some
> idiotic ad-hoc "send a signal" (of which that stupid original patch
> was just a very odd example).

Note that the races are beyond firmware, so all
kernel_read_file_from_path() users, as such re-using such old /sys/
interafeces for firmware will not suffice to cover all ground now for
the same race for other possible users.

 Luis


[PATCH v3 42/42] powerpc/64s: Remove unused exception code, small cleanups

2016-10-04 Thread Michael Ellerman
From: Nicholas Piggin 

This was not done before the big patches because I only noticed
them afterwards. It has become much easier to see which handlers
are branched to from which exception vectors now, and to see
exactly what vector space is being used for what.

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/exceptions-64s.S | 30 --
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index 1e17f8d4365a..08992f8f5036 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -57,6 +57,10 @@
  * 0x7000 - 0x7fff : FWNMI data area
  * 0x8000 -    : Common interrupt handlers, remaining early
  *   setup code, rest of kernel.
+ *
+ * We could reclaim 0x4000-0x42ff for real mode trampolines if the space
+ * is necessary. Until then it's more consistent to explicitly put VIRT_NONE
+ * vectors there.
  */
 OPEN_FIXED_SECTION(real_vectors,0x0100, 0x1900)
 OPEN_FIXED_SECTION(real_trampolines,0x1900, 0x4000)
@@ -88,6 +92,9 @@ USE_FIXED_SECTION(real_vectors)
.globl __start_interrupts
 __start_interrupts:
 
+/* No virt vectors corresponding with 0x0..0x100 */
+EXC_VIRT_NONE(0x4000, 0x4100)
+
 EXC_REAL_BEGIN(system_reset, 0x100, 0x200)
SET_SCRATCH0(r13)
 #ifdef CONFIG_PPC_P7_NAP
@@ -907,9 +914,7 @@ TRAMP_KVM(PACA_EXGEN, 0xd00)
 EXC_COMMON(single_step_common, 0xd00, single_step_exception)
 
 EXC_REAL_OOL_HV(h_data_storage, 0xe00, 0xe20)
-EXC_VIRT_BEGIN(unused, 0x4e00, 0x4e20)
-   b   .   /* Can't happen, see v2.07 Book III-S section 6.5 */
-EXC_VIRT_END(unused, 0x4e00, 0x4e20)
+EXC_VIRT_NONE(0x4e00, 0x4e20)
 TRAMP_KVM_HV_SKIP(PACA_EXGEN, 0xe00)
 EXC_COMMON_BEGIN(h_data_storage_common)
mfspr   r10,SPRN_HDAR
@@ -922,13 +927,10 @@ EXC_COMMON_BEGIN(h_data_storage_common)
addir3,r1,STACK_FRAME_OVERHEAD
bl  unknown_exception
b   ret_from_except
-EXC_COMMON(trap_0e_common, 0xe00, unknown_exception)
 
 
 EXC_REAL_OOL_HV(h_instr_storage, 0xe20, 0xe40)
-EXC_VIRT_BEGIN(unused, 0x4e20, 0x4e40)
-   b   .   /* Can't happen, see v2.07 Book III-S section 6.5 */
-EXC_VIRT_END(unused, 0x4e20, 0x4e40)
+EXC_VIRT_NONE(0x4e20, 0x4e40)
 TRAMP_KVM_HV(PACA_EXGEN, 0xe20)
 EXC_COMMON(h_instr_storage_common, 0xe20, unknown_exception)
 
@@ -939,11 +941,14 @@ TRAMP_KVM_HV(PACA_EXGEN, 0xe40)
 EXC_COMMON(emulation_assist_common, 0xe40, emulation_assist_interrupt)
 
 
+/*
+ * hmi_exception trampoline is a special case. It jumps to hmi_exception_early
+ * first, and then eventaully from there to the trampoline to get into virtual
+ * mode.
+ */
 __EXC_REAL_OOL_HV_DIRECT(hmi_exception, 0xe60, 0xe80, hmi_exception_early)
 __TRAMP_REAL_REAL_OOL_MASKABLE_HV(hmi_exception, 0xe60)
-EXC_VIRT_BEGIN(unused, 0x4e60, 0x4e80)
-   b   .   /* Can't happen, see v2.07 Book III-S section 6.5 */
-EXC_VIRT_END(unused, 0x4e60, 0x4e80)
+EXC_VIRT_NONE(0x4e60, 0x4e80)
 TRAMP_KVM_HV(PACA_EXGEN, 0xe60)
 TRAMP_REAL_BEGIN(hmi_exception_early)
EXCEPTION_PROLOG_1(PACA_EXGEN, KVMTEST_HV, 0xe60)
@@ -1118,6 +1123,7 @@ TRAMP_KVM_HV_SKIP(PACA_EXGEN, 0x1200)
 EXC_COMMON(cbe_system_error_common, 0x1200, cbe_system_error_exception)
 #else /* CONFIG_CBE_RAS */
 EXC_REAL_NONE(0x1200, 0x1300)
+EXC_VIRT_NONE(0x5200, 0x5300)
 #endif
 
 
@@ -1126,6 +1132,8 @@ EXC_VIRT(instruction_breakpoint, 0x5300, 0x5400, 0x1300)
 TRAMP_KVM_SKIP(PACA_EXGEN, 0x1300)
 EXC_COMMON(instruction_breakpoint_common, 0x1300, 
instruction_breakpoint_exception)
 
+EXC_REAL_NONE(0x1400, 0x1500)
+EXC_VIRT_NONE(0x5400, 0x5500)
 
 EXC_REAL_BEGIN(denorm_exception_hv, 0x1500, 0x1600)
mtspr   SPRN_SPRG_HSCRATCH0,r13
@@ -1228,6 +1236,7 @@ TRAMP_KVM_HV_SKIP(PACA_EXGEN, 0x1600)
 EXC_COMMON(cbe_maintenance_common, 0x1600, cbe_maintenance_exception)
 #else /* CONFIG_CBE_RAS */
 EXC_REAL_NONE(0x1600, 0x1700)
+EXC_VIRT_NONE(0x5600, 0x5700)
 #endif
 
 
@@ -1248,6 +1257,7 @@ TRAMP_KVM_HV_SKIP(PACA_EXGEN, 0x1800)
 EXC_COMMON(cbe_thermal_common, 0x1800, cbe_thermal_exception)
 #else /* CONFIG_CBE_RAS */
 EXC_REAL_NONE(0x1800, 0x1900)
+EXC_VIRT_NONE(0x5800, 0x5900)
 #endif
 
 
-- 
2.7.4



[PATCH v3 41/42] powerpc/64s: Use a single macro for both parts of OOL exception

2016-10-04 Thread Michael Ellerman
From: Nicholas Piggin 

Simple substitution. This is possible now that both parts of the OOL
initial handler get linked into their correct location.

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/exceptions-64s.S | 55 
 1 file changed, 18 insertions(+), 37 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index 9b26b7b6f74a..1e17f8d4365a 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -906,9 +906,7 @@ EXC_VIRT(single_step, 0x4d00, 0x4e00, 0xd00)
 TRAMP_KVM(PACA_EXGEN, 0xd00)
 EXC_COMMON(single_step_common, 0xd00, single_step_exception)
 
-
-__EXC_REAL_OOL_HV(h_data_storage, 0xe00, 0xe20)
-__TRAMP_REAL_REAL_OOL_HV(h_data_storage, 0xe00)
+EXC_REAL_OOL_HV(h_data_storage, 0xe00, 0xe20)
 EXC_VIRT_BEGIN(unused, 0x4e00, 0x4e20)
b   .   /* Can't happen, see v2.07 Book III-S section 6.5 */
 EXC_VIRT_END(unused, 0x4e00, 0x4e20)
@@ -927,8 +925,7 @@ EXC_COMMON_BEGIN(h_data_storage_common)
 EXC_COMMON(trap_0e_common, 0xe00, unknown_exception)
 
 
-__EXC_REAL_OOL_HV(h_instr_storage, 0xe20, 0xe40)
-__TRAMP_REAL_REAL_OOL_HV(h_instr_storage, 0xe20)
+EXC_REAL_OOL_HV(h_instr_storage, 0xe20, 0xe40)
 EXC_VIRT_BEGIN(unused, 0x4e20, 0x4e40)
b   .   /* Can't happen, see v2.07 Book III-S section 6.5 */
 EXC_VIRT_END(unused, 0x4e20, 0x4e40)
@@ -936,10 +933,8 @@ TRAMP_KVM_HV(PACA_EXGEN, 0xe20)
 EXC_COMMON(h_instr_storage_common, 0xe20, unknown_exception)
 
 
-__EXC_REAL_OOL_HV(emulation_assist, 0xe40, 0xe60)
-__TRAMP_REAL_REAL_OOL_HV(emulation_assist, 0xe40)
-__EXC_VIRT_OOL_HV(emulation_assist, 0x4e40, 0x4e60)
-__TRAMP_REAL_VIRT_OOL_HV(emulation_assist, 0xe40)
+EXC_REAL_OOL_HV(emulation_assist, 0xe40, 0xe60)
+EXC_VIRT_OOL_HV(emulation_assist, 0x4e40, 0x4e60, 0xe40)
 TRAMP_KVM_HV(PACA_EXGEN, 0xe40)
 EXC_COMMON(emulation_assist_common, 0xe40, emulation_assist_interrupt)
 
@@ -1002,10 +997,8 @@ hmi_exception_after_realmode:
 EXC_COMMON_ASYNC(hmi_exception_common, 0xe60, handle_hmi_exception)
 
 
-__EXC_REAL_OOL_MASKABLE_HV(h_doorbell, 0xe80, 0xea0)
-__TRAMP_REAL_REAL_OOL_MASKABLE_HV(h_doorbell, 0xe80)
-__EXC_VIRT_OOL_MASKABLE_HV(h_doorbell, 0x4e80, 0x4ea0)
-__TRAMP_REAL_VIRT_OOL_MASKABLE_HV(h_doorbell, 0xe80)
+EXC_REAL_OOL_MASKABLE_HV(h_doorbell, 0xe80, 0xea0)
+EXC_VIRT_OOL_MASKABLE_HV(h_doorbell, 0x4e80, 0x4ea0, 0xe80)
 TRAMP_KVM_HV(PACA_EXGEN, 0xe80)
 #ifdef CONFIG_PPC_DOORBELL
 EXC_COMMON_ASYNC(h_doorbell_common, 0xe80, doorbell_exception)
@@ -1014,10 +1007,8 @@ EXC_COMMON_ASYNC(h_doorbell_common, 0xe80, 
unknown_exception)
 #endif
 
 
-__EXC_REAL_OOL_MASKABLE_HV(h_virt_irq, 0xea0, 0xec0)
-__TRAMP_REAL_REAL_OOL_MASKABLE_HV(h_virt_irq, 0xea0)
-__EXC_VIRT_OOL_MASKABLE_HV(h_virt_irq, 0x4ea0, 0x4ec0)
-__TRAMP_REAL_VIRT_OOL_MASKABLE_HV(h_virt_irq, 0xea0)
+EXC_REAL_OOL_MASKABLE_HV(h_virt_irq, 0xea0, 0xec0)
+EXC_VIRT_OOL_MASKABLE_HV(h_virt_irq, 0x4ea0, 0x4ec0, 0xea0)
 TRAMP_KVM_HV(PACA_EXGEN, 0xea0)
 EXC_COMMON_ASYNC(h_virt_irq_common, 0xea0, do_IRQ)
 
@@ -1026,18 +1017,14 @@ EXC_REAL_NONE(0xec0, 0xf00)
 EXC_VIRT_NONE(0x4ec0, 0x4f00)
 
 
-__EXC_REAL_OOL(performance_monitor, 0xf00, 0xf20)
-__TRAMP_REAL_REAL_OOL(performance_monitor, 0xf00)
-__EXC_VIRT_OOL(performance_monitor, 0x4f00, 0x4f20)
-__TRAMP_REAL_VIRT_OOL(performance_monitor, 0xf00)
+EXC_REAL_OOL(performance_monitor, 0xf00, 0xf20)
+EXC_VIRT_OOL(performance_monitor, 0x4f00, 0x4f20, 0xf00)
 TRAMP_KVM(PACA_EXGEN, 0xf00)
 EXC_COMMON_ASYNC(performance_monitor_common, 0xf00, 
performance_monitor_exception)
 
 
-__EXC_REAL_OOL(altivec_unavailable, 0xf20, 0xf40)
-__TRAMP_REAL_REAL_OOL(altivec_unavailable, 0xf20)
-__EXC_VIRT_OOL(altivec_unavailable, 0x4f20, 0x4f40)
-__TRAMP_REAL_VIRT_OOL(altivec_unavailable, 0xf20)
+EXC_REAL_OOL(altivec_unavailable, 0xf20, 0xf40)
+EXC_VIRT_OOL(altivec_unavailable, 0x4f20, 0x4f40, 0xf20)
 TRAMP_KVM(PACA_EXGEN, 0xf20)
 EXC_COMMON_BEGIN(altivec_unavailable_common)
EXCEPTION_PROLOG_COMMON(0xf20, PACA_EXGEN)
@@ -1073,10 +1060,8 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
b   ret_from_except
 
 
-__EXC_REAL_OOL(vsx_unavailable, 0xf40, 0xf60)
-__TRAMP_REAL_REAL_OOL(vsx_unavailable, 0xf40)
-__EXC_VIRT_OOL(vsx_unavailable, 0x4f40, 0x4f60)
-__TRAMP_REAL_VIRT_OOL(vsx_unavailable, 0xf40)
+EXC_REAL_OOL(vsx_unavailable, 0xf40, 0xf60)
+EXC_VIRT_OOL(vsx_unavailable, 0x4f40, 0x4f60, 0xf40)
 TRAMP_KVM(PACA_EXGEN, 0xf40)
 EXC_COMMON_BEGIN(vsx_unavailable_common)
EXCEPTION_PROLOG_COMMON(0xf40, PACA_EXGEN)
@@ -,18 +1096,14 @@ END_FTR_SECTION_IFSET(CPU_FTR_VSX)
b   ret_from_except
 
 
-__EXC_REAL_OOL(facility_unavailable, 0xf60, 0xf80)
-__TRAMP_REAL_REAL_OOL(facility_unavailable, 0xf60)
-__EXC_VIRT_OOL(facility_unavailable, 0x4f60, 0x4f80)
-__TRAMP_REAL_VIRT_OOL(facility_unavailable, 0xf60)
+EXC_REAL_OOL(facility_unavailable, 0xf60, 0xf80)

[PATCH v3 40/42] powerpc/64s: Move __replay_interrupt function below handlers

2016-10-04 Thread Michael Ellerman
From: Nicholas Piggin 

This is not an exception handler as such, it's called from
local_irq_enable(), not exception entry.

Also clean up some now redundant comments at the end of the
consolidation series.

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/exceptions-64s.S | 74 ++--
 1 file changed, 36 insertions(+), 38 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index 307e117b95d3..9b26b7b6f74a 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -1317,43 +1317,6 @@ USE_FIXED_SECTION(virt_trampolines)
MASKED_INTERRUPT()
MASKED_INTERRUPT(H)
 
-/*
- * Called from arch_local_irq_enable when an interrupt needs
- * to be resent. r3 contains 0x500, 0x900, 0xa00 or 0xe80 to indicate
- * which kind of interrupt. MSR:EE is already off. We generate a
- * stackframe like if a real interrupt had happened.
- *
- * Note: While MSR:EE is off, we need to make sure that _MSR
- * in the generated frame has EE set to 1 or the exception
- * handler will not properly re-enable them.
- */
-USE_TEXT_SECTION()
-_GLOBAL(__replay_interrupt)
-   /* We are going to jump to the exception common code which
-* will retrieve various register values from the PACA which
-* we don't give a damn about, so we don't bother storing them.
-*/
-   mfmsr   r12
-   mflrr11
-   mfcrr9
-   ori r12,r12,MSR_EE
-   cmpwi   r3,0x900
-   beq decrementer_common
-   cmpwi   r3,0x500
-   beq hardware_interrupt_common
-BEGIN_FTR_SECTION
-   cmpwi   r3,0xe80
-   beq h_doorbell_common
-   cmpwi   r3,0xea0
-   beq h_virt_irq_common
-   cmpwi   r3,0xe60
-   beq hmi_exception_common
-FTR_SECTION_ELSE
-   cmpwi   r3,0xa00
-   beq doorbell_super_common
-ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE)
-   blr
-
 #ifdef CONFIG_KVM_BOOK3S_64_HANDLER
 TRAMP_REAL_BEGIN(kvmppc_skip_interrupt)
/*
@@ -1409,7 +1372,6 @@ TRAMP_REAL_BEGIN(kvmppc_skip_Hinterrupt)
 EXC_COMMON_BEGIN(ppc64_runlatch_on_trampoline)
b   __ppc64_runlatch_on
 
-   /* Equivalents to the above handlers for relocation-on interrupt 
vectors */
 USE_FIXED_SECTION(virt_trampolines)
/*
 * The __end_interrupts marker must be past the out-of-line (OOL)
@@ -1584,3 +1546,39 @@ END_FTR_SECTION_IFSET(CPU_FTR_CFAR)
 1: addir3,r1,STACK_FRAME_OVERHEAD
bl  kernel_bad_stack
b   1b
+
+/*
+ * Called from arch_local_irq_enable when an interrupt needs
+ * to be resent. r3 contains 0x500, 0x900, 0xa00 or 0xe80 to indicate
+ * which kind of interrupt. MSR:EE is already off. We generate a
+ * stackframe like if a real interrupt had happened.
+ *
+ * Note: While MSR:EE is off, we need to make sure that _MSR
+ * in the generated frame has EE set to 1 or the exception
+ * handler will not properly re-enable them.
+ */
+_GLOBAL(__replay_interrupt)
+   /* We are going to jump to the exception common code which
+* will retrieve various register values from the PACA which
+* we don't give a damn about, so we don't bother storing them.
+*/
+   mfmsr   r12
+   mflrr11
+   mfcrr9
+   ori r12,r12,MSR_EE
+   cmpwi   r3,0x900
+   beq decrementer_common
+   cmpwi   r3,0x500
+   beq hardware_interrupt_common
+BEGIN_FTR_SECTION
+   cmpwi   r3,0xe80
+   beq h_doorbell_common
+   cmpwi   r3,0xea0
+   beq h_virt_irq_common
+   cmpwi   r3,0xe60
+   beq hmi_exception_common
+FTR_SECTION_ELSE
+   cmpwi   r3,0xa00
+   beq doorbell_super_common
+ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE)
+   blr
-- 
2.7.4



[PATCH v3 39/42] powerpc/64s: Consolidate CBE Thermal 0x1800 interrupt

2016-10-04 Thread Michael Ellerman
From: Nicholas Piggin 

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/exceptions-64s.S | 15 ++-
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index 389032a8e744..307e117b95d3 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -1262,18 +1262,14 @@ EXC_COMMON(altivec_assist_common, 0x1700, 
unknown_exception)
 
 #ifdef CONFIG_CBE_RAS
 EXC_REAL_HV(cbe_thermal, 0x1800, 0x1900)
-
+EXC_VIRT_NONE(0x5800, 0x5900)
 TRAMP_KVM_HV_SKIP(PACA_EXGEN, 0x1800)
-
+EXC_COMMON(cbe_thermal_common, 0x1800, cbe_thermal_exception)
 #else /* CONFIG_CBE_RAS */
 EXC_REAL_NONE(0x1800, 0x1900)
 #endif
 
 
-/*** Out of line interrupts support ***/
-
-   /* moved from 0x200 */
-
 /*
  * An interrupt came in while soft-disabled. We set paca->irq_happened, then:
  * - If it was a decrementer interrupt, we bump the dec to max and and return.
@@ -1410,8 +1406,6 @@ TRAMP_REAL_BEGIN(kvmppc_skip_Hinterrupt)
 * come here.
 */
 
-EXC_VIRT_NONE(0x5800, 0x5900)
-
 EXC_COMMON_BEGIN(ppc64_runlatch_on_trampoline)
b   __ppc64_runlatch_on
 
@@ -1429,11 +1423,6 @@ USE_FIXED_SECTION(virt_trampolines)
 __end_interrupts:
 DEFINE_FIXED_SYMBOL(__end_interrupts)
 
-#ifdef CONFIG_CBE_RAS
-EXC_COMMON(cbe_thermal_common, 0x1800, cbe_thermal_exception)
-#endif /* CONFIG_CBE_RAS */
-
-
 #ifdef CONFIG_PPC_970_NAP
 TRAMP_REAL_BEGIN(power4_fixup_nap)
andcr9,r9,r10
-- 
2.7.4



[PATCH v3 38/42] powerpc/64s: Consolidate Altivec 0x1700 interrupt

2016-10-04 Thread Michael Ellerman
From: Nicholas Piggin 

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/exceptions-64s.S | 16 +++-
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index 40da203d4a07..389032a8e744 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -1251,8 +1251,14 @@ EXC_REAL_NONE(0x1600, 0x1700)
 
 
 EXC_REAL(altivec_assist, 0x1700, 0x1800)
-
+EXC_VIRT(altivec_assist, 0x5700, 0x5800, 0x1700)
 TRAMP_KVM(PACA_EXGEN, 0x1700)
+#ifdef CONFIG_ALTIVEC
+EXC_COMMON(altivec_assist_common, 0x1700, altivec_assist_exception)
+#else
+EXC_COMMON(altivec_assist_common, 0x1700, unknown_exception)
+#endif
+
 
 #ifdef CONFIG_CBE_RAS
 EXC_REAL_HV(cbe_thermal, 0x1800, 0x1900)
@@ -1388,12 +1394,6 @@ TRAMP_REAL_BEGIN(kvmppc_skip_Hinterrupt)
 /*** Common interrupt handlers ***/
 
 
-#ifdef CONFIG_ALTIVEC
-EXC_COMMON(altivec_assist_common, 0x1700, altivec_assist_exception)
-#else
-EXC_COMMON(altivec_assist_common, 0x1700, unknown_exception)
-#endif
-
/*
 * Relocation-on interrupts: A subset of the interrupts can be delivered
 * with IR=1/DR=1, if AIL==2 and MSR.HV won't be changed by delivering
@@ -1410,8 +1410,6 @@ EXC_COMMON(altivec_assist_common, 0x1700, 
unknown_exception)
 * come here.
 */
 
-EXC_VIRT(altivec_assist, 0x5700, 0x5800, 0x1700)
-
 EXC_VIRT_NONE(0x5800, 0x5900)
 
 EXC_COMMON_BEGIN(ppc64_runlatch_on_trampoline)
-- 
2.7.4



[PATCH v3 37/42] powerpc/64s: Consolidate Debug 0x1600 interrupt

2016-10-04 Thread Michael Ellerman
From: Nicholas Piggin 

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/exceptions-64s.S | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index 04d25c76adee..40da203d4a07 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -1242,13 +1242,14 @@ EXC_COMMON_HV(denorm_common, 0x1500, unknown_exception)
 
 #ifdef CONFIG_CBE_RAS
 EXC_REAL_HV(cbe_maintenance, 0x1600, 0x1700)
-
+EXC_VIRT_NONE(0x5600, 0x5700)
 TRAMP_KVM_HV_SKIP(PACA_EXGEN, 0x1600)
-
+EXC_COMMON(cbe_maintenance_common, 0x1600, cbe_maintenance_exception)
 #else /* CONFIG_CBE_RAS */
 EXC_REAL_NONE(0x1600, 0x1700)
 #endif
 
+
 EXC_REAL(altivec_assist, 0x1700, 0x1800)
 
 TRAMP_KVM(PACA_EXGEN, 0x1700)
@@ -1409,8 +1410,6 @@ EXC_COMMON(altivec_assist_common, 0x1700, 
unknown_exception)
 * come here.
 */
 
-EXC_VIRT_NONE(0x5600, 0x5700)
-
 EXC_VIRT(altivec_assist, 0x5700, 0x5800, 0x1700)
 
 EXC_VIRT_NONE(0x5800, 0x5900)
@@ -1433,7 +1432,6 @@ __end_interrupts:
 DEFINE_FIXED_SYMBOL(__end_interrupts)
 
 #ifdef CONFIG_CBE_RAS
-EXC_COMMON(cbe_maintenance_common, 0x1600, cbe_maintenance_exception)
 EXC_COMMON(cbe_thermal_common, 0x1800, cbe_thermal_exception)
 #endif /* CONFIG_CBE_RAS */
 
-- 
2.7.4



[PATCH v3 36/42] powerpc/64s: Consolidate Softpatch 0x1500 interrupt

2016-10-04 Thread Michael Ellerman
From: Nicholas Piggin 

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/exceptions-64s.S | 72 ++--
 1 file changed, 37 insertions(+), 35 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index 0214c97c117d..04d25c76adee 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -1163,34 +1163,15 @@ EXC_REAL_BEGIN(denorm_exception_hv, 0x1500, 0x1600)
EXCEPTION_PROLOG_PSERIES_1(denorm_common, EXC_HV)
 EXC_REAL_END(denorm_exception_hv, 0x1500, 0x1600)
 
-TRAMP_KVM_SKIP(PACA_EXGEN, 0x1500)
-
-#ifdef CONFIG_CBE_RAS
-EXC_REAL_HV(cbe_maintenance, 0x1600, 0x1700)
-
-TRAMP_KVM_HV_SKIP(PACA_EXGEN, 0x1600)
-
-#else /* CONFIG_CBE_RAS */
-EXC_REAL_NONE(0x1600, 0x1700)
-#endif
-
-EXC_REAL(altivec_assist, 0x1700, 0x1800)
-
-TRAMP_KVM(PACA_EXGEN, 0x1700)
-
-#ifdef CONFIG_CBE_RAS
-EXC_REAL_HV(cbe_thermal, 0x1800, 0x1900)
-
-TRAMP_KVM_HV_SKIP(PACA_EXGEN, 0x1800)
-
-#else /* CONFIG_CBE_RAS */
-EXC_REAL_NONE(0x1800, 0x1900)
+#ifdef CONFIG_PPC_DENORMALISATION
+EXC_VIRT_BEGIN(denorm_exception, 0x5500, 0x5600)
+   b   exc_real_0x1500_denorm_exception_hv
+EXC_VIRT_END(denorm_exception, 0x5500, 0x5600)
+#else
+EXC_VIRT_NONE(0x5500, 0x5600)
 #endif
 
-
-/*** Out of line interrupts support ***/
-
-   /* moved from 0x200 */
+TRAMP_KVM_SKIP(PACA_EXGEN, 0x1500)
 
 #ifdef CONFIG_PPC_DENORMALISATION
 TRAMP_REAL_BEGIN(denorm_assist)
@@ -1256,6 +1237,36 @@ END_FTR_SECTION_IFSET(CPU_FTR_CFAR)
b   .
 #endif
 
+EXC_COMMON_HV(denorm_common, 0x1500, unknown_exception)
+
+
+#ifdef CONFIG_CBE_RAS
+EXC_REAL_HV(cbe_maintenance, 0x1600, 0x1700)
+
+TRAMP_KVM_HV_SKIP(PACA_EXGEN, 0x1600)
+
+#else /* CONFIG_CBE_RAS */
+EXC_REAL_NONE(0x1600, 0x1700)
+#endif
+
+EXC_REAL(altivec_assist, 0x1700, 0x1800)
+
+TRAMP_KVM(PACA_EXGEN, 0x1700)
+
+#ifdef CONFIG_CBE_RAS
+EXC_REAL_HV(cbe_thermal, 0x1800, 0x1900)
+
+TRAMP_KVM_HV_SKIP(PACA_EXGEN, 0x1800)
+
+#else /* CONFIG_CBE_RAS */
+EXC_REAL_NONE(0x1800, 0x1900)
+#endif
+
+
+/*** Out of line interrupts support ***/
+
+   /* moved from 0x200 */
+
 /*
  * An interrupt came in while soft-disabled. We set paca->irq_happened, then:
  * - If it was a decrementer interrupt, we bump the dec to max and and return.
@@ -1376,7 +1387,6 @@ TRAMP_REAL_BEGIN(kvmppc_skip_Hinterrupt)
 /*** Common interrupt handlers ***/
 
 
-EXC_COMMON_HV(denorm_common, 0x1500, unknown_exception)
 #ifdef CONFIG_ALTIVEC
 EXC_COMMON(altivec_assist_common, 0x1700, altivec_assist_exception)
 #else
@@ -1399,14 +1409,6 @@ EXC_COMMON(altivec_assist_common, 0x1700, 
unknown_exception)
 * come here.
 */
 
-#ifdef CONFIG_PPC_DENORMALISATION
-EXC_VIRT_BEGIN(denorm_exception, 0x5500, 0x5600)
-   b   exc_real_0x1500_denorm_exception_hv
-EXC_VIRT_END(denorm_exception, 0x5500, 0x5600)
-#else
-EXC_VIRT_NONE(0x5500, 0x5600)
-#endif
-
 EXC_VIRT_NONE(0x5600, 0x5700)
 
 EXC_VIRT(altivec_assist, 0x5700, 0x5800, 0x1700)
-- 
2.7.4



[PATCH v3 35/42] powerpc/64s: Consolidate Instruction Breakpoint 0x1300 interrupt

2016-10-04 Thread Michael Ellerman
From: Nicholas Piggin 

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/exceptions-64s.S | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index 537d29a6e032..0214c97c117d 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -1141,8 +1141,10 @@ EXC_REAL_NONE(0x1200, 0x1300)
 
 
 EXC_REAL(instruction_breakpoint, 0x1300, 0x1400)
-
+EXC_VIRT(instruction_breakpoint, 0x5300, 0x5400, 0x1300)
 TRAMP_KVM_SKIP(PACA_EXGEN, 0x1300)
+EXC_COMMON(instruction_breakpoint_common, 0x1300, 
instruction_breakpoint_exception)
+
 
 EXC_REAL_BEGIN(denorm_exception_hv, 0x1500, 0x1600)
mtspr   SPRN_SPRG_HSCRATCH0,r13
@@ -1374,7 +1376,6 @@ TRAMP_REAL_BEGIN(kvmppc_skip_Hinterrupt)
 /*** Common interrupt handlers ***/
 
 
-EXC_COMMON(instruction_breakpoint_common, 0x1300, 
instruction_breakpoint_exception)
 EXC_COMMON_HV(denorm_common, 0x1500, unknown_exception)
 #ifdef CONFIG_ALTIVEC
 EXC_COMMON(altivec_assist_common, 0x1700, altivec_assist_exception)
@@ -1398,8 +1399,6 @@ EXC_COMMON(altivec_assist_common, 0x1700, 
unknown_exception)
 * come here.
 */
 
-EXC_VIRT(instruction_breakpoint, 0x5300, 0x5400, 0x1300)
-
 #ifdef CONFIG_PPC_DENORMALISATION
 EXC_VIRT_BEGIN(denorm_exception, 0x5500, 0x5600)
b   exc_real_0x1500_denorm_exception_hv
-- 
2.7.4



[PATCH v3 34/42] powerpc/64s: Consolidate CBE System Error 0x1200 interrupt

2016-10-04 Thread Michael Ellerman
From: Nicholas Piggin 

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/exceptions-64s.S | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index 34d439018ddd..537d29a6e032 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -1132,13 +1132,14 @@ EXC_VIRT_NONE(0x4fa0, 0x5200)
 
 #ifdef CONFIG_CBE_RAS
 EXC_REAL_HV(cbe_system_error, 0x1200, 0x1300)
-
+EXC_VIRT_NONE(0x5200, 0x5300)
 TRAMP_KVM_HV_SKIP(PACA_EXGEN, 0x1200)
-
+EXC_COMMON(cbe_system_error_common, 0x1200, cbe_system_error_exception)
 #else /* CONFIG_CBE_RAS */
 EXC_REAL_NONE(0x1200, 0x1300)
 #endif
 
+
 EXC_REAL(instruction_breakpoint, 0x1300, 0x1400)
 
 TRAMP_KVM_SKIP(PACA_EXGEN, 0x1300)
@@ -1397,8 +1398,6 @@ EXC_COMMON(altivec_assist_common, 0x1700, 
unknown_exception)
 * come here.
 */
 
-EXC_VIRT_NONE(0x5200, 0x5300)
-
 EXC_VIRT(instruction_breakpoint, 0x5300, 0x5400, 0x1300)
 
 #ifdef CONFIG_PPC_DENORMALISATION
@@ -1433,7 +1432,6 @@ __end_interrupts:
 DEFINE_FIXED_SYMBOL(__end_interrupts)
 
 #ifdef CONFIG_CBE_RAS
-EXC_COMMON(cbe_system_error_common, 0x1200, cbe_system_error_exception)
 EXC_COMMON(cbe_maintenance_common, 0x1600, cbe_maintenance_exception)
 EXC_COMMON(cbe_thermal_common, 0x1800, cbe_thermal_exception)
 #endif /* CONFIG_CBE_RAS */
-- 
2.7.4



[PATCH v3 33/42] powerpc/64s: Consolidate Reserved 0xfa0-0x1200 interrupts

2016-10-04 Thread Michael Ellerman
From: Nicholas Piggin 

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/exceptions-64s.S | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index d88024384bc6..34d439018ddd 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -1128,6 +1128,7 @@ EXC_COMMON(h_facility_unavailable_common, 0xf80, 
facility_unavailable_exception)
 
 
 EXC_REAL_NONE(0xfa0, 0x1200)
+EXC_VIRT_NONE(0x4fa0, 0x5200)
 
 #ifdef CONFIG_CBE_RAS
 EXC_REAL_HV(cbe_system_error, 0x1200, 0x1300)
@@ -1396,8 +1397,6 @@ EXC_COMMON(altivec_assist_common, 0x1700, 
unknown_exception)
 * come here.
 */
 
-EXC_VIRT_NONE(0x4fa0, 0x5200)
-
 EXC_VIRT_NONE(0x5200, 0x5300)
 
 EXC_VIRT(instruction_breakpoint, 0x5300, 0x5400, 0x1300)
-- 
2.7.4



[PATCH v3 32/42] powerpc/64s: Consolidate Hypervisor Facility Unavailable 0xf80 interrupt

2016-10-04 Thread Michael Ellerman
From: Nicholas Piggin 

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/exceptions-64s.S | 16 ++--
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index 2e89d4bfc7e6..d88024384bc6 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -1120,6 +1120,12 @@ EXC_COMMON(facility_unavailable_common, 0xf60, 
facility_unavailable_exception)
 
 
 __EXC_REAL_OOL_HV(h_facility_unavailable, 0xf80, 0xfa0)
+__TRAMP_REAL_REAL_OOL_HV(h_facility_unavailable, 0xf80)
+__EXC_VIRT_OOL_HV(h_facility_unavailable, 0x4f80, 0x4fa0)
+__TRAMP_REAL_VIRT_OOL_HV(h_facility_unavailable, 0xf80)
+TRAMP_KVM_HV(PACA_EXGEN, 0xf80)
+EXC_COMMON(h_facility_unavailable_common, 0xf80, 
facility_unavailable_exception)
+
 
 EXC_REAL_NONE(0xfa0, 0x1200)
 
@@ -1246,10 +1252,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_CFAR)
b   .
 #endif
 
-   /* moved from 0xf00 */
-__TRAMP_REAL_REAL_OOL_HV(h_facility_unavailable, 0xf80)
-TRAMP_KVM_HV(PACA_EXGEN, 0xf80)
-
 /*
  * An interrupt came in while soft-disabled. We set paca->irq_happened, then:
  * - If it was a decrementer interrupt, we bump the dec to max and and return.
@@ -1394,8 +1396,6 @@ EXC_COMMON(altivec_assist_common, 0x1700, 
unknown_exception)
 * come here.
 */
 
-__EXC_VIRT_OOL_HV(h_facility_unavailable, 0x4f80, 0x4fa0)
-
 EXC_VIRT_NONE(0x4fa0, 0x5200)
 
 EXC_VIRT_NONE(0x5200, 0x5300)
@@ -1420,8 +1420,6 @@ EXC_COMMON_BEGIN(ppc64_runlatch_on_trampoline)
b   __ppc64_runlatch_on
 
/* Equivalents to the above handlers for relocation-on interrupt 
vectors */
-__TRAMP_REAL_VIRT_OOL_HV(h_facility_unavailable, 0xf80)
-
 USE_FIXED_SECTION(virt_trampolines)
/*
 * The __end_interrupts marker must be past the out-of-line (OOL)
@@ -1435,8 +1433,6 @@ USE_FIXED_SECTION(virt_trampolines)
 __end_interrupts:
 DEFINE_FIXED_SYMBOL(__end_interrupts)
 
-EXC_COMMON(h_facility_unavailable_common, 0xf80, 
facility_unavailable_exception)
-
 #ifdef CONFIG_CBE_RAS
 EXC_COMMON(cbe_system_error_common, 0x1200, cbe_system_error_exception)
 EXC_COMMON(cbe_maintenance_common, 0x1600, cbe_maintenance_exception)
-- 
2.7.4



[PATCH v3 31/42] powerpc/64s: Consolidate Facility Unavailable 0xf60 interrupt

2016-10-04 Thread Michael Ellerman
From: Nicholas Piggin 

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/exceptions-64s.S | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index f8015d22657f..2e89d4bfc7e6 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -1112,6 +1112,12 @@ END_FTR_SECTION_IFSET(CPU_FTR_VSX)
 
 
 __EXC_REAL_OOL(facility_unavailable, 0xf60, 0xf80)
+__TRAMP_REAL_REAL_OOL(facility_unavailable, 0xf60)
+__EXC_VIRT_OOL(facility_unavailable, 0x4f60, 0x4f80)
+__TRAMP_REAL_VIRT_OOL(facility_unavailable, 0xf60)
+TRAMP_KVM(PACA_EXGEN, 0xf60)
+EXC_COMMON(facility_unavailable_common, 0xf60, facility_unavailable_exception)
+
 
 __EXC_REAL_OOL_HV(h_facility_unavailable, 0xf80, 0xfa0)
 
@@ -1241,9 +1247,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_CFAR)
 #endif
 
/* moved from 0xf00 */
-__TRAMP_REAL_REAL_OOL(facility_unavailable, 0xf60)
-TRAMP_KVM(PACA_EXGEN, 0xf60)
-
 __TRAMP_REAL_REAL_OOL_HV(h_facility_unavailable, 0xf80)
 TRAMP_KVM_HV(PACA_EXGEN, 0xf80)
 
@@ -1391,8 +1394,6 @@ EXC_COMMON(altivec_assist_common, 0x1700, 
unknown_exception)
 * come here.
 */
 
-__EXC_VIRT_OOL(facility_unavailable, 0x4f60, 0x4f80)
-
 __EXC_VIRT_OOL_HV(h_facility_unavailable, 0x4f80, 0x4fa0)
 
 EXC_VIRT_NONE(0x4fa0, 0x5200)
@@ -1419,7 +1420,6 @@ EXC_COMMON_BEGIN(ppc64_runlatch_on_trampoline)
b   __ppc64_runlatch_on
 
/* Equivalents to the above handlers for relocation-on interrupt 
vectors */
-__TRAMP_REAL_VIRT_OOL(facility_unavailable, 0xf60)
 __TRAMP_REAL_VIRT_OOL_HV(h_facility_unavailable, 0xf80)
 
 USE_FIXED_SECTION(virt_trampolines)
@@ -1435,7 +1435,6 @@ USE_FIXED_SECTION(virt_trampolines)
 __end_interrupts:
 DEFINE_FIXED_SYMBOL(__end_interrupts)
 
-EXC_COMMON(facility_unavailable_common, 0xf60, facility_unavailable_exception)
 EXC_COMMON(h_facility_unavailable_common, 0xf80, 
facility_unavailable_exception)
 
 #ifdef CONFIG_CBE_RAS
-- 
2.7.4



[PATCH v3 29/42] powerpc/64s: Consolidate Vector Unavailable 0xf20 interrupt

2016-10-04 Thread Michael Ellerman
From: Nicholas Piggin 

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/exceptions-64s.S | 76 ++--
 1 file changed, 37 insertions(+), 39 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index 5566f218734a..5b81ecf7c1a7 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -1035,6 +1035,43 @@ EXC_COMMON_ASYNC(performance_monitor_common, 0xf00, 
performance_monitor_exceptio
 
 
 __EXC_REAL_OOL(altivec_unavailable, 0xf20, 0xf40)
+__TRAMP_REAL_REAL_OOL(altivec_unavailable, 0xf20)
+__EXC_VIRT_OOL(altivec_unavailable, 0x4f20, 0x4f40)
+__TRAMP_REAL_VIRT_OOL(altivec_unavailable, 0xf20)
+TRAMP_KVM(PACA_EXGEN, 0xf20)
+EXC_COMMON_BEGIN(altivec_unavailable_common)
+   EXCEPTION_PROLOG_COMMON(0xf20, PACA_EXGEN)
+#ifdef CONFIG_ALTIVEC
+BEGIN_FTR_SECTION
+   beq 1f
+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
+  BEGIN_FTR_SECTION_NESTED(69)
+   /* Test if 2 TM state bits are zero.  If non-zero (ie. userspace was in
+* transaction), go do TM stuff
+*/
+   rldicl. r0, r12, (64-MSR_TS_LG), (64-2)
+   bne-2f
+  END_FTR_SECTION_NESTED(CPU_FTR_TM, CPU_FTR_TM, 69)
+#endif
+   bl  load_up_altivec
+   b   fast_exception_return
+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
+2: /* User process was in a transaction */
+   bl  save_nvgprs
+   RECONCILE_IRQ_STATE(r10, r11)
+   addir3,r1,STACK_FRAME_OVERHEAD
+   bl  altivec_unavailable_tm
+   b   ret_from_except
+#endif
+1:
+END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
+#endif
+   bl  save_nvgprs
+   RECONCILE_IRQ_STATE(r10, r11)
+   addir3,r1,STACK_FRAME_OVERHEAD
+   bl  altivec_unavailable_exception
+   b   ret_from_except
+
 
 __EXC_REAL_OOL(vsx_unavailable, 0xf40, 0xf60)
 
@@ -1168,9 +1205,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_CFAR)
 #endif
 
/* moved from 0xf00 */
-__TRAMP_REAL_REAL_OOL(altivec_unavailable, 0xf20)
-TRAMP_KVM(PACA_EXGEN, 0xf20)
-
 __TRAMP_REAL_REAL_OOL(vsx_unavailable, 0xf40)
 TRAMP_KVM(PACA_EXGEN, 0xf40)
 
@@ -1324,8 +1358,6 @@ EXC_COMMON(altivec_assist_common, 0x1700, 
unknown_exception)
 * come here.
 */
 
-__EXC_VIRT_OOL(altivec_unavailable, 0x4f20, 0x4f40)
-
 __EXC_VIRT_OOL(vsx_unavailable, 0x4f40, 0x4f60)
 
 __EXC_VIRT_OOL(facility_unavailable, 0x4f60, 0x4f80)
@@ -1355,39 +1387,6 @@ EXC_VIRT_NONE(0x5800, 0x5900)
 EXC_COMMON_BEGIN(ppc64_runlatch_on_trampoline)
b   __ppc64_runlatch_on
 
-EXC_COMMON_BEGIN(altivec_unavailable_common)
-   EXCEPTION_PROLOG_COMMON(0xf20, PACA_EXGEN)
-#ifdef CONFIG_ALTIVEC
-BEGIN_FTR_SECTION
-   beq 1f
-#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
-  BEGIN_FTR_SECTION_NESTED(69)
-   /* Test if 2 TM state bits are zero.  If non-zero (ie. userspace was in
-* transaction), go do TM stuff
-*/
-   rldicl. r0, r12, (64-MSR_TS_LG), (64-2)
-   bne-2f
-  END_FTR_SECTION_NESTED(CPU_FTR_TM, CPU_FTR_TM, 69)
-#endif
-   bl  load_up_altivec
-   b   fast_exception_return
-#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
-2: /* User process was in a transaction */
-   bl  save_nvgprs
-   RECONCILE_IRQ_STATE(r10, r11)
-   addir3,r1,STACK_FRAME_OVERHEAD
-   bl  altivec_unavailable_tm
-   b   ret_from_except
-#endif
-1:
-END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
-#endif
-   bl  save_nvgprs
-   RECONCILE_IRQ_STATE(r10, r11)
-   addir3,r1,STACK_FRAME_OVERHEAD
-   bl  altivec_unavailable_exception
-   b   ret_from_except
-
 EXC_COMMON_BEGIN(vsx_unavailable_common)
EXCEPTION_PROLOG_COMMON(0xf40, PACA_EXGEN)
 #ifdef CONFIG_VSX
@@ -1421,7 +1420,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_VSX)
b   ret_from_except
 
/* Equivalents to the above handlers for relocation-on interrupt 
vectors */
-__TRAMP_REAL_VIRT_OOL(altivec_unavailable, 0xf20)
 __TRAMP_REAL_VIRT_OOL(vsx_unavailable, 0xf40)
 __TRAMP_REAL_VIRT_OOL(facility_unavailable, 0xf60)
 __TRAMP_REAL_VIRT_OOL_HV(h_facility_unavailable, 0xf80)
-- 
2.7.4



[PATCH v3 30/42] powerpc/64s: Consolidate VSX Unavailable 0xf40 interrupt

2016-10-04 Thread Michael Ellerman
From: Nicholas Piggin 

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/exceptions-64s.S | 74 ++--
 1 file changed, 36 insertions(+), 38 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index 5b81ecf7c1a7..f8015d22657f 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -1074,6 +1074,42 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
 
 
 __EXC_REAL_OOL(vsx_unavailable, 0xf40, 0xf60)
+__TRAMP_REAL_REAL_OOL(vsx_unavailable, 0xf40)
+__EXC_VIRT_OOL(vsx_unavailable, 0x4f40, 0x4f60)
+__TRAMP_REAL_VIRT_OOL(vsx_unavailable, 0xf40)
+TRAMP_KVM(PACA_EXGEN, 0xf40)
+EXC_COMMON_BEGIN(vsx_unavailable_common)
+   EXCEPTION_PROLOG_COMMON(0xf40, PACA_EXGEN)
+#ifdef CONFIG_VSX
+BEGIN_FTR_SECTION
+   beq 1f
+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
+  BEGIN_FTR_SECTION_NESTED(69)
+   /* Test if 2 TM state bits are zero.  If non-zero (ie. userspace was in
+* transaction), go do TM stuff
+*/
+   rldicl. r0, r12, (64-MSR_TS_LG), (64-2)
+   bne-2f
+  END_FTR_SECTION_NESTED(CPU_FTR_TM, CPU_FTR_TM, 69)
+#endif
+   b   load_up_vsx
+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
+2: /* User process was in a transaction */
+   bl  save_nvgprs
+   RECONCILE_IRQ_STATE(r10, r11)
+   addir3,r1,STACK_FRAME_OVERHEAD
+   bl  vsx_unavailable_tm
+   b   ret_from_except
+#endif
+1:
+END_FTR_SECTION_IFSET(CPU_FTR_VSX)
+#endif
+   bl  save_nvgprs
+   RECONCILE_IRQ_STATE(r10, r11)
+   addir3,r1,STACK_FRAME_OVERHEAD
+   bl  vsx_unavailable_exception
+   b   ret_from_except
+
 
 __EXC_REAL_OOL(facility_unavailable, 0xf60, 0xf80)
 
@@ -1205,9 +1241,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_CFAR)
 #endif
 
/* moved from 0xf00 */
-__TRAMP_REAL_REAL_OOL(vsx_unavailable, 0xf40)
-TRAMP_KVM(PACA_EXGEN, 0xf40)
-
 __TRAMP_REAL_REAL_OOL(facility_unavailable, 0xf60)
 TRAMP_KVM(PACA_EXGEN, 0xf60)
 
@@ -1358,8 +1391,6 @@ EXC_COMMON(altivec_assist_common, 0x1700, 
unknown_exception)
 * come here.
 */
 
-__EXC_VIRT_OOL(vsx_unavailable, 0x4f40, 0x4f60)
-
 __EXC_VIRT_OOL(facility_unavailable, 0x4f60, 0x4f80)
 
 __EXC_VIRT_OOL_HV(h_facility_unavailable, 0x4f80, 0x4fa0)
@@ -1387,40 +1418,7 @@ EXC_VIRT_NONE(0x5800, 0x5900)
 EXC_COMMON_BEGIN(ppc64_runlatch_on_trampoline)
b   __ppc64_runlatch_on
 
-EXC_COMMON_BEGIN(vsx_unavailable_common)
-   EXCEPTION_PROLOG_COMMON(0xf40, PACA_EXGEN)
-#ifdef CONFIG_VSX
-BEGIN_FTR_SECTION
-   beq 1f
-#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
-  BEGIN_FTR_SECTION_NESTED(69)
-   /* Test if 2 TM state bits are zero.  If non-zero (ie. userspace was in
-* transaction), go do TM stuff
-*/
-   rldicl. r0, r12, (64-MSR_TS_LG), (64-2)
-   bne-2f
-  END_FTR_SECTION_NESTED(CPU_FTR_TM, CPU_FTR_TM, 69)
-#endif
-   b   load_up_vsx
-#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
-2: /* User process was in a transaction */
-   bl  save_nvgprs
-   RECONCILE_IRQ_STATE(r10, r11)
-   addir3,r1,STACK_FRAME_OVERHEAD
-   bl  vsx_unavailable_tm
-   b   ret_from_except
-#endif
-1:
-END_FTR_SECTION_IFSET(CPU_FTR_VSX)
-#endif
-   bl  save_nvgprs
-   RECONCILE_IRQ_STATE(r10, r11)
-   addir3,r1,STACK_FRAME_OVERHEAD
-   bl  vsx_unavailable_exception
-   b   ret_from_except
-
/* Equivalents to the above handlers for relocation-on interrupt 
vectors */
-__TRAMP_REAL_VIRT_OOL(vsx_unavailable, 0xf40)
 __TRAMP_REAL_VIRT_OOL(facility_unavailable, 0xf60)
 __TRAMP_REAL_VIRT_OOL_HV(h_facility_unavailable, 0xf80)
 
-- 
2.7.4



[PATCH v3 28/42] powerpc/64s: Consolidate Performance Monitor 0xf00 interrupt

2016-10-04 Thread Michael Ellerman
From: Nicholas Piggin 

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/exceptions-64s.S | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index ee9d4959948c..5566f218734a 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -1027,6 +1027,12 @@ EXC_VIRT_NONE(0x4ec0, 0x4f00)
 
 
 __EXC_REAL_OOL(performance_monitor, 0xf00, 0xf20)
+__TRAMP_REAL_REAL_OOL(performance_monitor, 0xf00)
+__EXC_VIRT_OOL(performance_monitor, 0x4f00, 0x4f20)
+__TRAMP_REAL_VIRT_OOL(performance_monitor, 0xf00)
+TRAMP_KVM(PACA_EXGEN, 0xf00)
+EXC_COMMON_ASYNC(performance_monitor_common, 0xf00, 
performance_monitor_exception)
+
 
 __EXC_REAL_OOL(altivec_unavailable, 0xf20, 0xf40)
 
@@ -1162,9 +1168,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_CFAR)
 #endif
 
/* moved from 0xf00 */
-__TRAMP_REAL_REAL_OOL(performance_monitor, 0xf00)
-TRAMP_KVM(PACA_EXGEN, 0xf00)
-
 __TRAMP_REAL_REAL_OOL(altivec_unavailable, 0xf20)
 TRAMP_KVM(PACA_EXGEN, 0xf20)
 
@@ -1297,7 +1300,6 @@ TRAMP_REAL_BEGIN(kvmppc_skip_Hinterrupt)
 /*** Common interrupt handlers ***/
 
 
-EXC_COMMON_ASYNC(performance_monitor_common, 0xf00, 
performance_monitor_exception)
 EXC_COMMON(instruction_breakpoint_common, 0x1300, 
instruction_breakpoint_exception)
 EXC_COMMON_HV(denorm_common, 0x1500, unknown_exception)
 #ifdef CONFIG_ALTIVEC
@@ -1322,8 +1324,6 @@ EXC_COMMON(altivec_assist_common, 0x1700, 
unknown_exception)
 * come here.
 */
 
-__EXC_VIRT_OOL(performance_monitor, 0x4f00, 0x4f20)
-
 __EXC_VIRT_OOL(altivec_unavailable, 0x4f20, 0x4f40)
 
 __EXC_VIRT_OOL(vsx_unavailable, 0x4f40, 0x4f60)
@@ -1421,7 +1421,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_VSX)
b   ret_from_except
 
/* Equivalents to the above handlers for relocation-on interrupt 
vectors */
-__TRAMP_REAL_VIRT_OOL(performance_monitor, 0xf00)
 __TRAMP_REAL_VIRT_OOL(altivec_unavailable, 0xf20)
 __TRAMP_REAL_VIRT_OOL(vsx_unavailable, 0xf40)
 __TRAMP_REAL_VIRT_OOL(facility_unavailable, 0xf60)
-- 
2.7.4



[PATCH v3 27/42] powerpc/64s: Consolidate Reserved 0xec0, 0xee0 interrupts

2016-10-04 Thread Michael Ellerman
From: Nicholas Piggin 

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/exceptions-64s.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index 54e352d6b50c..ee9d4959948c 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -1023,6 +1023,8 @@ EXC_COMMON_ASYNC(h_virt_irq_common, 0xea0, do_IRQ)
 
 
 EXC_REAL_NONE(0xec0, 0xf00)
+EXC_VIRT_NONE(0x4ec0, 0x4f00)
+
 
 __EXC_REAL_OOL(performance_monitor, 0xf00, 0xf20)
 
@@ -1320,8 +1322,6 @@ EXC_COMMON(altivec_assist_common, 0x1700, 
unknown_exception)
 * come here.
 */
 
-EXC_VIRT_NONE(0x4ec0, 0x4f00)
-
 __EXC_VIRT_OOL(performance_monitor, 0x4f00, 0x4f20)
 
 __EXC_VIRT_OOL(altivec_unavailable, 0x4f20, 0x4f40)
-- 
2.7.4



[PATCH v3 26/42] powerpc/64s: Consolidate Hypervisor Virtualization 0xea0 interrupt

2016-10-04 Thread Michael Ellerman
From: Nicholas Piggin 

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/exceptions-64s.S | 14 ++
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index 3e347c72a941..54e352d6b50c 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -1015,6 +1015,12 @@ EXC_COMMON_ASYNC(h_doorbell_common, 0xe80, 
unknown_exception)
 
 
 __EXC_REAL_OOL_MASKABLE_HV(h_virt_irq, 0xea0, 0xec0)
+__TRAMP_REAL_REAL_OOL_MASKABLE_HV(h_virt_irq, 0xea0)
+__EXC_VIRT_OOL_MASKABLE_HV(h_virt_irq, 0x4ea0, 0x4ec0)
+__TRAMP_REAL_VIRT_OOL_MASKABLE_HV(h_virt_irq, 0xea0)
+TRAMP_KVM_HV(PACA_EXGEN, 0xea0)
+EXC_COMMON_ASYNC(h_virt_irq_common, 0xea0, do_IRQ)
+
 
 EXC_REAL_NONE(0xec0, 0xf00)
 
@@ -1153,10 +1159,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_CFAR)
b   .
 #endif
 
-   /* moved from 0xe00 */
-__TRAMP_REAL_REAL_OOL_MASKABLE_HV(h_virt_irq, 0xea0)
-TRAMP_KVM_HV(PACA_EXGEN, 0xea0)
-
/* moved from 0xf00 */
 __TRAMP_REAL_REAL_OOL(performance_monitor, 0xf00)
 TRAMP_KVM(PACA_EXGEN, 0xf00)
@@ -1293,7 +1295,6 @@ TRAMP_REAL_BEGIN(kvmppc_skip_Hinterrupt)
 /*** Common interrupt handlers ***/
 
 
-EXC_COMMON_ASYNC(h_virt_irq_common, 0xea0, do_IRQ)
 EXC_COMMON_ASYNC(performance_monitor_common, 0xf00, 
performance_monitor_exception)
 EXC_COMMON(instruction_breakpoint_common, 0x1300, 
instruction_breakpoint_exception)
 EXC_COMMON_HV(denorm_common, 0x1500, unknown_exception)
@@ -1319,8 +1320,6 @@ EXC_COMMON(altivec_assist_common, 0x1700, 
unknown_exception)
 * come here.
 */
 
-__EXC_VIRT_OOL_MASKABLE_HV(h_virt_irq, 0x4ea0, 0x4ec0)
-
 EXC_VIRT_NONE(0x4ec0, 0x4f00)
 
 __EXC_VIRT_OOL(performance_monitor, 0x4f00, 0x4f20)
@@ -1422,7 +1421,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_VSX)
b   ret_from_except
 
/* Equivalents to the above handlers for relocation-on interrupt 
vectors */
-__TRAMP_REAL_VIRT_OOL_MASKABLE_HV(h_virt_irq, 0xea0)
 __TRAMP_REAL_VIRT_OOL(performance_monitor, 0xf00)
 __TRAMP_REAL_VIRT_OOL(altivec_unavailable, 0xf20)
 __TRAMP_REAL_VIRT_OOL(vsx_unavailable, 0xf40)
-- 
2.7.4



[PATCH v3 25/42] powerpc/64s: Consolidate Directed Hypervisor Doorbell 0xe80 interrupt

2016-10-04 Thread Michael Ellerman
From: Nicholas Piggin 

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/exceptions-64s.S | 21 ++---
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index 01950615d8d3..3e347c72a941 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -1003,6 +1003,16 @@ EXC_COMMON_ASYNC(hmi_exception_common, 0xe60, 
handle_hmi_exception)
 
 
 __EXC_REAL_OOL_MASKABLE_HV(h_doorbell, 0xe80, 0xea0)
+__TRAMP_REAL_REAL_OOL_MASKABLE_HV(h_doorbell, 0xe80)
+__EXC_VIRT_OOL_MASKABLE_HV(h_doorbell, 0x4e80, 0x4ea0)
+__TRAMP_REAL_VIRT_OOL_MASKABLE_HV(h_doorbell, 0xe80)
+TRAMP_KVM_HV(PACA_EXGEN, 0xe80)
+#ifdef CONFIG_PPC_DOORBELL
+EXC_COMMON_ASYNC(h_doorbell_common, 0xe80, doorbell_exception)
+#else
+EXC_COMMON_ASYNC(h_doorbell_common, 0xe80, unknown_exception)
+#endif
+
 
 __EXC_REAL_OOL_MASKABLE_HV(h_virt_irq, 0xea0, 0xec0)
 
@@ -1144,9 +1154,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_CFAR)
 #endif
 
/* moved from 0xe00 */
-__TRAMP_REAL_REAL_OOL_MASKABLE_HV(h_doorbell, 0xe80)
-TRAMP_KVM_HV(PACA_EXGEN, 0xe80)
-
 __TRAMP_REAL_REAL_OOL_MASKABLE_HV(h_virt_irq, 0xea0)
 TRAMP_KVM_HV(PACA_EXGEN, 0xea0)
 
@@ -1286,11 +1293,6 @@ TRAMP_REAL_BEGIN(kvmppc_skip_Hinterrupt)
 /*** Common interrupt handlers ***/
 
 
-#ifdef CONFIG_PPC_DOORBELL
-EXC_COMMON_ASYNC(h_doorbell_common, 0xe80, doorbell_exception)
-#else
-EXC_COMMON_ASYNC(h_doorbell_common, 0xe80, unknown_exception)
-#endif
 EXC_COMMON_ASYNC(h_virt_irq_common, 0xea0, do_IRQ)
 EXC_COMMON_ASYNC(performance_monitor_common, 0xf00, 
performance_monitor_exception)
 EXC_COMMON(instruction_breakpoint_common, 0x1300, 
instruction_breakpoint_exception)
@@ -1317,8 +1319,6 @@ EXC_COMMON(altivec_assist_common, 0x1700, 
unknown_exception)
 * come here.
 */
 
-__EXC_VIRT_OOL_MASKABLE_HV(h_doorbell, 0x4e80, 0x4ea0)
-
 __EXC_VIRT_OOL_MASKABLE_HV(h_virt_irq, 0x4ea0, 0x4ec0)
 
 EXC_VIRT_NONE(0x4ec0, 0x4f00)
@@ -1422,7 +1422,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_VSX)
b   ret_from_except
 
/* Equivalents to the above handlers for relocation-on interrupt 
vectors */
-__TRAMP_REAL_VIRT_OOL_MASKABLE_HV(h_doorbell, 0xe80)
 __TRAMP_REAL_VIRT_OOL_MASKABLE_HV(h_virt_irq, 0xea0)
 __TRAMP_REAL_VIRT_OOL(performance_monitor, 0xf00)
 __TRAMP_REAL_VIRT_OOL(altivec_unavailable, 0xf20)
-- 
2.7.4



[PATCH v3 24/42] powerpc/64s: Consolidate Hypervisor Maintenance 0xe60 interrupt

2016-10-04 Thread Michael Ellerman
From: Nicholas Piggin 

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/exceptions-64s.S | 113 +--
 1 file changed, 56 insertions(+), 57 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index 128b21b42f8b..01950615d8d3 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -945,6 +945,62 @@ EXC_COMMON(emulation_assist_common, 0xe40, 
emulation_assist_interrupt)
 
 
 __EXC_REAL_OOL_HV_DIRECT(hmi_exception, 0xe60, 0xe80, hmi_exception_early)
+__TRAMP_REAL_REAL_OOL_MASKABLE_HV(hmi_exception, 0xe60)
+EXC_VIRT_BEGIN(unused, 0x4e60, 0x4e80)
+   b   .   /* Can't happen, see v2.07 Book III-S section 6.5 */
+EXC_VIRT_END(unused, 0x4e60, 0x4e80)
+TRAMP_KVM_HV(PACA_EXGEN, 0xe60)
+TRAMP_REAL_BEGIN(hmi_exception_early)
+   EXCEPTION_PROLOG_1(PACA_EXGEN, KVMTEST_HV, 0xe60)
+   mr  r10,r1  /* Save r1  */
+   ld  r1,PACAEMERGSP(r13) /* Use emergency stack  */
+   subir1,r1,INT_FRAME_SIZE/* alloc stack frame*/
+   std r9,_CCR(r1) /* save CR in stackframe*/
+   mfspr   r11,SPRN_HSRR0  /* Save HSRR0 */
+   std r11,_NIP(r1)/* save HSRR0 in stackframe */
+   mfspr   r12,SPRN_HSRR1  /* Save SRR1 */
+   std r12,_MSR(r1)/* save SRR1 in stackframe  */
+   std r10,0(r1)   /* make stack chain pointer */
+   std r0,GPR0(r1) /* save r0 in stackframe*/
+   std r10,GPR1(r1)/* save r1 in stackframe*/
+   EXCEPTION_PROLOG_COMMON_2(PACA_EXGEN)
+   EXCEPTION_PROLOG_COMMON_3(0xe60)
+   addir3,r1,STACK_FRAME_OVERHEAD
+   bl  hmi_exception_realmode
+   /* Windup the stack. */
+   /* Move original HSRR0 and HSRR1 into the respective regs */
+   ld  r9,_MSR(r1)
+   mtspr   SPRN_HSRR1,r9
+   ld  r3,_NIP(r1)
+   mtspr   SPRN_HSRR0,r3
+   ld  r9,_CTR(r1)
+   mtctr   r9
+   ld  r9,_XER(r1)
+   mtxer   r9
+   ld  r9,_LINK(r1)
+   mtlrr9
+   REST_GPR(0, r1)
+   REST_8GPRS(2, r1)
+   REST_GPR(10, r1)
+   ld  r11,_CCR(r1)
+   mtcrr11
+   REST_GPR(11, r1)
+   REST_2GPRS(12, r1)
+   /* restore original r1. */
+   ld  r1,GPR1(r1)
+
+   /*
+* Go to virtual mode and pull the HMI event information from
+* firmware.
+*/
+   .globl hmi_exception_after_realmode
+hmi_exception_after_realmode:
+   SET_SCRATCH0(r13)
+   EXCEPTION_PROLOG_0(PACA_EXGEN)
+   b   tramp_real_hmi_exception
+
+EXC_COMMON_ASYNC(hmi_exception_common, 0xe60, handle_hmi_exception)
+
 
 __EXC_REAL_OOL_MASKABLE_HV(h_doorbell, 0xe80, 0xea0)
 
@@ -1088,9 +1144,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_CFAR)
 #endif
 
/* moved from 0xe00 */
-__TRAMP_REAL_REAL_OOL_MASKABLE_HV(hmi_exception, 0xe60)
-TRAMP_KVM_HV(PACA_EXGEN, 0xe60)
-
 __TRAMP_REAL_REAL_OOL_MASKABLE_HV(h_doorbell, 0xe80)
 TRAMP_KVM_HV(PACA_EXGEN, 0xe80)
 
@@ -1233,7 +1286,6 @@ TRAMP_REAL_BEGIN(kvmppc_skip_Hinterrupt)
 /*** Common interrupt handlers ***/
 
 
-EXC_COMMON_ASYNC(hmi_exception_common, 0xe60, handle_hmi_exception)
 #ifdef CONFIG_PPC_DOORBELL
 EXC_COMMON_ASYNC(h_doorbell_common, 0xe80, doorbell_exception)
 #else
@@ -1265,10 +1317,6 @@ EXC_COMMON(altivec_assist_common, 0x1700, 
unknown_exception)
 * come here.
 */
 
-EXC_VIRT_BEGIN(unused, 0x4e60, 0x4e80)
-   b   .   /* Can't happen, see v2.07 Book III-S section 6.5 */
-EXC_VIRT_END(unused, 0x4e60, 0x4e80)
-
 __EXC_VIRT_OOL_MASKABLE_HV(h_doorbell, 0x4e80, 0x4ea0)
 
 __EXC_VIRT_OOL_MASKABLE_HV(h_virt_irq, 0x4ea0, 0x4ec0)
@@ -1405,55 +1453,6 @@ EXC_COMMON(cbe_thermal_common, 0x1800, 
cbe_thermal_exception)
 #endif /* CONFIG_CBE_RAS */
 
 
-TRAMP_REAL_BEGIN(hmi_exception_early)
-   EXCEPTION_PROLOG_1(PACA_EXGEN, KVMTEST_HV, 0xe60)
-   mr  r10,r1  /* Save r1  */
-   ld  r1,PACAEMERGSP(r13) /* Use emergency stack  */
-   subir1,r1,INT_FRAME_SIZE/* alloc stack frame*/
-   std r9,_CCR(r1) /* save CR in stackframe*/
-   mfspr   r11,SPRN_HSRR0  /* Save HSRR0 */
-   std r11,_NIP(r1)/* save HSRR0 in stackframe */
-   mfspr   r12,SPRN_HSRR1  /* Save SRR1 */
-   std r12,_MSR(r1)/* save SRR1 in stackframe  */
-   std r10,0(r1)   /* make stack chain pointer */
-   std r0,GPR0(r1) /* save r0 in stackframe*/
-   std r10,GPR1(r1)/* save r1 in stackframe*/
-   EXCEPTION_PROLOG_COMMON_2(PACA_EXGEN)
-  

[PATCH v3 23/42] powerpc/64s: Consolidate Hypervisor Emulation Assistance 0xe40 interrupt

2016-10-04 Thread Michael Ellerman
From: Nicholas Piggin 

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/exceptions-64s.S | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index 5b2afa5ef919..128b21b42f8b 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -937,6 +937,12 @@ EXC_COMMON(h_instr_storage_common, 0xe20, 
unknown_exception)
 
 
 __EXC_REAL_OOL_HV(emulation_assist, 0xe40, 0xe60)
+__TRAMP_REAL_REAL_OOL_HV(emulation_assist, 0xe40)
+__EXC_VIRT_OOL_HV(emulation_assist, 0x4e40, 0x4e60)
+__TRAMP_REAL_VIRT_OOL_HV(emulation_assist, 0xe40)
+TRAMP_KVM_HV(PACA_EXGEN, 0xe40)
+EXC_COMMON(emulation_assist_common, 0xe40, emulation_assist_interrupt)
+
 
 __EXC_REAL_OOL_HV_DIRECT(hmi_exception, 0xe60, 0xe80, hmi_exception_early)
 
@@ -1082,9 +1088,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_CFAR)
 #endif
 
/* moved from 0xe00 */
-__TRAMP_REAL_REAL_OOL_HV(emulation_assist, 0xe40)
-TRAMP_KVM_HV(PACA_EXGEN, 0xe40)
-
 __TRAMP_REAL_REAL_OOL_MASKABLE_HV(hmi_exception, 0xe60)
 TRAMP_KVM_HV(PACA_EXGEN, 0xe60)
 
@@ -1230,7 +1233,6 @@ TRAMP_REAL_BEGIN(kvmppc_skip_Hinterrupt)
 /*** Common interrupt handlers ***/
 
 
-EXC_COMMON(emulation_assist_common, 0xe40, emulation_assist_interrupt)
 EXC_COMMON_ASYNC(hmi_exception_common, 0xe60, handle_hmi_exception)
 #ifdef CONFIG_PPC_DOORBELL
 EXC_COMMON_ASYNC(h_doorbell_common, 0xe80, doorbell_exception)
@@ -1263,8 +1265,6 @@ EXC_COMMON(altivec_assist_common, 0x1700, 
unknown_exception)
 * come here.
 */
 
-__EXC_VIRT_OOL_HV(emulation_assist, 0x4e40, 0x4e60)
-
 EXC_VIRT_BEGIN(unused, 0x4e60, 0x4e80)
b   .   /* Can't happen, see v2.07 Book III-S section 6.5 */
 EXC_VIRT_END(unused, 0x4e60, 0x4e80)
@@ -1374,7 +1374,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_VSX)
b   ret_from_except
 
/* Equivalents to the above handlers for relocation-on interrupt 
vectors */
-__TRAMP_REAL_VIRT_OOL_HV(emulation_assist, 0xe40)
 __TRAMP_REAL_VIRT_OOL_MASKABLE_HV(h_doorbell, 0xe80)
 __TRAMP_REAL_VIRT_OOL_MASKABLE_HV(h_virt_irq, 0xea0)
 __TRAMP_REAL_VIRT_OOL(performance_monitor, 0xf00)
-- 
2.7.4



[PATCH v3 22/42] powerpc/64s: Consolidate Hypervisor Instruction Storage 0xe20 interrupt

2016-10-04 Thread Michael Ellerman
From: Nicholas Piggin 

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/exceptions-64s.S | 16 +++-
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index 10cf57eb2e77..5b2afa5ef919 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -928,6 +928,13 @@ EXC_COMMON(trap_0e_common, 0xe00, unknown_exception)
 
 
 __EXC_REAL_OOL_HV(h_instr_storage, 0xe20, 0xe40)
+__TRAMP_REAL_REAL_OOL_HV(h_instr_storage, 0xe20)
+EXC_VIRT_BEGIN(unused, 0x4e20, 0x4e40)
+   b   .   /* Can't happen, see v2.07 Book III-S section 6.5 */
+EXC_VIRT_END(unused, 0x4e20, 0x4e40)
+TRAMP_KVM_HV(PACA_EXGEN, 0xe20)
+EXC_COMMON(h_instr_storage_common, 0xe20, unknown_exception)
+
 
 __EXC_REAL_OOL_HV(emulation_assist, 0xe40, 0xe60)
 
@@ -1075,9 +1082,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_CFAR)
 #endif
 
/* moved from 0xe00 */
-__TRAMP_REAL_REAL_OOL_HV(h_instr_storage, 0xe20)
-TRAMP_KVM_HV(PACA_EXGEN, 0xe20)
-
 __TRAMP_REAL_REAL_OOL_HV(emulation_assist, 0xe40)
 TRAMP_KVM_HV(PACA_EXGEN, 0xe40)
 
@@ -1259,10 +1263,6 @@ EXC_COMMON(altivec_assist_common, 0x1700, 
unknown_exception)
 * come here.
 */
 
-EXC_VIRT_BEGIN(unused, 0x4e20, 0x4e40)
-   b   .   /* Can't happen, see v2.07 Book III-S section 6.5 */
-EXC_VIRT_END(unused, 0x4e20, 0x4e40)
-
 __EXC_VIRT_OOL_HV(emulation_assist, 0x4e40, 0x4e60)
 
 EXC_VIRT_BEGIN(unused, 0x4e60, 0x4e80)
@@ -1308,8 +1308,6 @@ EXC_VIRT_NONE(0x5800, 0x5900)
 EXC_COMMON_BEGIN(ppc64_runlatch_on_trampoline)
b   __ppc64_runlatch_on
 
-EXC_COMMON(h_instr_storage_common, 0xe20, unknown_exception)
-
 EXC_COMMON_BEGIN(altivec_unavailable_common)
EXCEPTION_PROLOG_COMMON(0xf20, PACA_EXGEN)
 #ifdef CONFIG_ALTIVEC
-- 
2.7.4



[PATCH v3 21/42] powerpc/64s: Consolidate Hypervisor Data Storage 0xe00 interrupt

2016-10-04 Thread Michael Ellerman
From: Nicholas Piggin 

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/exceptions-64s.S | 42 
 1 file changed, 18 insertions(+), 24 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index f47c36d605d6..10cf57eb2e77 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -907,10 +907,25 @@ TRAMP_KVM(PACA_EXGEN, 0xd00)
 EXC_COMMON(single_step_common, 0xd00, single_step_exception)
 
 
-   /* At 0xe??? we have a bunch of hypervisor exceptions, we branch
-* out of line to handle them
-*/
 __EXC_REAL_OOL_HV(h_data_storage, 0xe00, 0xe20)
+__TRAMP_REAL_REAL_OOL_HV(h_data_storage, 0xe00)
+EXC_VIRT_BEGIN(unused, 0x4e00, 0x4e20)
+   b   .   /* Can't happen, see v2.07 Book III-S section 6.5 */
+EXC_VIRT_END(unused, 0x4e00, 0x4e20)
+TRAMP_KVM_HV_SKIP(PACA_EXGEN, 0xe00)
+EXC_COMMON_BEGIN(h_data_storage_common)
+   mfspr   r10,SPRN_HDAR
+   std r10,PACA_EXGEN+EX_DAR(r13)
+   mfspr   r10,SPRN_HDSISR
+   stw r10,PACA_EXGEN+EX_DSISR(r13)
+   EXCEPTION_PROLOG_COMMON(0xe00, PACA_EXGEN)
+   bl  save_nvgprs
+   RECONCILE_IRQ_STATE(r10, r11)
+   addir3,r1,STACK_FRAME_OVERHEAD
+   bl  unknown_exception
+   b   ret_from_except
+EXC_COMMON(trap_0e_common, 0xe00, unknown_exception)
+
 
 __EXC_REAL_OOL_HV(h_instr_storage, 0xe20, 0xe40)
 
@@ -1060,9 +1075,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_CFAR)
 #endif
 
/* moved from 0xe00 */
-__TRAMP_REAL_REAL_OOL_HV(h_data_storage, 0xe00)
-TRAMP_KVM_HV_SKIP(PACA_EXGEN, 0xe00)
-
 __TRAMP_REAL_REAL_OOL_HV(h_instr_storage, 0xe20)
 TRAMP_KVM_HV(PACA_EXGEN, 0xe20)
 
@@ -1214,7 +1226,6 @@ TRAMP_REAL_BEGIN(kvmppc_skip_Hinterrupt)
 /*** Common interrupt handlers ***/
 
 
-EXC_COMMON(trap_0e_common, 0xe00, unknown_exception)
 EXC_COMMON(emulation_assist_common, 0xe40, emulation_assist_interrupt)
 EXC_COMMON_ASYNC(hmi_exception_common, 0xe60, handle_hmi_exception)
 #ifdef CONFIG_PPC_DOORBELL
@@ -1248,10 +1259,6 @@ EXC_COMMON(altivec_assist_common, 0x1700, 
unknown_exception)
 * come here.
 */
 
-EXC_VIRT_BEGIN(unused, 0x4e00, 0x4e20)
-   b   .   /* Can't happen, see v2.07 Book III-S section 6.5 */
-EXC_VIRT_END(unused, 0x4e00, 0x4e20)
-
 EXC_VIRT_BEGIN(unused, 0x4e20, 0x4e40)
b   .   /* Can't happen, see v2.07 Book III-S section 6.5 */
 EXC_VIRT_END(unused, 0x4e20, 0x4e40)
@@ -1301,19 +1308,6 @@ EXC_VIRT_NONE(0x5800, 0x5900)
 EXC_COMMON_BEGIN(ppc64_runlatch_on_trampoline)
b   __ppc64_runlatch_on
 
-EXC_COMMON_BEGIN(h_data_storage_common)
-   mfspr   r10,SPRN_HDAR
-   std r10,PACA_EXGEN+EX_DAR(r13)
-   mfspr   r10,SPRN_HDSISR
-   stw r10,PACA_EXGEN+EX_DSISR(r13)
-   EXCEPTION_PROLOG_COMMON(0xe00, PACA_EXGEN)
-   bl  save_nvgprs
-   RECONCILE_IRQ_STATE(r10, r11)
-   addir3,r1,STACK_FRAME_OVERHEAD
-   bl  unknown_exception
-   b   ret_from_except
-
-
 EXC_COMMON(h_instr_storage_common, 0xe20, unknown_exception)
 
 EXC_COMMON_BEGIN(altivec_unavailable_common)
-- 
2.7.4



[PATCH v3 19/42] powerpc/64s: Consolidate System Call 0xc00 interrupt

2016-10-04 Thread Michael Ellerman
From: Nicholas Piggin 

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/exceptions-64s.S | 121 ++-
 1 file changed, 61 insertions(+), 60 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index 54dd9b8aba9a..6d4d7800895a 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -77,59 +77,6 @@ OPEN_TEXT_SECTION(0x7000)
 
 USE_FIXED_SECTION(real_vectors)
 
-#define LOAD_SYSCALL_HANDLER(reg)  \
-   ld  reg,PACAKBASE(r13); \
-   ori reg,reg,(ABS_ADDR(system_call_common))@l;
-
-   /* Syscall routine is used twice, in reloc-off and reloc-on paths */
-#define SYSCALL_PSERIES_1  \
-BEGIN_FTR_SECTION  \
-   cmpdi   r0,0x1ebe ; \
-   beq-1f ;\
-END_FTR_SECTION_IFSET(CPU_FTR_REAL_LE) \
-   mr  r9,r13 ;\
-   GET_PACA(r13) ; \
-   mfspr   r11,SPRN_SRR0 ; \
-0:
-
-#define SYSCALL_PSERIES_2_RFID \
-   mfspr   r12,SPRN_SRR1 ; \
-   LOAD_SYSCALL_HANDLER(r10) ; \
-   mtspr   SPRN_SRR0,r10 ; \
-   ld  r10,PACAKMSR(r13) ; \
-   mtspr   SPRN_SRR1,r10 ; \
-   rfid ;  \
-   b   . ; /* prevent speculative execution */
-
-#define SYSCALL_PSERIES_3  \
-   /* Fast LE/BE switch system call */ \
-1: mfspr   r12,SPRN_SRR1 ; \
-   xorir12,r12,MSR_LE ;\
-   mtspr   SPRN_SRR1,r12 ; \
-   rfid ;  /* return to userspace */   \
-   b   . ; /* prevent speculative execution */
-
-#if defined(CONFIG_RELOCATABLE)
-   /*
-* We can't branch directly so we do it via the CTR which
-* is volatile across system calls.
-*/
-#define SYSCALL_PSERIES_2_DIRECT   \
-   LOAD_SYSCALL_HANDLER(r12) ; \
-   mtctr   r12 ;   \
-   mfspr   r12,SPRN_SRR1 ; \
-   li  r10,MSR_RI ;\
-   mtmsrd  r10,1 ; \
-   bctr ;
-#else
-   /* We can branch directly */
-#define SYSCALL_PSERIES_2_DIRECT   \
-   mfspr   r12,SPRN_SRR1 ; \
-   li  r10,MSR_RI ;\
-   mtmsrd  r10,1 ; /* Set RI (EE=0) */ \
-   b   system_call_common ;
-#endif
-
 /*
  * This is the start of the interrupt handlers for pSeries
  * This code runs with relocation off.
@@ -864,6 +811,59 @@ TRAMP_KVM(PACA_EXGEN, 0xb00)
 EXC_COMMON(trap_0b_common, 0xb00, unknown_exception)
 
 
+#define LOAD_SYSCALL_HANDLER(reg)  \
+   ld  reg,PACAKBASE(r13); \
+   ori reg,reg,(ABS_ADDR(system_call_common))@l;
+
+/* Syscall routine is used twice, in reloc-off and reloc-on paths */
+#define SYSCALL_PSERIES_1  \
+BEGIN_FTR_SECTION  \
+   cmpdi   r0,0x1ebe ; \
+   beq-1f ;\
+END_FTR_SECTION_IFSET(CPU_FTR_REAL_LE) \
+   mr  r9,r13 ;\
+   GET_PACA(r13) ; \
+   mfspr   r11,SPRN_SRR0 ; \
+0:
+
+#define SYSCALL_PSERIES_2_RFID \
+   mfspr   r12,SPRN_SRR1 ; \
+   LOAD_SYSCALL_HANDLER(r10) ; \
+   mtspr   SPRN_SRR0,r10 ; \
+   ld  r10,PACAKMSR(r13) ; \
+   mtspr   SPRN_SRR1,r10 ; \
+   rfid ;  \
+   b   . ; /* prevent speculative execution */
+
+#define SYSCALL_PSERIES_3  \
+   /* Fast LE/BE switch system call */ \
+1: mfspr   

[PATCH v3 20/42] powerpc/64s: Consolidate Trace 0xd00 interrupt

2016-10-04 Thread Michael Ellerman
From: Nicholas Piggin 

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/exceptions-64s.S | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index 6d4d7800895a..f47c36d605d6 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -902,8 +902,9 @@ TRAMP_KVM(PACA_EXGEN, 0xc00)
 
 
 EXC_REAL(single_step, 0xd00, 0xe00)
-
+EXC_VIRT(single_step, 0x4d00, 0x4e00, 0xd00)
 TRAMP_KVM(PACA_EXGEN, 0xd00)
+EXC_COMMON(single_step_common, 0xd00, single_step_exception)
 
 
/* At 0xe??? we have a bunch of hypervisor exceptions, we branch
@@ -1213,7 +1214,6 @@ TRAMP_REAL_BEGIN(kvmppc_skip_Hinterrupt)
 /*** Common interrupt handlers ***/
 
 
-EXC_COMMON(single_step_common, 0xd00, single_step_exception)
 EXC_COMMON(trap_0e_common, 0xe00, unknown_exception)
 EXC_COMMON(emulation_assist_common, 0xe40, emulation_assist_interrupt)
 EXC_COMMON_ASYNC(hmi_exception_common, 0xe60, handle_hmi_exception)
@@ -1248,8 +1248,6 @@ EXC_COMMON(altivec_assist_common, 0x1700, 
unknown_exception)
 * come here.
 */
 
-EXC_VIRT(single_step, 0x4d00, 0x4e00, 0xd00)
-
 EXC_VIRT_BEGIN(unused, 0x4e00, 0x4e20)
b   .   /* Can't happen, see v2.07 Book III-S section 6.5 */
 EXC_VIRT_END(unused, 0x4e00, 0x4e20)
-- 
2.7.4



[PATCH v3 18/42] powerpc/64s: Consolidate Reserved 0xb00 interrupt

2016-10-04 Thread Michael Ellerman
From: Nicholas Piggin 

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/exceptions-64s.S | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index f73a10aaf54a..54dd9b8aba9a 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -859,8 +859,10 @@ EXC_COMMON_ASYNC(doorbell_super_common, 0xa00, 
unknown_exception)
 
 
 EXC_REAL(trap_0b, 0xb00, 0xc00)
-
+EXC_VIRT(trap_0b, 0x4b00, 0x4c00, 0xb00)
 TRAMP_KVM(PACA_EXGEN, 0xb00)
+EXC_COMMON(trap_0b_common, 0xb00, unknown_exception)
+
 
 EXC_REAL_BEGIN(system_call, 0xc00, 0xd00)
 /*
@@ -1203,7 +1205,6 @@ TRAMP_REAL_BEGIN(kvmppc_skip_Hinterrupt)
 /*** Common interrupt handlers ***/
 
 
-EXC_COMMON(trap_0b_common, 0xb00, unknown_exception)
 EXC_COMMON(single_step_common, 0xd00, single_step_exception)
 EXC_COMMON(trap_0e_common, 0xe00, unknown_exception)
 EXC_COMMON(emulation_assist_common, 0xe40, emulation_assist_interrupt)
@@ -1239,8 +1240,6 @@ EXC_COMMON(altivec_assist_common, 0x1700, 
unknown_exception)
 * come here.
 */
 
-EXC_VIRT(trap_0b, 0x4b00, 0x4c00, 0xb00)
-
 EXC_VIRT_BEGIN(system_call, 0x4c00, 0x4d00)
HMT_MEDIUM
SYSCALL_PSERIES_1
-- 
2.7.4



[PATCH v3 17/42] powerpc/64s: Consolidate Directed Privileged Doorbell 0xa00 interrupt

2016-10-04 Thread Michael Ellerman
From: Nicholas Piggin 

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/exceptions-64s.S | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index f9fe906feb37..f73a10aaf54a 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -849,8 +849,14 @@ EXC_COMMON(hdecrementer_common, 0x980, hdec_interrupt)
 
 
 EXC_REAL_MASKABLE(doorbell_super, 0xa00, 0xb00)
-
+EXC_VIRT_MASKABLE(doorbell_super, 0x4a00, 0x4b00, 0xa00)
 TRAMP_KVM(PACA_EXGEN, 0xa00)
+#ifdef CONFIG_PPC_DOORBELL
+EXC_COMMON_ASYNC(doorbell_super_common, 0xa00, doorbell_exception)
+#else
+EXC_COMMON_ASYNC(doorbell_super_common, 0xa00, unknown_exception)
+#endif
+
 
 EXC_REAL(trap_0b, 0xb00, 0xc00)
 
@@ -1197,11 +1203,6 @@ TRAMP_REAL_BEGIN(kvmppc_skip_Hinterrupt)
 /*** Common interrupt handlers ***/
 
 
-#ifdef CONFIG_PPC_DOORBELL
-EXC_COMMON_ASYNC(doorbell_super_common, 0xa00, doorbell_exception)
-#else
-EXC_COMMON_ASYNC(doorbell_super_common, 0xa00, unknown_exception)
-#endif
 EXC_COMMON(trap_0b_common, 0xb00, unknown_exception)
 EXC_COMMON(single_step_common, 0xd00, single_step_exception)
 EXC_COMMON(trap_0e_common, 0xe00, unknown_exception)
@@ -1238,7 +1239,6 @@ EXC_COMMON(altivec_assist_common, 0x1700, 
unknown_exception)
 * come here.
 */
 
-EXC_VIRT_MASKABLE(doorbell_super, 0x4a00, 0x4b00, 0xa00)
 EXC_VIRT(trap_0b, 0x4b00, 0x4c00, 0xb00)
 
 EXC_VIRT_BEGIN(system_call, 0x4c00, 0x4d00)
-- 
2.7.4



[PATCH v3 16/42] powerpc/64s: Consolidate Hypervisor Decrementer 0x980 interrupt

2016-10-04 Thread Michael Ellerman
From: Nicholas Piggin 

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/exceptions-64s.S | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index 01d5af00f2e2..f9fe906feb37 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -843,6 +843,10 @@ EXC_COMMON_ASYNC(decrementer_common, 0x900, 
timer_interrupt)
 
 
 EXC_REAL_HV(hdecrementer, 0x980, 0xa00)
+EXC_VIRT_HV(hdecrementer, 0x4980, 0x4a00, 0x980)
+TRAMP_KVM_HV(PACA_EXGEN, 0x980)
+EXC_COMMON(hdecrementer_common, 0x980, hdec_interrupt)
+
 
 EXC_REAL_MASKABLE(doorbell_super, 0xa00, 0xb00)
 
@@ -973,7 +977,6 @@ EXC_REAL_NONE(0x1800, 0x1900)
 /*** Out of line interrupts support ***/
 
/* moved from 0x200 */
-TRAMP_KVM_HV(PACA_EXGEN, 0x980)
 
 #ifdef CONFIG_PPC_DENORMALISATION
 TRAMP_REAL_BEGIN(denorm_assist)
@@ -1193,7 +1196,6 @@ TRAMP_REAL_BEGIN(kvmppc_skip_Hinterrupt)
 
 /*** Common interrupt handlers ***/
 
-EXC_COMMON(hdecrementer_common, 0x980, hdec_interrupt)
 
 #ifdef CONFIG_PPC_DOORBELL
 EXC_COMMON_ASYNC(doorbell_super_common, 0xa00, doorbell_exception)
@@ -1236,7 +1238,6 @@ EXC_COMMON(altivec_assist_common, 0x1700, 
unknown_exception)
 * come here.
 */
 
-EXC_VIRT_HV(hdecrementer, 0x4980, 0x4a00, 0x980)
 EXC_VIRT_MASKABLE(doorbell_super, 0x4a00, 0x4b00, 0xa00)
 EXC_VIRT(trap_0b, 0x4b00, 0x4c00, 0xb00)
 
-- 
2.7.4



[PATCH v3 15/42] powerpc/64s: Consolidate Decrementer 0x900 interrupt

2016-10-04 Thread Michael Ellerman
From: Nicholas Piggin 

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/exceptions-64s.S | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index ac727633cbb1..01d5af00f2e2 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -837,6 +837,10 @@ END_FTR_SECTION_IFSET(CPU_FTR_TM)
 
 
 EXC_REAL_MASKABLE(decrementer, 0x900, 0x980)
+EXC_VIRT_MASKABLE(decrementer, 0x4900, 0x4980, 0x900)
+TRAMP_KVM(PACA_EXGEN, 0x900)
+EXC_COMMON_ASYNC(decrementer_common, 0x900, timer_interrupt)
+
 
 EXC_REAL_HV(hdecrementer, 0x980, 0xa00)
 
@@ -969,7 +973,6 @@ EXC_REAL_NONE(0x1800, 0x1900)
 /*** Out of line interrupts support ***/
 
/* moved from 0x200 */
-TRAMP_KVM(PACA_EXGEN, 0x900)
 TRAMP_KVM_HV(PACA_EXGEN, 0x980)
 
 #ifdef CONFIG_PPC_DENORMALISATION
@@ -1190,7 +1193,6 @@ TRAMP_REAL_BEGIN(kvmppc_skip_Hinterrupt)
 
 /*** Common interrupt handlers ***/
 
-EXC_COMMON_ASYNC(decrementer_common, 0x900, timer_interrupt)
 EXC_COMMON(hdecrementer_common, 0x980, hdec_interrupt)
 
 #ifdef CONFIG_PPC_DOORBELL
@@ -1234,7 +1236,6 @@ EXC_COMMON(altivec_assist_common, 0x1700, 
unknown_exception)
 * come here.
 */
 
-EXC_VIRT_MASKABLE(decrementer, 0x4900, 0x4980, 0x900)
 EXC_VIRT_HV(hdecrementer, 0x4980, 0x4a00, 0x980)
 EXC_VIRT_MASKABLE(doorbell_super, 0x4a00, 0x4b00, 0xa00)
 EXC_VIRT(trap_0b, 0x4b00, 0x4c00, 0xb00)
-- 
2.7.4



[PATCH v3 14/42] powerpc/64s: Consolidate FP Unavailable 0x800 interrupt

2016-10-04 Thread Michael Ellerman
From: Nicholas Piggin 

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/exceptions-64s.S | 61 ++--
 1 file changed, 30 insertions(+), 31 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index 1df0283a5b3e..ac727633cbb1 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -804,8 +804,37 @@ EXC_COMMON_BEGIN(program_check_common)
 
 
 EXC_REAL(fp_unavailable, 0x800, 0x900)
-
+EXC_VIRT(fp_unavailable, 0x4800, 0x4900, 0x800)
 TRAMP_KVM(PACA_EXGEN, 0x800)
+EXC_COMMON_BEGIN(fp_unavailable_common)
+   EXCEPTION_PROLOG_COMMON(0x800, PACA_EXGEN)
+   bne 1f  /* if from user, just load it up */
+   bl  save_nvgprs
+   RECONCILE_IRQ_STATE(r10, r11)
+   addir3,r1,STACK_FRAME_OVERHEAD
+   bl  kernel_fp_unavailable_exception
+   BUG_OPCODE
+1:
+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
+BEGIN_FTR_SECTION
+   /* Test if 2 TM state bits are zero.  If non-zero (ie. userspace was in
+* transaction), go do TM stuff
+*/
+   rldicl. r0, r12, (64-MSR_TS_LG), (64-2)
+   bne-2f
+END_FTR_SECTION_IFSET(CPU_FTR_TM)
+#endif
+   bl  load_up_fpu
+   b   fast_exception_return
+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
+2: /* User process was in a transaction */
+   bl  save_nvgprs
+   RECONCILE_IRQ_STATE(r10, r11)
+   addir3,r1,STACK_FRAME_OVERHEAD
+   bl  fp_unavailable_tm
+   b   ret_from_except
+#endif
+
 
 EXC_REAL_MASKABLE(decrementer, 0x900, 0x980)
 
@@ -1205,7 +1234,6 @@ EXC_COMMON(altivec_assist_common, 0x1700, 
unknown_exception)
 * come here.
 */
 
-EXC_VIRT(fp_unavailable, 0x4800, 0x4900, 0x800)
 EXC_VIRT_MASKABLE(decrementer, 0x4900, 0x4980, 0x900)
 EXC_VIRT_HV(hdecrementer, 0x4980, 0x4a00, 0x980)
 EXC_VIRT_MASKABLE(doorbell_super, 0x4a00, 0x4b00, 0xa00)
@@ -1288,35 +1316,6 @@ EXC_COMMON_BEGIN(h_data_storage_common)
 
 EXC_COMMON(h_instr_storage_common, 0xe20, unknown_exception)
 
-EXC_COMMON_BEGIN(fp_unavailable_common)
-   EXCEPTION_PROLOG_COMMON(0x800, PACA_EXGEN)
-   bne 1f  /* if from user, just load it up */
-   bl  save_nvgprs
-   RECONCILE_IRQ_STATE(r10, r11)
-   addir3,r1,STACK_FRAME_OVERHEAD
-   bl  kernel_fp_unavailable_exception
-   BUG_OPCODE
-1:
-#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
-BEGIN_FTR_SECTION
-   /* Test if 2 TM state bits are zero.  If non-zero (ie. userspace was in
-* transaction), go do TM stuff
-*/
-   rldicl. r0, r12, (64-MSR_TS_LG), (64-2)
-   bne-2f
-END_FTR_SECTION_IFSET(CPU_FTR_TM)
-#endif
-   bl  load_up_fpu
-   b   fast_exception_return
-#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
-2: /* User process was in a transaction */
-   bl  save_nvgprs
-   RECONCILE_IRQ_STATE(r10, r11)
-   addir3,r1,STACK_FRAME_OVERHEAD
-   bl  fp_unavailable_tm
-   b   ret_from_except
-#endif
-
 EXC_COMMON_BEGIN(altivec_unavailable_common)
EXCEPTION_PROLOG_COMMON(0xf20, PACA_EXGEN)
 #ifdef CONFIG_ALTIVEC
-- 
2.7.4



[PATCH v3 13/42] powerpc/64s: Consolidate Program 0x700 interrupt

2016-10-04 Thread Michael Ellerman
From: Nicholas Piggin 

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/exceptions-64s.S | 19 +--
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index debd02436ed6..1df0283a5b3e 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -792,8 +792,16 @@ EXC_COMMON_BEGIN(alignment_common)
 
 
 EXC_REAL(program_check, 0x700, 0x800)
-
+EXC_VIRT(program_check, 0x4700, 0x4800, 0x700)
 TRAMP_KVM(PACA_EXGEN, 0x700)
+EXC_COMMON_BEGIN(program_check_common)
+   EXCEPTION_PROLOG_COMMON(0x700, PACA_EXGEN)
+   bl  save_nvgprs
+   RECONCILE_IRQ_STATE(r10, r11)
+   addir3,r1,STACK_FRAME_OVERHEAD
+   bl  program_check_exception
+   b   ret_from_except
+
 
 EXC_REAL(fp_unavailable, 0x800, 0x900)
 
@@ -1197,7 +1205,6 @@ EXC_COMMON(altivec_assist_common, 0x1700, 
unknown_exception)
 * come here.
 */
 
-EXC_VIRT(program_check, 0x4700, 0x4800, 0x700)
 EXC_VIRT(fp_unavailable, 0x4800, 0x4900, 0x800)
 EXC_VIRT_MASKABLE(decrementer, 0x4900, 0x4980, 0x900)
 EXC_VIRT_HV(hdecrementer, 0x4980, 0x4a00, 0x980)
@@ -1281,14 +1288,6 @@ EXC_COMMON_BEGIN(h_data_storage_common)
 
 EXC_COMMON(h_instr_storage_common, 0xe20, unknown_exception)
 
-EXC_COMMON_BEGIN(program_check_common)
-   EXCEPTION_PROLOG_COMMON(0x700, PACA_EXGEN)
-   bl  save_nvgprs
-   RECONCILE_IRQ_STATE(r10, r11)
-   addir3,r1,STACK_FRAME_OVERHEAD
-   bl  program_check_exception
-   b   ret_from_except
-
 EXC_COMMON_BEGIN(fp_unavailable_common)
EXCEPTION_PROLOG_COMMON(0x800, PACA_EXGEN)
bne 1f  /* if from user, just load it up */
-- 
2.7.4



[PATCH v3 12/42] powerpc/64s: Consolidate Alignment 0x600 interrupt

2016-10-04 Thread Michael Ellerman
From: Nicholas Piggin 

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/exceptions-64s.S | 35 +--
 1 file changed, 17 insertions(+), 18 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index 270a02b71b96..debd02436ed6 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -772,8 +772,24 @@ EXC_COMMON_ASYNC(hardware_interrupt_common, 0x500, do_IRQ)
 
 
 EXC_REAL(alignment, 0x600, 0x700)
-
+EXC_VIRT(alignment, 0x4600, 0x4700, 0x600)
 TRAMP_KVM(PACA_EXGEN, 0x600)
+EXC_COMMON_BEGIN(alignment_common)
+   mfspr   r10,SPRN_DAR
+   std r10,PACA_EXGEN+EX_DAR(r13)
+   mfspr   r10,SPRN_DSISR
+   stw r10,PACA_EXGEN+EX_DSISR(r13)
+   EXCEPTION_PROLOG_COMMON(0x600, PACA_EXGEN)
+   ld  r3,PACA_EXGEN+EX_DAR(r13)
+   lwz r4,PACA_EXGEN+EX_DSISR(r13)
+   std r3,_DAR(r1)
+   std r4,_DSISR(r1)
+   bl  save_nvgprs
+   RECONCILE_IRQ_STATE(r10, r11)
+   addir3,r1,STACK_FRAME_OVERHEAD
+   bl  alignment_exception
+   b   ret_from_except
+
 
 EXC_REAL(program_check, 0x700, 0x800)
 
@@ -1181,7 +1197,6 @@ EXC_COMMON(altivec_assist_common, 0x1700, 
unknown_exception)
 * come here.
 */
 
-EXC_VIRT(alignment, 0x4600, 0x4700, 0x600)
 EXC_VIRT(program_check, 0x4700, 0x4800, 0x700)
 EXC_VIRT(fp_unavailable, 0x4800, 0x4900, 0x800)
 EXC_VIRT_MASKABLE(decrementer, 0x4900, 0x4980, 0x900)
@@ -1266,22 +1281,6 @@ EXC_COMMON_BEGIN(h_data_storage_common)
 
 EXC_COMMON(h_instr_storage_common, 0xe20, unknown_exception)
 
-EXC_COMMON_BEGIN(alignment_common)
-   mfspr   r10,SPRN_DAR
-   std r10,PACA_EXGEN+EX_DAR(r13)
-   mfspr   r10,SPRN_DSISR
-   stw r10,PACA_EXGEN+EX_DSISR(r13)
-   EXCEPTION_PROLOG_COMMON(0x600, PACA_EXGEN)
-   ld  r3,PACA_EXGEN+EX_DAR(r13)
-   lwz r4,PACA_EXGEN+EX_DSISR(r13)
-   std r3,_DAR(r1)
-   std r4,_DSISR(r1)
-   bl  save_nvgprs
-   RECONCILE_IRQ_STATE(r10, r11)
-   addir3,r1,STACK_FRAME_OVERHEAD
-   bl  alignment_exception
-   b   ret_from_except
-
 EXC_COMMON_BEGIN(program_check_common)
EXCEPTION_PROLOG_COMMON(0x700, PACA_EXGEN)
bl  save_nvgprs
-- 
2.7.4



[PATCH v3 11/42] powerpc/64s: Consolidate External 0x500 interrupt

2016-10-04 Thread Michael Ellerman
From: Nicholas Piggin 

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/exceptions-64s.S | 24 +---
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index d084b0efd287..270a02b71b96 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -758,6 +758,19 @@ do_kvm_0x500:
ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206)
 EXC_REAL_END(hardware_interrupt, 0x500, 0x600)
 
+EXC_VIRT_BEGIN(hardware_interrupt, 0x4500, 0x4600)
+   .globl hardware_interrupt_relon_hv;
+hardware_interrupt_relon_hv:
+   BEGIN_FTR_SECTION
+   _MASKABLE_RELON_EXCEPTION_PSERIES(0x500, 
hardware_interrupt_common, EXC_HV, SOFTEN_TEST_HV)
+   FTR_SECTION_ELSE
+   _MASKABLE_RELON_EXCEPTION_PSERIES(0x500, 
hardware_interrupt_common, EXC_STD, SOFTEN_TEST_PR)
+   ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE)
+EXC_VIRT_END(hardware_interrupt, 0x4500, 0x4600)
+
+EXC_COMMON_ASYNC(hardware_interrupt_common, 0x500, do_IRQ)
+
+
 EXC_REAL(alignment, 0x600, 0x700)
 
 TRAMP_KVM(PACA_EXGEN, 0x600)
@@ -1124,7 +1137,6 @@ TRAMP_REAL_BEGIN(kvmppc_skip_Hinterrupt)
 
 /*** Common interrupt handlers ***/
 
-EXC_COMMON_ASYNC(hardware_interrupt_common, 0x500, do_IRQ)
 EXC_COMMON_ASYNC(decrementer_common, 0x900, timer_interrupt)
 EXC_COMMON(hdecrementer_common, 0x980, hdec_interrupt)
 
@@ -1169,16 +1181,6 @@ EXC_COMMON(altivec_assist_common, 0x1700, 
unknown_exception)
 * come here.
 */
 
-EXC_VIRT_BEGIN(hardware_interrupt, 0x4500, 0x4600)
-   .globl hardware_interrupt_relon_hv;
-hardware_interrupt_relon_hv:
-   BEGIN_FTR_SECTION
-   _MASKABLE_RELON_EXCEPTION_PSERIES(0x500, 
hardware_interrupt_common, EXC_HV, SOFTEN_TEST_HV)
-   FTR_SECTION_ELSE
-   _MASKABLE_RELON_EXCEPTION_PSERIES(0x500, 
hardware_interrupt_common, EXC_STD, SOFTEN_TEST_PR)
-   ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE)
-EXC_VIRT_END(hardware_interrupt, 0x4500, 0x4600)
-
 EXC_VIRT(alignment, 0x4600, 0x4700, 0x600)
 EXC_VIRT(program_check, 0x4700, 0x4800, 0x700)
 EXC_VIRT(fp_unavailable, 0x4800, 0x4900, 0x800)
-- 
2.7.4



[PATCH v3 10/42] powerpc/64s: Consolidate Instruction Segment 0x480 interrupt

2016-10-04 Thread Michael Ellerman
From: Nicholas Piggin 

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/exceptions-64s.S | 224 ++-
 1 file changed, 113 insertions(+), 111 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index 13eb8c7bc051..d084b0efd287 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -629,6 +629,119 @@ EXC_REAL_BEGIN(instruction_access_slb, 0x480, 0x500)
 #endif
 EXC_REAL_END(instruction_access_slb, 0x480, 0x500)
 
+EXC_VIRT_BEGIN(instruction_access_slb, 0x4480, 0x4500)
+   SET_SCRATCH0(r13)
+   EXCEPTION_PROLOG_0(PACA_EXSLB)
+   EXCEPTION_PROLOG_1(PACA_EXSLB, NOTEST, 0x480)
+   std r3,PACA_EXSLB+EX_R3(r13)
+   mfspr   r3,SPRN_SRR0/* SRR0 is faulting address */
+   mfspr   r12,SPRN_SRR1
+   crclr   4*cr6+eq
+#ifndef CONFIG_RELOCATABLE
+   b   slb_miss_realmode
+#else
+   mfctr   r11
+   LOAD_HANDLER(r10, slb_miss_realmode)
+   mtctr   r10
+   bctr
+#endif
+EXC_VIRT_END(instruction_access_slb, 0x4480, 0x4500)
+TRAMP_KVM(PACA_EXSLB, 0x480)
+
+
+/* This handler is used by both 0x380 and 0x480 slb miss interrupts */
+EXC_COMMON_BEGIN(slb_miss_realmode)
+   /*
+* r13 points to the PACA, r9 contains the saved CR,
+* r12 contain the saved SRR1, SRR0 is still ready for return
+* r3 has the faulting address
+* r9 - r13 are saved in paca->exslb.
+* r3 is saved in paca->slb_r3
+* cr6.eq is set for a D-SLB miss, clear for a I-SLB miss
+* We assume we aren't going to take any exceptions during this
+* procedure.
+*/
+   mflrr10
+#ifdef CONFIG_RELOCATABLE
+   mtctr   r11
+#endif
+
+   stw r9,PACA_EXSLB+EX_CCR(r13)   /* save CR in exc. frame */
+   std r10,PACA_EXSLB+EX_LR(r13)   /* save LR */
+   std r3,PACA_EXSLB+EX_DAR(r13)
+
+   crset   4*cr0+eq
+#ifdef CONFIG_PPC_STD_MMU_64
+BEGIN_MMU_FTR_SECTION
+   bl  slb_allocate_realmode
+END_MMU_FTR_SECTION_IFCLR(MMU_FTR_TYPE_RADIX)
+#endif
+
+   ld  r10,PACA_EXSLB+EX_LR(r13)
+   ld  r3,PACA_EXSLB+EX_R3(r13)
+   lwz r9,PACA_EXSLB+EX_CCR(r13)   /* get saved CR */
+   mtlrr10
+
+   beq 8f  /* if bad address, make full stack frame */
+
+   andi.   r10,r12,MSR_RI  /* check for unrecoverable exception */
+   beq-2f
+
+   /* All done -- return from exception. */
+
+.machine   push
+.machine   "power4"
+   mtcrf   0x80,r9
+   mtcrf   0x02,r9 /* I/D indication is in cr6 */
+   mtcrf   0x01,r9 /* slb_allocate uses cr0 and cr7 */
+.machine   pop
+
+   RESTORE_PPR_PACA(PACA_EXSLB, r9)
+   ld  r9,PACA_EXSLB+EX_R9(r13)
+   ld  r10,PACA_EXSLB+EX_R10(r13)
+   ld  r11,PACA_EXSLB+EX_R11(r13)
+   ld  r12,PACA_EXSLB+EX_R12(r13)
+   ld  r13,PACA_EXSLB+EX_R13(r13)
+   rfid
+   b   .   /* prevent speculative execution */
+
+2: mfspr   r11,SPRN_SRR0
+   LOAD_HANDLER(r10,unrecov_slb)
+   mtspr   SPRN_SRR0,r10
+   ld  r10,PACAKMSR(r13)
+   mtspr   SPRN_SRR1,r10
+   rfid
+   b   .
+
+8: mfspr   r11,SPRN_SRR0
+   LOAD_HANDLER(r10,bad_addr_slb)
+   mtspr   SPRN_SRR0,r10
+   ld  r10,PACAKMSR(r13)
+   mtspr   SPRN_SRR1,r10
+   rfid
+   b   .
+
+EXC_COMMON_BEGIN(unrecov_slb)
+   EXCEPTION_PROLOG_COMMON(0x4100, PACA_EXSLB)
+   RECONCILE_IRQ_STATE(r10, r11)
+   bl  save_nvgprs
+1: addir3,r1,STACK_FRAME_OVERHEAD
+   bl  unrecoverable_exception
+   b   1b
+
+EXC_COMMON_BEGIN(bad_addr_slb)
+   EXCEPTION_PROLOG_COMMON(0x380, PACA_EXSLB)
+   RECONCILE_IRQ_STATE(r10, r11)
+   ld  r3, PACA_EXSLB+EX_DAR(r13)
+   std r3, _DAR(r1)
+   beq cr6, 2f
+   li  r10, 0x480  /* fix trap number for I-SLB miss */
+   std r10, _TRAP(r1)
+2: bl  save_nvgprs
+   addir3, r1, STACK_FRAME_OVERHEAD
+   bl  slb_miss_bad_addr
+   b   ret_from_except
+
 EXC_REAL_BEGIN(hardware_interrupt, 0x500, 0x600)
.globl hardware_interrupt_hv;
 hardware_interrupt_hv:
@@ -790,7 +903,6 @@ EXC_REAL_NONE(0x1800, 0x1900)
 /*** Out of line interrupts support ***/
 
/* moved from 0x200 */
-TRAMP_KVM(PACA_EXSLB, 0x480)
 TRAMP_KVM(PACA_EXGEN, 0x900)
 TRAMP_KVM_HV(PACA_EXGEN, 0x980)
 
@@ -1057,24 +1169,6 @@ EXC_COMMON(altivec_assist_common, 0x1700, 
unknown_exception)
 * come here.
 */
 
-EXC_VIRT_BEGIN(instruction_access_slb, 0x4480, 0x4500)
-   SET_SCRATCH0(r13)
-   EXCEPTION_PROLOG_0(PACA_EXSLB)
-   EXCEPTION_PROLOG_1(PACA_EXSLB, NOTEST, 0x480)
-   std r3,PACA_EXSLB+EX_R3(r13)
-   mfspr   r3,SPRN_SRR0/* SRR0 is 

[PATCH v3 09/42] powerpc/64s: Consolidate Instruction Storage 0x400 interrupt

2016-10-04 Thread Michael Ellerman
From: Nicholas Piggin 

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/exceptions-64s.S | 35 ++-
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index c3e1f610cf29..13eb8c7bc051 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -592,6 +592,24 @@ TRAMP_KVM_SKIP(PACA_EXSLB, 0x380)
 
 
 EXC_REAL(instruction_access, 0x400, 0x480)
+EXC_VIRT(instruction_access, 0x4400, 0x4480, 0x400)
+TRAMP_KVM(PACA_EXGEN, 0x400)
+
+EXC_COMMON_BEGIN(instruction_access_common)
+   EXCEPTION_PROLOG_COMMON(0x400, PACA_EXGEN)
+   RECONCILE_IRQ_STATE(r10, r11)
+   ld  r12,_MSR(r1)
+   ld  r3,_NIP(r1)
+   andis.  r4,r12,0x5820
+   li  r5,0x400
+   std r3,_DAR(r1)
+   std r4,_DSISR(r1)
+BEGIN_MMU_FTR_SECTION
+   b   do_hash_page/* Try to handle as hpte fault */
+MMU_FTR_SECTION_ELSE
+   b   handle_page_fault
+ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX)
+
 
 EXC_REAL_BEGIN(instruction_access_slb, 0x480, 0x500)
SET_SCRATCH0(r13)
@@ -772,7 +790,6 @@ EXC_REAL_NONE(0x1800, 0x1900)
 /*** Out of line interrupts support ***/
 
/* moved from 0x200 */
-TRAMP_KVM(PACA_EXGEN, 0x400)
 TRAMP_KVM(PACA_EXSLB, 0x480)
 TRAMP_KVM(PACA_EXGEN, 0x900)
 TRAMP_KVM_HV(PACA_EXGEN, 0x980)
@@ -1040,8 +1057,6 @@ EXC_COMMON(altivec_assist_common, 0x1700, 
unknown_exception)
 * come here.
 */
 
-EXC_VIRT(instruction_access, 0x4400, 0x4480, 0x400)
-
 EXC_VIRT_BEGIN(instruction_access_slb, 0x4480, 0x4500)
SET_SCRATCH0(r13)
EXCEPTION_PROLOG_0(PACA_EXSLB)
@@ -1152,20 +1167,6 @@ EXC_COMMON_BEGIN(h_data_storage_common)
bl  unknown_exception
b   ret_from_except
 
-EXC_COMMON_BEGIN(instruction_access_common)
-   EXCEPTION_PROLOG_COMMON(0x400, PACA_EXGEN)
-   RECONCILE_IRQ_STATE(r10, r11)
-   ld  r12,_MSR(r1)
-   ld  r3,_NIP(r1)
-   andis.  r4,r12,0x5820
-   li  r5,0x400
-   std r3,_DAR(r1)
-   std r4,_DSISR(r1)
-BEGIN_MMU_FTR_SECTION
-   b   do_hash_page/* Try to handle as hpte fault */
-MMU_FTR_SECTION_ELSE
-   b   handle_page_fault
-ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX)
 
 EXC_COMMON(h_instr_storage_common, 0xe20, unknown_exception)
 
-- 
2.7.4



[PATCH v3 08/42] powerpc/64s: Consolidate Data Segment 0x380 interrupt

2016-10-04 Thread Michael Ellerman
From: Nicholas Piggin 

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/exceptions-64s.S | 50 ++--
 1 file changed, 25 insertions(+), 25 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index edab8cc4fdc1..c3e1f610cf29 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -566,6 +566,31 @@ EXC_REAL_BEGIN(data_access_slb, 0x380, 0x400)
 #endif
 EXC_REAL_END(data_access_slb, 0x380, 0x400)
 
+EXC_VIRT_BEGIN(data_access_slb, 0x4380, 0x4400)
+   SET_SCRATCH0(r13)
+   EXCEPTION_PROLOG_0(PACA_EXSLB)
+   EXCEPTION_PROLOG_1(PACA_EXSLB, NOTEST, 0x380)
+   std r3,PACA_EXSLB+EX_R3(r13)
+   mfspr   r3,SPRN_DAR
+   mfspr   r12,SPRN_SRR1
+   crset   4*cr6+eq
+#ifndef CONFIG_RELOCATABLE
+   b   slb_miss_realmode
+#else
+   /*
+* We can't just use a direct branch to slb_miss_realmode
+* because the distance from here to there depends on where
+* the kernel ends up being put.
+*/
+   mfctr   r11
+   LOAD_HANDLER(r10, slb_miss_realmode)
+   mtctr   r10
+   bctr
+#endif
+EXC_VIRT_END(data_access_slb, 0x4380, 0x4400)
+TRAMP_KVM_SKIP(PACA_EXSLB, 0x380)
+
+
 EXC_REAL(instruction_access, 0x400, 0x480)
 
 EXC_REAL_BEGIN(instruction_access_slb, 0x480, 0x500)
@@ -747,7 +772,6 @@ EXC_REAL_NONE(0x1800, 0x1900)
 /*** Out of line interrupts support ***/
 
/* moved from 0x200 */
-TRAMP_KVM_SKIP(PACA_EXSLB, 0x380)
 TRAMP_KVM(PACA_EXGEN, 0x400)
 TRAMP_KVM(PACA_EXSLB, 0x480)
 TRAMP_KVM(PACA_EXGEN, 0x900)
@@ -1016,30 +1040,6 @@ EXC_COMMON(altivec_assist_common, 0x1700, 
unknown_exception)
 * come here.
 */
 
-
-EXC_VIRT_BEGIN(data_access_slb, 0x4380, 0x4400)
-   SET_SCRATCH0(r13)
-   EXCEPTION_PROLOG_0(PACA_EXSLB)
-   EXCEPTION_PROLOG_1(PACA_EXSLB, NOTEST, 0x380)
-   std r3,PACA_EXSLB+EX_R3(r13)
-   mfspr   r3,SPRN_DAR
-   mfspr   r12,SPRN_SRR1
-   crset   4*cr6+eq
-#ifndef CONFIG_RELOCATABLE
-   b   slb_miss_realmode
-#else
-   /*
-* We can't just use a direct branch to slb_miss_realmode
-* because the distance from here to there depends on where
-* the kernel ends up being put.
-*/
-   mfctr   r11
-   LOAD_HANDLER(r10, slb_miss_realmode)
-   mtctr   r10
-   bctr
-#endif
-EXC_VIRT_END(data_access_slb, 0x4380, 0x4400)
-
 EXC_VIRT(instruction_access, 0x4400, 0x4480, 0x400)
 
 EXC_VIRT_BEGIN(instruction_access_slb, 0x4480, 0x4500)
-- 
2.7.4



[PATCH v3 07/42] powerpc/64s: Consolidate Data Storage 0x300 interrupt

2016-10-04 Thread Michael Ellerman
From: Nicholas Piggin 

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/exceptions-64s.S | 53 ++--
 1 file changed, 27 insertions(+), 26 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index afdb2043b1f3..edab8cc4fdc1 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -515,6 +515,33 @@ EXC_COMMON_BEGIN(unrecover_mce)
 
 
 EXC_REAL(data_access, 0x300, 0x380)
+EXC_VIRT(data_access, 0x4300, 0x4380, 0x300)
+TRAMP_KVM_SKIP(PACA_EXGEN, 0x300)
+
+EXC_COMMON_BEGIN(data_access_common)
+   /*
+* Here r13 points to the paca, r9 contains the saved CR,
+* SRR0 and SRR1 are saved in r11 and r12,
+* r9 - r13 are saved in paca->exgen.
+*/
+   mfspr   r10,SPRN_DAR
+   std r10,PACA_EXGEN+EX_DAR(r13)
+   mfspr   r10,SPRN_DSISR
+   stw r10,PACA_EXGEN+EX_DSISR(r13)
+   EXCEPTION_PROLOG_COMMON(0x300, PACA_EXGEN)
+   RECONCILE_IRQ_STATE(r10, r11)
+   ld  r12,_MSR(r1)
+   ld  r3,PACA_EXGEN+EX_DAR(r13)
+   lwz r4,PACA_EXGEN+EX_DSISR(r13)
+   li  r5,0x300
+   std r3,_DAR(r1)
+   std r4,_DSISR(r1)
+BEGIN_MMU_FTR_SECTION
+   b   do_hash_page/* Try to handle as hpte fault */
+MMU_FTR_SECTION_ELSE
+   b   handle_page_fault
+ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX)
+
 
 EXC_REAL_BEGIN(data_access_slb, 0x380, 0x400)
SET_SCRATCH0(r13)
@@ -720,7 +747,6 @@ EXC_REAL_NONE(0x1800, 0x1900)
 /*** Out of line interrupts support ***/
 
/* moved from 0x200 */
-TRAMP_KVM_SKIP(PACA_EXGEN, 0x300)
 TRAMP_KVM_SKIP(PACA_EXSLB, 0x380)
 TRAMP_KVM(PACA_EXGEN, 0x400)
 TRAMP_KVM(PACA_EXSLB, 0x480)
@@ -990,7 +1016,6 @@ EXC_COMMON(altivec_assist_common, 0x1700, 
unknown_exception)
 * come here.
 */
 
-EXC_VIRT(data_access, 0x4300, 0x4380, 0x300)
 
 EXC_VIRT_BEGIN(data_access_slb, 0x4380, 0x4400)
SET_SCRATCH0(r13)
@@ -1115,30 +1140,6 @@ EXC_VIRT_NONE(0x5800, 0x5900)
 EXC_COMMON_BEGIN(ppc64_runlatch_on_trampoline)
b   __ppc64_runlatch_on
 
-/*
- * Here r13 points to the paca, r9 contains the saved CR,
- * SRR0 and SRR1 are saved in r11 and r12,
- * r9 - r13 are saved in paca->exgen.
- */
-EXC_COMMON_BEGIN(data_access_common)
-   mfspr   r10,SPRN_DAR
-   std r10,PACA_EXGEN+EX_DAR(r13)
-   mfspr   r10,SPRN_DSISR
-   stw r10,PACA_EXGEN+EX_DSISR(r13)
-   EXCEPTION_PROLOG_COMMON(0x300, PACA_EXGEN)
-   RECONCILE_IRQ_STATE(r10, r11)
-   ld  r12,_MSR(r1)
-   ld  r3,PACA_EXGEN+EX_DAR(r13)
-   lwz r4,PACA_EXGEN+EX_DSISR(r13)
-   li  r5,0x300
-   std r3,_DAR(r1)
-   std r4,_DSISR(r1)
-BEGIN_MMU_FTR_SECTION
-   b   do_hash_page/* Try to handle as hpte fault */
-MMU_FTR_SECTION_ELSE
-   b   handle_page_fault
-ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX)
-
 EXC_COMMON_BEGIN(h_data_storage_common)
mfspr   r10,SPRN_HDAR
std r10,PACA_EXGEN+EX_DAR(r13)
-- 
2.7.4



[PATCH v3 06/42] powerpc/64s: Consolidate Machine Check 0x200 interrupt

2016-10-04 Thread Michael Ellerman
From: Nicholas Piggin 

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/exceptions-64s.S | 659 +--
 1 file changed, 329 insertions(+), 330 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index b163e7a62289..afdb2043b1f3 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -218,6 +218,301 @@ FTR_SECTION_ELSE
b   machine_check_pSeries_0
 ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE)
 EXC_REAL_END(machine_check, 0x200, 0x300)
+EXC_VIRT_NONE(0x4200, 0x4300)
+TRAMP_REAL_BEGIN(machine_check_powernv_early)
+BEGIN_FTR_SECTION
+   EXCEPTION_PROLOG_1(PACA_EXMC, NOTEST, 0x200)
+   /*
+* Register contents:
+* R13  = PACA
+* R9   = CR
+* Original R9 to R13 is saved on PACA_EXMC
+*
+* Switch to mc_emergency stack and handle re-entrancy (we limit
+* the nested MCE upto level 4 to avoid stack overflow).
+* Save MCE registers srr1, srr0, dar and dsisr and then set ME=1
+*
+* We use paca->in_mce to check whether this is the first entry or
+* nested machine check. We increment paca->in_mce to track nested
+* machine checks.
+*
+* If this is the first entry then set stack pointer to
+* paca->mc_emergency_sp, otherwise r1 is already pointing to
+* stack frame on mc_emergency stack.
+*
+* NOTE: We are here with MSR_ME=0 (off), which means we risk a
+* checkstop if we get another machine check exception before we do
+* rfid with MSR_ME=1.
+*/
+   mr  r11,r1  /* Save r1 */
+   lhz r10,PACA_IN_MCE(r13)
+   cmpwi   r10,0   /* Are we in nested machine check */
+   bne 0f  /* Yes, we are. */
+   /* First machine check entry */
+   ld  r1,PACAMCEMERGSP(r13)   /* Use MC emergency stack */
+0: subir1,r1,INT_FRAME_SIZE/* alloc stack frame */
+   addir10,r10,1   /* increment paca->in_mce */
+   sth r10,PACA_IN_MCE(r13)
+   /* Limit nested MCE to level 4 to avoid stack overflow */
+   cmpwi   r10,4
+   bgt 2f  /* Check if we hit limit of 4 */
+   std r11,GPR1(r1)/* Save r1 on the stack. */
+   std r11,0(r1)   /* make stack chain pointer */
+   mfspr   r11,SPRN_SRR0   /* Save SRR0 */
+   std r11,_NIP(r1)
+   mfspr   r11,SPRN_SRR1   /* Save SRR1 */
+   std r11,_MSR(r1)
+   mfspr   r11,SPRN_DAR/* Save DAR */
+   std r11,_DAR(r1)
+   mfspr   r11,SPRN_DSISR  /* Save DSISR */
+   std r11,_DSISR(r1)
+   std r9,_CCR(r1) /* Save CR in stackframe */
+   /* Save r9 through r13 from EXMC save area to stack frame. */
+   EXCEPTION_PROLOG_COMMON_2(PACA_EXMC)
+   mfmsr   r11 /* get MSR value */
+   ori r11,r11,MSR_ME  /* turn on ME bit */
+   ori r11,r11,MSR_RI  /* turn on RI bit */
+   LOAD_HANDLER(r12, machine_check_handle_early)
+1: mtspr   SPRN_SRR0,r12
+   mtspr   SPRN_SRR1,r11
+   rfid
+   b   .   /* prevent speculative execution */
+2:
+   /* Stack overflow. Stay on emergency stack and panic.
+* Keep the ME bit off while panic-ing, so that if we hit
+* another machine check we checkstop.
+*/
+   addir1,r1,INT_FRAME_SIZE/* go back to previous stack frame */
+   ld  r11,PACAKMSR(r13)
+   LOAD_HANDLER(r12, unrecover_mce)
+   li  r10,MSR_ME
+   andcr11,r11,r10 /* Turn off MSR_ME */
+   b   1b
+   b   .   /* prevent speculative execution */
+END_FTR_SECTION_IFSET(CPU_FTR_HVMODE)
+
+TRAMP_REAL_BEGIN(machine_check_pSeries)
+   .globl machine_check_fwnmi
+machine_check_fwnmi:
+   SET_SCRATCH0(r13)   /* save r13 */
+   EXCEPTION_PROLOG_0(PACA_EXMC)
+machine_check_pSeries_0:
+   EXCEPTION_PROLOG_1(PACA_EXMC, KVMTEST_PR, 0x200)
+   /*
+* The following is essentially EXCEPTION_PROLOG_PSERIES_1 with the
+* difference that MSR_RI is not enabled, because PACA_EXMC is being
+* used, so nested machine check corrupts it. machine_check_common
+* enables MSR_RI.
+*/
+   ld  r10,PACAKMSR(r13)
+   xorir10,r10,MSR_RI
+   mfspr   r11,SPRN_SRR0
+   LOAD_HANDLER(r12, machine_check_common)
+   mtspr   SPRN_SRR0,r12
+   mfspr   r12,SPRN_SRR1
+   mtspr   SPRN_SRR1,r10
+   rfid
+   b   .   /* prevent speculative execution */
+
+TRAMP_KVM_SKIP(PACA_EXMC, 0x200)
+
+EXC_COMMON_BEGIN(machine_check_common)
+   /*
+* Machine check 

[PATCH v3 04/42] powerpc: Use gas sections for arranging exception vectors

2016-10-04 Thread Michael Ellerman
From: Nicholas Piggin 

Use assembler sections of fixed size and location to arrange the 64-bit
Book3S exception vector code (64-bit Book3E also uses it in head_64.S
for 0x0..0x100).

This allows better flexibility in arranging exception code and hiding
unimportant details behind macros.

Gas sections can be a bit painful to use this way, mainly because the
assembler does not know where they will be finally linked. Taking
absolute addresses requires a bit of trickery for example, but it can
be hidden behind macros for the most part.

Generated code is mostly the same except locations, offsets, alignments.

The "+ 0x2" is only required for the trap number / kvm exit number,
which gets loaded as a constant into a register.

Previously, code also used + 0x2 for label names, but we changed to
using "H" to distinguish HV case for that. Remove the last vestiges
of that.

__after_prom_start is taking absolute address of a label in another
fixed section. Newer toolchains seemed to compile this okay, but older
ones do not. FIXED_SYMBOL_ABS_ADDR is more foolproof, it just takes an
additional line to define.

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/include/asm/exception-64s.h |   2 +-
 arch/powerpc/include/asm/head-64.h   | 261 +--
 arch/powerpc/kernel/exceptions-64s.S | 111 +
 arch/powerpc/kernel/head_64.S|  44 --
 arch/powerpc/kernel/vmlinux.lds.S|  53 ++-
 5 files changed, 404 insertions(+), 67 deletions(-)

diff --git a/arch/powerpc/include/asm/exception-64s.h 
b/arch/powerpc/include/asm/exception-64s.h
index 72f2b1e3f343..2e4e7d878c8e 100644
--- a/arch/powerpc/include/asm/exception-64s.h
+++ b/arch/powerpc/include/asm/exception-64s.h
@@ -91,7 +91,7 @@
  */
 #define LOAD_HANDLER(reg, label)   \
ld  reg,PACAKBASE(r13); /* get high part of  */   \
-   ori reg,reg,((label)-_stext)@l; /* virt addr of handler ... */
+   ori reg,reg,(FIXED_SYMBOL_ABS_ADDR(label))@l;
 
 /* Exception register prefixes */
 #define EXC_HV H
diff --git a/arch/powerpc/include/asm/head-64.h 
b/arch/powerpc/include/asm/head-64.h
index 613f743e91aa..ab90c2fa1ea6 100644
--- a/arch/powerpc/include/asm/head-64.h
+++ b/arch/powerpc/include/asm/head-64.h
@@ -3,28 +3,218 @@
 
 #include 
 
+/*
+ * We can't do CPP stringification and concatination directly into the section
+ * name for some reason, so these macros can do it for us.
+ */
+.macro define_ftsec name
+   .section ".head.text.\name\()","ax",@progbits
+.endm
+.macro define_data_ftsec name
+   .section ".head.data.\name\()","a",@progbits
+.endm
+.macro use_ftsec name
+   .section ".head.text.\name\()"
+.endm
+
+/*
+ * Fixed (location) sections are used by opening fixed sections and emitting
+ * fixed section entries into them before closing them. Multiple fixed sections
+ * can be open at any time.
+ *
+ * Each fixed section created in a .S file must have corresponding linkage
+ * directives including location, added to  arch/powerpc/kernel/vmlinux.lds.S
+ *
+ * For each fixed section, code is generated into it in the order which it
+ * appears in the source.  Fixed section entries can be placed at a fixed
+ * location within the section using _LOCATION postifx variants. These must
+ * be ordered according to their relative placements within the section.
+ *
+ * OPEN_FIXED_SECTION(section_name, start_address, end_address)
+ * FIXED_SECTION_ENTRY_BEGIN(section_name, label1)
+ *
+ * USE_FIXED_SECTION(section_name)
+ * label3:
+ * li  r10,128
+ * mv  r11,r10
+
+ * FIXED_SECTION_ENTRY_BEGIN_LOCATION(section_name, label2, start_address)
+ * FIXED_SECTION_ENTRY_END_LOCATION(section_name, label2, end_address)
+ * CLOSE_FIXED_SECTION(section_name)
+ *
+ * ZERO_FIXED_SECTION can be used to emit zeroed data.
+ *
+ * Troubleshooting:
+ * - If the build dies with "Error: attempt to move .org backwards" at
+ *   CLOSE_FIXED_SECTION() or elsewhere, there may be something
+ *   unexpected being added there. Remove the '. = x_len' line, rebuild, and
+ *   check what is pushing the section down.
+ * - If the build dies in linking, check arch/powerpc/kernel/vmlinux.lds.S
+ *   for instructions.
+ * - If the kernel crashes or hangs in very early boot, it could be linker
+ *   stubs at the start of the main text.
+ */
+
+#define OPEN_FIXED_SECTION(sname, start, end)  \
+   sname##_start = (start);\
+   sname##_end = (end);\
+   sname##_len = (end) - (start);  \
+   define_ftsec sname; \
+   . = 0x0;\
+start_##sname:
+
+#define OPEN_TEXT_SECTION(start)   \
+   text_start = (start); 

[PATCH v3 05/42] powerpc/64s: Consolidate System Reset 0x100 interrupt

2016-10-04 Thread Michael Ellerman
From: Nicholas Piggin 

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/exceptions-64s.S | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index 6ea330a3c51a..b163e7a62289 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -183,6 +183,19 @@ END_FTR_SECTION_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206)
EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, system_reset_common, EXC_STD,
 NOTEST, 0x100)
 EXC_REAL_END(system_reset, 0x100, 0x200)
+EXC_VIRT_NONE(0x4100, 0x4200)
+EXC_COMMON(system_reset_common, 0x100, system_reset_exception)
+
+#ifdef CONFIG_PPC_PSERIES
+/*
+ * Vectors for the FWNMI option.  Share common code.
+ */
+TRAMP_REAL_BEGIN(system_reset_fwnmi)
+   SET_SCRATCH0(r13)   /* save r13 */
+   EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, system_reset_common, EXC_STD,
+NOTEST, 0x100)
+#endif /* CONFIG_PPC_PSERIES */
+
 
 EXC_REAL_BEGIN(machine_check, 0x200, 0x300)
/* This is moved out of line as it can be patched by FW, but
@@ -699,17 +712,6 @@ FTR_SECTION_ELSE
 ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE)
blr
 
-#ifdef CONFIG_PPC_PSERIES
-/*
- * Vectors for the FWNMI option.  Share common code.
- */
-TRAMP_REAL_BEGIN(system_reset_fwnmi)
-   SET_SCRATCH0(r13)   /* save r13 */
-   EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, system_reset_common, EXC_STD,
-NOTEST, 0x100)
-
-#endif /* CONFIG_PPC_PSERIES */
-
 #ifdef CONFIG_KVM_BOOK3S_64_HANDLER
 TRAMP_REAL_BEGIN(kvmppc_skip_interrupt)
/*
@@ -745,7 +747,6 @@ TRAMP_REAL_BEGIN(kvmppc_skip_Hinterrupt)
 
 /*** Common interrupt handlers ***/
 
-EXC_COMMON(system_reset_common, 0x100, system_reset_exception)
 EXC_COMMON_ASYNC(hardware_interrupt_common, 0x500, do_IRQ)
 EXC_COMMON_ASYNC(decrementer_common, 0x900, timer_interrupt)
 EXC_COMMON(hdecrementer_common, 0x980, hdec_interrupt)
@@ -790,7 +791,6 @@ EXC_COMMON(altivec_assist_common, 0x1700, unknown_exception)
 * only has extra guff for STAB-based processors -- which never
 * come here.
 */
-EXC_VIRT_NONE(0x4100, 0x4200)
 EXC_VIRT_NONE(0x4200, 0x4300)
 
 EXC_VIRT(data_access, 0x4300, 0x4380, 0x300)
-- 
2.7.4



[PATCH v3 03/42] powerpc/64: Change the way relocation copy is calculated

2016-10-04 Thread Michael Ellerman
From: Nicholas Piggin 

With a subsequent patch to put text into different sections,
(_end - _stext) can no longer be computed at link time to determine
the end of the copy. Instead, calculate it at runtime with
(copy_to_here - _stext) + (_end - copy_to_here).

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/kernel/head_64.S | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
index f765b0434731..6e21812ee672 100644
--- a/arch/powerpc/kernel/head_64.S
+++ b/arch/powerpc/kernel/head_64.S
@@ -628,11 +628,16 @@ __after_prom_start:
bctr
 
 .balign 8
-p_end: .llong  _end - _stext
+p_end: .llong _end - copy_to_here
 
-4: /* Now copy the rest of the kernel up to _end */
-   addis   r5,r26,(p_end - _stext)@ha
-   ld  r5,(p_end - _stext)@l(r5)   /* get _end */
+4:
+   /*
+* Now copy the rest of the kernel up to _end, add
+* _end - copy_to_here to the copy limit and run again.
+*/
+   addis   r8,r26,(p_end - _stext)@ha
+   ld  r8,(p_end - _stext)@l(r8)
+   add r5,r5,r8
 5: bl  copy_and_flush  /* copy the rest */
 
 9: b   start_here_multiplatform
-- 
2.7.4



[PATCH v3 02/42] powerpc/64s: Consolidate exception handler alignment

2016-10-04 Thread Michael Ellerman
From: Nicholas Piggin 

Move exception handler alignment directives into the head-64.h macros,
beause they will no longer work in-place after the next patch. This
slightly changes functions that have alignments applied and therefore
code generation, which is why it was not done initially (see earlier
patch).

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/include/asm/head-64.h   |  1 +
 arch/powerpc/kernel/exceptions-64s.S | 36 
 2 files changed, 1 insertion(+), 36 deletions(-)

diff --git a/arch/powerpc/include/asm/head-64.h 
b/arch/powerpc/include/asm/head-64.h
index 358c25c80c62..613f743e91aa 100644
--- a/arch/powerpc/include/asm/head-64.h
+++ b/arch/powerpc/include/asm/head-64.h
@@ -18,6 +18,7 @@ exc_virt_##start##_##name:
 #define EXC_VIRT_END(name, start, end)
 
 #define EXC_COMMON_BEGIN(name) \
+   .align  7;  \
.global name;   \
 name:
 
diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index 52d22891f6a4..d398e8716ef8 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -366,7 +366,6 @@ EXC_REAL_NONE(0x1800, 0x1900)
 /*** Out of line interrupts support ***/
 
/* moved from 0x200 */
-   .align 7;
 TRAMP_REAL_BEGIN(machine_check_powernv_early)
 BEGIN_FTR_SECTION
EXCEPTION_PROLOG_1(PACA_EXMC, NOTEST, 0x200)
@@ -535,7 +534,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_CFAR)
b   .
 #endif
 
-   .align  7
/* moved from 0xe00 */
 __TRAMP_REAL_REAL_OOL_HV(h_data_storage, 0xe00)
 TRAMP_KVM_HV_SKIP(PACA_EXGEN, 0xe00)
@@ -652,7 +650,6 @@ ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE)
 /*
  * Vectors for the FWNMI option.  Share common code.
  */
-  .align 7
 TRAMP_REAL_BEGIN(system_reset_fwnmi)
SET_SCRATCH0(r13)   /* save r13 */
EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, system_reset_common, EXC_STD,
@@ -695,46 +692,30 @@ TRAMP_REAL_BEGIN(kvmppc_skip_Hinterrupt)
 
 /*** Common interrupt handlers ***/
 
-   .align 7;
 EXC_COMMON(system_reset_common, 0x100, system_reset_exception)
-   .align 7;
 EXC_COMMON_ASYNC(hardware_interrupt_common, 0x500, do_IRQ)
-   .align 7;
 EXC_COMMON_ASYNC(decrementer_common, 0x900, timer_interrupt)
-   .align 7;
 EXC_COMMON(hdecrementer_common, 0x980, hdec_interrupt)
 
-   .align 7;
 #ifdef CONFIG_PPC_DOORBELL
 EXC_COMMON_ASYNC(doorbell_super_common, 0xa00, doorbell_exception)
 #else
 EXC_COMMON_ASYNC(doorbell_super_common, 0xa00, unknown_exception)
 #endif
-   .align 7;
 EXC_COMMON(trap_0b_common, 0xb00, unknown_exception)
-   .align 7;
 EXC_COMMON(single_step_common, 0xd00, single_step_exception)
-   .align 7;
 EXC_COMMON(trap_0e_common, 0xe00, unknown_exception)
-   .align 7;
 EXC_COMMON(emulation_assist_common, 0xe40, emulation_assist_interrupt)
-   .align 7;
 EXC_COMMON_ASYNC(hmi_exception_common, 0xe60, handle_hmi_exception)
-   .align 7;
 #ifdef CONFIG_PPC_DOORBELL
 EXC_COMMON_ASYNC(h_doorbell_common, 0xe80, doorbell_exception)
 #else
 EXC_COMMON_ASYNC(h_doorbell_common, 0xe80, unknown_exception)
 #endif
-   .align 7;
 EXC_COMMON_ASYNC(h_virt_irq_common, 0xea0, do_IRQ)
-   .align 7;
 EXC_COMMON_ASYNC(performance_monitor_common, 0xf00, 
performance_monitor_exception)
-   .align 7;
 EXC_COMMON(instruction_breakpoint_common, 0x1300, 
instruction_breakpoint_exception)
-   .align 7;
 EXC_COMMON_HV(denorm_common, 0x1500, unknown_exception)
-   .align 7;
 #ifdef CONFIG_ALTIVEC
 EXC_COMMON(altivec_assist_common, 0x1700, altivec_assist_exception)
 #else
@@ -889,7 +870,6 @@ TRAMP_REAL_BEGIN(ppc64_runlatch_on_trampoline)
  * SRR0 and SRR1 are saved in r11 and r12,
  * r9 - r13 are saved in paca->exgen.
  */
-   .align  7
 EXC_COMMON_BEGIN(data_access_common)
mfspr   r10,SPRN_DAR
std r10,PACA_EXGEN+EX_DAR(r13)
@@ -909,7 +889,6 @@ MMU_FTR_SECTION_ELSE
b   handle_page_fault
 ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX)
 
-   .align  7
 EXC_COMMON_BEGIN(h_data_storage_common)
mfspr   r10,SPRN_HDAR
std r10,PACA_EXGEN+EX_DAR(r13)
@@ -922,7 +901,6 @@ EXC_COMMON_BEGIN(h_data_storage_common)
bl  unknown_exception
b   ret_from_except
 
-   .align  7
 EXC_COMMON_BEGIN(instruction_access_common)
EXCEPTION_PROLOG_COMMON(0x400, PACA_EXGEN)
RECONCILE_IRQ_STATE(r10, r11)
@@ -938,14 +916,12 @@ MMU_FTR_SECTION_ELSE
b   handle_page_fault
 ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX)
 
-   .align 7
 EXC_COMMON(h_instr_storage_common, 0xe20, unknown_exception)
 
/*
 * Machine check is different because we use a different
 * save area: PACA_EXMC instead of PACA_EXGEN.
 */
-   

[PATCH v3 01/42] powerpc/64s: Add new exception vector macros

2016-10-04 Thread Michael Ellerman
Create arch/powerpc/include/asm/head-64.h with macros that specify
an exception vector (name, type, location), which will be used to
label and lay out exceptions into the object file.

Naming is moved out of exception-64s.h, which is used to specify the
implementation of exception handlers.

objdump of generated code in exception vectors is unchanged except for
names. Alignment directives scattered around are annoying, but done
this way so that disassembly can verify identical instruction
generation before and after patch. These get cleaned up in future
patch.

We change the way KVMTEST works, explicitly passing EXC_HV or EXC_STD
rather than overloading the trap number. This removes the need to have
SOFTEN values for the overloaded trap numbers, eg. 0x502.

Signed-off-by: Nicholas Piggin 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/include/asm/exception-64s.h | 135 +++
 arch/powerpc/include/asm/head-64.h   | 163 +
 arch/powerpc/kernel/exceptions-64s.S | 597 +++
 3 files changed, 504 insertions(+), 391 deletions(-)
 create mode 100644 arch/powerpc/include/asm/head-64.h

diff --git a/arch/powerpc/include/asm/exception-64s.h 
b/arch/powerpc/include/asm/exception-64s.h
index 5032a80e8f6a..72f2b1e3f343 100644
--- a/arch/powerpc/include/asm/exception-64s.h
+++ b/arch/powerpc/include/asm/exception-64s.h
@@ -34,6 +34,7 @@
  * exception handlers (including pSeries LPAR) and iSeries LPAR
  * implementations as possible.
  */
+#include 
 
 #define EX_R9  0
 #define EX_R10 8
@@ -191,10 +192,10 @@ END_FTR_SECTION_NESTED(ftr,ftr,943)
EXCEPTION_PROLOG_1(area, extra, vec);   \
EXCEPTION_PROLOG_PSERIES_1(label, h);
 
-#define __KVMTEST(n)   \
-   lbz r10,HSTATE_IN_GUEST(r13);   \
+#define __KVMTEST(h, n)
\
+   lbz r10,HSTATE_IN_GUEST(r13);   \
cmpwi   r10,0;  \
-   bne do_kvm_##n
+   bne do_kvm_##h##n
 
 #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
 /*
@@ -207,8 +208,7 @@ END_FTR_SECTION_NESTED(ftr,ftr,943)
 #define kvmppc_interrupt kvmppc_interrupt_pr
 #endif
 
-#define __KVM_HANDLER(area, h, n)  \
-do_kvm_##n:\
+#define __KVM_HANDLER_PROLOG(area, n)  \
BEGIN_FTR_SECTION_NESTED(947)   \
ld  r10,area+EX_CFAR(r13);  \
std r10,HSTATE_CFAR(r13);   \
@@ -221,21 +221,23 @@ do_kvm_##n:   
\
stw r9,HSTATE_SCRATCH1(r13);\
ld  r9,area+EX_R9(r13); \
std r12,HSTATE_SCRATCH0(r13);   \
+
+#define __KVM_HANDLER(area, h, n)  \
+   __KVM_HANDLER_PROLOG(area, n)   \
li  r12,n;  \
b   kvmppc_interrupt
 
 #define __KVM_HANDLER_SKIP(area, h, n) \
-do_kvm_##n:\
cmpwi   r10,KVM_GUEST_MODE_SKIP;\
ld  r10,area+EX_R10(r13);   \
beq 89f;\
-   stw r9,HSTATE_SCRATCH1(r13);\
+   stw r9,HSTATE_SCRATCH1(r13);\
BEGIN_FTR_SECTION_NESTED(948)   \
ld  r9,area+EX_PPR(r13);\
std r9,HSTATE_PPR(r13); \
END_FTR_SECTION_NESTED(CPU_FTR_HAS_PPR,CPU_FTR_HAS_PPR,948);\
ld  r9,area+EX_R9(r13); \
-   std r12,HSTATE_SCRATCH0(r13);   \
+   std r12,HSTATE_SCRATCH0(r13);   \
li  r12,n;  \
b   kvmppc_interrupt;   \
 89:mtocrf  0x80,r9;\
@@ -243,12 +245,12 @@ do_kvm_##n:   
\
b   kvmppc_skip_##h##interrupt
 
 #ifdef CONFIG_KVM_BOOK3S_64_HANDLER
-#define KVMTEST(n) __KVMTEST(n)
+#define KVMTEST(h, n)  __KVMTEST(h, n)
 #define KVM_HANDLER(area, h, n)__KVM_HANDLER(area, h, n)
 

[PATCH v3 00/42] powerpc/64: use asm sections for head/exception layout

2016-10-04 Thread Michael Ellerman
This is v3 of Nick's series to change the way we construct the 64-bit Book3S
exception vectors, as applied to the tree by me.

Changes since his v2 are:
 - macro names have been shortened to EXC_REAL() etc.
 - the end macros which were empty have been dropped (until/if we need them)
 - some minor fixes for older toolchains.

Any bugs introduced since v2 are mine :)

cheers

Nicholas Piggin (42):
  powerpc/64s: Add new exception vector macros
  powerpc/64s: Consolidate exception handler alignment
  powerpc/64: Change the way relocation copy is calculated
  powerpc: Use gas sections for arranging exception vectors
  powerpc/64s: Consolidate System Reset 0x100 interrupt
  powerpc/64s: Consolidate Machine Check 0x200 interrupt
  powerpc/64s: Consolidate Data Storage 0x300 interrupt
  powerpc/64s: Consolidate Data Segment 0x380 interrupt
  powerpc/64s: Consolidate Instruction Storage 0x400 interrupt
  powerpc/64s: Consolidate Instruction Segment 0x480 interrupt
  powerpc/64s: Consolidate External 0x500 interrupt
  powerpc/64s: Consolidate Alignment 0x600 interrupt
  powerpc/64s: Consolidate Program 0x700 interrupt
  powerpc/64s: Consolidate FP Unavailable 0x800 interrupt
  powerpc/64s: Consolidate Decrementer 0x900 interrupt
  powerpc/64s: Consolidate Hypervisor Decrementer 0x980 interrupt
  powerpc/64s: Consolidate Directed Privileged Doorbell 0xa00 interrupt
  powerpc/64s: Consolidate Reserved 0xb00 interrupt
  powerpc/64s: Consolidate System Call 0xc00 interrupt
  powerpc/64s: Consolidate Trace 0xd00 interrupt
  powerpc/64s: Consolidate Hypervisor Data Storage 0xe00 interrupt
  powerpc/64s: Consolidate Hypervisor Instruction Storage 0xe20 interrupt
  powerpc/64s: Consolidate Hypervisor Emulation Assistance 0xe40 interrupt
  powerpc/64s: Consolidate Hypervisor Maintenance 0xe60 interrupt
  powerpc/64s: Consolidate Directed Hypervisor Doorbell 0xe80 interrupt
  powerpc/64s: Consolidate Hypervisor Virtualization 0xea0 interrupt
  powerpc/64s: Consolidate Reserved 0xec0, 0xee0 interrupts
  powerpc/64s: Consolidate Performance Monitor 0xf00 interrupt
  powerpc/64s: Consolidate Vector Unavailable 0xf20 interrupt
  powerpc/64s: Consolidate VSX Unavailable 0xf40 interrupt
  powerpc/64s: Consolidate Facility Unavailable 0xf60 interrupt
  powerpc/64s: Consolidate Hypervisor Facility Unavailable 0xf80 interrupt
  powerpc/64s: Consolidate Reserved 0xfa0-0x1200 interrupts
  powerpc/64s: Consolidate CBE System Error 0x1200 interrupt
  powerpc/64s: Consolidate Instruction Breakpoint 0x1300 interrupt
  powerpc/64s: Consolidate Softpatch 0x1500 interrupt
  powerpc/64s: Consolidate Debug 0x1600 interrupt
  powerpc/64s: Consolidate Altivec 0x1700 interrupt
  powerpc/64s: Consolidate CBE Thermal 0x1800 interrupt
  powerpc/64s: Move __replay_interrupt function below handlers
  powerpc/64s: Use a single macro for both parts of OOL exception
  powerpc/64s: Remove unused exception code, small cleanups

 arch/powerpc/include/asm/exception-64s.h |  137 +-
 arch/powerpc/include/asm/head-64.h   |  393 ++
 arch/powerpc/kernel/exceptions-64s.S | 2069 +++---
 arch/powerpc/kernel/head_64.S|   53 +-
 arch/powerpc/kernel/vmlinux.lds.S|   53 +-
 5 files changed, 1538 insertions(+), 1167 deletions(-)
 create mode 100644 arch/powerpc/include/asm/head-64.h

-- 
2.7.4



Re: [RFC] fs: add userspace critical mounts event support

2016-10-04 Thread Linus Torvalds
On Tue, Oct 4, 2016 at 5:00 PM, Luis R. Rodriguez  wrote:
>
> I am not sure how/why a firmware loading daemon would be a better
> idea now. What Marc describes that Josh proposed with signals for
> userspcae seems more aligned with what we likely need

Quite frankly, I doubt you want a signal.

You will want to have some way to specify where the firmware files
are. Right now we have "fw_path[]" which is hardcoded except for the
first entry that can be set as a module parameter. But you'd probably
want to expand on that, which implies some /sys or /proc interface.

And once you do that, wouldn't it make more sense to just make the
"update the firmware path /proc/sys/kernel/fw_path file" make things
re-search for firmware?

In other words, the interface has to be something *sensible*. Not some
idiotic ad-hoc "send a signal" (of which that stupid original patch
was just a very odd example).

  Linus


Re: [RFC] fs: add userspace critical mounts event support

2016-10-04 Thread Luis R. Rodriguez
On Sat, Sep 24, 2016 at 10:41:46AM -0700, Dmitry Torokhov wrote:
> On Fri, Sep 23, 2016 at 6:37 PM, Herbert, Marc  wrote:
> > On 03/09/2016 11:10, Dmitry Torokhov wrote:
> >> I was thinking if we kernel could post
> >> "conditions" (maybe simple stings) that it waits for, and userspace
> >> could unlock these "conditions". One of them might be "firmware
> >> available".
> >
> > On idea offered by Josh Triplett that seems to overlap with this one
> > is to have something similar to the (deprecated) userhelper with
> > *per-blob* requests and notifications except for one major difference:
> > userspace would not anymore be in charge of *providing* the blob but
> > would instead only *signal* when a given blob becomes available and is
> > either found or found missing. Then the kernel loads the blob _by
> > itself_; unlike the userhelper. No new “critical filesystem” concept
> > and a *per-blob basis*, allowing any variation of blob locations
> > across any number of initramfs and filesystems.
> >
> 
> Really, I do not quite understand why people have issues with usermode
> helper/uevents.

One reason is you'd have to implement your own cache for suspend/resume.

> It used to work reasonably well (if you were using
> request_firmware_nowait()), as the kernel would post the request and
> then, when userspace was ready[^Hier], uevents would be processed and
> firmware would be loaded. We had a timeout of 60(?) seconds by
> default, but that would be adjusted as systems needed.

The issue with the timeout was kernel developers *assumed* module init
and probe were detached, and saying 'thou shall not load firmware on
probe' seems actually like a more radical change than just saying
'thou shall load firmware on init'. I'll note that as it stands
its the right thing to complain about these users only because we
lack the semantics to ensure correctness if used on init or probe.
The timeout incurred huge latencies for optional firmwares, and
while we had a new API added to avoid the wait on optional firmware,
that obviously still leaved the races as possible. We now have async
probe which *does* enable some original misconceptions by kernel
developers, but by now other issues have also been found on the
usermode helper, the cache was one, another one was a recent discusion
over the user of the UMH lock with the assumption this was providing
a sort of safeguard on early boot use -- it does not, for the same
exact reasons why a UMH lock does not suffice to avoid all possible
rootfs races. For this later issue refer to a recent discussion in
review with Daniel Wagner's patches.

> Unfortunately it all broke when udev started insisting [1] on
> servicing some uevents in strict sequence, which resulted in boot
> stalls.

That was not the only issue... another implicit issue was that
you are reducing the number of possible supported number of
devices Linux supports per module by the timeout, it would
depend on the combine time it takes to both init and probe.
Some drivers are super complex and even if you *don't* have
firmware requirements and say burn the firmware onto a device
we found that *probe* alone was taking a long long time on some
device drivers -- check out cxgb4 driver, where one device actually
ends up loading about 4 subdevices underneath it. Yes that's a mess
and the driver needs a major rewrite to address this in a clean way
but that takes time. Its no trivial pursuit. The umh timeout then
would not be implicated anymore *but* since systemd implemented the
timeout in general for kmod loading it did mean system was limiting
them Linux drivers and how much devices a driver can support
depending on this timeout value. At SUSE we solved this by lifting
this timeout for kmod workers for now. A long term goal here, which
could help, is also to just detach init and probes, so we give to
system what it originally thought. Summary of this all is here:

http://www.do-not-panic.com/2015/12/linux-asynchronous-probe.html

I have some code that starts to enable some of this on systemd/kmod
but it still needs some more testing before I post.

> Maybe the ultimate answer is to write a firmware loading
> daemon that would also listen to netlink events and do properly what
> udev refused to be doing?

Meh, in the wireless subsystem we devised our own file loader,
check CRDA. That worked for us since we needed to optionally
enable digital RSA signed file checking, but long term our
experience is that this is pointless. So we're going to phase
that out in favor of using the firmware API for the file loading
of this file, and support then digital signatures on the firmware.

I am not sure how/why a firmware loading daemon would be a better
idea now. What Marc describes that Josh proposed with signals for
userspcae seems more aligned with what we likely need -- but note
that since we now use a shared common API for kernel reads from a
path via kernel_read_file_from_path() we'd probably want something

Re: [PATCH v3 4/5] powerpc/mm: restore top-down allocation when using movable_node

2016-10-04 Thread Reza Arbab

On Tue, Oct 04, 2016 at 11:48:30AM +1100, Balbir Singh wrote:

On 27/09/16 10:14, Reza Arbab wrote:
Right. To be clear, the background info I put in the commit log 
refers to x86, where the SRAT can describe movable nodes which exist 
at boot.  They're trying to avoid allocations from those nodes before 
they've been identified.


On power, movable nodes can only exist via hotplug, so that scenario 
can't happen. We can immediately go back to top-down allocation. That 
is the missing call being added in the patch.


Can we fix cmdline_parse_movable_node() to do the right thing? I 
suspect that code is heavily x86 only in the sense that no other arch 
needs it.


Good idea. We could change it so things only go bottom-up on x86 in the 
first place.


A nice consequence is that CONFIG_MOVABLE_NODE would then basically be 
usable on any platform with memory hotplug, not just PPC64 and X86_64.


I'll see if I can move the relevant code into an arch_*() call or 
otherwise factor it out.


--
Reza Arbab



Re: [PATCH v6] powerpc: Do not make the entire heap executable

2016-10-04 Thread Kees Cook
On Mon, Oct 3, 2016 at 5:18 PM, Michael Ellerman  wrote:
> Kees Cook  writes:
>
>> On Mon, Oct 3, 2016 at 9:13 AM, Denys Vlasenko  wrote:
>>> On 32-bit powerpc the ELF PLT sections of binaries (built with --bss-plt,
>>> or with a toolchain which defaults to it) look like this:
> ...
>>>
>>> Signed-off-by: Jason Gunthorpe 
>>> Signed-off-by: Denys Vlasenko 
>>> Acked-by: Kees Cook 
>>> Acked-by: Michael Ellerman 
>>> CC: Benjamin Herrenschmidt 
>>> CC: Paul Mackerras 
>>> CC: "Aneesh Kumar K.V" 
>>> CC: Kees Cook 
>>> CC: Oleg Nesterov 
>>> CC: Michael Ellerman 
>>> CC: Florian Weimer 
>>> CC: linux...@kvack.org
>>> CC: linuxppc-dev@lists.ozlabs.org
>>> CC: linux-ker...@vger.kernel.org
>>> ---
>>> Changes since v5:
>>> * made do_brk_flags() error out if any bits other than VM_EXEC are set.
>>>   (Kees Cook: "With this, I'd be happy to Ack.")
>>>   See https://patchwork.ozlabs.org/patch/661595/
>>
>> Excellent, thanks for the v6! Should this go via the ppc tree or the -mm 
>> tree?
>
> -mm would be best, given the diffstat I think it's less likely to
>  conflict if it goes via -mm.

Okay, excellent. Andrew, do you have this already in email? I think
you weren't on the explicit CC from the v6...

-Kees

-- 
Kees Cook
Nexus Security


RE: [net-next 08/13] fsl/fman: check pcsphy pointer before use

2016-10-04 Thread David Laight
From: Madalin Bucur
> Sent: 04 October 2016 08:33
> Subject: [net-next 08/13] fsl/fman: check pcsphy pointer before use
..
> --- a/drivers/net/ethernet/freescale/fman/fman_memac.c
> +++ b/drivers/net/ethernet/freescale/fman/fman_memac.c
> @@ -507,6 +507,9 @@ static void setup_sgmii_internal_phy(struct fman_mac 
> *memac,
>  {
>   u16 tmp_reg16;
> 
> + if (WARN_ON(!memac->pcsphy))
> + return;
> +

Why?

Either it can validly be NULL in which case you don't want the message.
Or it shouldn't be NULL in which case you need to find and fix the bug.
The later kernel OOPS will make the bug much easier to find.

David



Re: [PATCH] crypto: sha1-powerpc: little-endian support

2016-10-04 Thread Marcelo Cerri
Hi Michael,

On Ubuntu, CRYPTO_MANAGER_DISABLE_TESTS is set by default. So I had to
disable this config in order to make sha1-powerpc fail in the crypto API
tests. However, even with tests disabled, any usage of sha1-powerpc
should result in incorrect results.

-- 
Regards,
Marcelo

On Tue, Oct 04, 2016 at 05:23:16PM +1100, Michael Ellerman wrote:
> Marcelo Cerri  writes:
> 
> > [ Unknown signature status ]
> > On Wed, Sep 28, 2016 at 09:20:15PM +0800, Herbert Xu wrote:
> >> On Wed, Sep 28, 2016 at 10:15:51AM -0300, Marcelo Cerri wrote:
> >> > Hi Herbert,
> >> > 
> >> > Any thoughts on this one?
> >> 
> >> Can this patch wait until the next merge window? On the broken
> >> platforms it should just fail the self-test, right?
> >
> > Yes. It fails on any LE platform (including Ubuntu and RHEL 7.1).
> 
> How are you testing this? I thought I was running the crypto tests but
> I've never seen this fail.
> 
> cheers


signature.asc
Description: PGP signature


Re: [PATCH 2/2] powernv: Pass PSSCR value and mask to power9_idle_stop

2016-10-04 Thread Balbir Singh


On 04/10/16 21:32, Michael Ellerman wrote:
> "Gautham R. Shenoy"  writes:
> 
>> From: "Gautham R. Shenoy" 
>>
>> The power9_idle_stop method currently takes only the requested stop
>> level as a parameter and picks up the rest of the PSSCR bits from a
>> hand-coded macro. This is not a very flexible design, especially when
>> the firmware has the capability to communicate the psscr value and the
>> mask associated with a particular stop state via device tree.
>>
>> This patch modifies the power9_idle_stop API to take as parameters the
>> PSSCR value and the PSSCR mask corresponding to the stop state that
>> needs to be set. These PSSCR value and mask are respectively obtained
>> by parsing the "ibm,cpu-idle-state-psscr" and
>> "ibm,cpu-idle-state-psscr-mask" fields from the device tree.
>>
>> In addition to this, the patch adds support for handling stop states
>> for which ESL and EC bits in the PSSCR are zero. As per the
>> architecture, a wakeup from these stop states resumes execution from
>> the subsequent instruction as opposed to waking up at the System
>> Vector.
> 
> That looks good.
> 
>> This patch depends on the following skiboot patch that exports the
>> PSSCR values and the mask for all the stop states:
>> https://lists.ozlabs.org/pipermail/skiboot/2016-September/004869.html
> 
> But we can't depend on a skiboot patch. The kernel has to cope with
> running on an old skiboot.

Hi, Michael

I think with an older skiboot the flags don't get exported and the
new cpuidle (stop state) does not get discovered. I don't think there
is any breakage. Gautham am I missing something?

Balbir Singh.


[PATCH] net: ps3_gelic: Add missing \n to end of deb_dbg message

2016-10-04 Thread Colin King
From: Colin Ian King 

Trival fix, dev_dbg message is missing a \n, so add it.

Signed-off-by: Colin Ian King 
---
 drivers/net/ethernet/toshiba/ps3_gelic_net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/toshiba/ps3_gelic_net.c 
b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
index bc258d7..272f2b1 100644
--- a/drivers/net/ethernet/toshiba/ps3_gelic_net.c
+++ b/drivers/net/ethernet/toshiba/ps3_gelic_net.c
@@ -1769,7 +1769,7 @@ static int ps3_gelic_driver_probe(struct 
ps3_system_bus_device *dev)
gelic_ether_setup_netdev_ops(netdev, >napi);
result = gelic_net_setup_netdev(netdev, card);
if (result) {
-   dev_dbg(>core, "%s: setup_netdev failed %d",
+   dev_dbg(>core, "%s: setup_netdev failed %d\n",
__func__, result);
goto fail_setup_netdev;
}
-- 
2.9.3



[PATCH v2] cxl: Flush PSL cache before resetting the adapter

2016-10-04 Thread Frederic Barrat
If the capi link is going down while the PSL owns a dirty cache line,
any access from the host for that data could lead to an Uncorrectable
Error.
So when resetting the capi adapter through sysfs, make sure the PSL
cache is flushed. It won't help if there are any active Process
Elements on the card, as the cache would likely get new dirty cache
lines immediately, but if resetting an idle adapter, it should avoid
any bad surprises from data left over from terminated Process Elements.

Signed-off-by: Frederic Barrat 
---
Changelog:
v2:
  - fix typo in commit message
  - use ETIMEDOUT instead of EBUSY when the psl doesn't ack the flush request
  
 drivers/misc/cxl/cxl.h|  6 +-
 drivers/misc/cxl/native.c | 31 +++
 drivers/misc/cxl/pci.c|  3 +++
 3 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h
index 344a0ff..01d372a 100644
--- a/drivers/misc/cxl/cxl.h
+++ b/drivers/misc/cxl/cxl.h
@@ -162,7 +162,10 @@ static const cxl_p2n_reg_t CXL_PSL_WED_An = {0x0A0};
 #define CXL_PSL_SPAP_V0x0001ULL
 
 /** CXL_PSL_Control /
-#define CXL_PSL_Control_tb 0x0001ULL
+#define CXL_PSL_Control_tb  (0x1ull << (63-63))
+#define CXL_PSL_Control_Fr  (0x1ull << (63-31))
+#define CXL_PSL_Control_Fs_MASK (0x3ull << (63-29))
+#define CXL_PSL_Control_Fs_Complete (0x3ull << (63-29))
 
 /** CXL_PSL_DLCNTL */
 #define CXL_PSL_DLCNTL_D (0x1ull << (63-28))
@@ -854,6 +857,7 @@ int cxl_register_one_irq(struct cxl *adapter, irq_handler_t 
handler,
 int cxl_check_error(struct cxl_afu *afu);
 int cxl_afu_slbia(struct cxl_afu *afu);
 int cxl_tlb_slb_invalidate(struct cxl *adapter);
+int cxl_data_cache_flush(struct cxl *adapter);
 int cxl_afu_disable(struct cxl_afu *afu);
 int cxl_psl_purge(struct cxl_afu *afu);
 
diff --git a/drivers/misc/cxl/native.c b/drivers/misc/cxl/native.c
index e606fdc..13b9d01 100644
--- a/drivers/misc/cxl/native.c
+++ b/drivers/misc/cxl/native.c
@@ -290,6 +290,37 @@ int cxl_tlb_slb_invalidate(struct cxl *adapter)
return 0;
 }
 
+int cxl_data_cache_flush(struct cxl *adapter)
+{
+   u64 reg;
+   unsigned long timeout = jiffies + (HZ * CXL_TIMEOUT);
+
+   pr_devel("Flushing data cache\n");
+
+   reg = cxl_p1_read(adapter, CXL_PSL_Control);
+   reg |= CXL_PSL_Control_Fr;
+   cxl_p1_write(adapter, CXL_PSL_Control, reg);
+
+   reg = cxl_p1_read(adapter, CXL_PSL_Control);
+   while ((reg & CXL_PSL_Control_Fs_MASK) != CXL_PSL_Control_Fs_Complete) {
+   if (time_after_eq(jiffies, timeout)) {
+   dev_warn(>dev, "WARNING: cache flush timed 
out!\n");
+   return -ETIMEDOUT;
+   }
+
+   if (!cxl_ops->link_ok(adapter, NULL)) {
+   dev_warn(>dev, "WARNING: link down when 
flushing cache\n");
+   return -EIO;
+   }
+   cpu_relax();
+   reg = cxl_p1_read(adapter, CXL_PSL_Control);
+   }
+
+   reg &= ~CXL_PSL_Control_Fr;
+   cxl_p1_write(adapter, CXL_PSL_Control, reg);
+   return 0;
+}
+
 static int cxl_write_sstp(struct cxl_afu *afu, u64 sstp0, u64 sstp1)
 {
int rc;
diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c
index 6f0c4ac..731e2e2 100644
--- a/drivers/misc/cxl/pci.c
+++ b/drivers/misc/cxl/pci.c
@@ -1239,6 +1239,9 @@ int cxl_pci_reset(struct cxl *adapter)
 
dev_info(>dev, "CXL reset\n");
 
+   /* the adapter is about to be reset, so ignore errors */
+   cxl_data_cache_flush(adapter);
+
/* pcie_warm_reset requests a fundamental pci reset which includes a
 * PERST assert/deassert.  PERST triggers a loading of the image
 * if "user" or "factory" is selected in sysfs */
-- 
2.7.4



Re: [PATCH 2/2] powernv: Pass PSSCR value and mask to power9_idle_stop

2016-10-04 Thread Michael Ellerman
"Gautham R. Shenoy"  writes:

> From: "Gautham R. Shenoy" 
>
> The power9_idle_stop method currently takes only the requested stop
> level as a parameter and picks up the rest of the PSSCR bits from a
> hand-coded macro. This is not a very flexible design, especially when
> the firmware has the capability to communicate the psscr value and the
> mask associated with a particular stop state via device tree.
>
> This patch modifies the power9_idle_stop API to take as parameters the
> PSSCR value and the PSSCR mask corresponding to the stop state that
> needs to be set. These PSSCR value and mask are respectively obtained
> by parsing the "ibm,cpu-idle-state-psscr" and
> "ibm,cpu-idle-state-psscr-mask" fields from the device tree.
>
> In addition to this, the patch adds support for handling stop states
> for which ESL and EC bits in the PSSCR are zero. As per the
> architecture, a wakeup from these stop states resumes execution from
> the subsequent instruction as opposed to waking up at the System
> Vector.

That looks good.

> This patch depends on the following skiboot patch that exports the
> PSSCR values and the mask for all the stop states:
> https://lists.ozlabs.org/pipermail/skiboot/2016-September/004869.html

But we can't depend on a skiboot patch. The kernel has to cope with
running on an old skiboot.

I realise this is for Power9, and we haven't shipped any of them yet.
But skiboot has had Power9 support since May, so I don't think we want
to declare that all of those skiboot versions are unsupported because of
this.

So is there any way we can make this work on skiboot versions that don't
have the patch above?

cheers


Re: [PATCH] cxl: Flush PSL cache before resetting the adapter

2016-10-04 Thread Frederic Barrat

Hi Vaibhav,


Le 04/10/2016 à 07:49, Vaibhav Jain a écrit :

Hi Fred,

Frederic Barrat  writes:



+   /* the adapter is about to be reset, so ignore errors */
+   cxl_data_cache_flush(adapter);
+

Will be a good idea if we return error and not let the reset to proceed,
if cxl_data_cache_flush returns EBUSY as continuing again may cause the
UE error.


I'm going to change cxl_data_cache_flush() to return ETIMEOUT instead of 
EBUSY, as it is misleading. With the current patch, EBUSY is not 
returned because there are active contexts running on the card. It is 
returned when the hardware/psl doesn't reply within 5 seconds to the 
flush request. It's not supposed to happen and would show an issue with 
the hardware/psl. In which case the adapter is close to useless, so we 
might as well try resetting it.


On a related note, we've talked with the folks from cxlflash, and we'll 
test a separate (complementary) patch to deny resetting the adapter if 
there are any active contexts, since, as you say, the likelihood of 
hitting a UE would be pretty high.


  Fred



Re: [PATCH v21 16/19] perf, tools: Make alias matching case-insensitive

2016-10-04 Thread Jiri Olsa
On Mon, Oct 03, 2016 at 09:54:48PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Mon, Oct 03, 2016 at 09:47:06PM -0300, Arnaldo Carvalho de Melo escreveu:
> > Em Thu, Sep 15, 2016 at 03:24:53PM -0700, Sukadev Bhattiprolu escreveu:
> > > From: Andi Kleen 
> > > 
> > > Make alias matching the events parser case-insensitive. This is useful
> > > with the JSON events. perf uses lower case events, but the CPU manuals
> > > generally use upper case event names. The JSON files use lower
> > > case by default too. But if we search case insensitively then
> > > users can cut-n-paste the upper case event names.
> > > 
> > > So the following works:
> > > 
> > > % perf stat -e BR_INST_EXEC.TAKEN_INDIRECT_NEAR_CALL true
> > > 
> > >  Performance counter stats for 'true':
> > > 
> > >305  BR_INST_EXEC.TAKEN_INDIRECT_NEAR_CALL
> > > 
> > >0.000492799 seconds time elapsed
> > 
> > So now trying to figure this out:
> 
> Ok, so this is just another case of bad patch ordering: this uses 'perf
> stat' as the example, but it doesn't work at this point, one needs to go
> to the last patch, apply it and then test it again, when it will work.
> So just moved the last patch to before this one, sigh.

ok, you found it.. sry ;-)

jirka


Re: [PATCH v21 16/19] perf, tools: Make alias matching case-insensitive

2016-10-04 Thread Jiri Olsa
On Mon, Oct 03, 2016 at 09:47:06PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Thu, Sep 15, 2016 at 03:24:53PM -0700, Sukadev Bhattiprolu escreveu:
> > From: Andi Kleen 
> > 
> > Make alias matching the events parser case-insensitive. This is useful
> > with the JSON events. perf uses lower case events, but the CPU manuals
> > generally use upper case event names. The JSON files use lower
> > case by default too. But if we search case insensitively then
> > users can cut-n-paste the upper case event names.
> > 
> > So the following works:
> > 
> > % perf stat -e BR_INST_EXEC.TAKEN_INDIRECT_NEAR_CALL true
> > 
> >  Performance counter stats for 'true':
> > 
> >305  BR_INST_EXEC.TAKEN_INDIRECT_NEAR_CALL
> > 
> >0.000492799 seconds time elapsed
> 
> So now trying to figure this out:
> 
> [acme@jouet linux]$ perf stat -e br_inst_exec.all_direct_near_call true
> event syntax error: 'br_inst_exec.all_direct_near_call'
>  \___ 'period' is not usable in 'perf stat'
> Run 'perf list' for a list of valid events

looks like you need also this one:
  155128eaa62f Allow period= in perf stat CPU event descriptions.

jirka


Re: [GIT PULL 00/22] perf/core improvements and fixes

2016-10-04 Thread Ingo Molnar

* Arnaldo Carvalho de Melo  wrote:

> Hi Ingo,
> 
>   Please consider pulling,
> 
> - Arnaldo
> 
> Build and test stats at the end of the message.
> 
> The following changes since commit 41aad2a6d4fcdda8d73c9739daf7a9f3f49499d6:
> 
>   Merge tag 'perf-core-for-mingo-20160929' of 
> git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core 
> (2016-09-29 19:09:58 +0200)
> 
> are available in the git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git 
> tags/perf-core-for-mingo-20161003
> 
> for you to fetch changes up to b42c7369e3f451e22c2b0be5d193955498d37546:
> 
>   perf pmu-events: Add Skylake frontend MSR support (2016-10-03 21:52:01 
> -0300)
> 
> 
> perf/core improvements and fixes:
> 
> - Allow vendors to provide JSON files describing PMU events, that then
>   get parsed to generate C tables that are linked against perf, allowing
>   the use of the names in their documentations, such as:
> 
>   # perf list l1d
> 
>   List of pre-defined events (to be used in -e):
> 
>   Cache:
> l1d.replacement
>  [L1D data line replacements]
> l1d_pend_miss.fb_full
>  [Cycles a demand request was blocked due to Fill Buffers 
> inavailability]
> l1d_pend_miss.pending
>  [L1D miss oustandings duration in cycles]
> l1d_pend_miss.pending_cycles
>  [Cycles with L1D load Misses outstanding]
> l1d_pend_miss.pending_cycles_any
>  [Cycles with L1D load Misses outstanding from any thread on physical 
> core]
> l2_trans.l1d_wb
>  [L1D writebacks that access L2 cache]
> 
>   Pipeline:
> cycle_activity.cycles_l1d_miss
>  [Cycles while L1 cache miss demand load is outstanding]
> cycle_activity.cycles_l1d_pending
>  [Cycles while L1 cache miss demand load is outstanding]
> cycle_activity.stalls_l1d_miss
>  [Execution stalls while L1 cache miss demand load is outstanding]
> cycle_activity.stalls_l1d_pending
>  [Execution stalls while L1 cache miss demand load is outstanding]
> 
>   The above example was done on a Broadwell based ThinkPad t450s after
>   downloading and installing such JSON files which will be added to the
>   tools/perf/pmu-events/ directory in a subsequent patchkit.
> 
>   Now one can use those names with -e/--event in all 'perf tools'.
>   (Andi Kleen, Sukadev Bhattiprolu)
> 
> - Add a missing pointer dereference in 'perf probe' (Colin Ian King)
> 
> - Add support for building host programs to be used in generating files
>   to be used in the build process, such as fixdep and jevents, fixing
>   the usage of these features in a cross compilation setup (Jiri Olsa)
> 
> Signed-off-by: Arnaldo Carvalho de Melo 
> 
> 
> Andi Kleen (12):
>   perf tools: Add jsmn `jasmine' JSON parser
>   perf jevents: Program to convert JSON file
>   perf tools: Support CPU id matching for x86 v2
>   perf jevents: Handle header line in mapfile
>   perf pmu: Support alias descriptions
>   perf tools: Query terminal width and use in perf list
>   perf list: Add a --no-desc flag
>   perf pmu: Add override support for event list CPUID
>   perf list jevents: Add support for event list topics
>   perf tools: Make alias matching case-insensitive
>   perf pmu-events: Fix fixed counters on Intel
>   perf pmu-events: Add Skylake frontend MSR support
> 
> Arnaldo Carvalho de Melo (1):
>   perf tools: Experiment with cppcheck
> 
> Colin Ian King (1):
>   perf probe: Check if *ptr2 is zero and not ptr2
> 
> Jiri Olsa (2):
>   tools build: Add support for host programs format
>   tools build: Make fixdep a hostprog
> 
> Sukadev Bhattiprolu (6):
>   perf pmu: Use pmu_events table to create aliases
>   perf powerpc: Support CPU ID matching for Powerpc
>   perf jevents: Add support for long descriptions
>   perf list: Support long jevents descriptions
>   perf tools: Add README for info on parsing JSON/map files
>   perf tools: Allow period= in perf stat CPU event descriptions.
> 
>  tools/build/Build  |   2 +
>  tools/build/Build.include  |   5 +
>  tools/build/Makefile   |   8 +-
>  tools/build/Makefile.build |  19 +-
>  tools/build/Makefile.include   |   4 -
>  tools/lib/subcmd/pager.c   |  16 +
>  tools/lib/subcmd/pager.h   |   1 +
>  tools/perf/Documentation/perf-list.txt |  12 +-
>  tools/perf/Makefile.perf   |  34 +-
>  tools/perf/arch/powerpc/util/header.c  |  11 +
>  tools/perf/arch/x86/util/header.c  |  24 +-
>  tools/perf/builtin-list.c  |  20 +-
>  tools/perf/pmu-events/Build|  13 +
>  tools/perf/pmu-events/README   | 147 ++
>  tools/perf/pmu-events/jevents.c| 812 
> 

[net-next 13/13] MAINTAINERS: net: add entry for Freescale QorIQ DPAA FMan driver

2016-10-04 Thread Madalin Bucur
Add record for Freescale QORIQ DPAA FMan driver adding myself as
maintainer.

Signed-off-by: Madalin Bucur 
---
 MAINTAINERS | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 669909e..3460152 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4980,6 +4980,13 @@ F:   drivers/net/ethernet/freescale/fec_ptp.c
 F: drivers/net/ethernet/freescale/fec.h
 F: Documentation/devicetree/bindings/net/fsl-fec.txt
 
+FREESCALE QORIQ DPAA FMAN DRIVER
+M: Madalin Bucur 
+L: net...@vger.kernel.org
+S: Maintained
+F: drivers/net/ethernet/freescale/fman
+F: Documentation/devicetree/bindings/powerpc/fsl/fman.txt
+
 FREESCALE QUICC ENGINE LIBRARY
 L: linuxppc-dev@lists.ozlabs.org
 S: Orphan
-- 
2.1.0



[net-next 11/13] fsl/fman: fix return value checking

2016-10-04 Thread Madalin Bucur
Signed-off-by: Madalin Bucur 
---
 drivers/net/ethernet/freescale/fman/fman.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fman/fman.c 
b/drivers/net/ethernet/freescale/fman/fman.c
index 1fc1049..dafd9e1 100644
--- a/drivers/net/ethernet/freescale/fman/fman.c
+++ b/drivers/net/ethernet/freescale/fman/fman.c
@@ -618,7 +618,7 @@ struct fman {
unsigned long cam_offset;
size_t cam_size;
/* Fifo in MURAM */
-   int fifo_offset;
+   unsigned long fifo_offset;
size_t fifo_size;
 
u32 liodn_base[64];
@@ -2036,7 +2036,7 @@ static int fman_init(struct fman *fman)
/* allocate MURAM for FIFO according to total size */
fman->fifo_offset = fman_muram_alloc(fman->muram,
 fman->state->total_fifo_size);
-   if (IS_ERR_VALUE(fman->cam_offset)) {
+   if (IS_ERR_VALUE(fman->fifo_offset)) {
free_init_resources(fman);
dev_err(fman->dev, "%s: MURAM alloc for BMI FIFO failed\n",
__func__);
-- 
2.1.0



[net-next 08/13] fsl/fman: check pcsphy pointer before use

2016-10-04 Thread Madalin Bucur
Signed-off-by: Madalin Bucur 
---
 drivers/net/ethernet/freescale/fman/fman_memac.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/freescale/fman/fman_memac.c 
b/drivers/net/ethernet/freescale/fman/fman_memac.c
index 96dfe7e..53ef51e 100644
--- a/drivers/net/ethernet/freescale/fman/fman_memac.c
+++ b/drivers/net/ethernet/freescale/fman/fman_memac.c
@@ -507,6 +507,9 @@ static void setup_sgmii_internal_phy(struct fman_mac *memac,
 {
u16 tmp_reg16;
 
+   if (WARN_ON(!memac->pcsphy))
+   return;
+
/* SGMII mode */
tmp_reg16 = IF_MODE_SGMII_EN;
if (!fixed_link)
-- 
2.1.0



[net-next 12/13] fsl/fman: remove leftover comment

2016-10-04 Thread Madalin Bucur
Signed-off-by: Madalin Bucur 
---
 drivers/net/ethernet/freescale/fman/fman_mac.h | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fman/fman_mac.h 
b/drivers/net/ethernet/freescale/fman/fman_mac.h
index ddf0260..dd6d052 100644
--- a/drivers/net/ethernet/freescale/fman/fman_mac.h
+++ b/drivers/net/ethernet/freescale/fman/fman_mac.h
@@ -191,10 +191,6 @@ struct fman_mac_params {
u16 max_speed;
/* A handle to the FM object this port related to */
void *fm;
-   /* MDIO exceptions interrupt source - not valid for all
-* MACs; MUST be set to 0 for MACs that don't have
-* mdio-irq, or for polling
-*/
void *dev_id; /* device cookie used by the exception cbs */
fman_mac_exception_cb *event_cb;/* MDIO Events Callback Routine */
fman_mac_exception_cb *exception_cb;/* Exception Callback Routine */
-- 
2.1.0



[net-next 10/13] fsl/fman: simplify redundant condition

2016-10-04 Thread Madalin Bucur
Change suggested by David Binderman, thanks.

Signed-off-by: Madalin Bucur 
---
 drivers/net/ethernet/freescale/fman/fman.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fman/fman.c 
b/drivers/net/ethernet/freescale/fman/fman.c
index 2278bbd..1fc1049 100644
--- a/drivers/net/ethernet/freescale/fman/fman.c
+++ b/drivers/net/ethernet/freescale/fman/fman.c
@@ -2331,8 +2331,7 @@ int fman_set_mac_max_frame(struct fman *fman, u8 mac_id, 
u16 mfl)
 * or equal to the port's max
 */
if ((!fman->state->port_mfl[mac_id]) ||
-   (fman->state->port_mfl[mac_id] &&
-   (mfl <= fman->state->port_mfl[mac_id]))) {
+   (mfl <= fman->state->port_mfl[mac_id])) {
fman->state->mac_mfl[mac_id] = mfl;
} else {
dev_warn(fman->dev, "%s: MAC max_frame_length is larger than 
Port max_frame_length\n",
-- 
2.1.0



[net-next 09/13] fsl/fman: check of_get_phy_mode() return value

2016-10-04 Thread Madalin Bucur
For unknown compatibles avoid crashing and default to SGMII.

Signed-off-by: Madalin Bucur 
---
 drivers/net/ethernet/freescale/fman/mac.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fman/mac.c 
b/drivers/net/ethernet/freescale/fman/mac.c
index e4378c2..8fe6b3e 100644
--- a/drivers/net/ethernet/freescale/fman/mac.c
+++ b/drivers/net/ethernet/freescale/fman/mac.c
@@ -663,6 +663,7 @@ static int mac_probe(struct platform_device *_of_dev)
const u8*mac_addr;
u32  val;
u8  fman_id;
+   int phy_if;
 
dev = &_of_dev->dev;
mac_node = dev->of_node;
@@ -842,13 +843,14 @@ static int mac_probe(struct platform_device *_of_dev)
}
 
/* Get the PHY connection type */
-   priv->phy_if = of_get_phy_mode(mac_node);
-   if (priv->phy_if < 0) {
+   phy_if = of_get_phy_mode(mac_node);
+   if (phy_if < 0) {
dev_warn(dev,
-"of_get_phy_mode() for %s failed. Defaulting to MII\n",
+"of_get_phy_mode() for %s failed. Defaulting to 
SGMII\n",
 mac_node->full_name);
-   priv->phy_if = PHY_INTERFACE_MODE_MII;
+   phy_if = PHY_INTERFACE_MODE_SGMII;
}
+   priv->phy_if = phy_if;
 
priv->speed = phy2speed[priv->phy_if];
priv->max_speed = priv->speed;
-- 
2.1.0



[net-next 06/13] fsl/fman: return a phy_dev pointer from init

2016-10-04 Thread Madalin Bucur
Signed-off-by: Madalin Bucur 
---
 drivers/net/ethernet/freescale/fman/mac.c | 22 +++---
 drivers/net/ethernet/freescale/fman/mac.h |  3 ++-
 2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fman/mac.c 
b/drivers/net/ethernet/freescale/fman/mac.c
index dc04e61..e4378c2 100644
--- a/drivers/net/ethernet/freescale/fman/mac.c
+++ b/drivers/net/ethernet/freescale/fman/mac.c
@@ -469,9 +469,9 @@ static void adjust_link_memac(struct net_device *net_dev)
 /* Initializes driver's PHY state, and attaches to the PHY.
  * Returns 0 on success.
  */
-static int init_phy(struct net_device *net_dev,
-   struct mac_device *mac_dev,
-   void (*adj_lnk)(struct net_device *))
+static struct phy_device *init_phy(struct net_device *net_dev,
+  struct mac_device *mac_dev,
+  void (*adj_lnk)(struct net_device *))
 {
struct phy_device   *phy_dev;
struct mac_priv_s   *priv = mac_dev->priv;
@@ -480,7 +480,7 @@ static int init_phy(struct net_device *net_dev,
 priv->phy_if);
if (!phy_dev) {
netdev_err(net_dev, "Could not connect to PHY\n");
-   return -ENODEV;
+   return NULL;
}
 
/* Remove any features not supported by the controller */
@@ -493,23 +493,23 @@ static int init_phy(struct net_device *net_dev,
 
mac_dev->phy_dev = phy_dev;
 
-   return 0;
+   return phy_dev;
 }
 
-static int dtsec_init_phy(struct net_device *net_dev,
- struct mac_device *mac_dev)
+static struct phy_device *dtsec_init_phy(struct net_device *net_dev,
+struct mac_device *mac_dev)
 {
return init_phy(net_dev, mac_dev, _link_dtsec);
 }
 
-static int tgec_init_phy(struct net_device *net_dev,
-struct mac_device *mac_dev)
+static struct phy_device *tgec_init_phy(struct net_device *net_dev,
+   struct mac_device *mac_dev)
 {
return init_phy(net_dev, mac_dev, adjust_link_void);
 }
 
-static int memac_init_phy(struct net_device *net_dev,
- struct mac_device *mac_dev)
+static struct phy_device *memac_init_phy(struct net_device *net_dev,
+struct mac_device *mac_dev)
 {
return init_phy(net_dev, mac_dev, _link_memac);
 }
diff --git a/drivers/net/ethernet/freescale/fman/mac.h 
b/drivers/net/ethernet/freescale/fman/mac.h
index 0211cc9..d7313f0 100644
--- a/drivers/net/ethernet/freescale/fman/mac.h
+++ b/drivers/net/ethernet/freescale/fman/mac.h
@@ -58,7 +58,8 @@ struct mac_device {
bool tx_pause_active;
bool promisc;
 
-   int (*init_phy)(struct net_device *net_dev, struct mac_device *mac_dev);
+   struct phy_device *(*init_phy)(struct net_device *net_dev,
+  struct mac_device *mac_dev);
int (*init)(struct mac_device *mac_dev);
int (*start)(struct mac_device *mac_dev);
int (*stop)(struct mac_device *mac_dev);
-- 
2.1.0



[net-next 07/13] fsl/fman: MEMAC may use QSGMII PHY interface mode

2016-10-04 Thread Madalin Bucur
Signed-off-by: Madalin Bucur 
---
 drivers/net/ethernet/freescale/fman/fman_memac.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/freescale/fman/fman_memac.c 
b/drivers/net/ethernet/freescale/fman/fman_memac.c
index 45e98fd..96dfe7e 100644
--- a/drivers/net/ethernet/freescale/fman/fman_memac.c
+++ b/drivers/net/ethernet/freescale/fman/fman_memac.c
@@ -1151,7 +1151,8 @@ struct fman_mac *memac_config(struct fman_mac_params 
*params)
/* Save FMan revision */
fman_get_revision(memac->fm, >fm_rev_info);
 
-   if (memac->phy_if == PHY_INTERFACE_MODE_SGMII) {
+   if (memac->phy_if == PHY_INTERFACE_MODE_SGMII ||
+   memac->phy_if == PHY_INTERFACE_MODE_QSGMII) {
if (!params->internal_phy_node) {
pr_err("PCS PHY node is not available\n");
memac_free(memac);
-- 
2.1.0



[net-next 05/13] fsl/fman: simplify device tree reads

2016-10-04 Thread Madalin Bucur
From: Madalin Bucur 

Signed-off-by: Madalin Bucur 
---
 drivers/net/ethernet/freescale/fman/fman.c  | 30 ++---
 drivers/net/ethernet/freescale/fman/fman_port.c | 24 ++--
 drivers/net/ethernet/freescale/fman/mac.c   | 24 +---
 3 files changed, 30 insertions(+), 48 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fman/fman.c 
b/drivers/net/ethernet/freescale/fman/fman.c
index fb25748..2278bbd 100644
--- a/drivers/net/ethernet/freescale/fman/fman.c
+++ b/drivers/net/ethernet/freescale/fman/fman.c
@@ -2737,8 +2737,8 @@ static struct fman *read_dts_node(struct platform_device 
*of_dev)
struct fman *fman;
struct device_node *fm_node, *muram_node;
struct resource *res;
-   const u32 *u32_prop;
-   int lenp, err, irq;
+   u32 val, range[2];
+   int err, irq;
struct clk *clk;
u32 clk_rate;
phys_addr_t phys_base_addr;
@@ -2750,16 +2750,13 @@ static struct fman *read_dts_node(struct 
platform_device *of_dev)
 
fm_node = of_node_get(of_dev->dev.of_node);
 
-   u32_prop = (const u32 *)of_get_property(fm_node, "cell-index", );
-   if (!u32_prop) {
-   dev_err(_dev->dev, "%s: of_get_property(%s, cell-index) 
failed\n",
+   err = of_property_read_u32(fm_node, "cell-index", );
+   if (err) {
+   dev_err(_dev->dev, "%s: failed to read cell-index for %s\n",
__func__, fm_node->full_name);
goto fman_node_put;
}
-   if (WARN_ON(lenp != sizeof(u32)))
-   goto fman_node_put;
-
-   fman->dts_params.id = (u8)fdt32_to_cpu(u32_prop[0]);
+   fman->dts_params.id = (u8)val;
 
/* Get the FM interrupt */
res = platform_get_resource(of_dev, IORESOURCE_IRQ, 0);
@@ -2806,18 +2803,15 @@ static struct fman *read_dts_node(struct 
platform_device *of_dev)
/* Rounding to MHz */
fman->dts_params.clk_freq = DIV_ROUND_UP(clk_rate, 100);
 
-   u32_prop = (const u32 *)of_get_property(fm_node,
-   "fsl,qman-channel-range",
-   );
-   if (!u32_prop) {
-   dev_err(_dev->dev, "%s: of_get_property(%s, 
fsl,qman-channel-range) failed\n",
+   err = of_property_read_u32_array(fm_node, "fsl,qman-channel-range",
+[0], 2);
+   if (err) {
+   dev_err(_dev->dev, "%s: failed to read 
fsl,qman-channel-range for %s\n",
__func__, fm_node->full_name);
goto fman_node_put;
}
-   if (WARN_ON(lenp != sizeof(u32) * 2))
-   goto fman_node_put;
-   fman->dts_params.qman_channel_base = fdt32_to_cpu(u32_prop[0]);
-   fman->dts_params.num_of_qman_channels = fdt32_to_cpu(u32_prop[1]);
+   fman->dts_params.qman_channel_base = range[0];
+   fman->dts_params.num_of_qman_channels = range[1];
 
/* Get the MURAM base address and size */
muram_node = of_find_matching_node(fm_node, fman_muram_match);
diff --git a/drivers/net/ethernet/freescale/fman/fman_port.c 
b/drivers/net/ethernet/freescale/fman/fman_port.c
index 8b043e7..9f3bb50 100644
--- a/drivers/net/ethernet/freescale/fman/fman_port.c
+++ b/drivers/net/ethernet/freescale/fman/fman_port.c
@@ -1625,7 +1625,7 @@ static int fman_port_probe(struct platform_device *of_dev)
struct device_node *fm_node, *port_node;
struct resource res;
struct resource *dev_res;
-   const u32 *u32_prop;
+   u32 val;
int err = 0, lenp;
enum fman_port_type port_type;
u16 port_speed;
@@ -1654,28 +1654,20 @@ static int fman_port_probe(struct platform_device 
*of_dev)
goto return_err;
}
 
-   u32_prop = (const u32 *)of_get_property(port_node, "cell-index", );
-   if (!u32_prop) {
-   dev_err(port->dev, "%s: of_get_property(%s, cell-index) 
failed\n",
+   err = of_property_read_u32(port_node, "cell-index", );
+   if (err) {
+   dev_err(port->dev, "%s: reading cell-index for %s failed\n",
__func__, port_node->full_name);
err = -EINVAL;
goto return_err;
}
-   if (WARN_ON(lenp != sizeof(u32))) {
-   err = -EINVAL;
-   goto return_err;
-   }
-   port_id = (u8)fdt32_to_cpu(u32_prop[0]);
-
+   port_id = (u8)val;
port->dts_params.id = port_id;
 
if (of_device_is_compatible(port_node, "fsl,fman-v3-port-tx")) {
port_type = FMAN_PORT_TYPE_TX;
port_speed = 1000;
-   u32_prop = (const u32 *)of_get_property(port_node,
-   "fsl,fman-10g-port",
-   );
-   if (u32_prop)
+   if 

[net-next 04/13] fsl/fman: use of_get_phy_mode()

2016-10-04 Thread Madalin Bucur
From: Madalin Bucur 

Signed-off-by: Madalin Bucur 
---
 drivers/net/ethernet/freescale/fman/mac.c | 33 ++-
 1 file changed, 2 insertions(+), 31 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fman/mac.c 
b/drivers/net/ethernet/freescale/fman/mac.c
index e33d9d2..f94fad7 100644
--- a/drivers/net/ethernet/freescale/fman/mac.c
+++ b/drivers/net/ethernet/freescale/fman/mac.c
@@ -583,31 +583,6 @@ static void setup_memac(struct mac_device *mac_dev)
 
 static DEFINE_MUTEX(eth_lock);
 
-static const char phy_str[][11] = {
-   [PHY_INTERFACE_MODE_MII]= "mii",
-   [PHY_INTERFACE_MODE_GMII]   = "gmii",
-   [PHY_INTERFACE_MODE_SGMII]  = "sgmii",
-   [PHY_INTERFACE_MODE_TBI]= "tbi",
-   [PHY_INTERFACE_MODE_RMII]   = "rmii",
-   [PHY_INTERFACE_MODE_RGMII]  = "rgmii",
-   [PHY_INTERFACE_MODE_RGMII_ID]   = "rgmii-id",
-   [PHY_INTERFACE_MODE_RGMII_RXID] = "rgmii-rxid",
-   [PHY_INTERFACE_MODE_RGMII_TXID] = "rgmii-txid",
-   [PHY_INTERFACE_MODE_RTBI]   = "rtbi",
-   [PHY_INTERFACE_MODE_XGMII]  = "xgmii"
-};
-
-static phy_interface_t __pure __attribute__((nonnull)) str2phy(const char *str)
-{
-   int i;
-
-   for (i = 0; i < ARRAY_SIZE(phy_str); i++)
-   if (strcmp(str, phy_str[i]) == 0)
-   return (phy_interface_t)i;
-
-   return PHY_INTERFACE_MODE_MII;
-}
-
 static const u16 phy2speed[] = {
[PHY_INTERFACE_MODE_MII]= SPEED_100,
[PHY_INTERFACE_MODE_GMII]   = SPEED_1000,
@@ -686,7 +661,6 @@ static int mac_probe(struct platform_device *_of_dev)
struct resource  res;
struct mac_priv_s   *priv;
const u8*mac_addr;
-   const char  *char_prop;
const u32   *u32_prop;
u8  fman_id;
 
@@ -870,15 +844,12 @@ static int mac_probe(struct platform_device *_of_dev)
}
 
/* Get the PHY connection type */
-   char_prop = (const char *)of_get_property(mac_node,
- "phy-connection-type", NULL);
-   if (!char_prop) {
+   priv->phy_if = of_get_phy_mode(mac_node);
+   if (priv->phy_if < 0) {
dev_warn(dev,
 "of_get_property(%s, phy-connection-type) failed. 
Defaulting to MII\n",
 mac_node->full_name);
priv->phy_if = PHY_INTERFACE_MODE_MII;
-   } else {
-   priv->phy_if = str2phy(char_prop);
}
 
priv->speed = phy2speed[priv->phy_if];
-- 
2.1.0



[net-next 03/13] fsl/fman: small fixes

2016-10-04 Thread Madalin Bucur
From: Madalin Bucur 

Make module params static, proper NULL checks, remove __iomem label
when misused.

Signed-off-by: Madalin Bucur 
---
 drivers/net/ethernet/freescale/fman/fman.c  | 6 +++---
 drivers/net/ethernet/freescale/fman/fman_port.c | 8 +---
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fman/fman.c 
b/drivers/net/ethernet/freescale/fman/fman.c
index ef5f228..fb25748 100644
--- a/drivers/net/ethernet/freescale/fman/fman.c
+++ b/drivers/net/ethernet/freescale/fman/fman.c
@@ -2462,7 +2462,7 @@ EXPORT_SYMBOL(fman_get_mem_region);
  * particular forwarding scenarios that add extra headers to the
  * forwarded frame.
  */
-int fsl_fm_rx_extra_headroom = FSL_FM_RX_EXTRA_HEADROOM;
+static int fsl_fm_rx_extra_headroom = FSL_FM_RX_EXTRA_HEADROOM;
 module_param(fsl_fm_rx_extra_headroom, int, 0);
 MODULE_PARM_DESC(fsl_fm_rx_extra_headroom, "Extra headroom for Rx buffers");
 
@@ -2475,7 +2475,7 @@ MODULE_PARM_DESC(fsl_fm_rx_extra_headroom, "Extra 
headroom for Rx buffers");
  * Could be overridden once, at boot-time, via the
  * fm_set_max_frm() callback.
  */
-int fsl_fm_max_frm = FSL_FM_MAX_FRAME_SIZE;
+static int fsl_fm_max_frm = FSL_FM_MAX_FRAME_SIZE;
 module_param(fsl_fm_max_frm, int, 0);
 MODULE_PARM_DESC(fsl_fm_max_frm, "Maximum frame size, across all interfaces");
 
@@ -2868,7 +2868,7 @@ static struct fman *read_dts_node(struct platform_device 
*of_dev)
 
fman->dts_params.base_addr =
devm_ioremap(_dev->dev, phys_base_addr, mem_size);
-   if (fman->dts_params.base_addr == 0) {
+   if (!fman->dts_params.base_addr) {
dev_err(_dev->dev, "%s: devm_ioremap() failed\n", __func__);
goto fman_free;
}
diff --git a/drivers/net/ethernet/freescale/fman/fman_port.c 
b/drivers/net/ethernet/freescale/fman/fman_port.c
index 6de808e..8b043e7 100644
--- a/drivers/net/ethernet/freescale/fman/fman_port.c
+++ b/drivers/net/ethernet/freescale/fman/fman_port.c
@@ -1477,7 +1477,8 @@ EXPORT_SYMBOL(fman_port_cfg_buf_prefix_content);
  */
 int fman_port_disable(struct fman_port *port)
 {
-   u32 __iomem *bmi_cfg_reg, *bmi_status_reg, tmp;
+   u32 __iomem *bmi_cfg_reg, *bmi_status_reg;
+   u32 tmp;
bool rx_port, failure = false;
int count;
 
@@ -1553,7 +1554,8 @@ EXPORT_SYMBOL(fman_port_disable);
  */
 int fman_port_enable(struct fman_port *port)
 {
-   u32 __iomem *bmi_cfg_reg, tmp;
+   u32 __iomem *bmi_cfg_reg;
+   u32 tmp;
bool rx_port;
 
if (!is_init_done(port->cfg))
@@ -1743,7 +1745,7 @@ static int fman_port_probe(struct platform_device *of_dev)
 
port->dts_params.base_addr = devm_ioremap(port->dev, res.start,
  resource_size());
-   if (port->dts_params.base_addr == 0)
+   if (!port->dts_params.base_addr)
dev_err(port->dev, "%s: devm_ioremap() failed\n", __func__);
 
dev_set_drvdata(_dev->dev, port);
-- 
2.1.0



[net-next 02/13] fsl/fman: fix loadable module compilation

2016-10-04 Thread Madalin Bucur
From: Igal Liberman 

Signed-off-by: Igal Liberman 
---
 drivers/net/ethernet/freescale/fman/Makefile| 10 ---
 drivers/net/ethernet/freescale/fman/fman.c  | 35 +++--
 drivers/net/ethernet/freescale/fman/fman_port.c | 23 +++-
 drivers/net/ethernet/freescale/fman/fman_sp.c   |  3 +++
 4 files changed, 64 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fman/Makefile 
b/drivers/net/ethernet/freescale/fman/Makefile
index 51fd2e6..6049177 100644
--- a/drivers/net/ethernet/freescale/fman/Makefile
+++ b/drivers/net/ethernet/freescale/fman/Makefile
@@ -1,7 +1,9 @@
 subdir-ccflags-y +=  -I$(srctree)/drivers/net/ethernet/freescale/fman
 
-obj-y  += fsl_fman.o fsl_fman_mac.o fsl_mac.o
+obj-$(CONFIG_FSL_FMAN) += fsl_fman.o
+obj-$(CONFIG_FSL_FMAN) += fsl_fman_port.o
+obj-$(CONFIG_FSL_FMAN) += fsl_mac.o
 
-fsl_fman-objs  := fman_muram.o fman.o fman_sp.o fman_port.o
-fsl_fman_mac-objs := fman_dtsec.o fman_memac.o fman_tgec.o
-fsl_mac-objs += mac.o
+fsl_fman-objs  := fman_muram.o fman.o fman_sp.o
+fsl_fman_port-objs := fman_port.o
+fsl_mac-objs:= mac.o fman_dtsec.o fman_memac.o fman_tgec.o
diff --git a/drivers/net/ethernet/freescale/fman/fman.c 
b/drivers/net/ethernet/freescale/fman/fman.c
index 1de2e1e..ef5f228 100644
--- a/drivers/net/ethernet/freescale/fman/fman.c
+++ b/drivers/net/ethernet/freescale/fman/fman.c
@@ -2115,6 +2115,7 @@ void fman_register_intr(struct fman *fman, enum 
fman_event_modules module,
fman->intr_mng[event].isr_cb = isr_cb;
fman->intr_mng[event].src_handle = src_arg;
 }
+EXPORT_SYMBOL(fman_register_intr);
 
 /**
  * fman_unregister_intr
@@ -2138,6 +2139,7 @@ void fman_unregister_intr(struct fman *fman, enum 
fman_event_modules module,
fman->intr_mng[event].isr_cb = NULL;
fman->intr_mng[event].src_handle = NULL;
 }
+EXPORT_SYMBOL(fman_unregister_intr);
 
 /**
  * fman_set_port_params
@@ -2241,6 +2243,7 @@ return_err:
spin_unlock_irqrestore(>spinlock, flags);
return err;
 }
+EXPORT_SYMBOL(fman_set_port_params);
 
 /**
  * fman_reset_mac
@@ -2310,6 +2313,7 @@ int fman_reset_mac(struct fman *fman, u8 mac_id)
 
return 0;
 }
+EXPORT_SYMBOL(fman_reset_mac);
 
 /**
  * fman_set_mac_max_frame
@@ -2337,6 +2341,7 @@ int fman_set_mac_max_frame(struct fman *fman, u8 mac_id, 
u16 mfl)
}
return 0;
 }
+EXPORT_SYMBOL(fman_set_mac_max_frame);
 
 /**
  * fman_get_clock_freq
@@ -2363,6 +2368,7 @@ u32 fman_get_bmi_max_fifo_size(struct fman *fman)
 {
return fman->state->bmi_max_fifo_size;
 }
+EXPORT_SYMBOL(fman_get_bmi_max_fifo_size);
 
 /**
  * fman_get_revision
@@ -2384,6 +2390,7 @@ void fman_get_revision(struct fman *fman, struct 
fman_rev_info *rev_info)
FPM_REV1_MAJOR_SHIFT);
rev_info->minor = tmp & FPM_REV1_MINOR_MASK;
 }
+EXPORT_SYMBOL(fman_get_revision);
 
 /**
  * fman_get_qman_channel_id
@@ -2419,6 +2426,7 @@ u32 fman_get_qman_channel_id(struct fman *fman, u32 
port_id)
 
return fman->state->qman_channel_base + i;
 }
+EXPORT_SYMBOL(fman_get_qman_channel_id);
 
 /**
  * fman_get_mem_region
@@ -2432,6 +2440,7 @@ struct resource *fman_get_mem_region(struct fman *fman)
 {
return fman->state->res;
 }
+EXPORT_SYMBOL(fman_get_mem_region);
 
 /* Bootargs defines */
 /* Extra headroom for RX buffers - Default, min and max */
@@ -2538,6 +2547,7 @@ struct fman *fman_bind(struct device *fm_dev)
 {
return (struct fman *)(dev_get_drvdata(get_device(fm_dev)));
 }
+EXPORT_SYMBOL(fman_bind);
 
 static irqreturn_t fman_err_irq(int irq, void *handle)
 {
@@ -2930,7 +2940,7 @@ static const struct of_device_id fman_match[] = {
{}
 };
 
-MODULE_DEVICE_TABLE(of, fm_match);
+MODULE_DEVICE_TABLE(of, fman_match);
 
 static struct platform_driver fman_driver = {
.driver = {
@@ -2940,4 +2950,25 @@ static struct platform_driver fman_driver = {
.probe = fman_probe,
 };
 
-builtin_platform_driver(fman_driver);
+static int __init fman_load(void)
+{
+   int err;
+
+   pr_debug("FSL DPAA FMan driver\n");
+
+   err = platform_driver_register(_driver);
+   if (err < 0)
+   pr_err("Error, platform_driver_register() = %d\n", err);
+
+   return err;
+}
+module_init(fman_load);
+
+static void __exit fman_unload(void)
+{
+   platform_driver_unregister(_driver);
+}
+module_exit(fman_unload);
+
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_DESCRIPTION("Freescale DPAA Frame Manager driver");
diff --git a/drivers/net/ethernet/freescale/fman/fman_port.c 
b/drivers/net/ethernet/freescale/fman/fman_port.c
index 70c198d..6de808e 100644
--- a/drivers/net/ethernet/freescale/fman/fman_port.c
+++ b/drivers/net/ethernet/freescale/fman/fman_port.c
@@ -1775,4 +1775,25 @@ static struct platform_driver fman_port_driver = {
.probe = fman_port_probe,
 };
 
-builtin_platform_driver(fman_port_driver);
+static int __init 

[net-next 01/13] fsl/fman: split lines over 80 characters

2016-10-04 Thread Madalin Bucur
Signed-off-by: Madalin Bucur 
---
 drivers/net/ethernet/freescale/fman/fman_muram.c | 3 ++-
 drivers/net/ethernet/freescale/fman/fman_muram.h | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fman/fman_muram.c 
b/drivers/net/ethernet/freescale/fman/fman_muram.c
index 47394c4..5ec94d2 100644
--- a/drivers/net/ethernet/freescale/fman/fman_muram.c
+++ b/drivers/net/ethernet/freescale/fman/fman_muram.c
@@ -150,7 +150,8 @@ unsigned long fman_muram_alloc(struct muram_info *muram, 
size_t size)
  *
  * Free an allocated memory from FM-MURAM partition.
  */
-void fman_muram_free_mem(struct muram_info *muram, unsigned long offset, 
size_t size)
+void fman_muram_free_mem(struct muram_info *muram, unsigned long offset,
+size_t size)
 {
unsigned long addr = fman_muram_offset_to_vbase(muram, offset);
 
diff --git a/drivers/net/ethernet/freescale/fman/fman_muram.h 
b/drivers/net/ethernet/freescale/fman/fman_muram.h
index 889649a..453bf84 100644
--- a/drivers/net/ethernet/freescale/fman/fman_muram.h
+++ b/drivers/net/ethernet/freescale/fman/fman_muram.h
@@ -46,6 +46,7 @@ unsigned long fman_muram_offset_to_vbase(struct muram_info 
*muram,
 
 unsigned long fman_muram_alloc(struct muram_info *muram, size_t size);
 
-void fman_muram_free_mem(struct muram_info *muram, unsigned long offset, 
size_t size);
+void fman_muram_free_mem(struct muram_info *muram, unsigned long offset,
+size_t size);
 
 #endif /* __FM_MURAM_EXT */
-- 
2.1.0



[net-next 00/13] fsl/fman: cleanup and small fixes

2016-10-04 Thread Madalin Bucur
This series contains fixes for the DPAA FMan driver.
Adding myself as maintainer of the driver.

The following are changes since commit a4cc96d1f0170b779c32c6b2cc58764f5d2cdef0
 net: phy: Add Edge-rate driver for Microsemi PHYs.
and are available on the fman-next branch in the git repository at
 git://git.freescale.com/ppc/upstream/linux.git

Igal Liberman (1):
  fsl/fman: fix loadable module compilation

Madalin Bucur (12):
  fsl/fman: split lines over 80 characters
  fsl/fman: small fixes
  fsl/fman: use of_get_phy_mode()
  fsl/fman: simplify device tree reads
  fsl/fman: return a phy_dev pointer from init
  fsl/fman: MEMAC may use QSGMII PHY interface mode
  fsl/fman: check pcsphy pointer before use
  fsl/fman: check of_get_phy_mode() return value
  fsl/fman: simplify redundant condition
  fsl/fman: fix return value checking
  fsl/fman: remove leftover comment
  MAINTAINERS: net: add entry for Freescale QorIQ DPAA FMan driver

 MAINTAINERS  |  7 ++
 drivers/net/ethernet/freescale/fman/Makefile | 10 +--
 drivers/net/ethernet/freescale/fman/fman.c   | 78 ++
 drivers/net/ethernet/freescale/fman/fman_mac.h   |  4 --
 drivers/net/ethernet/freescale/fman/fman_memac.c |  6 +-
 drivers/net/ethernet/freescale/fman/fman_muram.c |  3 +-
 drivers/net/ethernet/freescale/fman/fman_muram.h |  3 +-
 drivers/net/ethernet/freescale/fman/fman_port.c  | 55 ++--
 drivers/net/ethernet/freescale/fman/fman_sp.c|  3 +
 drivers/net/ethernet/freescale/fman/mac.c| 83 
 drivers/net/ethernet/freescale/fman/mac.h|  3 +-
 11 files changed, 139 insertions(+), 116 deletions(-)

-- 
2.1.0



[net-next 00/13] fsl/fman: cleanup and small fixes

2016-10-04 Thread Madalin Bucur
This series contains fixes for the DPAA FMan driver.
Adding myself as maintainer of the driver.

The following are changes since commit a4cc96d1f0170b779c32c6b2cc58764f5d2cdef0
 net: phy: Add Edge-rate driver for Microsemi PHYs.
and are available on the fman-next branch in the git repository at
 git://git.freescale.com/ppc/upstream/linux.git

Igal Liberman (1):
  fsl/fman: fix loadable module compilation

Madalin Bucur (12):
  fsl/fman: split lines over 80 characters
  fsl/fman: small fixes
  fsl/fman: use of_get_phy_mode()
  fsl/fman: simplify device tree reads
  fsl/fman: return a phy_dev pointer from init
  fsl/fman: MEMAC may use QSGMII PHY interface mode
  fsl/fman: check pcsphy pointer before use
  fsl/fman: check of_get_phy_mode() return value
  fsl/fman: simplify redundant condition
  fsl/fman: fix return value checking
  fsl/fman: remove leftover comment
  MAINTAINERS: net: add entry for Freescale QorIQ DPAA FMan driver

 MAINTAINERS  |  7 ++
 drivers/net/ethernet/freescale/fman/Makefile | 10 +--
 drivers/net/ethernet/freescale/fman/fman.c   | 78 ++
 drivers/net/ethernet/freescale/fman/fman_mac.h   |  4 --
 drivers/net/ethernet/freescale/fman/fman_memac.c |  6 +-
 drivers/net/ethernet/freescale/fman/fman_muram.c |  3 +-
 drivers/net/ethernet/freescale/fman/fman_muram.h |  3 +-
 drivers/net/ethernet/freescale/fman/fman_port.c  | 55 ++--
 drivers/net/ethernet/freescale/fman/fman_sp.c|  3 +
 drivers/net/ethernet/freescale/fman/mac.c| 83 
 drivers/net/ethernet/freescale/fman/mac.h|  3 +-
 11 files changed, 139 insertions(+), 116 deletions(-)

-- 
2.1.0



  1   2   >