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

2021-04-01 Thread Alexey Kardashevskiy
On 01/04/2021 21:35, Nicholas Piggin wrote: 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

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

2021-04-01 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 v5.12-rc5 next-20210401] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented

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

2021-04-01 Thread Srikar Dronamraju
* Nathan Lynch [2021-04-01 17:51:05]: Thanks Nathan for reviewing. > > - set_numa_node(numa_cpu_lookup_table[cpu]); > > - set_numa_mem(local_memory_node(numa_cpu_lookup_table[cpu])); > > - > > Regardless of your change: at boot time, this set of calls to > set_numa_node() and

[PATCH] powerpc/powernv: Enable HAIL (HV AIL) for ISA v3.1 processors

2021-04-01 Thread Nicholas Piggin
Starting with ISA v3.1, LPCR[AIL] no longer controls the interrupt mode for HV=1 interrupts. Instead, a new LPCR[HAIL] bit is defined which behaves like AIL=3 for HV interrupts when set. Set HAIL on bare metal to give us mmu-on interrupts and improve performance. This also fixes an scv bug: we

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

2021-04-01 Thread Sergey Senozhatsky
On (21/04/01 16:17), Petr Mladek wrote: > > For the long term, we should introduce a printk-context API that allows > > callers to perfectly pack their multi-line output into a single > > entry. We discussed [0][1] this back in August 2020. > > We need a "short" term solution. There are currently

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

2021-04-01 Thread Nicholas Piggin
Excerpts from Segher Boessenkool's message of April 2, 2021 2:11 am: > On Thu, Apr 01, 2021 at 10:55:58AM +0800, Xiongwei Song wrote: >> Segher Boessenkool 于2021年4月1日周四 上午6:15写道: >> >> > On Wed, Mar 31, 2021 at 08:58:17PM +1100, Michael Ellerman wrote: >> > > So perhaps: >> > > >> > >

[PATCH] powerpc/pseries: Add shutdown() to vio_driver and vio_bus

2021-04-01 Thread Tyrel Datwyler
Currently, neither the vio_bus or vio_driver structures provide support for a shutdown() routine. Add support for shutdown() by allowing drivers to provide a implementation via function pointer in their vio_driver struct and provide a proper implementation in the driver template for the vio_bus

Re: [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
Excerpts from Nicholas Piggin's message of April 2, 2021 1:03 am: > 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 [...] > @@ -2527,28 +2259,14 @@ BEGIN_FTR_SECTION >

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

2021-04-01 Thread Nicholas Piggin
Excerpts from Nicholas Piggin's message of April 2, 2021 1:03 am: > 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

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

2021-04-01 Thread Nathan Lynch
Hi Srikar, Thanks for figuring this out. Srikar Dronamraju writes: > > Some of the per-CPU masks use cpu_cpu_mask as a filter to limit the search > for related CPUs. On a dlpar add of a CPU, update cpu_cpu_mask before > updating the per-CPU masks. This will ensure the cpu_cpu_mask is updated >

Re: [PATCH v2 3/7] powerpc: convert config files to generic cmdline

2021-04-01 Thread Rob Herring
On Tue, Mar 30, 2021 at 6:31 PM Daniel Walker wrote: > > On Tue, Mar 30, 2021 at 03:13:04PM -0500, Rob Herring wrote: > > On Tue, Mar 30, 2021 at 12:33 PM Daniel Walker wrote: > > > > > > On Thu, Mar 25, 2021 at 05:29:44PM -0600, Rob Herring wrote: > > > > On Thu, Mar 25, 2021 at 2:00 PM Daniel

Re: [PATCH printk v2 3/5] printk: remove NMI tracking

2021-04-01 Thread Petr Mladek
On Tue 2021-03-30 17:35:10, John Ogness wrote: > All NMI contexts are handled the same as the safe context: store the > message and defer printing. There is no need to have special NMI > context tracking for this. Using in_nmi() is enough. > > Signed-off-by: John Ogness This is another great

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

2021-04-01 Thread Petr Mladek
On Thu 2021-04-01 15:19:52, John Ogness wrote: > 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);

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

2021-04-01 Thread Cédric Le Goater
On 4/1/21 2:45 PM, Greg Kurz wrote: > 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

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

2021-04-01 Thread Petr Mladek
On Tue 2021-03-30 17:35:09, John Ogness wrote: > With @logbuf_lock removed, the high level printk functions for > storing messages are lockless. Messages can be stored from any > context, so there is no need for the NMI and safe buffers anymore. > Remove the NMI and safe buffers. > > Although the

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

2021-04-01 Thread Segher Boessenkool
On Thu, Apr 01, 2021 at 06:01:29PM +1000, Nicholas Piggin wrote: > 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 > >>>

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

2021-04-01 Thread Segher Boessenkool
On Thu, Apr 01, 2021 at 10:55:58AM +0800, Xiongwei Song wrote: > Segher Boessenkool 于2021年4月1日周四 上午6:15写道: > > > On Wed, Mar 31, 2021 at 08:58:17PM +1100, Michael Ellerman wrote: > > > So perhaps: > > > > > > EXC_SYSTEM_RESET > > > EXC_MACHINE_CHECK > > > EXC_DATA_STORAGE > > >

Re: [PATCH v3 1/2] powerpc/perf: Infrastructure to support checking of attr.config*

2021-04-01 Thread Athira Rajeev
> On 25-Mar-2021, at 5:23 PM, Madhavan Srinivasan wrote: > > Introduce code to support the checking of attr.config* for > values which are reserved for a given platform. > Performance Monitoring Unit (PMU) configuration registers > have fields that are reserved and some specific values for >

[PATCH 20/20] iommu: remove iommu_domain_{get,set}_attr

2021-04-01 Thread Christoph Hellwig
Remove the now unused iommu attr infrastructure. Signed-off-by: Christoph Hellwig Acked-by: Will Deacon --- drivers/iommu/iommu.c | 26 -- include/linux/iommu.h | 36 2 files changed, 62 deletions(-) diff --git

[PATCH 19/20] iommu: remove DOMAIN_ATTR_IO_PGTABLE_CFG

2021-04-01 Thread Christoph Hellwig
Use an explicit set_pgtable_quirks method instead that just passes the actual quirk bitmask instead. Signed-off-by: Christoph Hellwig Acked-by: Will Deacon Acked-by: Li Yang --- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 5 +- drivers/iommu/arm/arm-smmu/arm-smmu.c | 64

[PATCH 18/20] iommu: remove DOMAIN_ATTR_DMA_USE_FLUSH_QUEUE

2021-04-01 Thread Christoph Hellwig
From: Robin Murphy Instead make the global iommu_dma_strict paramete in iommu.c canonical by exporting helpers to get and set it and use those directly in the drivers. This make sure that the iommu.strict parameter also works for the AMD and Intel IOMMU drivers on x86. As those default to lazy

[PATCH 17/20] iommu: remove iommu_set_cmd_line_dma_api and iommu_cmd_line_dma_api

2021-04-01 Thread Christoph Hellwig
Don't obsfucate the trivial bit flag check. Signed-off-by: Christoph Hellwig Acked-by: Will Deacon --- drivers/iommu/iommu.c | 23 +-- 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index

[PATCH 16/20] iommu: remove DOMAIN_ATTR_NESTING

2021-04-01 Thread Christoph Hellwig
Use an explicit enable_nesting method instead. Signed-off-by: Christoph Hellwig Acked-by: Will Deacon Acked-by: Li Yang --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 43 - drivers/iommu/arm/arm-smmu/arm-smmu.c | 30 +++--- drivers/iommu/intel/iommu.c

[PATCH 15/20] iommu: remove DOMAIN_ATTR_GEOMETRY

2021-04-01 Thread Christoph Hellwig
The geometry information can be trivially queried from the iommu_domain struture. Signed-off-by: Christoph Hellwig Acked-by: Will Deacon Acked-by: Li Yang --- drivers/iommu/iommu.c | 20 +++- drivers/vfio/vfio_iommu_type1.c | 26 --

[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

[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 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(+),

[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

[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 ---

[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

[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 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

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

[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

[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

[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

[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

[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 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 --

[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:

[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 +-

[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 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 ++-

[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 ++--

[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

[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

[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:

[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 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 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

[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

[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

[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

[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 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

[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

[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 +++---

[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 ---

[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

[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 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

[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 ---

[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 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 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 ++

[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

[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

[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 ---

[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 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

[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

[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 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 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

[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

[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 ---

[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

[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 ---

[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:

[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 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

[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

[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

[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

[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 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

[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

[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

[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

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

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

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

[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

[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 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

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

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 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 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

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

  1   2   >