Re: [RFC PATCH 0/5] KVM: arm64: Add pvtime LPT support

2020-08-20 Thread zhukeqian
On 2020/8/19 16:54, Steven Price wrote: > On 18/08/2020 15:41, Marc Zyngier wrote: >> On 2020-08-17 09:41, Keqian Zhu wrote: >>> Hi all, >>> >>> This patch series picks up the LPT pvtime feature originally developed >>> by Steven Price: https://patchwork.kernel.org/cover/10726499/ >>> >>> Backgr

[PATCH v2 19/20] KVM: arm64: nVHE: Fix pointers during SMCCC convertion

2020-08-20 Thread Andrew Scull
The host need not concern itself with the pointer differences for the hyp interfaces that are shared between VHE and nVHE so leave it to the hyp to handle. As the SMCCC function IDs are converted into function calls, it is a suitable place to also convert any pointer arguments into hyp pointers. T

[PATCH v2 13/20] KVM: arm64: nVHE: Switch to hyp context for EL2

2020-08-20 Thread Andrew Scull
Save and restore the host context when switching to and from hyp. This gives hyp its own context that the host will not see as a step towards a full trust boundary between the two. SP_EL0 and pointer authentication keys are currently shared between the host and hyp so don't need to be switched yet

[PATCH v2 11/20] KVM: arm64: Restore hyp when panicking in guest context

2020-08-20 Thread Andrew Scull
If the guest context is loaded when a panic is triggered, restore the hyp context so e.g. the shadow call stack works when hyp_panic() is called and SP_EL0 is valid when the host's panic() is called. Use the hyp context's __hyp_running_vcpu field to track when hyp transitions to and from the guest

[PATCH v2 17/20] KVM: arm64: nVHE: Migrate hyp interface to SMCCC

2020-08-20 Thread Andrew Scull
Rather than passing arbitrary function pointers to run at hyp, define and equivalent set of SMCCC functions. Since the SMCCC functions are strongly tied to the original function prototypes, it is not expected for the host to ever call an invalid ID but a warning is raised if this does ever occur.

[PATCH v2 12/20] KVM: arm64: Share context save and restore macros

2020-08-20 Thread Andrew Scull
To avoid duplicating the context save and restore macros, move them into a shareable header. Signed-off-by: Andrew Scull --- arch/arm64/include/asm/kvm_asm.h | 39 arch/arm64/kvm/hyp/entry.S | 39 2 files changed, 39 inserti

[PATCH v2 10/20] KVM: arm64: Update context references from host to hyp

2020-08-20 Thread Andrew Scull
Hyp now has its own nominal context for saving and restoring its state when switching to and from a guest. Update the related comments and utilities to match the new name. Signed-off-by: Andrew Scull --- arch/arm64/include/asm/kvm_ptrauth.h | 6 +++--- arch/arm64/kvm/hyp/entry.S | 22

[PATCH v2 15/20] smccc: Cast arguments to unsigned long

2020-08-20 Thread Andrew Scull
To avoid warning about implicit casting, make the casting explicit. This allows, for example, pointers to be used as arguments as are used in the KVM hyp interface. Cc: Sudeep Holla Signed-off-by: Andrew Scull --- include/linux/arm-smccc.h | 20 ++-- 1 file changed, 10 insertion

[PATCH v2 14/20] KVM: arm64: nVHE: Handle hyp panics

2020-08-20 Thread Andrew Scull
Restore the host context when panicking from hyp to give the best chance of the panic being clean. The host requires that registers be preserved such as x18 for the shadow callstack. If the panic is caused by an exception from EL1, the host context is still valid so the panic can return straight b

[PATCH v2 18/20] KVM: arm64: nVHE: Migrate hyp-init to SMCCC

2020-08-20 Thread Andrew Scull
To complete the transition to SMCCC, the hyp initialization is given a function ID. This looks neater than comparing the hyp stub function IDs to the page table physical address. Some care is taken to only clobber x0-3 before the host context is saved as only those registers can be clobbered accor

[PATCH v2 20/20] KVM: arm64: nVHE: Handle stub HVCs in the host loop

2020-08-20 Thread Andrew Scull
Since the host is called from the hyp run loop, we can use that context to identify calls from the host rather than checking VTTBR_EL2, which will be used for the host's stage 2 in future. Moving this to C also allows for more flexibiliy e.g. in applying policies, such as forbidding HVC_RESET_VECT

[PATCH v2 16/20] KVM: arm64: nVHE: Pass pointers consistently to hyp-init

2020-08-20 Thread Andrew Scull
Rather than some being kernel pointer and others being hyp pointers, standardize on all pointers being hyp pointers. Signed-off-by: Andrew Scull --- arch/arm64/kvm/arm.c | 1 + arch/arm64/kvm/hyp/nvhe/hyp-init.S | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/ar

[PATCH v2 07/20] KVM: arm64: nVHE: Don't consume host SErrors with ESB

2020-08-20 Thread Andrew Scull
The ESB at the start of the host vector may cause SErrors to be consumed to DISR_EL1. However, this is not checked for the host so the SError could go unhandled. Remove the ESB so that SErrors are not consumed but are instead left pending for the host to consume. __guest_enter already defers entry

[PATCH v2 04/20] KVM: arm64: Restrict symbol aliasing to outside nVHE

2020-08-20 Thread Andrew Scull
nVHE symbols are prefixed but this is sometimes hidden from the host by aliasing the non-prefixed symbol to the prefixed version with a macro. This runs into problems if nVHE tries to use the symbol as it becomes doubly prefixed. Avoid this by omitting the aliasing macro for nVHE. Cc: David Brazdi

[PATCH v2 02/20] KVM: arm64: Remove hyp_panic arguments

2020-08-20 Thread Andrew Scull
hyp_panic is able to find all the context it needs from within itself so remove the argument. The __hyp_panic wrapper becomes redundant so is also removed. Signed-off-by: Andrew Scull --- arch/arm64/include/asm/kvm_hyp.h | 2 +- arch/arm64/kvm/hyp/hyp-entry.S | 11 +++ arch/arm64/kvm/

[PATCH v2 06/20] KVM: arm64: nVHE: Use separate vector for the host

2020-08-20 Thread Andrew Scull
The host is treated differently from the guests when an exception is taken so introduce a separate vector that is specialized for the host. This also allows the nVHE specific code to move out of hyp-entry.S and into nvhe/host.S. The host is only expected to make HVC calls and anything else is cons

[PATCH v2 03/20] KVM: arm64: Remove kvm_host_data_t typedef

2020-08-20 Thread Andrew Scull
The kvm_host_data_t typedef is used inconsistently and goes against the kernel's coding style. Remove it in favour of the full struct specifier. Signed-off-by: Andrew Scull --- arch/arm64/include/asm/kvm_host.h | 4 +--- arch/arm64/kvm/arm.c | 4 ++-- 2 files changed, 3 insertions(+

[PATCH v2 05/20] KVM: arm64: Save chosen hyp vector to a percpu variable

2020-08-20 Thread Andrew Scull
Introduce a percpu variable to hold the address of the selected hyp vector that will be used with guests. This avoids the selection process each time a guest is being entered and can be used by nVHE when a separate vector is introduced for the host. Signed-off-by: Andrew Scull --- arch/arm64/inc

[PATCH v2 01/20] KVM: arm64: Remove __activate_vm wrapper

2020-08-20 Thread Andrew Scull
The __activate_vm wrapper serves no useful function and has a misleading name as it simply calls __load_guest_stage2 and does not touch HCR_EL2.VM so remove it. Also rename __deactivate_vm to __load_host_stage2 to match naming pattern. Signed-off-by: Andrew Scull --- arch/arm64/kvm/hyp/include/

[PATCH v2 08/20] KVM: arm64: Preserve host DISR_EL1

2020-08-20 Thread Andrew Scull
With the RAS extension available, guest exits can overwrite DISR_EL1 after checking for any guest SErrors. If the host was using DISR_EL1 to track a deferred SError, it would be lost so save and restore DISR_EL1 for the host. Cc: James Morse Signed-off-by: Andrew Scull --- This may not be neces

[PATCH v2 00/20] Introduce separate nVHE hyp context

2020-08-20 Thread Andrew Scull
As a step on the way to isolating hyp from the host on nVHE as part of Android's "Protected KVM" project, this series introduces a separate register context for hyp visiting these topics on the way: - RAS for nVHE - Panicking from guest vectors with SCS - Switching to hyp context - Migration h

[PATCH v2 09/20] KVM: arm64: Introduce hyp context

2020-08-20 Thread Andrew Scull
During __guest_enter, save and restore from a new hyp context rather than the host context. This is preparation for separation of the hyp and host context in nVHE. Signed-off-by: Andrew Scull --- arch/arm64/include/asm/kvm_hyp.h| 3 ++- arch/arm64/kernel/image-vars.h | 1 + ar

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

2020-08-20 Thread Will Deacon
On Tue, Jul 28, 2020 at 01:07:14AM +, Jianyong Wu wrote: > > > > -Original Message- > > From: Will Deacon > > Sent: Monday, July 27, 2020 7:38 PM > > To: Jianyong Wu > > Cc: net...@vger.kernel.org; yangbo...@nxp.com; john.stu...@linaro.org; > > t...@linutronix.de; pbonz...@redhat.co

Re: [PATCH v2 1/2] KVM: arm64: Add PMU event filtering infrastructure

2020-08-20 Thread Marc Zyngier
On 2020-08-19 00:24, Alexander Graf wrote: Hi Marc, [...] I haven't seen a v3 follow-up after this. Do you happen to have that somewhere in a local branch and just need to send it out or would you prefer if I pick up v2 and address the comments? I'll look into it. M. -- Jazz is not

Re: [PATCH 0/2] KVM: arm64: Fix sleeping while atomic BUG() on OOM

2020-08-20 Thread Paolo Bonzini
On 18/08/20 12:16, Will Deacon wrote: > Please note that I'm planning on rewriting most of the arm64 KVM page-table > code for 5.10, so if you can get this series in early (e.g. for -rc2), then > it would _really_ help with managing the kvm/arm64 queue for the next merge > window. Yes, I plan to s