[PATCH v16 9/9] arm64: Add kvm capability check extension for ptp_kvm

2020-12-08 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 | 1 + include/uapi/linux/kvm.h | 1 + 2 files c

[PATCH v16 8/9] doc: add ptp_kvm introduction for arm64 support

2020-12-08 Thread Jianyong Wu
PTP_KVM implementation depends on hypercall using SMCCC. So we introduce a new SMCCC service ID. This doc explains how does the ID define and how does PTP_KVM works on arm/arm64. Signed-off-by: Jianyong Wu --- Documentation/virt/kvm/api.rst | 9 +++ Documentation/virt/kvm/arm/index.

[PATCH v16 7/9] ptp: arm/arm64: Enable ptp_kvm for arm/arm64

2020-12-08 Thread Jianyong Wu
Currently, there is no mechanism to keep time sync between guest and host in arm/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 milli

[PATCH v16 6/9] arm64/kvm: Add hypercall service for kvm ptp.

2020-12-08 Thread Jianyong Wu
ptp_kvm will get this service through SMCC call. The service offers wall time and cycle count of host to guest. The caller must specify whether they want the host cycle count or the difference between host cycle count and cntvoff. Signed-off-by: Jianyong Wu --- arch/arm64/kvm/hypercalls.c | 59 +

[PATCH v16 5/9] clocksource: Add clocksource id for arm arch counter

2020-12-08 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 v16 4/9] time: Add mechanism to recognize clocksource in time_get_snapshot

2020-12-08 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 v16 3/9] ptp: Reorganize ptp_kvm module to make it arch-independent.

2020-12-08 Thread Jianyong Wu
Currently, ptp_kvm modules implementation is only for x86 which includes large part of arch-specific code. This patch moves all of this code into a new arch related file in the same directory. Signed-off-by: Jianyong Wu --- drivers/ptp/Makefile| 1 + drivers/ptp/{ptp_kv

[PATCH v16 2/9] arm/arm64: KVM: Advertise KVM UID to guests via SMCCC

2020-12-08 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 | 27 ++- 1 file

[PATCH v16 1/9] arm64: Probe for the presence of KVM hypervisor

2020-12-08 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

[PATCH v16 0/9] Enable ptp_kvm for arm/arm64

2020-12-08 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

Re: [RFC][PATCH 0/4] arm64:kvm: teach guest sched that VCPUs can be preempted

2020-12-08 Thread Joel Fernandes
On Fri, Sep 11, 2020 at 4:58 AM Sergey Senozhatsky wrote: > > My apologies for the slow reply. > > On (20/08/17 13:25), Marc Zyngier wrote: > > > > It really isn't the same thing at all. You are exposing PV spinlocks, > > while Sergey exposes preemption to vcpus. > > > > Correct, we see vcpu preem

Re: [PATCH v4 00/26] Opt-in always-on nVHE hypervisor

2020-12-08 Thread David Brazdil
Hey Marc, On Thu, Dec 03, 2020 at 07:23:19PM +, Marc Zyngier wrote: > On Wed, 2 Dec 2020 18:40:56 +, David Brazdil wrote: > > As we progress towards being able to keep guest state private to the > > host running nVHE hypervisor, this series allows the hypervisor to > > install itself on ne

Re: [PATCH v4 00/26] Opt-in always-on nVHE hypervisor

2020-12-08 Thread Marc Zyngier
On Tue, 08 Dec 2020 19:14:47 +, David Brazdil wrote: > > Hey Marc, > > On Thu, Dec 03, 2020 at 07:23:19PM +, Marc Zyngier wrote: > > On Wed, 2 Dec 2020 18:40:56 +, David Brazdil wrote: > > > As we progress towards being able to keep guest state private to the > > > host running nVHE

[PATCH 5/6] kvm: arm64: Remove unused includes in psci-relay.c

2020-12-08 Thread David Brazdil
Minor cleanup removing unused includes. Signed-off-by: David Brazdil --- arch/arm64/kvm/hyp/nvhe/psci-relay.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/psci-relay.c b/arch/arm64/kvm/hyp/nvhe/psci-relay.c index 0d6f4aa39621..1f7237e45148 100644 --- a/arch/arm6

[PATCH 6/6] kvm: arm64: Move skip_host_instruction to adjust_pc.h

2020-12-08 Thread David Brazdil
Move function for skipping host instruction in the host trap handler to a header file containing analogical helpers for guests. Signed-off-by: David Brazdil --- arch/arm64/kvm/hyp/include/hyp/adjust_pc.h | 9 + arch/arm64/kvm/hyp/nvhe/hyp-main.c | 12 ++-- 2 files change

[PATCH 2/6] kvm: arm64: Use lm_alias in nVHE-only VA conversion

2020-12-08 Thread David Brazdil
init_hyp_physvirt_offset() computes PA from a kernel VA. Conversion to kernel linear-map is required first but the code used kvm_ksym_ref() for this purpose. Under VHE that is a NOP and resulted in a runtime warning. Replace kvm_ksym_ref with lm_alias. Reported-by: Qian Cai Signed-off-by: David B

[PATCH 4/6] kvm: arm64: Minor cleanup of hyp variables used in host

2020-12-08 Thread David Brazdil
Small cleanup moving declarations of hyp-exported variables to kvm_host.h and using macros to avoid having to refer to them with kvm_nvhe_sym() in host. No functional change intended. Signed-off-by: David Brazdil --- arch/arm64/include/asm/kvm_host.h | 6 ++ arch/arm64/kvm/arm.c

[PATCH 3/6] kvm: arm64: Skip computing hyp VA layout for VHE

2020-12-08 Thread David Brazdil
Computing the hyp VA layout is redundant when the kernel runs in EL2 and hyp shares its VA mappings. Make calling kvm_compute_layout() conditional on not just CONFIG_KVM but also !is_kernel_in_hyp_mode(). Signed-off-by: David Brazdil --- arch/arm64/kernel/smp.c | 2 +- 1 file changed, 1 insertio

[PATCH 0/6] Fixes and cleanups of PSCI relay for kvmarm/next

2020-12-08 Thread David Brazdil
Small batch of improvements for the 'Opt-in always-on nVHE hypervisor' series, now merged in kvmarm/next. Patch #1 fixes potential use of invalid v0.1 functions IDs reported by Mark Rutland, patch #2 fixes a warning reported by Qian Cai. Patch #3 avoids a code path not used in VHE, can be dropped

[PATCH 1/6] kvm: arm64: Prevent use of invalid PSCI v0.1 function IDs

2020-12-08 Thread David Brazdil
PSCI driver exposes a struct containing the PSCI v0.1 function IDs configured in the DT. However, the struct does not convey the information whether these were set from DT or contain the default value zero. This could be a problem for PSCI proxy in KVM protected mode. Extend config passed to KVM w

Re: [PATCH v5 0/2] MTE support for KVM guest

2020-12-08 Thread Marc Zyngier
On 2020-12-08 17:21, Catalin Marinas wrote: On Mon, Dec 07, 2020 at 07:03:13PM +, Marc Zyngier wrote: On Mon, 07 Dec 2020 16:34:05 +, Catalin Marinas wrote: > On Mon, Dec 07, 2020 at 04:05:55PM +, Marc Zyngier wrote: > > What I'd really like to see is a description of how shared mem

Re: [PATCH 1/6] kvm: arm64: Prevent use of invalid PSCI v0.1 function IDs

2020-12-08 Thread Mark Rutland
On Tue, Dec 08, 2020 at 03:56:39PM +, Marc Zyngier wrote: > On 2020-12-08 14:24, David Brazdil wrote: > > PSCI driver exposes a struct containing the PSCI v0.1 function IDs > > configured in the DT. However, the struct does not convey the > > information whether these were set from DT or contai

Re: [PATCH v5 0/2] MTE support for KVM guest

2020-12-08 Thread Catalin Marinas
On Mon, Dec 07, 2020 at 07:03:13PM +, Marc Zyngier wrote: > On Mon, 07 Dec 2020 16:34:05 +, > Catalin Marinas wrote: > > On Mon, Dec 07, 2020 at 04:05:55PM +, Marc Zyngier wrote: > > > What I'd really like to see is a description of how shared memory > > > is, in general, supposed to w

Re: [PATCH 1/6] kvm: arm64: Prevent use of invalid PSCI v0.1 function IDs

2020-12-08 Thread Marc Zyngier
On 2020-12-08 14:24, David Brazdil wrote: PSCI driver exposes a struct containing the PSCI v0.1 function IDs configured in the DT. However, the struct does not convey the information whether these were set from DT or contain the default value zero. This could be a problem for PSCI proxy in KVM pr

Re: [PATCH v4 17/26] kvm: arm64: Add offset for hyp VA <-> PA conversion

2020-12-08 Thread David Brazdil
Hi Qian, > > +/* > > + * Store a hyp VA <-> PA offset into a hyp-owned variable. > > + */ > > +static void init_hyp_physvirt_offset(void) > > +{ > > + extern s64 kvm_nvhe_sym(hyp_physvirt_offset); > > + u64 kern_va, hyp_va; > > + > > + /* Compute the offset from the hyp VA and PA of a random

Re: [PATCH v5 0/2] MTE support for KVM guest

2020-12-08 Thread Haibo Xu
On Tue, 8 Dec 2020 at 18:01, Marc Zyngier wrote: > > On 2020-12-08 09:51, Haibo Xu wrote: > > On Mon, 7 Dec 2020 at 22:48, Steven Price wrote: > >> > > [...] > > >> Sounds like you are making good progress - thanks for the update. Have > >> you thought about how the PROT_MTE mappings might work i

Re: [PATCH v5 0/2] MTE support for KVM guest

2020-12-08 Thread Haibo Xu
On Tue, 8 Dec 2020 at 00:44, Dr. David Alan Gilbert wrote: > > * Steven Price (steven.pr...@arm.com) wrote: > > On 07/12/2020 15:27, Peter Maydell wrote: > > > On Mon, 7 Dec 2020 at 14:48, Steven Price wrote: > > > > Sounds like you are making good progress - thanks for the update. Have > > > > y

Re: [PATCH v5 0/2] MTE support for KVM guest

2020-12-08 Thread Marc Zyngier
On 2020-12-08 09:51, Haibo Xu wrote: On Mon, 7 Dec 2020 at 22:48, Steven Price wrote: [...] Sounds like you are making good progress - thanks for the update. Have you thought about how the PROT_MTE mappings might work if QEMU itself were to use MTE? My worry is that we end up with MTE in a

Re: [PATCH v5 0/2] MTE support for KVM guest

2020-12-08 Thread Haibo Xu
On Mon, 7 Dec 2020 at 22:48, Steven Price wrote: > > On 04/12/2020 08:25, Haibo Xu wrote: > > On Fri, 20 Nov 2020 at 17:51, Steven Price wrote: > >> > >> On 19/11/2020 19:11, Marc Zyngier wrote: > >>> On 2020-11-19 18:42, Andrew Jones wrote: > On Thu, Nov 19, 2020 at 03:45:40PM +, Peter

Re: [RFC PATCH 16/27] KVM: arm64: Prepare Hyp memory protection

2020-12-08 Thread Will Deacon
On Mon, Dec 07, 2020 at 02:11:20PM +, Quentin Perret wrote: > On Monday 07 Dec 2020 at 13:40:52 (+), Will Deacon wrote: > > Why not use the RESERVEDMEM_OF_DECLARE() interface for the hypervisor > > memory? That way, the hypervisor memory can either be statically partitioned > > as a carveou

Re: [RFC PATCH v1 3/4] KVM: arm64: GICv4.1: Restore VLPI's pending state to physical side

2020-12-08 Thread Shenming Lu
On 2020/12/1 20:15, Shenming Lu wrote: > On 2020/12/1 19:50, Marc Zyngier wrote: >> On 2020-12-01 11:40, Shenming Lu wrote: >>> On 2020/12/1 18:55, Marc Zyngier wrote: On 2020-11-30 07:23, Shenming Lu wrote: Hi Shenming, > We are pondering over this problem these days, but s

Re: [PATCH v4 17/26] kvm: arm64: Add offset for hyp VA <-> PA conversion

2020-12-08 Thread Qian Cai
On Wed, 2020-12-02 at 18:41 +, David Brazdil wrote: > Add a host-initialized constant to KVM nVHE hyp code for converting > between EL2 linear map virtual addresses and physical addresses. > Also add `__hyp_pa` macro that performs the conversion. > > Signed-off-by: David Brazdil > --- > arch