Re: [PATCH] powerpc/64s: power4 nap fixup in C

2021-04-01 Thread Nicholas Piggin
Excerpts from Andreas Schwab's message of March 30, 2021 2:23 am: > On Mär 29 2021, Andreas Schwab wrote: > >> On Mär 29 2021, Michael Ellerman wrote: >> >>> Nicholas Piggin writes: There is no need for this to be in asm, use the new intrrupt entry wrapper. Signed-off-by: Nicholas

Re: [PATCH v2] powerpc/traps: Enhance readability for trap types

2021-04-01 Thread Nicholas Piggin
Excerpts from Michael Ellerman's message of April 1, 2021 12:39 pm: > Segher Boessenkool writes: >> On Wed, Mar 31, 2021 at 08:58:17PM +1100, Michael Ellerman wrote: >>> So perhaps: >>> >>> EXC_SYSTEM_RESET >>> EXC_MACHINE_CHECK >>> EXC_DATA_STORAGE >>> EXC_DATA_SEGMENT >>> EXC_INST_STO

Re: [PATCH v3 0/9] powerpc/xive: Map one IPI interrupt per node

2021-04-01 Thread Greg Kurz
On Wed, 31 Mar 2021 16:45:05 +0200 Cédric Le Goater wrote: > > Hello, > > ipistorm [*] can be used to benchmark the raw interrupt rate of an > interrupt controller by measuring the number of IPIs a system can > sustain. When applied to the XIVE interrupt controller of POWER9 and > POWER10 syste

Re: [PATCH v3 0/9] powerpc/xive: Map one IPI interrupt per node

2021-04-01 Thread Cédric Le Goater
Hello, On 3/31/21 4:45 PM, Cédric Le Goater wrote: > > Hello, > > ipistorm [*] can be used to benchmark the raw interrupt rate of an > interrupt controller by measuring the number of IPIs a system can > sustain. When applied to the XIVE interrupt controller of POWER9 and > POWER10 systems, a si

[PATCH V2 RESEND] mm/memtest: Add ARCH_USE_MEMTEST

2021-04-01 Thread Anshuman Khandual
early_memtest() does not get called from all architectures. Hence enabling CONFIG_MEMTEST and providing a valid memtest=[1..N] kernel command line option might not trigger the memory pattern tests as would be expected in normal circumstances. This situation is misleading. The change here prevents

Re: [PATCH 05/18] iommu/fsl_pamu: remove support for multiple windows

2021-04-01 Thread Christoph Hellwig
On Tue, Mar 30, 2021 at 01:22:34PM +0100, Will Deacon wrote: > > * win_arr contains information of the configured > > * windows for a domain. This is allocated only > > * when the number of windows for the domain are > > * set. > > */ > > The last part of this comment is n

Re: [PATCH 06/18] iommu/fsl_pamu: remove ->domain_window_enable

2021-04-01 Thread Christoph Hellwig
On Tue, Mar 30, 2021 at 01:40:09PM +0100, Will Deacon wrote: > > + ret = pamu_config_ppaace(liodn, geom->aperture_start, > > +geom->aperture_end - 1, ~(u32)0, > > You're passing 'geom->aperture_end - 1' as the size here, but the old code > seemed to _add_ 1: > > > -

Re: [PATCH v4 02/46] KVM: PPC: Book3S HV: Add a function to filter guest LPCR bits

2021-04-01 Thread Nicholas Piggin
Excerpts from Paul Mackerras's message of March 31, 2021 2:08 pm: > On Tue, Mar 23, 2021 at 11:02:21AM +1000, Nicholas Piggin wrote: >> Guest LPCR depends on hardware type, and future changes will add >> restrictions based on errata and guest MMU mode. Move this logic >> to a common function and us

Re: [PATCH 08/18] iommu/fsl_pamu: merge pamu_set_liodn and map_liodn

2021-04-01 Thread Christoph Hellwig
On Tue, Mar 30, 2021 at 01:46:51PM +0100, Will Deacon wrote: > > + ret = pamu_config_ppaace(liodn, geom->aperture_start, > > +geom->aperture_end - 1, ~(u32)0, > > +0, dma_domain->snoop_id, dma_domain->stash_id, > > +

Re: [PATCH v3 0/9] powerpc/xive: Map one IPI interrupt per node

2021-04-01 Thread Cédric Le Goater
Hello, On 4/1/21 10:04 AM, Greg Kurz wrote: > On Wed, 31 Mar 2021 16:45:05 +0200 > Cédric Le Goater wrote: > >> >> Hello, >> >> ipistorm [*] can be used to benchmark the raw interrupt rate of an >> interrupt controller by measuring the number of IPIs a system can >> sustain. When applied to the

Re: [PATCH 11/18] iommu/fsl_pamu: remove the snoop_id field

2021-04-01 Thread Christoph Hellwig
On Tue, Mar 30, 2021 at 01:58:17PM +0100, Will Deacon wrote: > pamu_config_ppaace() takes quite a few useless parameters at this stage, > but anyway: I'll see it it makes sense to throw in another patch at the end to cut it down a bit more. > Acked-by: Will Deacon > > Do you know if this driver

Re: [PATCH v4 04/46] KVM: PPC: Book3S HV: Prevent radix guests from setting LPCR[TC]

2021-04-01 Thread Nicholas Piggin
Excerpts from Paul Mackerras's message of March 31, 2021 2:34 pm: > On Tue, Mar 23, 2021 at 11:02:23AM +1000, Nicholas Piggin wrote: >> This bit only applies to hash partitions. >> >> Signed-off-by: Nicholas Piggin >> --- >> arch/powerpc/kvm/book3s_hv.c| 6 ++ >> arch/powerpc/kvm/boo

Re: [PATCH v4 09/46] powerpc/64s: remove KVM SKIP test from instruction breakpoint handler

2021-04-01 Thread Nicholas Piggin
Excerpts from Paul Mackerras's message of March 31, 2021 2:54 pm: > On Tue, Mar 23, 2021 at 11:02:28AM +1000, Nicholas Piggin wrote: >> The code being executed in KVM_GUEST_MODE_SKIP is hypervisor code with >> MSR[IR]=0, so the faults of concern are the d-side ones caused by access >> to guest cont

Re: [PATCH v4 11/46] KVM: PPC: Book3S HV: Ensure MSR[HV] is always clear in guest MSR

2021-04-01 Thread Nicholas Piggin
Excerpts from Paul Mackerras's message of March 31, 2021 2:58 pm: > On Tue, Mar 23, 2021 at 11:02:30AM +1000, Nicholas Piggin wrote: >> Rather than clear the HV bit from the MSR at guest entry, make it clear >> that the hypervisor does not allow the guest to set the bit. >> >> The HV clear is kept

Re: [PATCH v3 1/9] powerpc/xive: Use cpu_to_node() instead of "ibm,chip-id" property

2021-04-01 Thread Cédric Le Goater
On 4/1/21 4:49 AM, David Gibson wrote: > On Wed, Mar 31, 2021 at 04:45:06PM +0200, Cédric Le Goater wrote: >> The 'chip_id' field of the XIVE CPU structure is used to choose a >> target for a source located on the same chip when possible. The XIVE >> driver queries the chip id value from the "ibm,c

Re: [PATCH v4 13/46] KVM: PPC: Book3S 64: Move GUEST_MODE_SKIP test into KVM

2021-04-01 Thread Nicholas Piggin
Excerpts from Paul Mackerras's message of April 1, 2021 3:32 pm: > On Tue, Mar 23, 2021 at 11:02:32AM +1000, Nicholas Piggin wrote: >> Move the GUEST_MODE_SKIP logic into KVM code. This is quite a KVM >> internal detail that has no real need to be in common handlers. >> >> Also add a comment expla

Re: [PATCH 16/18] iommu: remove DOMAIN_ATTR_DMA_USE_FLUSH_QUEUE

2021-04-01 Thread Christoph Hellwig
For now I'll just pass the iommu_domain to iommu_get_dma_strict, so that we can check for it. We can do additional cleanups on top of that later.

Re: [PATCH v4 15/46] KVM: PPC: Book3S 64: Move hcall early register setup to KVM

2021-04-01 Thread Nicholas Piggin
Excerpts from Paul Mackerras's message of April 1, 2021 3:41 pm: > On Tue, Mar 23, 2021 at 11:02:34AM +1000, Nicholas Piggin wrote: >> System calls / hcalls have a different calling convention than >> other interrupts, so there is code in the KVMTEST to massage these >> into the same form as other

Re: [PATCH v4 24/46] KVM: PPC: Book3S HV P9: Use large decrementer for HDEC

2021-04-01 Thread Nicholas Piggin
Excerpts from Alexey Kardashevskiy's message of March 26, 2021 12:05 pm: > > > On 23/03/2021 12:02, Nicholas Piggin wrote: >> 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 gues

Re: [PATCH] soc/fsl: qbman: fix conflicting alignment attributes

2021-04-01 Thread Arnd Bergmann
From: Arnd Bergmann On Tue, 23 Mar 2021 14:15:23 +0100, Arnd Bergmann wrote: > When building with W=1, gcc points out that the __packed attribute > on struct qm_eqcr_entry conflicts with the 8-byte alignment > attribute on struct qm_fd inside it: > > drivers/soc/fsl/qbman/qman.c:189:1: error: al

Re: [PATCH v4 29/46] KVM: PPC: Book3S HV P9: Implement the rest of the P9 path in C

2021-04-01 Thread Nicholas Piggin
Excerpts from Alexey Kardashevskiy's message of April 1, 2021 3:30 pm: > > > On 3/23/21 12:02 PM, Nicholas Piggin wrote: >> Almost all logic is moved to C, by introducing a new in_guest mode that >> selects and branches very early in the interrupt handler to the P9 exit >> code. [...] >> +/* >>

[RFC 2/2] sched: Use H_IDLE_HINT hcall to find if a vCPU can be wakeup target

2021-04-01 Thread Parth Shah
During checking for an available_idle_cpu, if the vCPU is yielded then check if it will be scheduled instantly by hypervisor or not. From guestOS, use H_IDLE_HINT hcall to ask for this hint from the hypverisor, and consider the yielded vCPU as target for wakeups iff it is hinted to be scheduled ins

[RFC 1/2] KVM:PPC: Add new hcall to provide hint if a vcpu task will be scheduled instantly.

2021-04-01 Thread Parth Shah
H_IDLE_HINT is a new hcall introduced to provide a hint to the guestOS indicating if a given vCPU can be scheduled instantly or not. The task scheduler generally prefers previous cpu of a task if it is available_idle. So if a prev_cpu of the corresponding vCPU task_struct is found to be available_

[RFC 0/2] Define a new apporach to determine if an idle vCPU will be scheduled instantly or not

2021-04-01 Thread Parth Shah
Abstract: = The Linux task scheduler tries to find an idle cpu for a wakee task thereby lowering the wakeup latency as much as possible. The process of determining if a cpu is idle or not has evolved over time. Currently, a cpu is considered idle if - there are no task running or enqueued

Re: [PATCH v3 0/9] powerpc/xive: Map one IPI interrupt per node

2021-04-01 Thread Greg Kurz
On Thu, 1 Apr 2021 11:18:10 +0200 Cédric Le Goater wrote: > Hello, > > On 4/1/21 10:04 AM, Greg Kurz wrote: > > On Wed, 31 Mar 2021 16:45:05 +0200 > > Cédric Le Goater wrote: > > > >> > >> Hello, > >> > >> ipistorm [*] can be used to benchmark the raw interrupt rate of an > >> interrupt contro

Re: [PATCH v3 8/9] powerpc/xive: Map one IPI interrupt per node

2021-04-01 Thread Nicholas Piggin
Excerpts from Cédric Le Goater's message of April 1, 2021 12:45 am: > ipistorm [*] can be used to benchmark the raw interrupt rate of an > interrupt controller by measuring the number of IPIs a system can > sustain. When applied to the XIVE interrupt controller of POWER9 and > POWER10 systems, a si

Re: [PATCH printk v2 2/5] printk: remove safe buffers

2021-04-01 Thread John Ogness
On 2021-04-01, Petr Mladek wrote: >> --- a/kernel/printk/printk.c >> +++ b/kernel/printk/printk.c >> @@ -1142,24 +1128,37 @@ void __init setup_log_buf(int early) >> new_descs, ilog2(new_descs_count), >> new_infos); >> >> -printk_safe_enter_irqsave(flags); >> +

Re: [PATCH 16/18] iommu: remove DOMAIN_ATTR_DMA_USE_FLUSH_QUEUE

2021-04-01 Thread Will Deacon
On Thu, Apr 01, 2021 at 11:59:45AM +0200, Christoph Hellwig wrote: > For now I'll just pass the iommu_domain to iommu_get_dma_strict, > so that we can check for it. We can do additional cleanups on top > of that later. Sounds good to me, cheers! Will

Re: [PATCH v4 02/46] KVM: PPC: Book3S HV: Add a function to filter guest LPCR bits

2021-04-01 Thread Nicholas Piggin
Excerpts from Nicholas Piggin's message of April 1, 2021 7:32 pm: > Excerpts from Paul Mackerras's message of March 31, 2021 2:08 pm: >> On Tue, Mar 23, 2021 at 11:02:21AM +1000, Nicholas Piggin wrote: >>> Guest LPCR depends on hardware type, and future changes will add >>> restrictions based on er

[PATCH 2/3] powerpc/8xx: Define a MODULE area below kernel text

2021-04-01 Thread Christophe Leroy
On the 8xx, TASK_SIZE is 0x8000. The space between TASK_SIZE and PAGE_OFFSET is not used. In order to benefit from the powerpc specific module_alloc() function which allocate modules with 32 Mbytes from end of kernel text, define MODULES_VADDR and MODULES_END. Set a 256Mb area just below PAGE

[PATCH 3/3] powerpc/32s: Define a MODULE area below kernel text all the time

2021-04-01 Thread Christophe Leroy
On book3s/32, the segment below kernel text is used for module allocation when CONFIG_STRICT_KERNEL_RWX is defined. In order to benefit from the powerpc specific module_alloc() function which allocate modules with 32 Mbytes from end of kernel text, use that segment below PAGE_OFFSET at all time.

[PATCH 1/3] powerpc/modules: Load modules closer to kernel text

2021-04-01 Thread Christophe Leroy
On book3s/32, when STRICT_KERNEL_RWX is selected, modules are allocated on the segment just before kernel text, ie on the 0xb000-0xbfff when PAGE_OFFSET is 0xc000. On the 8xx, TASK_SIZE is 0x8000. The space between TASK_SIZE and PAGE_OFFSET is not used and could be used for modules

Re: [PATCH v10 03/10] powerpc: Always define MODULES_{VADDR,END}

2021-04-01 Thread Christophe Leroy
Le 30/03/2021 à 06:51, Jordan Niethe a écrit : If MODULES_{VADDR,END} are not defined set them to VMALLOC_START and VMALLOC_END respectively. This reduces the need for special cases. For example, powerpc's module_alloc() was previously predicated on MODULES_VADDR being defined but now is uncon

Re: [PATCH 3/3] powerpc/sstep: Always test lmw and stmw

2021-04-01 Thread Michael Ellerman
Hi Jordan, Jordan Niethe writes: > Load Multiple Word (lmw) and Store Multiple Word (stmw) will raise an > Alignment Exception: > - Little Endian mode: always > - Big Endian mode: address not word aligned > > These conditions do not depend on cache inhibited memory. Test the > alignment handl

Re: [PATCH] powerpc/8xx: Load modules closer to kernel text

2021-04-01 Thread Christophe Leroy
Le 01/04/2021 à 06:33, Michael Ellerman a écrit : Christophe Leroy writes: Le 31/03/2021 à 15:39, Michael Ellerman a écrit : Christophe Leroy writes: On the 8xx, TASK_SIZE is 0x8000. The space between TASK_SIZE and PAGE_OFFSET is not used. Use it to load modules in order to minimise

[PATCH v5 00/48] KVM: PPC: Book3S: C-ify the P9 entry/exit code

2021-04-01 Thread Nicholas Piggin
Git tree here https://github.com/npiggin/linux/tree/kvm-in-c-v5 Now tested on P10 with hash host and radix host with hash and radix guests with some basic kbuild stress testing. Main changes since v4: - Accounted for reviews so far. Comment and changelog fixes. - Fix PR KVM register clobber [Pa

[PATCH v5 01/48] KVM: PPC: Book3S HV: Nested move LPCR sanitising to sanitise_hv_regs

2021-04-01 Thread Nicholas Piggin
This will get a bit more complicated in future patches. Move it into the helper function. This change allows the L1 hypervisor to determine some of the LPCR bits that the L0 is using to run it, which could be a privilege violation (LPCR is HV-privileged), although the same problem exists now for H

[PATCH v5 02/48] KVM: PPC: Book3S HV: Add a function to filter guest LPCR bits

2021-04-01 Thread Nicholas Piggin
Guest LPCR depends on hardware type, and future changes will add restrictions based on errata and guest MMU mode. Move this logic to a common function and use it for the cases where the guest wants to update its LPCR (or the LPCR of a nested guest). This also adds a warning in other places that se

[PATCH v5 03/48] KVM: PPC: Book3S HV: Disallow LPCR[AIL] to be set to 1 or 2

2021-04-01 Thread Nicholas Piggin
These are already disallowed by H_SET_MODE from the guest, also disallow these by updating LPCR directly. AIL modes can affect the host interrupt behaviour while the guest LPCR value is set, so filter it here too. Acked-by: Paul Mackerras Suggested-by: Fabiano Rosas Signed-off-by: Nicholas Pigg

[PATCH v5 04/48] KVM: PPC: Book3S HV: Prevent radix guests setting LPCR[TC]

2021-04-01 Thread Nicholas Piggin
Prevent radix guests setting LPCR[TC]. This bit only applies to hash partitions. Reviewed-by: Alexey Kardashevskiy Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c | 4 1 file changed, 4 insertions(+) diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c

[PATCH v5 06/48] KVM: PPC: Book3S HV: remove unused kvmppc_h_protect argument

2021-04-01 Thread Nicholas Piggin
The va argument is not used in the function or set by its asm caller, so remove it to be safe. Acked-by: Paul Mackerras Reviewed-by: Daniel Axtens Signed-off-by: Nicholas Piggin --- arch/powerpc/include/asm/kvm_ppc.h | 3 +-- arch/powerpc/kvm/book3s_hv_rm_mmu.c | 3 +-- 2 files changed, 2 ins

[PATCH v5 05/48] KVM: PPC: Book3S HV: Remove redundant mtspr PSPB

2021-04-01 Thread Nicholas Piggin
This SPR is set to 0 twice when exiting the guest. Acked-by: Paul Mackerras Suggested-by: Fabiano Rosas Reviewed-by: Daniel Axtens Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm

[PATCH v5 08/48] powerpc/64s: Remove KVM handler support from CBE_RAS interrupts

2021-04-01 Thread Nicholas Piggin
Cell does not support KVM. Acked-by: Paul Mackerras Reviewed-by: Fabiano Rosas Signed-off-by: Nicholas Piggin --- arch/powerpc/kernel/exceptions-64s.S | 6 -- 1 file changed, 6 deletions(-) diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S index 808

[PATCH v5 07/48] KVM: PPC: Book3S HV: Fix CONFIG_SPAPR_TCE_IOMMU=n default hcalls

2021-04-01 Thread Nicholas Piggin
This config option causes the warning in init_default_hcalls to fire because the TCE handlers are in the default hcall list but not implemented. Acked-by: Paul Mackerras Reviewed-by: Daniel Axtens Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c | 2 ++ 1 file changed, 2 inserti

[PATCH v5 09/48] powerpc/64s: remove KVM SKIP test from instruction breakpoint handler

2021-04-01 Thread Nicholas Piggin
The code being executed in KVM_GUEST_MODE_SKIP is hypervisor code with MSR[IR]=0, so the faults of concern are the d-side ones caused by access to guest context by the hypervisor. Instruction breakpoint interrupts are not a concern here. It's unlikely any good would come of causing breaks in this

[PATCH v5 10/48] KVM: PPC: Book3S HV: Ensure MSR[ME] is always set in guest MSR

2021-04-01 Thread Nicholas Piggin
Rather than add the ME bit to the MSR at guest entry, make it clear that the hypervisor does not allow the guest to clear the bit. The ME set is kept in guest entry for now, but a future patch will warn if it's not present. Acked-by: Paul Mackerras Reviewed-by: Daniel Axtens Reviewed-by: Fabian

[PATCH v5 11/48] KVM: PPC: Book3S HV: Ensure MSR[HV] is always clear in guest MSR

2021-04-01 Thread Nicholas Piggin
Rather than clear the HV bit from the MSR at guest entry, make it clear that the hypervisor does not allow the guest to set the bit. The HV clear is kept in guest entry for now, but a future patch will warn if it is present. Acked-by: Paul Mackerras Signed-off-by: Nicholas Piggin --- arch/powe

[PATCH v5 12/48] KVM: PPC: Book3S 64: move KVM interrupt entry to a common entry point

2021-04-01 Thread Nicholas Piggin
Rather than bifurcate the call depending on whether or not HV is possible, and have the HV entry test for PR, just make a single common point which does the demultiplexing. This makes it simpler to add another type of exit handler. Acked-by: Paul Mackerras Reviewed-by: Daniel Axtens Reviewed-by:

[PATCH v5 13/48] KVM: PPC: Book3S 64: Move GUEST_MODE_SKIP test into KVM

2021-04-01 Thread Nicholas Piggin
Move the GUEST_MODE_SKIP logic into KVM code. This is quite a KVM internal detail that has no real need to be in common handlers. Also add a comment explaining why this thing exists. Reviewed-by: Daniel Axtens Reviewed-by: Fabiano Rosas Signed-off-by: Nicholas Piggin --- arch/powerpc/kernel/e

[PATCH v5 14/48] KVM: PPC: Book3S 64: add hcall interrupt handler

2021-04-01 Thread Nicholas Piggin
Add a separate hcall entry point. This can be used to deal with the different calling convention. Reviewed-by: Daniel Axtens Reviewed-by: Fabiano Rosas Signed-off-by: Nicholas Piggin --- arch/powerpc/kernel/exceptions-64s.S | 6 +++--- arch/powerpc/kvm/book3s_64_entry.S | 6 +- 2 files c

[PATCH v5 15/48] KVM: PPC: Book3S 64: Move hcall early register setup to KVM

2021-04-01 Thread Nicholas Piggin
System calls / hcalls have a different calling convention than other interrupts, so there is code in the KVMTEST to massage these into the same form as other interrupt handlers. Move this work into the KVM hcall handler. This means teaching KVM a little more about the low level interrupt handler s

[PATCH v5 16/48] KVM: PPC: Book3S 64: Move interrupt early register setup to KVM

2021-04-01 Thread Nicholas Piggin
Like the earlier patch for hcalls, KVM interrupt entry requires a different calling convention than the Linux interrupt handlers set up. Move the code that converts from one to the other into KVM. Signed-off-by: Nicholas Piggin --- arch/powerpc/kernel/exceptions-64s.S | 131 +

[PATCH v5 17/48] KVM: PPC: Book3S 64: move bad_host_intr check to HV handler

2021-04-01 Thread Nicholas Piggin
This is not used by PR KVM. Reviewed-by: Alexey Kardashevskiy Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_64_entry.S | 4 arch/powerpc/kvm/book3s_hv_rmhandlers.S | 4 +++- arch/powerpc/kvm/book3s_segment.S | 3 +++ 3 files changed, 6 insertions(+), 5 deletions(-)

[PATCH v5 18/48] KVM: PPC: Book3S 64: Minimise hcall handler calling convention differences

2021-04-01 Thread Nicholas Piggin
This sets up the same calling convention from interrupt entry to KVM interrupt handler for system calls as exists for other interrupt types. This is a better API, it uses a save area rather than SPR, and it has more registers free to use. Using a single common API helps maintain it, and it becomes

[PATCH v5 19/48] KVM: PPC: Book3S HV P9: Move radix MMU switching instructions together

2021-04-01 Thread Nicholas Piggin
Switching the MMU from radix<->radix mode is tricky particularly as the MMU can remain enabled and requires a certain sequence of SPR updates. Move these together into their own functions. This also includes the radix TLB check / flush because it's tied in to MMU switching due to tlbiel getting LP

[PATCH v5 20/48] KVM: PPC: Book3S HV P9: implement kvmppc_xive_pull_vcpu in C

2021-04-01 Thread Nicholas Piggin
This is more symmetric with kvmppc_xive_push_vcpu. The extra test in the asm will go away in a later change. Reviewed-by: Cédric Le Goater Reviewed-by: Alexey Kardashevskiy Signed-off-by: Nicholas Piggin --- arch/powerpc/include/asm/kvm_ppc.h | 2 ++ arch/powerpc/kvm/book3s_hv.c

[PATCH v5 21/48] KVM: PPC: Book3S HV P9: Move xive vcpu context management into kvmhv_p9_guest_entry

2021-04-01 Thread Nicholas Piggin
Move the xive management up so the low level register switching can be pushed further down in a later patch. XIVE MMIO CI operations can run in higher level code with machine checks, tracing, etc., available. Reviewed-by: Alexey Kardashevskiy Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/

[PATCH v5 22/48] KVM: PPC: Book3S HV P9: Stop handling hcalls in real-mode in the P9 path

2021-04-01 Thread Nicholas Piggin
In the interest of minimising the amount of code that is run in "real-mode", don't handle hcalls in real mode in the P9 path. POWER8 and earlier are much more expensive to exit from HV real mode and switch to host mode, because on those processors HV interrupts get to the hypervisor with the MMU o

[PATCH v5 23/48] KVM: PPC: Book3S HV P9: Move setting HDEC after switching to guest LPCR

2021-04-01 Thread Nicholas Piggin
LPCR[HDICE]=0 suppresses hypervisor decrementer exceptions on some processors, so it must be enabled before HDEC is set. Rather than set it in the host LPCR then setting HDEC, move the HDEC update to after the guest MMU context (including LPCR) is loaded. There shouldn't be much concern with delay

[PATCH v5 24/48] KVM: PPC: Book3S HV P9: Use large decrementer for HDEC

2021-04-01 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 ++ arch/powerpc/kerne

[PATCH v5 25/48] KVM: PPC: Book3S HV P9: Use host timer accounting to avoid decrementer read

2021-04-01 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. Signed-off-by: Nicholas Piggin --- arch/powerpc/include/asm/time.h | 5 + arch/powerpc/kernel/time.c | 1 + arch/powerpc/kvm/book3s_hv.c| 14 +

[PATCH v5 26/48] KVM: PPC: Book3S HV P9: Reduce mftb per guest entry/exit

2021-04-01 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 | 9 ++

[PATCH v5 27/48] KVM: PPC: Book3S HV P9: Reduce irq_work vs guest decrementer races

2021-04-01 Thread Nicholas Piggin
irq_work's use of the DEC SPR is racy with guest<->host switch and guest entry which flips the DEC interrupt to guest, which could lose a host work interrupt. This patch closes one race, and attempts to comment another class of races. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_h

[PATCH v5 28/48] KMV: PPC: Book3S HV: Use set_dec to set decrementer to host

2021-04-01 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 m

[PATCH v5 29/48] powerpc: add set_dec_or_work API for safely updating decrementer

2021-04-01 Thread Nicholas Piggin
Decrementer updates must always check for new irq work to avoid an irq work decrementer interrupt being lost. Add an API for this in the timer code so callers don't have to care about details. Reviewed-by: Alexey Kardashevskiy Signed-off-by: Nicholas Piggin --- arch/powerpc/include/asm/time.h

[PATCH v5 30/48] KVM: PPC: Book3S HV P9: Implement the rest of the P9 path in C

2021-04-01 Thread Nicholas Piggin
Almost all logic is moved to C, by introducing a new in_guest mode that selects and branches very early in the interrupt handler to the P9 exit code. The remaining assembly is only about 160 lines of low level stack setup, with VCPU vs host register save and restore, plus a small shim to the legac

[PATCH v5 31/48] KVM: PPC: Book3S HV P9: inline kvmhv_load_hv_regs_and_go into __kvmhv_vcpu_entry_p9

2021-04-01 Thread Nicholas Piggin
Now the initial C implementation is done, inline more HV code to make rearranging things easier. And rename __kvmhv_vcpu_entry_p9 to drop the leading underscores as it's now C, and is now a more complete vcpu entry. Reviewed-by: Fabiano Rosas Signed-off-by: Nicholas Piggin --- arch/powerpc/inc

[PATCH v5 32/48] KVM: PPC: Book3S HV P9: Read machine check registers while MSR[RI] is 0

2021-04-01 Thread Nicholas Piggin
SRR0/1, DAR, DSISR must all be protected from machine check which can clobber them. Ensure MSR[RI] is clear while they are live. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c | 11 +++-- arch/powerpc/kvm/book3s_hv_interrupt.c | 33 +++--- arch/

[PATCH v5 33/48] KVM: PPC: Book3S HV P9: Improve exit timing accounting coverage

2021-04-01 Thread Nicholas Piggin
The C conversion caused exit timing to become a bit cramped. Expand it to cover more of the entry and exit code. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv_interrupt.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/kvm/book3s_hv_interr

[PATCH v5 34/48] KVM: PPC: Book3S HV P9: Move SPR loading after expiry time check

2021-04-01 Thread Nicholas Piggin
This is wasted work if the time limit is exceeded. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv_interrupt.c | 36 -- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/arch/powerpc/kvm/book3s_hv_interrupt.c b/arch/powerpc/kvm/book3s_hv_inter

[PATCH v5 35/48] KVM: PPC: Book3S HV P9: Add helpers for OS SPR handling

2021-04-01 Thread Nicholas Piggin
This is a first step to wrapping supervisor and user SPR saving and loading up into helpers, which will then be called independently in bare metal and nested HV cases in order to optimise SPR access. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c | 141 ++

[PATCH v5 36/48] KVM: PPC: Book3S HV P9: Switch to guest MMU context as late as possible

2021-04-01 Thread Nicholas Piggin
Move MMU context switch as late as reasonably possible to minimise code running with guest context switched in. This becomes more important when this code may run in real-mode, with later changes. Move WARN_ON as early as possible so program check interrupts are less likely to tangle everything up

[PATCH v5 37/48] KVM: PPC: Book3S HV: Implement radix prefetch workaround by disabling MMU

2021-04-01 Thread Nicholas Piggin
Rather than partition the guest PID space + flush a rogue guest PID to work around this problem, instead fix it by always disabling the MMU when switching in or out of guest MMU context in HV mode. This may be a bit less efficient, but it is a lot less complicated and allows the P9 path to trivall

[PATCH v5 38/48] KVM: PPC: Book3S HV: Remove support for dependent threads mode on P9

2021-04-01 Thread Nicholas Piggin
Radix guest support will be removed from the P7/8 path, so disallow dependent threads mode on P9. Signed-off-by: Nicholas Piggin --- arch/powerpc/include/asm/kvm_host.h | 1 - arch/powerpc/kvm/book3s_hv.c| 27 +-- 2 files changed, 5 insertions(+), 23 deletions(-)

[PATCH v5 39/48] KVM: PPC: Book3S HV: Remove radix guest support from P7/8 path

2021-04-01 Thread Nicholas Piggin
The P9 path now runs all supported radix guest combinations, so remove radix guest support from the P7/8 path. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv_rmhandlers.S | 79 + 1 file changed, 3 insertions(+), 76 deletions(-) diff --git a/arch/powerpc/kv

[PATCH v5 40/48] KVM: PPC: Book3S HV: Remove virt mode checks from real mode handlers

2021-04-01 Thread Nicholas Piggin
Now that the P7/8 path no longer supports radix, real-mode handlers do not need to deal with being called in virt mode. This change effectively reverts commit acde25726bc6 ("KVM: PPC: Book3S HV: Add radix checks in real-mode hypercall handlers"). It removes a few more real-mode tests in rm hcall

[PATCH v5 41/48] KVM: PPC: Book3S HV: Remove unused nested HV tests in XICS emulation

2021-04-01 Thread Nicholas Piggin
Commit f3c18e9342a44 ("KVM: PPC: Book3S HV: Use XICS hypercalls when running as a nested hypervisor") added nested HV tests in XICS hypercalls, but not all are required. * icp_eoi is only called by kvmppc_deliver_irq_passthru which is only called by kvmppc_check_passthru which is only caled by

[PATCH v5 42/48] KVM: PPC: Book3S HV: Radix guests should not have userspace hcalls reflected to them

2021-04-01 Thread Nicholas Piggin
The reflection of sc 1 hcalls from PR=1 userspace is required to support PR KVM. Radix guests don't support PR KVM nor do they support nested hash guests, so this sc 1 reflection can be removed from radix guests. Cause a privileged program check instead, which is less surprising. Signed-off-by: Ni

[PATCH v5 43/48] KVM: PPC: Book3S HV P9: Allow all P9 processors to enable nested HV

2021-04-01 Thread Nicholas Piggin
All radix guests go via the P9 path now, so there is no need to limit nested HV to processors that support "mixed mode" MMU. Remove the restriction. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/kv

[PATCH v5 44/48] KVM: PPC: Book3S HV: small pseries_do_hcall cleanup

2021-04-01 Thread Nicholas Piggin
Functionality should not be changed. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c | 29 +++-- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index f4fa39f4cd4c..8416ec0d88bc 10

[PATCH v5 45/48] KVM: PPC: Book3S HV: add virtual mode handlers for HPT hcalls and page faults

2021-04-01 Thread Nicholas Piggin
In order to support hash guests in the P9 path (which does not do real mode hcalls or page fault handling), these real-mode hash specific interrupts need to be implemented in virt mode. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c| 126 ++-- arc

[PATCH v5 46/48] KVM: PPC: Book3S HV P9: implement hash guest support

2021-04-01 Thread Nicholas Piggin
Guest entry/exit has to restore and save/clear the SLB, plus several other bits to accommodate hash guests in the P9 path. Radix host, hash guest support is removed from the P7/8 path. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c| 20 ++- arch/powerpc/kvm/book3s_

[PATCH v5 47/48] KVM: PPC: Book3S HV P9: implement hash host / hash guest support

2021-04-01 Thread Nicholas Piggin
This additionally has to save and restore the host SLB, and also ensure that the MMU is off while switching into the guest SLB. P9 and later CPUs now always go via the P9 path. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_64_entry.S | 6 + arch/powerpc/kvm/book3s_hv.c

[PATCH v5 48/48] KVM: PPC: Book3S HV: remove ISA v3.0 and v3.1 support from P7/8 path

2021-04-01 Thread Nicholas Piggin
POWER9 and later processors always go via the P9 guest entry path now. Remove the remaining support from the P7/8 path. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c| 62 ++-- arch/powerpc/kvm/book3s_hv_interrupts.S | 9 +- arch/powerpc/kvm/book3s_hv_rmhandlers.S

[PATCH 1/1] powerpc/smp: Set numa node before updating mask

2021-04-01 Thread Srikar Dronamraju
Geethika reported a trace when doing a dlpar CPU add. [ cut here ] WARNING: CPU: 152 PID: 1134 at kernel/sched/topology.c:2057 CPU: 152 PID: 1134 Comm: kworker/152:1 Not tainted 5.12.0-rc5-master #5 Workqueue: events cpuset_hotplug_workfn NIP: c01cfc14 LR: c000

[PATCH 02/20] iommu/fsl_pamu: remove fsl_pamu_get_domain_attr

2021-04-01 Thread Christoph Hellwig
None of the values returned by this function are ever queried. Also remove the DOMAIN_ATTR_FSL_PAMUV1 enum value that is not otherwise used. Signed-off-by: Christoph Hellwig Acked-by: Will Deacon Acked-by: Li Yang --- drivers/iommu/fsl_pamu_domain.c | 30 -- includ

[PATCH 03/20] iommu/fsl_pamu: remove support for setting DOMAIN_ATTR_GEOMETRY

2021-04-01 Thread Christoph Hellwig
The default geometry is the same as the one set by qman_port given that FSL_PAMU depends on having 64-bit physical and thus DMA addresses. Remove the support to update the geometry and remove the now pointless geom_size field. Signed-off-by: Christoph Hellwig Acked-by: Will Deacon Acked-by: Li

[PATCH 05/20] iommu/fsl_pamu: remove support for multiple windows

2021-04-01 Thread Christoph Hellwig
The only domains allocated forces use of a single window. Remove all the code related to multiple window support, as well as the need for qman_portal to force a single window. Remove the now unused DOMAIN_ATTR_WINDOWS iommu_attr. Signed-off-by: Christoph Hellwig Acked-by: Will Deacon Acked-by:

[PATCH 04/20] iommu/fsl_pamu: merge iommu_alloc_dma_domain into fsl_pamu_domain_alloc

2021-04-01 Thread Christoph Hellwig
Keep the functionality to allocate the domain together. Signed-off-by: Christoph Hellwig Acked-by: Will Deacon Acked-by: Li Yang --- drivers/iommu/fsl_pamu_domain.c | 34 ++--- 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/drivers/iommu/fsl_pamu_do

[PATCH 06/20] iommu/fsl_pamu: remove ->domain_window_enable

2021-04-01 Thread Christoph Hellwig
The only thing that fsl_pamu_window_enable does for the current caller is to fill in the prot value in the only dma_window structure, and to propagate a few values from the iommu_domain_geometry struture into the dma_window. Remove the dma_window entirely, hardcode the prot value and otherwise use

[PATCH 01/20] iommu: remove the unused domain_window_disable method

2021-04-01 Thread Christoph Hellwig
domain_window_disable is wired up by fsl_pamu, but never actually called. Signed-off-by: Christoph Hellwig Acked-by: Will Deacon Acked-by: Li Yang --- drivers/iommu/fsl_pamu_domain.c | 48 - include/linux/iommu.h | 2 -- 2 files changed, 50 deletions(

cleanup unused or almost unused IOMMU APIs and the FSL PAMU driver v3

2021-04-01 Thread Christoph Hellwig
Hi all, there are a bunch of IOMMU APIs that are entirely unused, or only used as a private communication channel between the FSL PAMU driver and it's only consumer, the qbman portal driver. So this series drops a huge chunk of entirely unused FSL PAMU functionality, then drops all kinds of unuse

[PATCH 07/20] iommu/fsl_pamu: replace DOMAIN_ATTR_FSL_PAMU_STASH with a direct call

2021-04-01 Thread Christoph Hellwig
Add a fsl_pamu_configure_l1_stash API that qman_portal can call directly instead of indirecting through the iommu attr API. Signed-off-by: Christoph Hellwig Acked-by: Will Deacon Acked-by: Li Yang --- arch/powerpc/include/asm/fsl_pamu_stash.h | 12 +++- drivers/iommu/fsl_pamu_domain.c

[PATCH 08/20] iommu/fsl_pamu: merge pamu_set_liodn and map_liodn

2021-04-01 Thread Christoph Hellwig
Merge the two fuctions that configure the ppaace into a single coherent function. I somehow doubt we need the two pamu_config_ppaace calls, but keep the existing behavior just to be on the safe side. Signed-off-by: Christoph Hellwig Acked-by: Li Yang --- drivers/iommu/fsl_pamu_domain.c | 65 ++

[PATCH 09/20] iommu/fsl_pamu: merge handle_attach_device into fsl_pamu_attach_device

2021-04-01 Thread Christoph Hellwig
No good reason to split this functionality over two functions. Signed-off-by: Christoph Hellwig Acked-by: Will Deacon Acked-by: Li Yang --- drivers/iommu/fsl_pamu_domain.c | 59 +++-- 1 file changed, 20 insertions(+), 39 deletions(-) diff --git a/drivers/iommu/fsl_

[PATCH 10/20] iommu/fsl_pamu: enable the liodn when attaching a device

2021-04-01 Thread Christoph Hellwig
Instead of a separate call to enable all devices from the list, just enable the liodn once the device is attached to the iommu domain. This also remove the DOMAIN_ATTR_FSL_PAMU_ENABLE iommu_attr. Signed-off-by: Christoph Hellwig Acked-by: Will Deacon Acked-by: Li Yang --- drivers/iommu/fsl_pa

[PATCH 11/20] iommu/fsl_pamu: remove the snoop_id field

2021-04-01 Thread Christoph Hellwig
The snoop_id is always set to ~(u32)0. Signed-off-by: Christoph Hellwig Acked-by: Will Deacon Acked-by: Li Yang --- drivers/iommu/fsl_pamu_domain.c | 5 ++--- drivers/iommu/fsl_pamu_domain.h | 1 - 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/fsl_pamu_domain.c b

[PATCH 12/20] iommu/fsl_pamu: remove the rpn and snoop_id arguments to pamu_config_ppaac

2021-04-01 Thread Christoph Hellwig
These are always wired to fixed values, so don't bother passing them as arguments. Signed-off-by: Christoph Hellwig --- drivers/iommu/fsl_pamu.c| 14 +++--- drivers/iommu/fsl_pamu.h| 3 +-- drivers/iommu/fsl_pamu_domain.c | 6 +++--- 3 files changed, 7 insertions(+), 16

[PATCH 13/20] iommu/fsl_pamu: hardcode the window address and size in pamu_config_ppaace

2021-04-01 Thread Christoph Hellwig
The win_addr and win_size parameters are always set to 0 and 1 << 36 respectively, so just hard code them. Signed-off-by: Christoph Hellwig --- drivers/iommu/fsl_pamu.c| 23 --- drivers/iommu/fsl_pamu.h| 3 +-- drivers/iommu/fsl_pamu_domain.c | 10 ++

[PATCH 14/20] iommu: remove DOMAIN_ATTR_PAGING

2021-04-01 Thread Christoph Hellwig
DOMAIN_ATTR_PAGING is never used. Signed-off-by: Christoph Hellwig Acked-by: Will Deacon Acked-by: Li Yang --- drivers/iommu/iommu.c | 5 - include/linux/iommu.h | 1 - 2 files changed, 6 deletions(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index b212bf0261820b..9a4cda3

  1   2   >