Re: [PATCH -next v2] KVM: PPC: Book3S HV: XIVE: Convert to DEFINE_SHOW_ATTRIBUTE

2020-09-22 Thread Paul Mackerras
On Sat, Sep 19, 2020 at 09:29:25AM +0800, Qinglang Miao wrote: > Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code. > > Signed-off-by: Qinglang Miao Thanks, applied. Paul.

Re: [PATCH] KVM: PPC: Don't return -ENOTSUPP to userspace in ioctls

2020-09-22 Thread Paul Mackerras
On Fri, Sep 11, 2020 at 12:53:45PM +0200, Greg Kurz wrote: > ENOTSUPP is a linux only thingy, the value of which is unknown to > userspace, not to be confused with ENOTSUP which linux maps to > EOPNOTSUPP, as permitted by POSIX [1]: > > [EOPNOTSUPP] > Operation not supported on socket. The type

Re: [PATCH] KVM: PPC: Book3S HV: Do not allocate HPT for a nested guest

2020-09-22 Thread Paul Mackerras
On Fri, Sep 11, 2020 at 01:16:07AM -0300, Fabiano Rosas wrote: > The current nested KVM code does not support HPT guests. This is > informed/enforced in some ways: > > - Hosts < P9 will not be able to enable the nested HV feature; > > - The nested hypervisor MMU capabilities will not contain >

Re: [PATCH] KVM: PPC: Book3S: Remove redundant initialization of variable ret

2020-09-22 Thread Paul Mackerras
On Sat, Sep 19, 2020 at 03:12:30PM +0800, Jing Xiangfeng wrote: > The variable ret is being initialized with '-ENOMEM' that is meaningless. > So remove it. > > Signed-off-by: Jing Xiangfeng Thanks, applied. Paul.

Re: [PATCH -next] powerpc/kvm/books: Fix symbol undeclared warnings

2020-09-22 Thread Paul Mackerras
On Mon, Sep 21, 2020 at 11:22:11AM +, Wang Wensheng wrote: > Build the kernel with `C=2`: > arch/powerpc/kvm/book3s_hv_nested.c:572:25: warning: symbol > 'kvmhv_alloc_nested' was not declared. Should it be static? > arch/powerpc/kvm/book3s_64_mmu_radix.c:350:6: warning: symbol >

Re: [PATCH V2] Doc: admin-guide: Add entry for kvm_cma_resv_ratio kernel param

2020-09-21 Thread Paul Mackerras
sh mode PowerPC KVM guests. > > Cc: linux-ker...@vger.kernel.org > Cc: kvm-...@vger.kernel.org > Cc: linuxppc-dev@lists.ozlabs.org > Cc: Paul Mackerras > Cc: Michael Ellerman > Cc: Jonathan Corbet > Reviewed-by: Randy Dunlap > Signed-off-by: Satheesh Rajendran > -

Re: [PATCH] powerpc/64s: handle ISA v3.1 local copy-paste context switches

2020-09-02 Thread Paul Mackerras
: Nicholas Piggin For the KVM part: Acked-by: Paul Mackerras

Re: [RFC PATCH 1/2] KVM: PPC: Use the ppc_inst type

2020-09-02 Thread Paul Mackerras
On Wed, Sep 02, 2020 at 06:00:24PM +1000, Jordan Niethe wrote: > On Wed, Sep 2, 2020 at 4:18 PM Paul Mackerras wrote: > > > > On Thu, Aug 20, 2020 at 01:39:21PM +1000, Jordan Niethe wrote: > > > The ppc_inst type was added to help cope with the addition of prefixed >

Re: [RFC PATCH 2/2] KVM: PPC: Book3S HV: Support prefixed instructions

2020-09-02 Thread Paul Mackerras
On Thu, Aug 20, 2020 at 01:39:22PM +1000, Jordan Niethe wrote: > There are two main places where instructions are loaded from the guest: > * Emulate loadstore - such as when performing MMIO emulation > triggered by an HDSI > * After an HV emulation assistance interrupt (e40) > > If

Re: [RFC PATCH 1/2] KVM: PPC: Use the ppc_inst type

2020-09-02 Thread Paul Mackerras
On Thu, Aug 20, 2020 at 01:39:21PM +1000, Jordan Niethe wrote: > The ppc_inst type was added to help cope with the addition of prefixed > instructions to the ISA. Convert KVM to use this new type for dealing > wiht instructions. For now do not try to add further support for > prefixed

Re: [PATCH -next] powerpc: Convert to DEFINE_SHOW_ATTRIBUTE

2020-09-01 Thread Paul Mackerras
On Thu, Jul 16, 2020 at 05:07:12PM +0800, Qinglang Miao wrote: > From: Chen Huang > > Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code. > > Signed-off-by: Chen Huang For the arch/powerpc/kvm part: Acked-by: Paul Mackerras I expect Michael Ellerman will take the patch t

Re: [PATCH 0/7] powerpc/watchpoint: 2nd DAWR kvm enablement + selftests

2020-09-01 Thread Paul Mackerras
On Thu, Jul 23, 2020 at 03:50:51PM +0530, Ravi Bangoria wrote: > Patch #1, #2 and #3 enables p10 2nd DAWR feature for Book3S kvm guest. DAWR > is a hypervisor resource and thus H_SET_MODE hcall is used to set/unset it. > A new case H_SET_MODE_RESOURCE_SET_DAWR1 is introduced in H_SET_MODE hcall >

Re: [PATCH 2/7] powerpc/watchpoint/kvm: Add infrastructure to support 2nd DAWR

2020-09-01 Thread Paul Mackerras
On Thu, Jul 23, 2020 at 03:50:53PM +0530, Ravi Bangoria wrote: > kvm code assumes single DAWR everywhere. Add code to support 2nd DAWR. > DAWR is a hypervisor resource and thus H_SET_MODE hcall is used to set/ > unset it. Introduce new case H_SET_MODE_RESOURCE_SET_DAWR1 for 2nd DAWR. Is this the

Re: [PATCH 1/7] powerpc/watchpoint/kvm: Rename current DAWR macros and variables

2020-09-01 Thread Paul Mackerras
On Thu, Jul 23, 2020 at 03:50:52PM +0530, Ravi Bangoria wrote: > Power10 is introducing second DAWR. Use real register names (with > suffix 0) from ISA for current macros and variables used by kvm. Most of this looks fine, but I think we should not change the existing names in

Re: [PATCH v6 0/5] Migrate non-migrated pages of a SVM.

2020-07-27 Thread Paul Mackerras
On Mon, Jul 27, 2020 at 11:07:13AM -0700, Ram Pai wrote: > The time to switch a VM to Secure-VM, increases by the size of the VM. > A 100GB VM takes about 7minutes. This is unacceptable. This linear > increase is caused by a suboptimal behavior by the Ultravisor and the > Hypervisor. The

Re: [PATCH v2 0/2] Rework secure memslot dropping

2020-07-27 Thread Paul Mackerras
On Mon, Jul 27, 2020 at 12:24:27PM -0700, Ram Pai wrote: > From: Laurent Dufour > > When doing memory hotplug on a secure VM, the secure pages are not well > cleaned from the secure device when dropping the memslot. This silent > error, is then preventing the SVM to reboot properly after the

Re: [PATCH v6 3/5] KVM: PPC: clean up redundant kvm_run parameters in assembly

2020-07-23 Thread Paul Mackerras
On Tue, Jun 23, 2020 at 09:14:16PM +0800, Tianjia Zhang wrote: > In the current kvm version, 'kvm_run' has been included in the 'kvm_vcpu' > structure. For historical reasons, many kvm-related function parameters > retain the 'kvm_run' and 'kvm_vcpu' parameters at the same time. This > patch does

Re: [PATCH] powerpc/kvm: Enable support for ISA v3.1 guests

2020-07-23 Thread Paul Mackerras
On Tue, Jun 02, 2020 at 03:53:25PM +1000, Alistair Popple wrote: > Adds support for emulating ISAv3.1 guests by adding the appropriate PCR > and FSCR bits. > > Signed-off-by: Alistair Popple Thanks, patch applied to my kvm-ppc-next branch. Paul.

Re: [PATCH kernel] KVM: PPC: Protect kvm_vcpu_read_guest with srcu locks

2020-07-23 Thread Paul Mackerras
On Tue, Jun 09, 2020 at 12:12:29PM +1000, Alexey Kardashevskiy wrote: > The kvm_vcpu_read_guest/kvm_vcpu_write_guest used for nested guests > eventually call srcu_dereference_check to dereference a memslot and > lockdep produces a warning as neither kvm->slots_lock nor > kvm->srcu lock is held and

Re: [PATCH] KVM: PPC: Book3S HV: increase KVMPPC_NR_LPIDS on POWER8 and POWER9

2020-07-23 Thread Paul Mackerras
On Mon, Jun 08, 2020 at 01:57:14PM +0200, Cédric Le Goater wrote: > POWER8 and POWER9 have 12-bit LPIDs. Change LPID_RSVD to support up to > (4096 - 2) guests on these processors. POWER7 is kept the same with a > limitation of (1024 - 2), but it might be time to drop KVM support for > POWER7. > >

Re: [RFC PATCH] powerpc/pseries/svm: capture instruction faulting on MMIO access, in sprg0 register

2020-07-21 Thread Paul Mackerras
On Thu, Jul 16, 2020 at 01:32:13AM -0700, Ram Pai wrote: > An instruction accessing a mmio address, generates a HDSI fault. This fault > is > appropriately handled by the Hypervisor. However in the case of secureVMs, > the > fault is delivered to the ultravisor. > > Unfortunately the

Re: [v3 02/15] KVM: PPC: Book3S HV: Cleanup updates for kvm vcpu MMCR

2020-07-21 Thread Paul Mackerras
On Wed, Jul 22, 2020 at 07:39:26AM +0530, Athira Rajeev wrote: > > > > On 21-Jul-2020, at 9:24 AM, Paul Mackerras wrote: > > > > On Fri, Jul 17, 2020 at 10:38:14AM -0400, Athira Rajeev wrote: > >> Currently `kvm_vcpu_arch` stores all Monitor Mode Control regist

Re: [PATCH 2/2] KVM: PPC: Book3S HV: rework secure mem slot dropping

2020-07-20 Thread Paul Mackerras
the pages, the > > > VMA is fetched in a lazy way, to not trigger find_vma() all the time. In > > > addition, the mmap_sem is help in read mode during that time, not in write > > > mode since the virual memory layout is not impacted, and > > >

Re: [PATCH] KVM: PPC: Book3S HV: Use feature flag CPU_FTR_P9_TIDR when accessing TIDR

2020-07-20 Thread Paul Mackerras
On Tue, Jun 23, 2020 at 06:50:27PM +0200, Cédric Le Goater wrote: > The TIDR register is only available on POWER9 systems and code > accessing this register is not always protected by the CPU_FTR_P9_TIDR > flag. Fix that to make sure POWER10 systems won't use it as TIDR has > been removed. I'm

Re: [v3 02/15] KVM: PPC: Book3S HV: Cleanup updates for kvm vcpu MMCR

2020-07-20 Thread Paul Mackerras
On Fri, Jul 17, 2020 at 10:38:14AM -0400, Athira Rajeev wrote: > Currently `kvm_vcpu_arch` stores all Monitor Mode Control registers > in a flat array in order: mmcr0, mmcr1, mmcra, mmcr2, mmcrs > Split this to give mmcra and mmcrs its own entries in vcpu and > use a flat array for mmcr0 to mmcr2.

Re: [PATCH] pseries: Fix 64 bit logical memory block panic

2020-07-16 Thread Paul Mackerras
On Wed, Jul 15, 2020 at 06:12:25PM +0530, Aneesh Kumar K.V wrote: > Anton Blanchard writes: > > > Booting with a 4GB LMB size causes us to panic: > > > > qemu-system-ppc64: OS terminated: OS panic: > > Memory block size not suitable: 0x0 > > > > Fix pseries_memory_block_size() to handle

Re: [RFC PATCH v0 2/2] KVM: PPC: Book3S HV: Use H_RPT_INVALIDATE in nested KVM

2020-07-09 Thread Paul Mackerras
On Thu, Jul 09, 2020 at 02:38:51PM +0530, Bharata B Rao wrote: > On Thu, Jul 09, 2020 at 03:18:03PM +1000, Paul Mackerras wrote: > > On Fri, Jul 03, 2020 at 04:14:20PM +0530, Bharata B Rao wrote: > > > In the nested KVM case, replace H_TLB_INVALIDATE by the new hcall >

Re: [RFC PATCH v0 2/2] KVM: PPC: Book3S HV: Use H_RPT_INVALIDATE in nested KVM

2020-07-08 Thread Paul Mackerras
On Fri, Jul 03, 2020 at 04:14:20PM +0530, Bharata B Rao wrote: > In the nested KVM case, replace H_TLB_INVALIDATE by the new hcall > H_RPT_INVALIDATE if available. The availability of this hcall > is determined from "hcall-rpt-invalidate" string in ibm,hypertas-functions > DT property. What are

Re: [PATCH v2 2/3] powerpc/64s: remove PROT_SAO support

2020-07-08 Thread Paul Mackerras
On Fri, Jul 03, 2020 at 11:19:57AM +1000, Nicholas Piggin wrote: > ISA v3.1 does not support the SAO storage control attribute required to > implement PROT_SAO. PROT_SAO was used by specialised system software > (Lx86) that has been discontinued for about 7 years, and is not thought > to be used

Re: [PATCH 1/1] KVM/PPC: Fix typo on H_DISABLE_AND_GET hcall

2020-07-08 Thread Paul Mackerras
for InfiniBand usage"), and was > later used without having the typo noticed. > > Signed-off-by: Leonardo Bras Acked-by: Paul Mackerras Since this hypercall is not implemented in KVM nor used by KVM guests, I'll leave this one for Michael to pick up. Paul.

Re: [PATCH v2 02/10] KVM: PPC: Book3S HV: Save/restore new PMU registers

2020-07-01 Thread Paul Mackerras
On Wed, Jul 01, 2020 at 05:20:54AM -0400, Athira Rajeev wrote: > PowerISA v3.1 has added new performance monitoring unit (PMU) > special purpose registers (SPRs). They are > > Monitor Mode Control Register 3 (MMCR3) > Sampled Instruction Event Register A (SIER2) > Sampled Instruction Event

Re: [PATCH 3/3] powerpc/pseries: Add KVM guest doorbell restrictions

2020-06-30 Thread Paul Mackerras
On Tue, Jun 30, 2020 at 03:35:08PM +1000, Nicholas Piggin wrote: > Excerpts from Paul Mackerras's message of June 30, 2020 12:27 pm: > > On Sun, Jun 28, 2020 at 01:04:28AM +1000, Nicholas Piggin wrote: > >> KVM guests have certain restrictions and performance quirks when > >> using doorbells. This

Re: [PATCH 3/3] powerpc/pseries: Add KVM guest doorbell restrictions

2020-06-29 Thread Paul Mackerras
On Sun, Jun 28, 2020 at 01:04:28AM +1000, Nicholas Piggin wrote: > KVM guests have certain restrictions and performance quirks when > using doorbells. This patch tests for KVM environment in doorbell > setup, and optimises IPI performance: > > - PowerVM guests may now use doorbells even if they

Re: [PATCH v4 09/22] powerpc/kvm/book3s: Add helper to walk partition scoped linux page table.

2020-05-28 Thread Paul Mackerras
On Thu, May 28, 2020 at 11:31:04AM +0530, Aneesh Kumar K.V wrote: > On 5/28/20 7:13 AM, Paul Mackerras wrote: > > On Tue, May 05, 2020 at 12:47:16PM +0530, Aneesh Kumar K.V wrote: > > > The locking rules for walking partition scoped table is different from > > > proces

Re: [PATCH v4 09/22] powerpc/kvm/book3s: Add helper to walk partition scoped linux page table.

2020-05-27 Thread Paul Mackerras
On Tue, May 05, 2020 at 12:47:16PM +0530, Aneesh Kumar K.V wrote: > The locking rules for walking partition scoped table is different from process > scoped table. Hence add a helper for secondary linux page table walk and also > add check whether we are holding the right locks. This patch is

Re: [PATCH] KVM: PPC: Book3S HV: read ibm,secure-memory nodes

2020-05-26 Thread Paul Mackerras
On Thu, Apr 16, 2020 at 06:27:15PM +0200, Laurent Dufour wrote: > The newly introduced ibm,secure-memory nodes supersede the > ibm,uv-firmware's property secure-memory-ranges. > > Firmware will no more expose the secure-memory-ranges property so first > read the new one and if not found rollback

Re: [PATCH v4 3/7] KVM: PPC: Remove redundant kvm_run from vcpu_arch

2020-05-26 Thread Paul Mackerras
On Mon, Apr 27, 2020 at 12:35:10PM +0800, Tianjia Zhang wrote: > The 'kvm_run' field already exists in the 'vcpu' structure, which > is the same structure as the 'kvm_run' in the 'vcpu_arch' and > should be deleted. > > Signed-off-by: Tianjia Zhang Thanks, patches 3 and 4 of this series applied

Re: [PATCH -next] KVM: PPC: Book3S HV: remove redundant NULL check

2020-05-26 Thread Paul Mackerras
On Wed, Apr 01, 2020 at 09:09:03PM +0800, Chen Zhou wrote: > Free function kfree() already does NULL check, so the additional > check is unnecessary, just remove it. > > Signed-off-by: Chen Zhou Thanks, applied to my kvm-ppc-next branch. Paul.

Re: [PATCH v2] KVM: PPC: Book3S HV: relax check on H_SVM_INIT_ABORT

2020-05-26 Thread Paul Mackerras
On Wed, May 20, 2020 at 07:43:08PM +0200, Laurent Dufour wrote: > The commit 8c47b6ff29e3 ("KVM: PPC: Book3S HV: Check caller of H_SVM_* > Hcalls") added checks of secure bit of SRR1 to filter out the Hcall > reserved to the Ultravisor. > > However, the Hcall H_SVM_INIT_ABORT is made by the

Re: [PATCH] powerpc/kvm/radix: ignore kmemleak false positives

2020-05-26 Thread Paul Mackerras
On Wed, May 13, 2020 at 09:39:15AM -0400, Qian Cai wrote: > kvmppc_pmd_alloc() and kvmppc_pte_alloc() allocate some memory but then > pud_populate() and pmd_populate() will use __pa() to reference the newly > allocated memory. > > Since kmemleak is unable to track the physical memory resulting in

Re: [PATCH] powerpc/kvm/book3s64/vio: fix some RCU-list locks

2020-05-26 Thread Paul Mackerras
On Sun, May 10, 2020 at 01:18:34AM -0400, Qian Cai wrote: > It is unsafe to traverse kvm->arch.spapr_tce_tables and > stt->iommu_tables without the RCU read lock held. Also, add > cond_resched_rcu() in places with the RCU read lock held that could take > a while to finish. > >

Re: [PATCH] powerpc/kvm/book3s64/vio: fix some RCU-list locks

2020-05-26 Thread Paul Mackerras
On Sun, May 10, 2020 at 01:18:34AM -0400, Qian Cai wrote: > It is unsafe to traverse kvm->arch.spapr_tce_tables and > stt->iommu_tables without the RCU read lock held. Also, add > cond_resched_rcu() in places with the RCU read lock held that could take > a while to finish. This mostly looks fine.

Re: [linux-next PATCH] mm/gup.c: Convert to use get_user_{page|pages}_fast_only()

2020-05-26 Thread Paul Mackerras
f the API. > > Signed-off-by: Souptick Joarder The arch/powerpc/kvm bits look reasonable. Reviewed-by: Paul Mackerras

Re: [PATCH v4 5/7] KVM: PPC: clean up redundant kvm_run parameters in assembly

2020-05-26 Thread Paul Mackerras
On Mon, Apr 27, 2020 at 12:35:12PM +0800, Tianjia Zhang wrote: > In the current kvm version, 'kvm_run' has been included in the 'kvm_vcpu' > structure. For historical reasons, many kvm-related function parameters > retain the 'kvm_run' and 'kvm_vcpu' parameters at the same time. This > patch does

Re: [PATCH v4 4/7] KVM: PPC: clean up redundant 'kvm_run' parameters

2020-05-25 Thread Paul Mackerras
; patch does a unified cleanup of these remaining redundant parameters. > > Signed-off-by: Tianjia Zhang This looks OK, though possibly a little larger than it needs to be because of variable name changes (kvm_run -> run) that aren't strictly necessary. Reviewed-by: Paul Mackerras

Re: [PATCH v4 3/7] KVM: PPC: Remove redundant kvm_run from vcpu_arch

2020-05-25 Thread Paul Mackerras
ch architecture sub-maintainer is taking the relevant patches from this series via their tree - is that right? Reviewed-by: Paul Mackerras

[PATCH RFC 2/4] powerpc: Add Microwatt platform

2020-05-08 Thread Paul Mackerras
Microwatt is a FPGA-based implementation of the Power ISA. It currently only implements little-endian 64-bit mode, and does not (yet) support SMP. This adds a new machine type to support FPGA-based SoCs with a Microwatt core. Signed-off-by: Paul Mackerras --- arch/powerpc/Kconfig

[PATCH RFC 0/4] Add support for Microwatt-based SoCs

2020-05-08 Thread Paul Mackerras
This patch series adds support for running Linux on a Microwatt SoC (system on chip) implementation on an FPGA. Microwatt is a small Power ISA implementation, targetted at FPGAs, aiming for PowerISA v3.0B compliance. It does not currently implement any floating-point or vector instructions,

[PATCH RFC 1/4] powerpc/radix: Fix compilation for radix with CONFIG_SMP=n

2020-05-08 Thread Paul Mackerras
This fixes the compile errors we currently get with CONFIG_SMP=n and CONFIG_PPC_RADIX_MMU=y. Signed-off-by: Paul Mackerras --- arch/powerpc/include/asm/book3s/64/tlbflush-radix.h | 2 ++ arch/powerpc/mm/book3s64/radix_tlb.c| 2 -- 2 files changed, 2 insertions(+), 2 deletions

[PATCH RFC 4/4] powerpc/radix: Add support for microwatt's PRTBL SPR

2020-05-08 Thread Paul Mackerras
, as that is in the range of SPR numbers assigned for experimental use. PRTBL is only written when we have neither the FW_FEATURE_LPAR feature nor the CPU_FTR_HVMODE feature. Signed-off-by: Paul Mackerras --- arch/powerpc/include/asm/reg.h | 1 + arch/powerpc/mm/book3s64/radix_pgtable.c

[PATCH RFC 3/4] powerpc/microwatt: Add early debug UART support for Microwatt

2020-05-08 Thread Paul Mackerras
Currently microwatt-based SoCs come with a "potato" UART. This adds udbg support for the potato UART, giving us both an early debug console, and a runtime console using the hvc-udbg support. Signed-off-by: Paul Mackerras --- arch/powerpc/Kconfig.debug | 6 ++ ar

[PATCH] KVM: PPC: Book3S HV: Handle non-present PTEs in page fault functions

2020-04-15 Thread Paul Mackerras
_to_pfn_memslot in HPT page fault handler" Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1820402 Reported-by: David Gibson Signed-off-by: Paul Mackerras --- This is a reworked version of the patch David Gibson sent recently, with the fix applied to the radix case as well. The comm

Re: CVE-2020-11669: Linux kernel 4.10 to 5.1: powerpc: guest can cause DoS on POWER9 KVM hosts

2020-04-15 Thread Paul Mackerras
On Wed, Apr 15, 2020 at 04:03:29PM +0200, Michal Suchánek wrote: > On Wed, Apr 15, 2020 at 10:52:53PM +1000, Andrew Donnellan wrote: > > The Linux kernel for powerpc from v4.10 to v5.1 has a bug where the > > Authority Mask Register (AMR), Authority Mask Override Register (AMOR) and > > User

Re: [PATCH v3 1/1] ppc/crash: Reset spinlocks during crash

2020-04-08 Thread Paul Mackerras
On Wed, Apr 08, 2020 at 10:21:29PM +1000, Michael Ellerman wrote: > > We should be able to just allocate the rtas_args on the stack, it's only > ~80 odd bytes. And then we can use rtas_call_unlocked() which doesn't > take the global lock. Do we instantiate a 64-bit RTAS these days, or is it

Re: [RFC PATCH 1/1] ppc/smp: Replace unnecessary 'while' by 'if'

2020-03-26 Thread Paul Mackerras
On Thu, Mar 26, 2020 at 05:37:52PM -0300, Leonardo Bras wrote: > spin_until_cond() will wait until nmi_ipi_busy == false, and > nmi_ipi_lock_start() does not seem to change nmi_ipi_busy, so there is > no way this while will ever repeat. > > Replace this 'while' by an 'if', so it does not look

Re: [PATCH 0/2] Fix SVM hang at startup

2020-03-23 Thread Paul Mackerras
On Fri, Mar 20, 2020 at 11:26:41AM +0100, Laurent Dufour wrote: > This series is fixing a SVM hang occurring when starting a SVM requiring > more secure memory than available. The hang happens in the SVM when calling > UV_ESM. > > The following is happening: > > 1. SVM calls UV_ESM > 2.

Re: [PATCH] KVM: PPC: Book3S HV: Skip kvmppc_uvmem_free if Ultravisor is not supported

2020-03-23 Thread Paul Mackerras
On Thu, Mar 19, 2020 at 07:55:10PM -0300, Fabiano Rosas wrote: > kvmppc_uvmem_init checks for Ultravisor support and returns early if > it is not present. Calling kvmppc_uvmem_free at module exit will cause > an Oops: > > $ modprobe -r kvm-hv > > Oops: Kernel access of bad area, sig: 11 [#1] >

Re: [PATCH 1/2] KVM: PPC: Book3S HV: check caller of H_SVM_* Hcalls

2020-03-23 Thread Paul Mackerras
On Fri, Mar 20, 2020 at 01:22:48PM +0100, Greg Kurz wrote: > On Fri, 20 Mar 2020 11:26:42 +0100 > Laurent Dufour wrote: > > > The Hcall named H_SVM_* are reserved to the Ultravisor. However, nothing > > prevent a malicious VM or SVM to call them. This could lead to weird result > > and should be

Re: [PATCH] KVM: PPC: Book3S HV: Skip kvmppc_uvmem_free if Ultravisor is not supported

2020-03-19 Thread Paul Mackerras
Support for running secure guests") > Reported-by: Greg Kurz > Signed-off-by: Fabiano Rosas Good catch! This should be Cc: sta...@vger.kernel.org # v5.5+ Acked-by: Paul Mackerras Paul.

Re: [PATCH 0/3] KVM: PPC: Fix host kernel crash with PR KVM

2020-03-19 Thread Paul Mackerras
On Wed, Mar 18, 2020 at 06:43:24PM +0100, Greg Kurz wrote: > Recent cleanup from Sean Christopherson introduced a use-after-free > condition that crashes the kernel when shutting down the VM with > PR KVM. It went unnoticed so far because PR isn't tested/used much > these days (mostly used for

Re: [PATCH] KVM: PPC: Book3S HV: Use RADIX_PTE_INDEX_SIZE in Radix MMU code

2020-03-19 Thread Paul Mackerras
On Tue, Feb 18, 2020 at 03:36:50PM +1100, Michael Ellerman wrote: > In kvmppc_unmap_free_pte() in book3s_64_mmu_radix.c, we use the > non-constant value PTE_INDEX_SIZE to clear a PTE page. > > We can instead use the constant RADIX_PTE_INDEX_SIZE, because we know > this code will only be running

Re: [PATCH -next 016/491] KERNEL VIRTUAL MACHINE FOR POWERPC (KVM/powerpc): Use fallthrough;

2020-03-19 Thread Paul Mackerras
On Wed, Mar 18, 2020 at 06:22:29PM -0700, Joe Perches wrote: > On Thu, 2020-03-19 at 12:18 +1100, Paul Mackerras wrote: > > On Tue, Mar 10, 2020 at 09:51:30PM -0700, Joe Perches wrote: > > > Convert the various uses of fallthrough comments to fallthrough; > > > >

Re: [PATCH] KVM: PPC: Book3S HV: Fix H_CEDE return code for nested guests

2020-03-19 Thread Paul Mackerras
78556 > > Fixes: 4bad77799fed ("KVM: PPC: Book3S HV: Handle hypercalls correctly when > nested") > Cc: linuxppc-...@ozlabs.org > Cc: David Gibson > Cc: Paul Mackerras > Signed-off-by: Michael Roth Thanks, applied to my kvm-ppc-next branch. Paul.

Re: [PATCH v3] KVM: PPC: Book3S HV: Treat TM-related invalid form instructions on P9 like the valid ones

2020-03-19 Thread Paul Mackerras
On Fri, Feb 21, 2020 at 11:29:50AM -0500, Gustavo Romero wrote: > On P9 DD2.2 due to a CPU defect some TM instructions need to be emulated by > KVM. This is handled at first by the hardware raising a softpatch interrupt > when certain TM instructions that need KVM assistance are executed in the >

Re: [PATCH -next 016/491] KERNEL VIRTUAL MACHINE FOR POWERPC (KVM/powerpc): Use fallthrough;

2020-03-18 Thread Paul Mackerras
d-off-by: Joe Perches The subject line should look like "KVM: PPC: Use fallthrough". Apart from that, Acked-by: Paul Mackerras How are these patches going upstream? Do you want me to take this via my tree? Paul.

Re: [PATCH FIX] KVM: PPC: Book3S HV: Release lock on page-out failure path

2020-01-29 Thread Paul Mackerras
On Wed, Jan 22, 2020 at 10:25:42AM +0530, Bharata B Rao wrote: > When migrate_vma_setup() fails in kvmppc_svm_page_out(), > release kvm->arch.uvmem_lock before returning. > > Fixes: ca9f4942670 ("KVM: PPC: Book3S HV: Support for running secure guests") > Signed-off-by: Bharata B Rao Thanks,

Re: [PATCH v3] powerpc/mm: Remove kvm radix prefetch workaround for Power9 DD2.2

2020-01-16 Thread Paul Mackerras
ormed. This means that we can get rid of the workarounds for > Power9 DD2.2 and later revisions. Add a new cpu feature > CPU_FTR_P9_RADIX_PREFETCH_BUG to indicate if the workarounds are needed. > > Signed-off-by: Jordan Niethe Acked-by: Paul Mackerras

Re: [PATCH v3 2/2] powerpc/pseries/svm: Disable BHRB/EBB/PMU access

2020-01-12 Thread Paul Mackerras
On Thu, Jan 09, 2020 at 09:19:57PM -0800, Sukadev Bhattiprolu wrote: > Ultravisor disables some CPU features like BHRB, EBB and PMU in > secure virtual machines (SVMs). Skip accessing those registers > in SVMs to avoid getting a Program Interrupt. It would be useful to have more explanation of

Re: [PATCH 2/3] powerpc sstep: add support for divde[.] and divdeu[.] instructions

2020-01-08 Thread Paul Mackerras
On Tue, Dec 10, 2019 at 12:49:03PM +0530, Balamuruhan S wrote: > This patch adds emulation support for divde, divdeu instructions, > * Divide Doubleword Extended (divde[.]) > * Divide Doubleword Extended Unsigned (divdeu[.]) > > Signed-off-by: Balamuruhan S > --- >

Re: [PATCH V3 2/2] KVM: PPC: Implement H_SVM_INIT_ABORT hcall

2019-12-17 Thread Paul Mackerras
MSR_S bit will be clear and the VM wont be able to > access its pages even to do a clean exit). > > Based on patches and discussion with Paul Mackerras, Ram Pai and > Bharata Rao. > > Signed-off-by: Ram Pai > Signed-off-by: Sukadev Bhattiprolu > Signed-off-by: Bharata B Rao Mino

Re: [PATCH V3 1/2] KVM: PPC: Add skip_page_out parameter

2019-12-17 Thread Paul Mackerras
c 2019 15:06:16 -0600 > Subject: [PATCH V3 1/2] KVM: PPC: Add skip_page_out parameter > > Add 'skip_page_out' parameter to kvmppc_uvmem_drop_pages() which will > be needed in a follow-on patch that implements H_SVM_INIT_ABORT hcall. > > Signed-off-by: Sukadev Bhattiprolu Reviewed-by: Paul Mackerras

Re: [PATCH 1/1] powerpc/kvm/book3s: Fixes possible 'use after release' of kvm

2019-11-27 Thread Paul Mackerras
On Tue, Nov 26, 2019 at 02:52:12PM -0300, Leonardo Bras wrote: > Fixes a possible 'use after free' of kvm variable. > It does use mutex_unlock(>lock) after possible freeing a variable > with kvm_put_kvm(kvm). Comments below... > diff --git a/arch/powerpc/kvm/book3s_64_vio.c >

Re: [PATCH v10 7/8] KVM: PPC: Implement H_SVM_INIT_ABORT hcall

2019-11-13 Thread Paul Mackerras
On Wed, Nov 13, 2019 at 01:50:42PM -0800, Ram Pai wrote: > On Thu, Nov 14, 2019 at 08:18:24AM +1100, Paul Mackerras wrote: > > On Tue, Nov 12, 2019 at 10:32:33PM -0800, Ram Pai wrote: > > > On Wed, Nov 13, 2019 at 11:14:27AM +1100, Paul Mackerras wrote: > > > > On T

Re: [PATCH v10 6/8] KVM: PPC: Support reset of secure guest

2019-11-13 Thread Paul Mackerras
On Wed, Nov 13, 2019 at 08:59:08PM +0530, Bharata B Rao wrote: > On Tue, Nov 12, 2019 at 04:34:34PM +1100, Paul Mackerras wrote: > > On Mon, Nov 04, 2019 at 09:47:58AM +0530, Bharata B Rao wrote: > > [snip] > > > @@ -5442,6 +5471,64 @@ static int kvmhv_store_to_eaddr(stru

Re: [PATCH v10 7/8] KVM: PPC: Implement H_SVM_INIT_ABORT hcall

2019-11-13 Thread Paul Mackerras
On Tue, Nov 12, 2019 at 10:32:33PM -0800, Ram Pai wrote: > On Wed, Nov 13, 2019 at 11:14:27AM +1100, Paul Mackerras wrote: > > On Tue, Nov 12, 2019 at 06:45:55AM -0800, Ram Pai wrote: > > > On Tue, Nov 12, 2019 at 10:32:04PM +1100, Paul Mackerras wrote: > > > > On M

Re: [PATCH v10 7/8] KVM: PPC: Implement H_SVM_INIT_ABORT hcall

2019-11-12 Thread Paul Mackerras
On Tue, Nov 12, 2019 at 06:45:55AM -0800, Ram Pai wrote: > On Tue, Nov 12, 2019 at 10:32:04PM +1100, Paul Mackerras wrote: > > On Mon, Nov 11, 2019 at 11:52:15PM -0800, Ram Pai wrote: > > > There is subtle problem removing that code from the assembly. > > > > >

Re: [PATCH v10 7/8] KVM: PPC: Implement H_SVM_INIT_ABORT hcall

2019-11-12 Thread Paul Mackerras
On Mon, Nov 11, 2019 at 11:52:15PM -0800, Ram Pai wrote: > On Tue, Nov 12, 2019 at 04:38:36PM +1100, Paul Mackerras wrote: > > On Mon, Nov 11, 2019 at 05:01:58PM -0800, Ram Pai wrote: > > > On Mon, Nov 11, 2019 at 03:19:24PM +1100, Paul Mackerras wrote: > > > > On M

Re: [PATCH v10 7/8] KVM: PPC: Implement H_SVM_INIT_ABORT hcall

2019-11-11 Thread Paul Mackerras
On Mon, Nov 11, 2019 at 05:01:58PM -0800, Ram Pai wrote: > On Mon, Nov 11, 2019 at 03:19:24PM +1100, Paul Mackerras wrote: > > On Mon, Nov 04, 2019 at 09:47:59AM +0530, Bharata B Rao wrote: > > > From: Sukadev Bhattiprolu > > > > > > Implement the H_SVM_INIT_

Re: [PATCH v10 6/8] KVM: PPC: Support reset of secure guest

2019-11-11 Thread Paul Mackerras
On Mon, Nov 04, 2019 at 09:47:58AM +0530, Bharata B Rao wrote: [snip] > @@ -5442,6 +5471,64 @@ static int kvmhv_store_to_eaddr(struct kvm_vcpu *vcpu, > ulong *eaddr, void *ptr, > return rc; > } > > +/* > + * IOCTL handler to turn off secure mode of guest > + * > + * - Issue ucall to

Re: [PATCH v10 6/8] KVM: PPC: Support reset of secure guest

2019-11-10 Thread Paul Mackerras
On Mon, Nov 04, 2019 at 09:47:58AM +0530, Bharata B Rao wrote: > Add support for reset of secure guest via a new ioctl KVM_PPC_SVM_OFF. > This ioctl will be issued by QEMU during reset and includes the > the following steps: > > - Ask UV to terminate the guest via UV_SVM_TERMINATE ucall > - Unpin

Re: [PATCH v10 5/8] KVM: PPC: Handle memory plug/unplug to secure VM

2019-11-10 Thread Paul Mackerras
ukadev Bhattiprolu > [Added skip_page_out arg to kvmppc_uvmem_drop_pages()] Reviewed-by: Paul Mackerras

Re: [PATCH v10 7/8] KVM: PPC: Implement H_SVM_INIT_ABORT hcall

2019-11-10 Thread Paul Mackerras
On Mon, Nov 04, 2019 at 09:47:59AM +0530, Bharata B Rao wrote: > From: Sukadev Bhattiprolu > > Implement the H_SVM_INIT_ABORT hcall which the Ultravisor can use to > abort an SVM after it has issued the H_SVM_INIT_START and before the > H_SVM_INIT_DONE hcalls. This hcall could be used when

Re: [PATCH v10 1/8] mm: ksm: Export ksm_madvise()

2019-11-06 Thread Paul Mackerras
On Wed, Nov 06, 2019 at 12:15:42PM +0530, Bharata B Rao wrote: > On Wed, Nov 06, 2019 at 03:33:29PM +1100, Paul Mackerras wrote: > > On Mon, Nov 04, 2019 at 09:47:53AM +0530, Bharata B Rao wrote: > > > KVM PPC module needs ksm_madvise() for supporting secure guests. > > &

Re: [PATCH v10 2/8] KVM: PPC: Support for running secure guests

2019-11-05 Thread Paul Mackerras
to the guest becomes secure, a page from > this private device memory is used to represent and track that secure > page on the HV side. The movement of pages between normal and secure > memory is done via migrate_vma_pages() using UV_PAGE_IN and > UV_PAGE_OUT ucalls. > > Signed-off-by: Bharata B Rao Reviewed-by: Paul Mackerras

Re: [PATCH v10 1/8] mm: ksm: Export ksm_madvise()

2019-11-05 Thread Paul Mackerras
m_madvise call, then as far as I can tell, it should all still work correctly, but we might have KSM pulling pages in unnecessarily, causing a reduction in performance. Is that right? > Signed-off-by: Bharata B Rao Acked-by: Paul Mackerras

Re: [PATCH v10 4/8] KVM: PPC: Radix changes for secure guest

2019-11-05 Thread Paul Mackerras
On Mon, Nov 04, 2019 at 09:47:56AM +0530, Bharata B Rao wrote: > - After the guest becomes secure, when we handle a page fault of a page > belonging to SVM in HV, send that page to UV via UV_PAGE_IN. > - Whenever a page is unmapped on the HV side, inform UV via UV_PAGE_INVAL. > - Ensure all

Re: [PATCH v10 3/8] KVM: PPC: Shared pages support for secure guests

2019-11-05 Thread Paul Mackerras
On Mon, Nov 04, 2019 at 09:47:55AM +0530, Bharata B Rao wrote: > A secure guest will share some of its pages with hypervisor (Eg. virtio > bounce buffers etc). Support sharing of pages between hypervisor and > ultravisor. > > Shared page is reachable via both HV and UV side page tables. Once a >

Re: [PATCH v10 0/8] KVM: PPC: Driver to manage pages of secure guest

2019-11-05 Thread Paul Mackerras
On Mon, Nov 04, 2019 at 09:47:52AM +0530, Bharata B Rao wrote: > Hi, > > This is the next version of the patchset that adds required support > in the KVM hypervisor to run secure guests on PEF-enabled POWER platforms. > > The major change in this version is about not using kvm.arch->rmap[] >

Re: [PATCH v9 2/8] KVM: PPC: Move pages between normal and secure memory

2019-10-22 Thread Paul Mackerras
On Tue, Oct 22, 2019 at 11:59:35AM +0530, Bharata B Rao wrote: > On Fri, Oct 18, 2019 at 8:31 AM Paul Mackerras wrote: > > > > On Wed, Sep 25, 2019 at 10:36:43AM +0530, Bharata B Rao wrote: > > > Manage migration of pages betwen normal and secure memory of secure >

Re: [PATCH v2 0/6] KVM: PPC: Book3S: HV: XIVE: Allocate less VPs in OPAL

2019-10-20 Thread Paul Mackerras
On Wed, Oct 16, 2019 at 11:44:03PM +0200, Greg Kurz wrote: > On Fri, 27 Sep 2019 13:53:32 +0200 > Greg Kurz wrote: > > > This brings some fixes and allows to start more VMs with an in-kernel > > XIVE or XICS-on-XIVE device. > > > > Changes since v1 (https://patchwork.ozlabs.org/cover/1166099/):

Re: [PATCH v9 2/8] KVM: PPC: Move pages between normal and secure memory

2019-10-17 Thread Paul Mackerras
On Wed, Sep 25, 2019 at 10:36:43AM +0530, Bharata B Rao wrote: > Manage migration of pages betwen normal and secure memory of secure > guest by implementing H_SVM_PAGE_IN and H_SVM_PAGE_OUT hcalls. > > H_SVM_PAGE_IN: Move the content of a normal page to secure page > H_SVM_PAGE_OUT: Move the

Re: [PATCH 3/6] KVM: PPC: Book3S HV: XIVE: Ensure VP isn't already in use

2019-09-24 Thread Paul Mackerras
On Mon, Sep 23, 2019 at 05:43:48PM +0200, Greg Kurz wrote: > We currently prevent userspace to connect a new vCPU if we already have > one with the same vCPU id. This is good but unfortunately not enough, > because VP ids derive from the packed vCPU ids, and kvmppc_pack_vcpu_id() > can return

Re: [PATCH 1/6] KVM: PPC: Book3S HV: XIVE: initialize private pointer when VPs are allocated

2019-09-23 Thread Paul Mackerras
On Mon, Sep 23, 2019 at 05:43:37PM +0200, Greg Kurz wrote: > From: Cédric Le Goater > > Do not assign the device private pointer before making sure the XIVE > VPs are allocated in OPAL and test pointer validity when releasing > the device. > > Fixes: 5422e95103cf ("KVM: PPC: Book3S HV: XIVE:

Re: [PATCH v2] KVM: PPC: Book3S HV: use smp_mb() when setting/clearing host_ipi flag

2019-09-23 Thread Paul Mackerras
5: // hangs waiting on 42 to process messages/call_single_queue > > Fixing this scenario would require an smp_mb() *after* clearing > host_ipi flag in kvmppc_set_host_ipi() to order the store vs. > subsequent processing of IPI messages. > > To handle both cases, this patch splits kvmppc_set_host_ipi() into > separate set/clear functions, where we execute smp_mb() prior to > setting host_ipi flag, and after clearing host_ipi flag. These > functions pair with each other to synchronize the sender and receiver > sides. > > With that change in place the above workload ran for 20 hours without > triggering any lock-ups. > > Fixes: 755563bc79c7 ("powerpc/powernv: Fixes for hypervisor doorbell > handling") # v4.0 > Cc: Michael Ellerman > Cc: Paul Mackerras > Cc: Nicholas Piggin > Cc: kvm-...@vger.kernel.org > Signed-off-by: Michael Roth Looks good, makes sense. Acked-by: Paul Mackerras

Re: [PATCH kernel v2 2/4] KVM: PPC: Invalidate multiple TCEs at once

2019-08-26 Thread Paul Mackerras
MA window; > roughly 20s to 10s for each guest's 100GB of DMA space. > > Signed-off-by: Alexey Kardashevskiy With the addition of "Book3S" to the patch title, Acked-by: Paul Mackerras

[PATCH] KVM: PPC: Book3S: Enable XIVE native capability only if OPAL has required functions

2019-08-26 Thread Paul Mackerras
and the KVM_CAP_PPC_IRQ_XIVE capability returns false. Userspace can then either provide a software emulation of XIVE, or else tell the guest that it does not have a XIVE controller available to it. Signed-off-by: Paul Mackerras --- arch/powerpc/include/asm/kvm_ppc.h| 1 + arch/powerpc

Re: [PATCH v7 0/7] KVMPPC driver to manage secure guest pages

2019-08-22 Thread Paul Mackerras
On Thu, Aug 22, 2019 at 03:56:13PM +0530, Bharata B Rao wrote: > Hi, > > A pseries guest can be run as a secure guest on Ultravisor-enabled > POWER platforms. On such platforms, this driver will be used to manage > the movement of guest pages between the normal memory managed by > hypervisor(HV)

Re: [PATCH kernel] vfio/spapr_tce: Fix incorrect tce_iommu_group memory free

2019-08-22 Thread Paul Mackerras
nasty since it is a double free. Alex, are you going to take this, or would you prefer it goes via Michael Ellerman's tree? Reviewed-by: Paul Mackerras

Re: [PATCH v6 7/7] powerpc/kvm: Use UV_RETURN ucall to return to ultravisor

2019-08-22 Thread Paul Mackerras
n interrupt for the guest. The ultravisor needs to detect this case and respond appropriately. > Thanks to input from Paul Mackerras, Ram Pai and Mike Anderson. > > Signed-off-by: Sukadev Bhattiprolu > Signed-off-by: Claudio Carvalho Apart from that comment on the patch description - Acked-by: Paul Mackerras

Re: [PATCH v2 1/3] KVM: PPC: Book3S HV: Fix race in re-enabling XIVE escalation interrupts

2019-08-14 Thread Paul Mackerras
On Wed, Aug 14, 2019 at 02:46:38PM +1000, Jordan Niethe wrote: > On Tue, 2019-08-13 at 20:03 +1000, Paul Mackerras wrote: [snip] > > diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S > > b/arch/powerpc/kvm/book3s_hv_rmhandlers.S > > index 337e644..2e7e788 100644 >

  1   2   3   4   5   6   7   8   9   10   >