Re: clang/ld.lld build fails with `can't create dynamic relocation R_PPC64_ADDR64 against local symbol in readonly segment`

2021-08-11 Thread Michael Ellerman
Paul Menzel writes: > Am 29.07.21 um 10:23 schrieb Paul Menzel: > >> I just wanted to make you aware that building Linux for ppc64le with >> clang/lld.ld fails with [1]: >> >>     ld.lld: error: can't create dynamic relocation R_PPC64_ADDR64 >> against symbol: empty_zero_page in readonly

Re: [PATCH v2 7/9] usb: phy: fsl-usb: add IRQ check

2021-08-11 Thread Felipe Balbi
Sergey Shtylyov writes: > The driver neglects to check the result of platform_get_irq()'s call and > blithely passes the negative error codes to request_irq() (which takes > *unsigned* IRQ #), causing it to fail with -EINVAL, overriding an original > error code. Stop calling request_irq() with

[PATCH v2 1/2] KVM: Refactor kvm_arch_vcpu_fault() to return a struct page pointer

2021-08-11 Thread Hou Wenlong
From: Sean Christopherson Refactor kvm_arch_vcpu_fault() to return 'struct page *' instead of 'vm_fault_t' to simplify architecture specific implementations that do more than return SIGBUS. Currently this only applies to s390, but a future patch will move x86's pio_data handling into x86 where

Re: [PATCH v7 5/6] powerpc/pseries: Add support for FORM2 associativity

2021-08-11 Thread Aneesh Kumar K.V
On 8/12/21 7:11 AM, David Gibson wrote: On Wed, Aug 11, 2021 at 09:39:32AM +0530, Aneesh Kumar K.V wrote: David Gibson writes: On Mon, Aug 09, 2021 at 10:54:33AM +0530, Aneesh Kumar K.V wrote: PAPR interface currently supports two different ways of communicating resource grouping details to

Re: [PATCH v7 5/6] powerpc/pseries: Add support for FORM2 associativity

2021-08-11 Thread David Gibson
On Wed, Aug 11, 2021 at 09:39:32AM +0530, Aneesh Kumar K.V wrote: > David Gibson writes: > > > On Mon, Aug 09, 2021 at 10:54:33AM +0530, Aneesh Kumar K.V wrote: > >> PAPR interface currently supports two different ways of communicating > >> resource > >> grouping details to the OS. These are

Re: clang/ld.lld build fails with `can't create dynamic relocation R_PPC64_ADDR64 against local symbol in readonly segment`

2021-08-11 Thread Paul Menzel
Dear Christophe, Am 11.08.21 um 16:10 schrieb Christophe Leroy: Le 10/08/2021 à 20:38, Paul Menzel a écrit : Am 29.07.21 um 10:23 schrieb Paul Menzel: I just wanted to make you aware that building Linux for ppc64le with clang/lld.ld fails with [1]: ld.lld: error: can't create

Re: [PATCH v2 40/60] KVM: PPC: Book3S HV P9: Implement TM fastpath for guest entry/exit

2021-08-11 Thread kernel test robot
Hi Nicholas, I love your patch! Yet something to improve: [auto build test ERROR on powerpc/next] [also build test ERROR on linus/master v5.14-rc5 next-20210811] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base

Re: [PATCH v2 27/60] KVM: PPC: Book3S HV P9: Reduce mtmsrd instructions required to save host SPRs

2021-08-11 Thread kernel test robot
Hi Nicholas, I love your patch! Yet something to improve: [auto build test ERROR on powerpc/next] [also build test ERROR on linus/master v5.14-rc5 next-20210811] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base

Re: [PATCH v2 27/60] KVM: PPC: Book3S HV P9: Reduce mtmsrd instructions required to save host SPRs

2021-08-11 Thread kernel test robot
Hi Nicholas, I love your patch! Perhaps something to improve: [auto build test WARNING on powerpc/next] [also build test WARNING on linus/master v5.14-rc5 next-20210811] [cannot apply to scottwood/next kvm-ppc/kvm-ppc-next] [If your patch is applied to the wrong git tree, kindly drop us a note

Re: [PATCH v5 7/8] powerpc/64s: Initialize and use a temporary mm for patching on Radix

2021-08-11 Thread Christopher M. Riedl
On Thu Aug 5, 2021 at 4:48 AM CDT, Christophe Leroy wrote: > > > Le 13/07/2021 à 07:31, Christopher M. Riedl a écrit : > > When code patching a STRICT_KERNEL_RWX kernel the page containing the > > address to be patched is temporarily mapped as writeable. Currently, a > > per-cpu vmalloc patch area

Re: [PATCH v5 6/8] powerpc: Rework and improve STRICT_KERNEL_RWX patching

2021-08-11 Thread Christopher M. Riedl
On Thu Aug 5, 2021 at 4:34 AM CDT, Christophe Leroy wrote: > > > Le 13/07/2021 à 07:31, Christopher M. Riedl a écrit : > > Rework code-patching with STRICT_KERNEL_RWX to prepare for the next > > patch which uses a temporary mm for patching under the Book3s64 Radix > > MMU. Make improvements by

Re: [PATCH v5 2/8] lkdtm/powerpc: Add test to hijack a patch mapping

2021-08-11 Thread Kees Cook
On Wed, Aug 11, 2021 at 12:57:00PM -0500, Christopher M. Riedl wrote: > On Thu Aug 5, 2021 at 4:13 AM CDT, Christophe Leroy wrote: > > > > > > Le 13/07/2021 à 07:31, Christopher M. Riedl a écrit : > > > When live patching with STRICT_KERNEL_RWX the CPU doing the patching > > > must temporarily

Re: [PATCH v5 5/8] powerpc/64s: Introduce temporary mm for Radix MMU

2021-08-11 Thread Christopher M. Riedl
On Thu Aug 5, 2021 at 4:27 AM CDT, Christophe Leroy wrote: > > > Le 13/07/2021 à 07:31, Christopher M. Riedl a écrit : > > x86 supports the notion of a temporary mm which restricts access to > > temporary PTEs to a single CPU. A temporary mm is useful for situations > > where a CPU needs to

Re: [PATCH v5 8/8] lkdtm/powerpc: Fix code patching hijack test

2021-08-11 Thread Christopher M. Riedl
On Thu Aug 5, 2021 at 4:18 AM CDT, Christophe Leroy wrote: > > > Le 13/07/2021 à 07:31, Christopher M. Riedl a écrit : > > Code patching on powerpc with a STRICT_KERNEL_RWX uses a userspace > > address in a temporary mm on Radix now. Use __put_user() to avoid write > > failures due to KUAP when

Re: [PATCH v5 2/8] lkdtm/powerpc: Add test to hijack a patch mapping

2021-08-11 Thread Christopher M. Riedl
On Thu Aug 5, 2021 at 4:13 AM CDT, Christophe Leroy wrote: > > > Le 13/07/2021 à 07:31, Christopher M. Riedl a écrit : > > When live patching with STRICT_KERNEL_RWX the CPU doing the patching > > must temporarily remap the page(s) containing the patch site with +W > > permissions. While this

Re: [PATCH v5 4/8] lkdtm/x86_64: Add test to hijack a patch mapping

2021-08-11 Thread Christopher M. Riedl
On Thu Aug 5, 2021 at 4:09 AM CDT, Christophe Leroy wrote: > > > Le 13/07/2021 à 07:31, Christopher M. Riedl a écrit : > > A previous commit implemented an LKDTM test on powerpc to exploit the > > temporary mapping established when patching code with STRICT_KERNEL_RWX > > enabled. Extend the test

Re: [PATCH v5 0/8] Use per-CPU temporary mappings for patching on Radix MMU

2021-08-11 Thread Christopher M. Riedl
On Thu Aug 5, 2021 at 4:03 AM CDT, Christophe Leroy wrote: > > > Le 13/07/2021 à 07:31, Christopher M. Riedl a écrit : > > When compiled with CONFIG_STRICT_KERNEL_RWX, the kernel must create > > temporary mappings when patching itself. These mappings temporarily > > override the strict RWX text

[PATCH v2 60/60] KVM: PPC: Book3S HV P9: Remove subcore HMI handling

2021-08-11 Thread Nicholas Piggin
On POWER9 and newer, rather than the complex HMI synchronisation and subcore state, have each thread un-apply the guest TB offset before calling into the early HMI handler. This allows the subcore state to be avoided, including subcore enter / exit guest, which includes an expensive divide that

[PATCH v2 59/60] KVM: PPC: Book3S HV P9: Stop using vc->dpdes

2021-08-11 Thread Nicholas Piggin
The P9 path uses vc->dpdes only for msgsndp / SMT emulation. This adds an ordering requirement between vcpu->doorbell_request and vc->dpdes for no real benefit. Use vcpu->doorbell_request directly. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c | 18 ++

[PATCH v2 58/60] KVM: PPC: Book3S HV P9: Tidy kvmppc_create_dtl_entry

2021-08-11 Thread Nicholas Piggin
This goes further to removing vcores from the P9 path. Also avoid the memset in favour of explicitly initialising all fields. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c | 61 +--- 1 file changed, 35 insertions(+), 26 deletions(-) diff --git

[PATCH v2 57/60] KVM: PPC: Book3S HV P9: Remove most of the vcore logic

2021-08-11 Thread Nicholas Piggin
The P9 path always uses one vcpu per vcore, so none of the the vcore, locks, stolen time, blocking logic, shared waitq, etc., is required. Remove most of it. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c | 147 --- 1 file changed, 85

[PATCH v2 56/60] KVM: PPC: Book3S HV P9: Avoid cpu_in_guest atomics on entry and exit

2021-08-11 Thread Nicholas Piggin
cpu_in_guest is set to determine if a CPU needs to be IPI'ed to exit the guest and notice the need_tlb_flush bit. This can be implemented as a global per-CPU pointer to the currently running guest instead of per-guest cpumasks, saving 2 atomics per entry/exit. P7/8 doesn't require cpu_in_guest,

[PATCH v2 55/60] KVM: PPC: Book3S HV P9: Add unlikely annotation for !mmu_ready

2021-08-11 Thread Nicholas Piggin
The mmu will almost always be ready. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index 979223018c8e..d3fc486a4817 100644 ---

[PATCH v2 54/60] KVM: PPC: Book3S HV P9: Avoid changing MSR[RI] in entry and exit

2021-08-11 Thread Nicholas Piggin
kvm_hstate.in_guest provides the equivalent of MSR[RI]=0 protection, and it covers the existing MSR[RI]=0 section in late entry and early exit, so clearing and setting MSR[RI] in those cases does not actually do anything useful. Remove the RI manipulation and replace it with comments. Make the

[PATCH v2 53/60] KVM: PPC: Book3S HV P9: Optimise hash guest SLB saving

2021-08-11 Thread Nicholas Piggin
slbmfee/slbmfev instructions are very expensive, moreso than a regular mfspr instruction, so minimising them significantly improves hash guest exit performance. The slbmfev is only required if slbmfee found a valid SLB entry. Signed-off-by: Nicholas Piggin ---

[PATCH v2 52/60] KVM: PPC: Book3S HV P9: Improve mfmsr performance on entry

2021-08-11 Thread Nicholas Piggin
Rearrange the MSR saving on entry so it does not follow the mtmsrd to disable interrupts, avoiding a possible RAW scoreboard stall. Signed-off-by: Nicholas Piggin --- arch/powerpc/include/asm/kvm_book3s_64.h | 2 + arch/powerpc/kvm/book3s_hv.c | 18 ++-

[PATCH v2 51/60] KVM: PPC: Book3S HV Nested: Avoid extra mftb() in nested entry

2021-08-11 Thread Nicholas Piggin
mftb() is expensive and one can be avoided on nested guest dispatch. If the time checking code distinguishes between the L0 timer and the nested HV timer, then both can be tested in the same place with the same mftb() value. This also nicely illustrates the relationship between the L0 and nested

[PATCH v2 50/60] KVM: PPC: Book3S HV P9: Avoid tlbsync sequence on radix guest exit

2021-08-11 Thread Nicholas Piggin
Use the existing TLB flushing logic to IPI the previous CPU and run the necessary barriers before running a guest vCPU on a new physical CPU, to do the necessary radix GTSE barriers for handling the case of an interrupted guest tlbie sequence. This results in more IPIs than the TLB flush logic

[PATCH v2 49/60] KVM: PPC: Book3S HV P9: Don't restore PSSCR if not needed

2021-08-11 Thread Nicholas Piggin
This also moves the PSSCR update in nested entry to avoid a SPR scoreboard stall. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c | 7 +-- arch/powerpc/kvm/book3s_hv_p9_entry.c | 26 +++--- 2 files changed, 24 insertions(+), 9 deletions(-) diff

[PATCH v2 48/60] KVM: PPC: Book3S HV P9: Test dawr_enabled() before saving host DAWR SPRs

2021-08-11 Thread Nicholas Piggin
Some of the DAWR SPR access is already predicated on dawr_enabled(), apply this to the remainder of the accesses. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv_p9_entry.c | 34 --- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git

[PATCH v2 47/60] KVM: PPC: Book3S HV P9: Comment and fix MMU context switching code

2021-08-11 Thread Nicholas Piggin
Tighten up partition switching code synchronisation and comments. In particular, hwsync ; isync is required after the last access that is performed in the context of a partition, before the partition is switched away from. Signed-off-by: Nicholas Piggin ---

[PATCH v2 46/60] KVM: PPC: Book3S HV P9: Use Linux SPR save/restore to manage some host SPRs

2021-08-11 Thread Nicholas Piggin
Linux implements SPR save/restore including storage space for registers in the task struct for process context switching. Make use of this similarly to the way we make use of the context switching fp/vec save restore. This improves code reuse, allows some stack space to be saved, and helps with

[PATCH v2 45/60] KVM: PPC: Book3S HV P9: Demand fault TM facility registers

2021-08-11 Thread Nicholas Piggin
Use HFSCR facility disabling to implement demand faulting for TM, with a hysteresis counter similar to the load_fp etc counters in context switching that implement the equivalent demand faulting for userspace facilities. This speeds up guest entry/exit by avoiding the register save/restore when a

[PATCH v2 44/60] KVM: PPC: Book3S HV P9: Demand fault EBB facility registers

2021-08-11 Thread Nicholas Piggin
Use HFSCR facility disabling to implement demand faulting for EBB, with a hysteresis counter similar to the load_fp etc counters in context switching that implement the equivalent demand faulting for userspace facilities. This speeds up guest entry/exit by avoiding the register save/restore when

[PATCH v2 43/60] KVM: PPC: Book3S HV P9: More SPR speed improvements

2021-08-11 Thread Nicholas Piggin
This avoids more scoreboard stalls and reduces mtSPRs. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv_p9_entry.c | 73 --- 1 file changed, 43 insertions(+), 30 deletions(-) diff --git a/arch/powerpc/kvm/book3s_hv_p9_entry.c

[PATCH v2 42/60] KVM: PPC: Book3S HV P9: Restrict DSISR canary workaround to processors that require it

2021-08-11 Thread Nicholas Piggin
Use CPU_FTR_P9_RADIX_PREFETCH_BUG to apply the workaround, to test for DD2.1 and below processors. This saves a mtSPR in guest entry. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c | 3 ++- arch/powerpc/kvm/book3s_hv_p9_entry.c | 6 -- 2 files changed, 6

[PATCH v2 41/60] KVM: PPC: Book3S HV P9: Switch PMU to guest as late as possible

2021-08-11 Thread Nicholas Piggin
This moves PMU switch to guest as late as possible in entry, and switch back to host as early as possible at exit. This helps the host get the most perf coverage of KVM entry/exit code as possible. This is slightly suboptimal for SPR scheduling point of view when the PMU is enabled, but when perf

[PATCH v2 40/60] KVM: PPC: Book3S HV P9: Implement TM fastpath for guest entry/exit

2021-08-11 Thread Nicholas Piggin
If TM is not active, only TM register state needs to be saved and restored, avoiding several mfmsr/mtmsrd instructions and improving performance. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv_p9_entry.c | 23 +++ 1 file changed, 19 insertions(+), 4

[PATCH v2 39/60] KVM: PPC: Book3S HV P9: Move remaining SPR and MSR access into low level entry

2021-08-11 Thread Nicholas Piggin
Move register saving and loading from kvmhv_p9_guest_entry() into the HV and nested entry handlers. Accesses are scheduled to reduce mtSPR / mfSPR interleaving which reduces SPR scoreboard stalls. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c | 79

[PATCH v2 38/60] KVM: PPC: Book3S HV P9: Move nested guest entry into its own function

2021-08-11 Thread Nicholas Piggin
Move the part of the guest entry which is specific to nested HV into its own function. This is just refactoring. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c | 125 +++ 1 file changed, 67 insertions(+), 58 deletions(-) diff --git

[PATCH v2 37/60] KVM: PPC: Book3S HV P9: Move host OS save/restore functions to built-in

2021-08-11 Thread Nicholas Piggin
Move the P9 guest/host register switching functions to the built-in P9 entry code, and export it for nested to use as well. This allows more flexibility in scheduling these supervisor privileged SPR accesses with the HV privileged and PR SPR accesses in the low level entry code. Signed-off-by:

[PATCH v2 36/60] KVM: PPC: Book3S HV P9: Move vcpu register save/restore into functions

2021-08-11 Thread Nicholas Piggin
This should be no functional difference but makes the caller easier to read. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c | 65 +++- 1 file changed, 41 insertions(+), 24 deletions(-) diff --git a/arch/powerpc/kvm/book3s_hv.c

[PATCH v2 35/60] KVM: PPC: Book3S HV P9: Juggle SPR switching around

2021-08-11 Thread Nicholas Piggin
This juggles SPR switching on the entry and exit sides to be more symmetric, which makes the next refactoring patch possible with no functional change. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git

[PATCH v2 34/60] KVM: PPC: Book3S HV P9: Only execute mtSPR if the value changed

2021-08-11 Thread Nicholas Piggin
Keep better track of the current SPR value in places where they are to be loaded with a new context, to reduce expensive mtSPR operations. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c | 64 ++-- 1 file changed, 39 insertions(+), 25 deletions(-)

[PATCH v2 33/60] KVM: PPC: Book3S HV P9: Avoid SPR scoreboard stalls

2021-08-11 Thread Nicholas Piggin
Avoid interleaving mfSPR and mtSPR to reduce SPR scoreboard stalls. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c | 8 arch/powerpc/kvm/book3s_hv_p9_entry.c | 19 +++ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git

[PATCH v2 32/60] KVM: PPC: Book3S HV P9: Optimise timebase reads

2021-08-11 Thread Nicholas Piggin
Reduce the number of mfTB executed by passing the current timebase around entry and exit code rather than read it multiple times. Signed-off-by: Nicholas Piggin --- arch/powerpc/include/asm/kvm_book3s_64.h | 2 +- arch/powerpc/kvm/book3s_hv.c | 88 +---

[PATCH v2 31/60] KVM: PPC: Book3S HV P9: Move TB updates

2021-08-11 Thread Nicholas Piggin
Move the TB updates between saving and loading guest and host SPRs, to improve scheduling by keeping issue-NTC operations together as much as possible. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv_p9_entry.c | 36 +-- 1 file changed, 18 insertions(+), 18

[PATCH v2 30/60] KVM: PPC: Book3S HV: Change dec_expires to be relative to guest timebase

2021-08-11 Thread Nicholas Piggin
Change dec_expires to be relative to the guest timebase, and allow it to be moved into low level P9 guest entry functions, to improve SPR access scheduling. Signed-off-by: Nicholas Piggin --- arch/powerpc/include/asm/kvm_book3s.h | 6 +++ arch/powerpc/include/asm/kvm_host.h | 2 +-

[PATCH v2 29/60] KVM: PPC: Book3S HV P9: Add kvmppc_stop_thread to match kvmppc_start_thread

2021-08-11 Thread Nicholas Piggin
Small cleanup makes it a bit easier to match up entry and exit operations. Reviewed-by: Fabiano Rosas Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c | 11 +-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kvm/book3s_hv.c

[PATCH v2 28/60] KVM: PPC: Book3S HV P9: Improve mtmsrd scheduling by delaying MSR[EE] disable

2021-08-11 Thread Nicholas Piggin
Moving the mtmsrd after the host SPRs are saved and before the guest SPRs start to be loaded can prevent an SPR scoreboard stall (because the mtmsrd is L=1 type which does not cause context synchronisation. This is also now more convenient to combined with the mtmsrd L=0 instruction to enable

[PATCH v2 27/60] KVM: PPC: Book3S HV P9: Reduce mtmsrd instructions required to save host SPRs

2021-08-11 Thread Nicholas Piggin
This reduces the number of mtmsrd required to enable facility bits when saving/restoring registers, by having the KVM code set all bits up front rather than using individual facility functions that set their particular MSR bits. Signed-off-by: Nicholas Piggin --- arch/powerpc/kernel/process.c

[PATCH v2 26/60] KVM: PPC: Book3S HV P9: Move SPRG restore to restore_p9_host_os_sprs

2021-08-11 Thread Nicholas Piggin
Move the SPR update into its relevant helper function. This will help with SPR scheduling improvements in later changes. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kvm/book3s_hv.c

[PATCH v2 25/60] KVM: PPC: Book3S HV: CTRL SPR does not require read-modify-write

2021-08-11 Thread Nicholas Piggin
Processors that support KVM HV do not require read-modify-write of the CTRL SPR to set/clear their thread's runlatch. Just write 1 or 0 to it. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c| 2 +- arch/powerpc/kvm/book3s_hv_rmhandlers.S | 15 ++- 2

[PATCH v2 24/60] KVM: PPC: Book3S HV P9: Factor out yield_count increment

2021-08-11 Thread Nicholas Piggin
Factor duplicated code into a helper function. Reviewed-by: Fabiano Rosas Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c | 24 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c

[PATCH v2 23/60] KVM: PPC: Book3S HV P9: Demand fault PMU SPRs when marked not inuse

2021-08-11 Thread Nicholas Piggin
The pmcregs_in_use field in the guest VPA can not be trusted to reflect what the guest is doing with PMU SPRs, so the PMU must always be managed (stopped) when exiting the guest, and SPR values set when entering the guest to ensure it can't cause a covert channel or otherwise cause other guests or

[PATCH v2 22/60] KVM: PPC: Book3S HV P9: Factor PMU save/load into context switch functions

2021-08-11 Thread Nicholas Piggin
Rather than guest/host save/retsore functions, implement context switch functions that take care of details like the VPA update for nested. The reason to split these kind of helpers into explicit save/load functions is mainly to schedule SPR access nicely, but PMU is a special case where the load

[PATCH v2 21/60] KVM: PPC: Book3S HV P9: Implement PMU save/restore in C

2021-08-11 Thread Nicholas Piggin
Implement the P9 path PMU save/restore code in C, and remove the POWER9/10 code from the P7/8 path assembly. Cc: Athira Jajeev Cc: Madhavan Srinivasan Signed-off-by: Nicholas Piggin --- arch/powerpc/include/asm/asm-prototypes.h | 5 - arch/powerpc/kvm/book3s_hv.c | 221

[PATCH v2 20/60] powerpc/64s: Implement PMU override command line option

2021-08-11 Thread Nicholas Piggin
It can be useful in simulators (with very constrained environments) to allow some PMCs to run from boot so they can be sampled directly by a test harness, rather than having to run perf. A previous change freezes counters at boot by default, so provide a boot time option to un-freeze (plus a bit

[PATCH v2 19/60] powerpc/64s: Always set PMU control registers to frozen/disabled when not in use

2021-08-11 Thread Nicholas Piggin
KVM PMU management code looks for particular frozen/disabled bits in the PMU registers so it knows whether it must clear them when coming out of a guest or not. Setting this up helps KVM make these optimisations without getting confused. Longer term the better approach might be to move guest/host

[PATCH v2 18/60] KVM: PPC: Book3S HV: Don't always save PMU for guest capable of nesting

2021-08-11 Thread Nicholas Piggin
Provide a config option that controls the the workaround added by commit 63279eeb7f93a ("KVM: PPC: Book3S HV: Always save guest pmu for guest capable of nesting"). The option defaults to y for now, but is expected to go away within a few releases. Nested capable guests running with the earlier

[PATCH v2 17/60] powerpc/64s: Keep AMOR SPR a constant ~0 at runtime

2021-08-11 Thread Nicholas Piggin
This register controls supervisor SPR modifications, and as such is only relevant for KVM. KVM always sets AMOR to ~0 on guest entry, and never restores it coming back out to the host, so it can be kept constant and avoid the mtSPR in KVM guest entry. Reviewed-by: Fabiano Rosas Signed-off-by:

[PATCH v2 16/60] KVM: PPC: Book3S HV: POWER10 enable HAIL when running radix guests

2021-08-11 Thread Nicholas Piggin
HV interrupts may be taken with the MMU enabled when radix guests are running. Enable LPCR[HAIL] on ISA v3.1 processors for radix guests. Make this depend on the host LPCR[HAIL] being enabled. Currently that is always enabled, but having this test means any issue that might require LPCR[HAIL] to

[PATCH v2 15/60] powerpc/time: add API for KVM to re-arm the host timer/decrementer

2021-08-11 Thread Nicholas Piggin
Rather than have KVM look up the host timer and fiddle with the irq-work internal details, have the powerpc/time.c code provide a function for KVM to re-arm the Linux timer code when exiting a guest. This is implementation has an improvement over existing code of marking a decrementer interrupt

[PATCH v2 14/60] KVM: PPC: Book3S HV P9: Reduce mftb per guest entry/exit

2021-08-11 Thread Nicholas Piggin
mftb is serialising (dispatch next-to-complete) so it is heavy weight for a mfspr. Avoid reading it multiple times in the entry or exit paths. A small number of cycles delay to timers is tolerable. Reviewed-by: Fabiano Rosas Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c

[PATCH v2 13/60] KVM: PPC: Book3S HV P9: Use large decrementer for HDEC

2021-08-11 Thread Nicholas Piggin
On processors that don't suppress the HDEC exceptions when LPCR[HDICE]=0, this could help reduce needless guest exits due to leftover exceptions on entering the guest. Reviewed-by: Alexey Kardashevskiy Signed-off-by: Nicholas Piggin --- arch/powerpc/include/asm/time.h | 2 ++

[PATCH v2 12/60] KVM: PPC: Book3S HV P9: Use host timer accounting to avoid decrementer read

2021-08-11 Thread Nicholas Piggin
There is no need to save away the host DEC value, as it is derived from the host timer subsystem which maintains the next timer time, so it can be restored from there. Signed-off-by: Nicholas Piggin --- arch/powerpc/include/asm/time.h | 5 + arch/powerpc/kernel/time.c | 1 +

[PATCH v2 11/60] KMV: PPC: Book3S HV P9: Use set_dec to set decrementer to host

2021-08-11 Thread Nicholas Piggin
The host Linux timer code arms the decrementer with the value 'decrementers_next_tb - current_tb' using set_dec(), which stores val - 1 on Book3S-64, which is not quite the same as what KVM does to re-arm the host decrementer when exiting the guest. This shouldn't be a significant change, but it

[PATCH v2 10/60] powerpc/64s: Remove WORT SPR from POWER9/10

2021-08-11 Thread Nicholas Piggin
This register is not architected and not implemented in POWER9 or 10, it just reads back zeroes for compatibility. Reviewed-by: Fabiano Rosas Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c | 3 --- arch/powerpc/platforms/powernv/idle.c | 2 -- 2 files changed, 5

[PATCH v2 09/60] KVM: PPC: Book3S HV Nested: Reflect guest PMU in-use to L0 when guest SPRs are live

2021-08-11 Thread Nicholas Piggin
After the L1 saves its PMU SPRs but before loading the L2's PMU SPRs, switch the pmcregs_in_use field in the L1 lppaca to the value advertised by the L2 in its VPA. On the way out of the L2, set it back after saving the L2 PMU registers (if they were in-use). This transfers the PMU liveness

[PATCH v2 08/60] KVM: PPC: Book3S HV Nested: save_hv_return_state does not require trap argument

2021-08-11 Thread Nicholas Piggin
From: Fabiano Rosas vcpu is already anargument so vcpu->arch.trap can be used directly. Signed-off-by: Fabiano Rosas Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv_nested.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git

[PATCH v2 07/60] KVM: PPC: Book3S HV Nested: Stop forwarding all HFUs to L1

2021-08-11 Thread Nicholas Piggin
From: Fabiano Rosas If the nested hypervisor has no access to a facility because it has been disabled by the host, it should also not be able to see the Hypervisor Facility Unavailable that arises from one of its guests trying to access the facility. This patch turns a HFU that happened in L2

[PATCH v2 06/60] KVM: PPC: Book3S HV Nested: Make nested HFSCR state accessible

2021-08-11 Thread Nicholas Piggin
When the L0 runs a nested L2, there are several permutations of HFSCR that can be relevant. The HFSCR that the L1 vcpu L1 requested, the HFSCR that the L1 vcpu may use, and the HFSCR that is actually being used to run the L2. The L1 requested HFSCR is not accessible outside the nested hcall

[PATCH v2 05/60] KVM: PPC: Book3S HV Nested: Sanitise vcpu registers

2021-08-11 Thread Nicholas Piggin
From: Fabiano Rosas As one of the arguments of the H_ENTER_NESTED hypercall, the nested hypervisor (L1) prepares a structure containing the values of various hypervisor-privileged registers with which it wants the nested guest (L2) to run. Since the nested HV runs in supervisor mode it needs the

[PATCH v2 04/60] KVM: PPC: Book3S HV Nested: Fix TM softpatch HFAC interrupt emulation

2021-08-11 Thread Nicholas Piggin
Have the TM softpatch emulation code set up the HFAC interrupt and return -1 in case an instruction was executed with HFSCR bits clear, and have the interrupt exit handler fall through to the HFAC handler. When the L0 is running a nested guest, this ensures the HFAC interrupt is correctly passed

[PATCH v2 03/60] KVM: PPC: Book3S HV P9: Fixes for TM softpatch interrupt NIP

2021-08-11 Thread Nicholas Piggin
The softpatch interrupt sets HSRR0 to the faulting instruction +4, so it should subtract 4 for the faulting instruction address in the case it is a TM softpatch interrupt (the instruction was not executed) and it was not emulated. Signed-off-by: Nicholas Piggin ---

[PATCH v2 02/60] KVM: PPC: Book3S HV: Remove TM emulation from POWER7/8 path

2021-08-11 Thread Nicholas Piggin
TM fake-suspend emulation is only used by POWER9. Remove it from the old code path. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv_rmhandlers.S | 42 - 1 file changed, 42 deletions(-) diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S

[PATCH v2 01/60] KVM: PPC: Book3S HV: Initialise vcpu MSR with MSR_ME

2021-08-11 Thread Nicholas Piggin
It is possible to create a VCPU without setting the MSR before running it, which results in a warning in kvmhv_vcpu_entry_p9() that MSR_ME is not set. This is pretty harmless because the MSR_ME bit is added to HSRR1 before HRFID to guest, and a normal qemu guest doesn't hit it. Initialise the

[PATCH v2 00/60] KVM: PPC: Book3S HV P9: entry/exit optimisations

2021-08-11 Thread Nicholas Piggin
This reduces radix guest full entry/exit latency on POWER9 and POWER10 by 2x. Nested HV guests should see smaller improvements in their L1 entry/exit, but this is also combined with most L0 speedups also applying to nested entry. nginx localhost throughput test in a SMP nested guest is improved

Re: [PATCH 07/11] treewide: Replace the use of mem_encrypt_active() with prot_guest_has()

2021-08-11 Thread Tom Lendacky
On 8/11/21 7:19 AM, Kirill A. Shutemov wrote: > On Tue, Aug 10, 2021 at 02:48:54PM -0500, Tom Lendacky wrote: >> On 8/10/21 1:45 PM, Kuppuswamy, Sathyanarayanan wrote: >>> >>> >>> On 7/27/21 3:26 PM, Tom Lendacky wrote: diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c

Re: [PATCH 01/11] mm: Introduce a function to check for virtualization protection features

2021-08-11 Thread Tom Lendacky
On 8/11/21 9:53 AM, Kuppuswamy, Sathyanarayanan wrote: > On 7/27/21 3:26 PM, Tom Lendacky wrote: >> diff --git a/include/linux/protected_guest.h >> b/include/linux/protected_guest.h >> new file mode 100644 >> index ..f8ed7b72967b >> --- /dev/null >> +++

Re: [PATCH 01/11] mm: Introduce a function to check for virtualization protection features

2021-08-11 Thread Kuppuswamy, Sathyanarayanan
On 7/27/21 3:26 PM, Tom Lendacky wrote: diff --git a/include/linux/protected_guest.h b/include/linux/protected_guest.h new file mode 100644 index ..f8ed7b72967b --- /dev/null +++ b/include/linux/protected_guest.h @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +

Re: clang/ld.lld build fails with `can't create dynamic relocation R_PPC64_ADDR64 against local symbol in readonly segment`

2021-08-11 Thread Christophe Leroy
Le 10/08/2021 à 20:38, Paul Menzel a écrit : Dear Linux folks, Am 29.07.21 um 10:23 schrieb Paul Menzel: I just wanted to make you aware that building Linux for ppc64le with clang/lld.ld fails with [1]: ld.lld: error: can't create dynamic relocation R_PPC64_ADDR64 against symbol:

Re: [PATCH v3 7/8] PCI: Replace pci_dev::driver usage by pci_dev::dev.driver

2021-08-11 Thread Boris Ostrovsky
On 8/11/21 4:06 AM, Uwe Kleine-König wrote: > struct pci_dev::driver contains (apart from a constant offset) the same > data as struct pci_dev::dev->driver. Replace all remaining users of the > former pointer by the latter to allow removing the former. > > Signed-off-by: Uwe Kleine-König Xen:

[PATCH v3 0/8] PCI: Drop duplicated tracking of a pci_dev's bound driver

2021-08-11 Thread Uwe Kleine-König
From: Uwe Kleine-König Hello, Today the following is always true for a struct pci_dev *pdev: pdev->driver == pdev->dev.driver ? to_pci_driver(pdev->dev.driver) : NULL This series is about getting rid of struct pci_dev::driver. The first three patches are unmodified

Re: [PATCH v1 16/55] powerpc/64s: Implement PMU override command line option

2021-08-11 Thread Madhavan Srinivasan
On 8/6/21 4:08 PM, Nicholas Piggin wrote: Excerpts from Madhavan Srinivasan's message of August 6, 2021 5:33 pm: On 7/26/21 9:19 AM, Nicholas Piggin wrote: It can be useful in simulators (with very constrained environments) to allow some PMCs to run from boot so they can be sampled directly

Re: [PATCH 07/11] treewide: Replace the use of mem_encrypt_active() with prot_guest_has()

2021-08-11 Thread Kirill A. Shutemov
On Tue, Aug 10, 2021 at 02:48:54PM -0500, Tom Lendacky wrote: > On 8/10/21 1:45 PM, Kuppuswamy, Sathyanarayanan wrote: > > > > > > On 7/27/21 3:26 PM, Tom Lendacky wrote: > >> diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c > >> index de01903c3735..cafed6456d45 100644 > >> ---

[PATCH] soc: fsl: qe: fix static checker warning

2021-08-11 Thread Maxim Kochetkov
The patch be7ecbd240b2: "soc: fsl: qe: convert QE interrupt controller to platform_device" from Aug 3, 2021, leads to the following static checker warning: drivers/soc/fsl/qe/qe_ic.c:438 qe_ic_init() warn: unsigned 'qe_ic->virq_low' is never less than zero. In old variant

Re: [PATCH v1 16/55] powerpc/64s: Implement PMU override command line option

2021-08-11 Thread Athira Rajeev
> On 06-Aug-2021, at 4:12 PM, Nicholas Piggin wrote: > > Excerpts from Athira Rajeev's message of August 6, 2021 7:28 pm: >> >> >>> On 26-Jul-2021, at 9:19 AM, Nicholas Piggin wrote: >>> >>> It can be useful in simulators (with very constrained environments) >>> to allow some PMCs to run

[powerpc:merge] BUILD SUCCESS 6f3d46e4a4a9ca09288540d39c0a31c9802d2602

2021-08-11 Thread kernel test robot
tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git merge branch HEAD: 6f3d46e4a4a9ca09288540d39c0a31c9802d2602 Automatic merge of 'fixes' into merge (2021-08-10 22:50) elapsed time: 1044m configs tested: 59 configs skipped: 3 The following configs have been built

[PATCH v3 7/8] PCI: Replace pci_dev::driver usage by pci_dev::dev.driver

2021-08-11 Thread Uwe Kleine-König
struct pci_dev::driver contains (apart from a constant offset) the same data as struct pci_dev::dev->driver. Replace all remaining users of the former pointer by the latter to allow removing the former. Signed-off-by: Uwe Kleine-König --- arch/powerpc/kernel/eeh_driver.c | 10 -

[PATCH v3 4/8] PCI: replace pci_dev::driver usage that gets the driver name

2021-08-11 Thread Uwe Kleine-König
struct pci_dev::driver holds (apart from a constant offset) the same data as struct pci_dev::dev->driver. With the goal to remove struct pci_dev::driver to get rid of data duplication replace getting the driver name by dev_driver_string() which implicitly makes use of struct pci_dev::dev->driver.

Re: [PATCH v2] powerpc/kprobes: Fix kprobe Oops happens in booke

2021-08-11 Thread Pu Lehui
On 2021/8/11 13:31, Christophe Leroy wrote: Le 11/08/2021 à 04:53, Pu Lehui a écrit : Ping, serious problem here. All booke ppc will trigger Oops when perform kprobes related operations. As far as I can see it is in the fixes branch: