Re: [PATCH v3 00/21] KVM: arm64: Rewrite page-table code and fault handling

2020-09-04 Thread Gavin Shan
Hi Marc, On 9/4/20 8:07 PM, Marc Zyngier wrote: On 2020-09-04 01:51, Gavin Shan wrote: On 9/3/20 10:16 PM, Will Deacon wrote: On Thu, Sep 03, 2020 at 09:48:18PM +1000, Gavin Shan wrote: On 9/3/20 9:13 PM, Gavin Shan wrote: On 9/3/20 5:34 PM, Gavin Shan wrote: On 8/25/20 7:39 PM, Will Deacon

Re: [PATCH v14 09/10] doc: add ptp_kvm introduction for arm64 support

2020-09-04 Thread Marc Zyngier
On Fri, 04 Sep 2020 10:27:43 +0100, Jianyong Wu wrote: > > ptp_kvm implementation depends on hypercall using SMCCC. So we > introduce a new SMCCC service ID. This doc explain how we define > and use this new ID. > > Signed-off-by: Jianyong Wu > --- > Documentation/virt/kvm/arm/ptp_kvm.rst | 72

Re: [PATCH v14 07/10] arm64/kvm: Add hypercall service for kvm ptp.

2020-09-04 Thread Marc Zyngier
On Fri, 04 Sep 2020 10:27:41 +0100, Jianyong Wu wrote: > > ptp_kvm will get this service through smccc call. > The service offers wall time and counter cycle of host for guest. > caller must explicitly determines which cycle of virtual counter or > physical counter to return if it needs counter c

Re: [PATCH 22/23] KVM: arm64: Add a rVIC/rVID in-kernel implementation

2020-09-04 Thread Jonathan Cameron
On Thu, 3 Sep 2020 16:26:09 +0100 Marc Zyngier wrote: > The rVIC (reduced Virtual Interrupt Controller), and its rVID > (reduced Virtual Interrupt Distributor) companion are the two > parts of a PV interrupt controller architecture, aiming at supporting > VMs with minimal interrupt requirements.

[PATCH v2 0/2] MTE support for KVM guest

2020-09-04 Thread Steven Price
Arm's Memory Tagging Extension (MTE) adds 4 bits of tag data to every 16 bytes of memory in the system. This along with stashing a tag within the high bit of virtual addresses allows runtime checking of memory accesses. These patches add support to KVM to enable MTE within a guest. They are based

[PATCH v2 1/2] arm64: kvm: Save/restore MTE registers

2020-09-04 Thread Steven Price
Define the new system registers that MTE introduces and context switch them. The MTE feature is still hidden from the ID register as it isn't supported in a VM yet. Signed-off-by: Steven Price --- arch/arm64/include/asm/kvm_host.h | 4 arch/arm64/include/asm/sysreg.h|

[PATCH v2 2/2] arm64: kvm: Introduce MTE VCPU feature

2020-09-04 Thread Steven Price
Add a new VCPU features 'KVM_ARM_VCPU_MTE' which enables memory tagging on a VCPU. When enabled on any VCPU in the virtual machine this causes all pages that are faulted into the VM to have the PG_mte_tagged flag set (and the tag storage cleared if this is the first use). Signed-off-by: Steven Pri

Re: [PATCH 12/23] KVM: arm64: Move kvm_vgic_vcpu_pending_irq() to irqchip_flow

2020-09-04 Thread Jonathan Cameron
On Thu, 3 Sep 2020 16:25:59 +0100 Marc Zyngier wrote: > Abstract the calls to kvm_vgic_vcpu_pending_irq() via the irqchip_flow > structure. > > No functional change. > > Signed-off-by: Marc Zyngier A couple of stray lines in here that I think should be in patch 14 Jonathan > --- > arch/arm

Re: [PATCH 05/23] KVM: arm64: Move GIC model out of the distributor

2020-09-04 Thread Jonathan Cameron
On Thu, 3 Sep 2020 16:25:52 +0100 Marc Zyngier wrote: > In order to allow more than just GIC implementations in the future, > let's move the GIC model outside of the distributor. This also > allows us to back irqchip_in_kernel() with its own irqchip type > (IRQCHIP_USER), removing another field

Re: [PATCH 04/23] irqchip/rvid: Add PCI MSI support

2020-09-04 Thread Jonathan Cameron
On Thu, 3 Sep 2020 16:25:51 +0100 Marc Zyngier wrote: > Signed-off-by: Marc Zyngier Few minor comments inline. Thanks, Jonathan > --- > drivers/irqchip/irq-rvid.c | 182 + > 1 file changed, 182 insertions(+) > > diff --git a/drivers/irqchip/irq-rvid.c b/

Re: [PATCH 03/23] irqchip: Add Reduced Virtual Interrupt Distributor support

2020-09-04 Thread Jonathan Cameron
On Thu, 3 Sep 2020 16:25:50 +0100 Marc Zyngier wrote: > Signed-off-by: Marc Zyngier Hi Marc, Again, only trivial stuff in here from me. Jonathan > --- > drivers/irqchip/Kconfig | 6 + > drivers/irqchip/Makefile | 1 + > drivers/irqchip/irq-rvid.c | 259 ++

Re: [PATCH 02/23] irqchip/rvic: Add support for untrusted interrupt allocation

2020-09-04 Thread Jonathan Cameron
On Thu, 3 Sep 2020 16:25:49 +0100 Marc Zyngier wrote: > Signed-off-by: Marc Zyngier Hi Marc, One trivial comment inline. > --- > drivers/irqchip/irq-rvic.c | 47 +++--- > 1 file changed, 44 insertions(+), 3 deletions(-) > > diff --git a/drivers/irqchip/irq-rv

[PATCH 8/9] KVM: arm64: Fix address truncation in traces

2020-09-04 Thread Marc Zyngier
Owing to their ARMv7 origins, the trace events are truncating most address values to 32bits. That's not really helpful. Expand the printing of such values to their full glory. Signed-off-by: Marc Zyngier --- arch/arm64/kvm/trace_arm.h | 16 arch/arm64/kvm/trace_handle_e

[GIT PULL] KVM/arm64 fixes for 5.9

2020-09-04 Thread Marc Zyngier
Hi Paolo, Here's a bunch of fixes for 5.9. The gist of it is the stolen time rework from Andrew, but we also have a couple of MM fixes that have surfaced as people have started to use hugetlbfs in anger. Please pull, M. The following changes since commit 9123e3a74ec7b934a4a099e98af6a61c

[PATCH 4/9] KVM: arm64: pvtime: Fix stolen time accounting across migration

2020-09-04 Thread Marc Zyngier
From: Andrew Jones When updating the stolen time we should always read the current stolen time from the user provided memory, not from a kernel cache. If we use a cache then we'll end up resetting stolen time to zero on the first update after migration. Signed-off-by: Andrew Jones Signed-off-by

[PATCH 2/9] KVM: arm64: pvtime: Fix potential loss of stolen time

2020-09-04 Thread Marc Zyngier
From: Andrew Jones We should only check current->sched_info.run_delay once when updating stolen time. Otherwise there's a chance there could be a change between checks that we miss (preemption disabling comes after vcpu request checks). Signed-off-by: Andrew Jones Signed-off-by: Marc Zyngier L

[PATCH 7/9] KVM: arm64: Do not try to map PUDs when they are folded into PMD

2020-09-04 Thread Marc Zyngier
For the obscure cases where PMD and PUD are the same size (64kB pages with 42bit VA, for example, which results in only two levels of page tables), we can't map anything as a PUD, because there is... erm... no PUD to speak of. Everything is either a PMD or a PTE. So let's only try and map a PUD wh

[PATCH 6/9] arm64/x86: KVM: Introduce steal-time cap

2020-09-04 Thread Marc Zyngier
From: Andrew Jones arm64 requires a vcpu fd (KVM_HAS_DEVICE_ATTR vcpu ioctl) to probe support for steal-time. However this is unnecessary, as only a KVM fd is required, and it complicates userspace (userspace may prefer delaying vcpu creation until after feature probing). Introduce a cap that can

[PATCH 9/9] KVM: arm64: Update page shift if stage 2 block mapping not supported

2020-09-04 Thread Marc Zyngier
From: Alexandru Elisei Commit 196f878a7ac2e (" KVM: arm/arm64: Signal SIGBUS when stage2 discovers hwpoison memory") modifies user_mem_abort() to send a SIGBUS signal when the fault IPA maps to a hwpoisoned page. Commit 1559b7583ff6 ("KVM: arm/arm64: Re-check VMA on detecting a poisoned page") ch

[PATCH 5/9] KVM: Documentation: Minor fixups

2020-09-04 Thread Marc Zyngier
From: Andrew Jones In preparation for documenting a new capability let's fix up the formatting of the current ones. Signed-off-by: Andrew Jones Signed-off-by: Marc Zyngier Reviewed-by: Steven Price Link: https://lore.kernel.org/r/20200804170604.42662-6-drjo...@redhat.com --- Documentation/vi

[PATCH 3/9] KVM: arm64: Drop type input from kvm_put_guest

2020-09-04 Thread Marc Zyngier
From: Andrew Jones We can use typeof() to avoid the need for the type input. Suggested-by: Marc Zyngier Signed-off-by: Andrew Jones Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/20200804170604.42662-4-drjo...@redhat.com --- arch/arm64/kvm/pvtime.c | 2 +- include/linux/kvm_ho

[PATCH 1/9] KVM: arm64: pvtime: steal-time is only supported when configured

2020-09-04 Thread Marc Zyngier
From: Andrew Jones Don't confuse the guest by saying steal-time is supported when it hasn't been configured by userspace and won't work. Signed-off-by: Andrew Jones Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/20200804170604.42662-2-drjo...@redhat.com --- arch/arm64/kvm/pvtime.

Re: [PATCH 0/2] KVM: arm64: user_mem_abort() improvements

2020-09-04 Thread Marc Zyngier
On Tue, 1 Sep 2020 14:33:55 +0100, Alexandru Elisei wrote: > The first patch is a fix for a bug that I found by code inspection. > > The second patch is an enhancement for the way user_mem_abort() handles > hugetlbfs backed VM memory. > > Tested on a rockpro64 with 4K pages and hugetlbfs hugepage

Re: [PATCH v3 00/21] KVM: arm64: Rewrite page-table code and fault handling

2020-09-04 Thread Marc Zyngier
On 2020-09-04 01:51, Gavin Shan wrote: Hi Will, On 9/3/20 10:16 PM, Will Deacon wrote: On Thu, Sep 03, 2020 at 09:48:18PM +1000, Gavin Shan wrote: On 9/3/20 9:13 PM, Gavin Shan wrote: On 9/3/20 5:34 PM, Gavin Shan wrote: On 8/25/20 7:39 PM, Will Deacon wrote: Hello folks, This is version t

Re: [PATCH v3 20/21] KVM: arm64: Remove unused 'pgd' field from 'struct kvm_s2_mmu'

2020-09-04 Thread Marc Zyngier
On 2020-09-04 01:59, Gavin Shan wrote: Hi Will, On 9/4/20 2:50 AM, Will Deacon wrote: On Thu, Sep 03, 2020 at 03:07:17PM +1000, Gavin Shan wrote: On 8/25/20 7:39 PM, Will Deacon wrote: The stage-2 page-tables are entirely encapsulated by the 'pgt' field of 'struct kvm_s2_mmu', so remove the

Re: [PATCH 2/2] KVM: arm64: Try PMD block mappings if PUD mappings are not supported

2020-09-04 Thread Marc Zyngier
Hi Alex, On Tue, 01 Sep 2020 14:33:57 +0100, Alexandru Elisei wrote: > > When userspace uses hugetlbfs for the VM memory, user_mem_abort() tries to > use the same block size to map the faulting IPA in stage 2. If stage 2 > cannot use the same size mapping because the block size doesn't fit in th

[PATCH v14 10/10] arm64: Add kvm capability check extension for ptp_kvm

2020-09-04 Thread Jianyong Wu
Let userspace check if there is kvm ptp service in host. Before VMs migrate to another host, VMM may check if this cap is available to determine the next behavior. Signed-off-by: Jianyong Wu Suggested-by: Marc Zyngier --- arch/arm64/kvm/arm.c | 4 include/uapi/linux/kvm.h | 1 + 2 file

[PATCH v14 03/10] smccc: Export smccc conduit get helper.

2020-09-04 Thread Jianyong Wu
Export arm_smccc_1_1_get_conduit then modules can use smccc helper which adopts it. Acked-by: Mark Rutland Signed-off-by: Jianyong Wu --- drivers/firmware/smccc/smccc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/firmware/smccc/smccc.c b/drivers/firmware/smccc/smccc.c index 4e80

[PATCH v14 09/10] doc: add ptp_kvm introduction for arm64 support

2020-09-04 Thread Jianyong Wu
ptp_kvm implementation depends on hypercall using SMCCC. So we introduce a new SMCCC service ID. This doc explain how we define and use this new ID. Signed-off-by: Jianyong Wu --- Documentation/virt/kvm/arm/ptp_kvm.rst | 72 ++ 1 file changed, 72 insertions(+) create mod

[PATCH v14 05/10] time: Add mechanism to recognize clocksource in time_get_snapshot

2020-09-04 Thread Jianyong Wu
From: Thomas Gleixner System time snapshots are not conveying information about the current clocksource which was used, but callers like the PTP KVM guest implementation have the requirement to evaluate the clocksource type to select the appropriate mechanism. Introduce a clocksource id field in

[PATCH v14 08/10] ptp: arm64: Enable ptp_kvm for arm64

2020-09-04 Thread Jianyong Wu
Currently, there is no mechanism to keep time sync between guest and host in arm64 virtualization environment. Time in guest will drift compared with host after boot up as they may both use third party time sources to correct their time respectively. The time deviation will be in order of milliseco

[PATCH v14 07/10] arm64/kvm: Add hypercall service for kvm ptp.

2020-09-04 Thread Jianyong Wu
ptp_kvm will get this service through smccc call. The service offers wall time and counter cycle of host for guest. caller must explicitly determines which cycle of virtual counter or physical counter to return if it needs counter cycle. Signed-off-by: Jianyong Wu --- arch/arm64/kvm/Kconfig

[PATCH v14 02/10] arm/arm64: KVM: Advertise KVM UID to guests via SMCCC

2020-09-04 Thread Jianyong Wu
From: Will Deacon We can advertise ourselves to guests as KVM and provide a basic features bitmap for discoverability of future hypervisor services. Cc: Marc Zyngier Signed-off-by: Will Deacon Signed-off-by: Jianyong Wu --- arch/arm64/kvm/hypercalls.c | 29 +++-- 1 fi

[PATCH v14 06/10] clocksource: Add clocksource id for arm arch counter

2020-09-04 Thread Jianyong Wu
Add clocksource id for arm arch counter to let it be identified easily and elegantly in ptp_kvm implementation for arm. Signed-off-by: Jianyong Wu --- drivers/clocksource/arm_arch_timer.c | 2 ++ include/linux/clocksource_ids.h | 1 + 2 files changed, 3 insertions(+) diff --git a/drivers/c

[PATCH v14 04/10] ptp: Reorganize ptp_kvm module to make it arch-independent.

2020-09-04 Thread Jianyong Wu
Currently, ptp_kvm modules implementation is only for x86 which includs large part of arch-specific code. This patch move all of those code into new arch related file in the same directory. Signed-off-by: Jianyong Wu --- drivers/ptp/Makefile| 5 ++ drivers/ptp/ptp_kvm.h

[PATCH v14 00/10] Enable ptp_kvm for arm64

2020-09-04 Thread Jianyong Wu
Currently, we offen use ntp (sync time with remote network clock) to sync time in VM. But the precision of ntp is subject to network delay so it's difficult to sync time in a high precision. kvm virtual ptp clock (ptp_kvm) offers another way to sync time in VM, as the remote clock locates in the h

[PATCH v14 01/10] arm64: Probe for the presence of KVM hypervisor services during boot

2020-09-04 Thread Jianyong Wu
From: Will Deacon Although the SMCCC specification provides some limited functionality for describing the presence of hypervisor and firmware services, this is generally applicable only to functions designated as "Arm Architecture Service Functions" and no portable discovery mechanism is provided