Re: [PATCH v2 07/15] KVM: arm64: Introduce kvm_share_hyp()

2021-10-21 Thread David Brazdil
Hi Quentin, > diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c > index 0019b2309f70..0cc4b295e525 100644 > --- a/arch/arm64/kvm/mmu.c > +++ b/arch/arm64/kvm/mmu.c > @@ -299,6 +299,17 @@ static int pkvm_share_hyp(phys_addr_t start, phys_addr_t > end) > return 0; > } > > +int

Re: [PATCH] KVM: arm64: Allow KVM to be disabled from the command line

2021-09-28 Thread David Brazdil
Hey Marc, that all makes sense: Reviewed-by: David Brazdil > @@ -2137,8 +2142,15 @@ static int __init early_kvm_mode_cfg(char *arg) > return 0; > } > > - if (strcmp(arg, "nvhe") == 0 && !WARN_ON(is_kernel_in_hyp_mode())) > + if (

[PATCH 1/2] KVM: arm64: Fix off-by-one in range_is_memory

2021-07-28 Thread David Brazdil
Perret Fixes: 90134ac9cabb6 ("KVM: arm64: Protect the .hyp sections from the host") Signed-off-by: David Brazdil --- arch/arm64/kvm/hyp/nvhe/mem_protect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/kvm/hyp/nvhe/mem_protect.c b/arch/arm64/kvm/hyp/nvhe/mem

[PATCH 2/2] KVM: arm64: Minor optimization of range_is_memory

2021-07-28 Thread David Brazdil
and then checking that the upper bound is in the same memblock. Signed-off-by: David Brazdil --- arch/arm64/kvm/hyp/nvhe/mem_protect.c | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/mem_protect.c b/arch/arm64/kvm/hyp/nvhe/mem_protect.c index

[PATCH 0/2] Fix off-by-one in range_is_memory

2021-07-28 Thread David Brazdil
Hi, here is an off-by-one bug fix and a very minor improvement for the range_is_memory function in hyp. David Brazdil (2): KVM: arm64: Fix off-by-one in range_is_memory KVM: arm64: Minor optimization of range_is_memory arch/arm64/kvm/hyp/nvhe/mem_protect.c | 11 --- 1 file changed

[PATCH] KVM: arm64: Support PREL/PLT relocs in EL2 code

2021-03-31 Thread David Brazdil
arm64: Generate hyp relocation data") Cc: Reported-by: Will Deacon Signed-off-by: David Brazdil --- arch/arm64/kvm/hyp/nvhe/gen-hyprel.c | 18 ++ 1 file changed, 18 insertions(+) diff --git a/arch/arm64/kvm/hyp/nvhe/gen-hyprel.c b/arch/arm64/kvm/hyp/nvhe/gen-hyprel.c index ea

Re: [PATCH v2 4/8] KVM: arm64: Generate hyp relocation data

2021-02-01 Thread David Brazdil
Thanks for writing the fix, Marc! There are no corner cases in this code so if it boots, that should be a good indicator that all BE inputs were converted. Just one little thing I noticed below, otherwise: Acked-by: David Brazdil > arch/arm64/kvm/hyp/nvhe/Makefile | 1 + > arch/arm

Re: [PATCH v4 00/21] arm64: Early CPU feature override, and applications to VHE, BTI and PAuth

2021-01-18 Thread David Brazdil
104135011.2063104-1-...@kernel.org > [3] https://lore.kernel.org/r/2021032811.2455113-1-...@kernel.org Pretty cool! Left a few minor comments here and there, other than that: Acked-by: David Brazdil ___ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

Re: [PATCH v4 18/21] arm64: Move "nokaslr" over to the early cpufeature infrastructure

2021-01-18 Thread David Brazdil
On Mon, Jan 18, 2021 at 09:45:30AM +, Marc Zyngier wrote: > Given that the early cpufeature infrastructure has borrowed quite > a lot of code from the kaslr implementation, let's reimplement > the matching of the "nokaslr" option with it. > > Signed-off-by: Marc

Re: [PATCH v4 17/21] KVM: arm64: Document HVC_VHE_RESTART stub hypercall

2021-01-18 Thread David Brazdil
On Mon, Jan 18, 2021 at 09:45:29AM +, Marc Zyngier wrote: > For completeness, let's document the HVC_VHE_RESTART stub. > > Signed-off-by: Marc Zyngier Acked-by: David Brazdil > --- > Documentation/virt/kvm/arm/hyp-abi.rst | 9 + > 1 file changed, 9 insertions(

Re: [PATCH v4 15/21] arm64: Add an aliasing facility for the idreg override

2021-01-18 Thread David Brazdil
Zyngier Acked-by: David Brazdil > --- > arch/arm64/kernel/idreg-override.c | 20 > 1 file changed, 20 insertions(+) > > diff --git a/arch/arm64/kernel/idreg-override.c > b/arch/arm64/kernel/idreg-override.c > index 75d9845f489b..16bc8b3b93ae 100644 > -

Re: [PATCH v4 14/21] arm64: Honor VHE being disabled from the command-line

2021-01-18 Thread David Brazdil
On Mon, Jan 18, 2021 at 09:45:26AM +, Marc Zyngier wrote: > Finally we can check whether VHE is disabled on the command line, > and not enable it if that's the user's wish. > > Signed-off-by: Marc Zyngier Acked-by: David Brazdil > --- > arch/arm64/kern

Re: [PATCH v4 12/21] arm64: cpufeature: Add an early command-line cpufeature override facility

2021-01-18 Thread David Brazdil
override val/mask pair. > > No features are currently defined, so no expected change in > functionality. > > Signed-off-by: Marc Zyngier Acked-by: David Brazdil > --- > arch/arm64/kernel/Makefile | 2 +- > arch/arm64/kernel/head.S | 1

Re: [PATCH v4 04/21] arm64: Provide an 'upgrade to VHE' stub hypercall

2021-01-18 Thread David Brazdil
On Mon, Jan 18, 2021 at 09:45:16AM +, Marc Zyngier wrote: > As we are about to change the way a VHE system boots, let's > provide the core helper, in the form of a stub hypercall that > enables VHE and replicates the full EL1 context at EL2, thanks > to EL1 and VHE-EL2 being extremely similar.

Re: [PATCH v4 01/21] arm64: Fix labels in el2_setup macros

2021-01-18 Thread David Brazdil
Zyngier > --- > arch/arm64/include/asm/el2_setup.h | 24 > 1 file changed, 12 insertions(+), 12 deletions(-) Acked-by: David Brazdil ___ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

Re: [PATCH v3 3/9] KVM: arm64: Enable UBSAN_BOUNDS for the both the kernel and hyp/nVHE

2021-01-18 Thread David Brazdil
On Fri, Jan 15, 2021 at 05:18:24PM +, Elena Petrova wrote: > From: George Popescu > > If an out of bounds happens inside the hyp/nVHE code, the ubsan_out_of_bounds > handler stores the logging data inside the kvm_ubsan_buffer. The one > responsible > for printing is the kernel

Re: [PATCH v3 9/9] KVM: arm64: Add UBSan tests for PKVM.

2021-01-18 Thread David Brazdil
On Fri, Jan 15, 2021 at 05:18:30PM +, Elena Petrova wrote: > From: George-Aurelian Popescu > > Test the UBsan functionality inside hyp/nVHE. > Because modules are not supported inside of hyp/nVHE code, the default > testing module for UBSan can not be used. > New functions have to be defined

Re: [PATCH v3 2/9] KVM: arm64: Add a buffer that can pass UBSan data from hyp/nVHE to kernel

2021-01-18 Thread David Brazdil
On Fri, Jan 15, 2021 at 05:18:23PM +, Elena Petrova wrote: > From: George Popescu > > Share a buffer between the kernel and the hyp/nVHE code by using the > macros from kvm_debug_buffer.h. > The hyp/nVHE code requires a write index which counts how many elements > have been writtens inside

Re: [PATCH v3 1/9] KVM: arm64: Enable UBSan instrumentation in nVHE hyp code

2021-01-18 Thread David Brazdil
he ones defined in kernel-proper lib/ubsan.c. > > In this way, enabling UBSAN_MISC won't cause a link error. The commit message needs to be updated - UBSAN_MISC does not exist any longer. Also "nVHe" is a typo. Other than that: Acked-by: David Brazdil > > Signed-off-by: Elena Petr

Re: [PATCH] KVM: arm64: Allow PSCI SYSTEM_OFF/RESET to return

2020-12-30 Thread David Brazdil
On Tue, Dec 29, 2020 at 05:16:41PM +, Marc Zyngier wrote: > Hi David, > > On 2020-12-29 16:00, David Brazdil wrote: > > The KVM/arm64 PSCI relay assumes that SYSTEM_OFF and SYSTEM_RESET should > > not return, as dictated by the PSCI spec. However, there is firmware out &

[PATCH] KVM: arm64: Allow PSCI SYSTEM_OFF/RESET to return

2020-12-29 Thread David Brazdil
The KVM/arm64 PSCI relay assumes that SYSTEM_OFF and SYSTEM_RESET should not return, as dictated by the PSCI spec. However, there is firmware out there which breaks this assumption, leading to a hyp panic. Make KVM more robust to broken firmware by allowing these to return. Signed-off-by: David

[PATCH 9/9] KVM: arm64: Remove hyp_symbol_addr

2020-12-09 Thread David Brazdil
Hyp code used the hyp_symbol_addr helper to force PC-relative addressing because absolute addressing results in kernel VAs due to the way hyp code is linked. This is not true anymore, so remove the helper and update all of its users. Acked-by: Ard Biesheuvel Signed-off-by: David Brazdil

[PATCH 8/9] KVM: arm64: Remove patching of fn pointers in hyp

2020-12-09 Thread David Brazdil
Storing a function pointer in hyp now generates relocation information used at early boot to convert the address to hyp VA. The existing alternative-based conversion mechanism is therefore obsolete. Remove it and simplify its users. Acked-by: Ard Biesheuvel Signed-off-by: David Brazdil

[PATCH 7/9] KVM: arm64: Fix constant-pool users in hyp

2020-12-09 Thread David Brazdil
accordingly. Signed-off-by: David Brazdil --- arch/arm64/include/asm/kvm_mmu.h | 42 -- arch/arm64/kvm/hyp/nvhe/host.S | 29 +++-- arch/arm64/kvm/hyp/nvhe/hyp-init.S | 2 -- 3 files changed, 31 insertions(+), 42 deletions(-) diff --git a/arch/arm64

[PATCH 5/9] KVM: arm64: Generate hyp relocation data

2020-12-09 Thread David Brazdil
with addend + . The linker of `vmlinux` will therefore fill the slot accordingly. This relocation data will be used at runtime to convert the kernel VAs at those positions to hyp VAs. Signed-off-by: David Brazdil --- arch/arm64/kernel/vmlinux.lds.S | 11 + arch/arm64/kvm/hyp/nvhe/Makefile

[PATCH 4/9] KVM: arm64: Add symbol at the beginning of each hyp section

2020-12-09 Thread David Brazdil
as an anchor. The linker of `vmlinux` will place the symbols together with the sections. Signed-off-by: David Brazdil --- arch/arm64/include/asm/hyp_image.h | 29 +++-- arch/arm64/kvm/hyp/nvhe/hyp.lds.S | 4 ++-- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/arch

[PATCH 3/9] KVM: arm64: Set up .hyp.rodata ELF section

2020-12-09 Thread David Brazdil
We will need to recognize pointers in .rodata specific to hyp, so establish a .hyp.rodata ELF section. Merge it with the existing .hyp.data..ro_after_init as they are treated the same at runtime. Signed-off-by: David Brazdil --- arch/arm64/include/asm/sections.h | 2 +- arch/arm64/kernel

[PATCH 0/9] KVM: arm64: Relocate absolute hyp VAs

2020-12-09 Thread David Brazdil
/hyp-reloc_v1 -David David Brazdil (8): KVM: arm64: Rename .idmap.text in hyp linker script KVM: arm64: Set up .hyp.rodata ELF section KVM: arm64: Add symbol at the beginning of each hyp section KVM: arm64: Generate hyp relocation data KVM: arm64: Apply hyp relocations at runtime KVM

[PATCH 6/9] KVM: arm64: Apply hyp relocations at runtime

2020-12-09 Thread David Brazdil
-by: David Brazdil --- arch/arm64/configs/defconfig | 1 + arch/arm64/include/asm/kvm_mmu.h | 1 + arch/arm64/include/asm/sections.h | 1 + arch/arm64/kernel/smp.c | 4 +++- arch/arm64/kvm/va_layout.c| 28 5 files changed, 34 insertions(+), 1

[PATCH 1/9] KVM: arm64: Correctly align nVHE percpu data

2020-12-09 Thread David Brazdil
-unit-tests or starting any VM and subsequent soft lockup on a Cortex A72 device. Fixes: 30c953911c43 ("kvm: arm64: Set up hyp percpu data for nVHE") Signed-off-by: Jamie Iles Signed-off-by: Marc Zyngier Acked-by: David Brazdil Cc: David Brazdil Cc: Marc Zyngier Cc: Will Deacon L

[PATCH 2/9] KVM: arm64: Rename .idmap.text in hyp linker script

2020-12-09 Thread David Brazdil
-by: David Brazdil --- arch/arm64/kvm/hyp/nvhe/hyp-init.S | 2 +- arch/arm64/kvm/hyp/nvhe/hyp.lds.S | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-init.S b/arch/arm64/kvm/hyp/nvhe/hyp-init.S index 31b060a44045..68fd64f2313e 100644 --- a/arch/arm64

Re: [RFC PATCH 5/6] kvm: arm64: Fix constant-pool users in hyp

2020-12-09 Thread David Brazdil
Hey, relized I never replied to this... On Tue, Nov 24, 2020 at 03:08:20PM +0100, Ard Biesheuvel wrote: > On Thu, 19 Nov 2020 at 17:26, David Brazdil wrote: > > > > Hyp code used to use absolute addressing via a constant pool to obtain > > the kernel VA of 3 symbols - pani

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 +0000, 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 >

[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

[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

[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

[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

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

2020-12-08 Thread David Brazdil
if any concerns arise. The remaining patches are minor cleanups from review. -David David Brazdil (6): kvm: arm64: Prevent use of invalid PSCI v0.1 function IDs kvm: arm64: Use lm_alias in nVHE-only VA conversion kvm: arm64: Skip computing hyp VA layout for VHE kvm: arm64: Minor cleanup

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

2020-12-08 Thread David Brazdil
. Reported-by: Mark Rutland Signed-off-by: David Brazdil --- arch/arm64/include/asm/kvm_host.h| 20 +++ arch/arm64/kvm/arm.c | 14 +--- arch/arm64/kvm/hyp/nvhe/psci-relay.c | 53 +--- 3 files changed, 70 insertions(+), 17 deletions(-) diff

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

Re: [PATCH v4 06/26] psci: Add accessor for psci_0_1_function_ids

2020-12-03 Thread David Brazdil
On Thu, Dec 03, 2020 at 10:47:12AM +, Mark Rutland wrote: > On Wed, Dec 02, 2020 at 06:41:02PM +0000, David Brazdil wrote: > > Make it possible to retrieve a copy of the psci_0_1_function_ids struct. > > This is useful for KVM if it is configured to intercept host's PSCI SMCs.

[PATCH v4 23/26] kvm: arm64: Intercept host's SYSTEM_SUSPEND PSCI SMCs

2020-12-02 Thread David Brazdil
Add a handler of SYSTEM_SUSPEND host PSCI SMCs. The semantics are equivalent to CPU_SUSPEND, typically called on the last online CPU. Reuse the same entry point and boot args struct as CPU_SUSPEND. Signed-off-by: David Brazdil --- arch/arm64/kvm/hyp/nvhe/hyp-init.S | 2 +- arch/arm64/kvm/hyp

[PATCH v4 21/26] kvm: arm64: Intercept host's CPU_ON SMCs

2020-12-02 Thread David Brazdil
returning ERET to the provided PC in EL1. There is a simple atomic lock around the boot args struct. If it is already locked, CPU_ON will return PENDING_ON error code. Signed-off-by: David Brazdil --- arch/arm64/kvm/hyp/nvhe/hyp-init.S | 48 +++ arch/arm64/kvm/hyp/nvhe/psci-relay.c | 115

[PATCH v4 14/26] kvm: arm64: Create nVHE copy of cpu_logical_map

2020-12-02 Thread David Brazdil
features were not checked against the finalized capabilities. Signed-off-by: David Brazdil --- arch/arm64/kvm/arm.c | 19 +++ arch/arm64/kvm/hyp/nvhe/hyp-smp.c | 16 2 files changed, 35 insertions(+) diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm

[PATCH v4 26/26] kvm: arm64: Fix EL2 mode availability checks

2020-12-02 Thread David Brazdil
at the point of KVM init and KVM will not allow cores not present at init to boot. That said, the function is never used after KVM is initialized. Signed-off-by: David Brazdil --- arch/arm64/include/asm/virt.h | 18 ++ arch/arm64/kvm/arm.c | 9 ++--- 2 files changed

[PATCH v4 09/26] kvm: arm64: Remove vector_ptr param of hyp-init

2020-12-02 Thread David Brazdil
. Signed-off-by: David Brazdil --- arch/arm64/include/asm/kvm_asm.h | 2 -- arch/arm64/include/asm/kvm_mmu.h | 24 arch/arm64/kvm/arm.c | 4 +--- arch/arm64/kvm/hyp/nvhe/hyp-init.S | 9 ++--- 4 files changed, 31 insertions(+), 8 deletions(-) diff

[PATCH v4 24/26] kvm: arm64: Keep nVHE EL2 vector installed

2020-12-02 Thread David Brazdil
KVM by default keeps the stub vector installed and installs the nVHE vector only briefly for init and later on demand. Change this policy to install the vector at init and then never uninstall it if the kernel was given the protected KVM command line parameter. Signed-off-by: David Brazdil

[PATCH v4 10/26] kvm: arm64: Move hyp-init params to a per-CPU struct

2020-12-02 Thread David Brazdil
. Refactor __do_hyp_init to accept its parameters in a struct. This prepares the code for KVM booting cores as well as removes any limits on the number of __do_hyp_init arguments. Signed-off-by: David Brazdil --- arch/arm64/include/asm/kvm_asm.h | 6 ++ arch/arm64/include/asm/kvm_hyp.h | 2

[PATCH v4 13/26] kvm: arm64: Support per_cpu_ptr in nVHE hyp code

2020-12-02 Thread David Brazdil
only this_cpu_ptr() was supported by setting TPIDR_EL2. Signed-off-by: David Brazdil --- arch/arm64/include/asm/percpu.h | 6 ++ arch/arm64/kernel/image-vars.h| 3 +++ arch/arm64/kvm/hyp/nvhe/Makefile | 3 ++- arch/arm64/kvm/hyp/nvhe/hyp-smp.c | 24 4 files

[PATCH v4 25/26] kvm: arm64: Trap host SMCs in protected mode

2020-12-02 Thread David Brazdil
of HCR flags to use while the nVHE vector is installed when the kernel was booted with the protected flag enabled. Switch back to the default HCR flags when switching back to the stub vector. Signed-off-by: David Brazdil --- arch/arm64/include/asm/kvm_arm.h | 1 + arch/arm64/kvm/hyp/nvhe/hyp

[PATCH v4 12/26] kvm: arm64: Add .hyp.data..ro_after_init ELF section

2020-12-02 Thread David Brazdil
in the section and they are never changed by hyp afterwards. Signed-off-by: David Brazdil --- arch/arm64/include/asm/sections.h | 1 + arch/arm64/kernel/vmlinux.lds.S | 10 ++ arch/arm64/kvm/arm.c | 8 arch/arm64/kvm/hyp/nvhe/hyp.lds.S | 1 + 4 files changed, 20 insertions

[PATCH v4 02/26] kvm: arm64: Add ARM64_KVM_PROTECTED_MODE CPU capability

2020-12-02 Thread David Brazdil
Expose the boolean value whether the system is running with KVM in protected mode (nVHE + kernel param). CPU capability was selected over a global variable to allow use in alternatives. Signed-off-by: David Brazdil --- arch/arm64/include/asm/cpucaps.h | 3 ++- arch/arm64/include/asm

[PATCH v4 22/26] kvm: arm64: Intercept host's CPU_SUSPEND PSCI SMCs

2020-12-02 Thread David Brazdil
struct psci_boot_args to store the state upon powerup, with each CPU having separate structs for CPU_ON and CPU_SUSPEND so that CPU_SUSPEND can operate locklessly and so that a CPU_ON call targeting a CPU cannot interfere with a concurrent CPU_SUSPEND call on that CPU. Signed-off-by: David Brazdil

[PATCH v4 06/26] psci: Add accessor for psci_0_1_function_ids

2020-12-02 Thread David Brazdil
Make it possible to retrieve a copy of the psci_0_1_function_ids struct. This is useful for KVM if it is configured to intercept host's PSCI SMCs. Signed-off-by: David Brazdil --- drivers/firmware/psci/psci.c | 12 +--- include/linux/psci.h | 9 + 2 files changed, 14

[PATCH v4 01/26] kvm: arm64: Add kvm-arm.mode early kernel parameter

2020-12-02 Thread David Brazdil
Signed-off-by: David Brazdil --- Documentation/admin-guide/kernel-parameters.txt | 10 ++ arch/arm64/include/asm/kvm_host.h | 9 + arch/arm64/kvm/arm.c| 16 3 files changed, 35 insertions(+) diff --git a/Documentation/admin-gu

[PATCH v4 20/26] kvm: arm64: Add function to enter host from KVM nVHE hyp code

2020-12-02 Thread David Brazdil
code after the trap handler would have returned. Signed-off-by: David Brazdil --- arch/arm64/kvm/hyp/nvhe/host.S | 9 + 1 file changed, 9 insertions(+) diff --git a/arch/arm64/kvm/hyp/nvhe/host.S b/arch/arm64/kvm/hyp/nvhe/host.S index 2b56f0bdf874..a820dfdc9c25 100644 --- a/arch/arm64/kvm

[PATCH v4 19/26] kvm: arm64: Extract __do_hyp_init into a helper function

2020-12-02 Thread David Brazdil
In preparation for adding a CPU entry point in nVHE hyp code, extract most of __do_hyp_init hypervisor initialization code into a common helper function. This will be invoked by the entry point to install KVM on the newly booted CPU. Signed-off-by: David Brazdil --- arch/arm64/kvm/hyp/nvhe/hyp

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

2020-12-02 Thread David Brazdil
atomic * make cpu_logical_map ro_after_init David Brazdil (26): kvm: arm64: Add kvm-arm.mode early kernel parameter kvm: arm64: Add ARM64_KVM_PROTECTED_MODE CPU capability psci: Support psci_ops.get_version for v0.1 psci: Split functions to v0.1 and v0.2+ variants psci: Replace

[PATCH v4 15/26] kvm: arm64: Add SMC handler in nVHE EL2

2020-12-02 Thread David Brazdil
for arguments and results, other GPRs are preserved. Signed-off-by: David Brazdil --- arch/arm64/kvm/hyp/nvhe/host.S | 38 ++ arch/arm64/kvm/hyp/nvhe/hyp-main.c | 35 --- 2 files changed, 70 insertions(+), 3 deletions(-) diff --git a/arch/arm64

[PATCH v4 05/26] psci: Replace psci_function_id array with a struct

2020-12-02 Thread David Brazdil
s checking. Signed-off-by: David Brazdil --- drivers/firmware/psci/psci.c | 29 ++--- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 13b9ed71b446..593fdd0e09a2 100644 --- a/drivers/firmware/psci/ps

[PATCH v4 07/26] arm64: Make cpu_logical_map() take unsigned int

2020-12-02 Thread David Brazdil
-by: David Brazdil --- arch/arm64/include/asm/smp.h | 4 ++-- arch/arm64/kernel/setup.c| 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm64/include/asm/smp.h b/arch/arm64/include/asm/smp.h index 2e7f529ec5a6..bcb01ca15325 100644 --- a/arch/arm64/include/asm/smp.h

[PATCH v4 03/26] psci: Support psci_ops.get_version for v0.1

2020-12-02 Thread David Brazdil
is currently unused so this has no effect on existing functionality. Acked-by: Mark Rutland Signed-off-by: David Brazdil --- drivers/firmware/psci/psci.c | 13 ++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index

[PATCH v4 11/26] kvm: arm64: Init MAIR/TCR_EL2 from params struct

2020-12-02 Thread David Brazdil
and can be used when booting new cores. Take the opportunity to move copying the T0SZ value from idmap_t0sz in KVM init rather than in .hyp.idmap.text. This avoids the need for the idmap_t0sz symbol alias. Signed-off-by: David Brazdil --- arch/arm64/include/asm/kvm_asm.h | 2 ++ arch/arm64

[PATCH v4 18/26] kvm: arm64: Forward safe PSCI SMCs coming from host

2020-12-02 Thread David Brazdil
* SYSTEM_RESET * SYSTEM_RESET2 Signed-off-by: David Brazdil --- arch/arm64/kvm/hyp/nvhe/psci-relay.c | 42 +++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kvm/hyp/nvhe/psci-relay.c b/arch/arm64/kvm/hyp/nvhe/psci-relay.c index 70b42f433449

[PATCH v4 04/26] psci: Split functions to v0.1 and v0.2+ variants

2020-12-02 Thread David Brazdil
-off-by: David Brazdil --- drivers/firmware/psci/psci.c | 94 +++- 1 file changed, 60 insertions(+), 34 deletions(-) diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index ace5b9ac676c..13b9ed71b446 100644 --- a/drivers/firmware/psci/psci.c

[PATCH v4 08/26] arm64: Extract parts of el2_setup into a macro

2020-12-02 Thread David Brazdil
No functional change intended. Size of el2_setup increased by 148 bytes due to duplication. Signed-off-by: David Brazdil --- arch/arm64/include/asm/el2_setup.h | 182 + arch/arm64/kernel/head.S | 144 +++ 2 files changed, 198 insertions

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

2020-12-02 Thread David Brazdil
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/arm64/kvm/hyp/nvhe/psci-relay.c | 3 +++ arch/arm64/kvm/va_layout.c

[PATCH v4 16/26] kvm: arm64: Bootstrap PSCI SMC handler in nVHE EL2

2020-12-02 Thread David Brazdil
+), the SMC is handled by the PSCI handler. For now, all SMCs return PSCI_RET_NOT_SUPPORTED. Signed-off-by: David Brazdil --- arch/arm64/include/asm/kvm_hyp.h | 2 + arch/arm64/kvm/arm.c | 25 - .../arm64/kvm/hyp/include/nvhe/trap_handler.h | 18 arch

Re: [PATCH v3 16/23] kvm: arm64: Forward safe PSCI SMCs coming from host

2020-12-02 Thread David Brazdil
On Fri, Nov 27, 2020 at 10:14:33AM +, Lorenzo Pieralisi wrote: > On Thu, Nov 26, 2020 at 03:54:14PM +0000, David Brazdil wrote: > > Forward the following PSCI SMCs issued by host to EL3 as they do not > > require the hypervisor's intervention. This assumes that EL3 correctly

Re: [PATCH v3 03/23] arm64: Make cpu_logical_map() take unsigned int

2020-12-02 Thread David Brazdil
On Thu, Nov 26, 2020 at 05:28:38PM +, Mark Rutland wrote: > On Thu, Nov 26, 2020 at 03:54:01PM +0000, David Brazdil wrote: > > CPU index should never be negative. Change the signature of > > (set_)cpu_logical_map to take an unsigned int. > > > > S

Re: [PATCH v3 06/23] kvm: arm64: Add kvm-arm.protected early kernel parameter

2020-12-01 Thread David Brazdil
> > > be just me, but if you agree please update so that it doesn't give remote > > > idea that it is not valid on VHE enabled hardware. > > > > > > I was trying to run this on the hardware and was trying to understand the > > > details on how to do that. > > > > I see what you're saying, but

Re: [PATCH v3 04/23] arm64: Move MAIR_EL1_SET to asm/memory.h

2020-12-01 Thread David Brazdil
Hey Mark, > > diff --git a/arch/arm64/include/asm/memory.h > > b/arch/arm64/include/asm/memory.h > > index cd61239bae8c..54a22cb5b17b 100644 > > --- a/arch/arm64/include/asm/memory.h > > +++ b/arch/arm64/include/asm/memory.h > > @@ -152,6 +152,19 @@ > > #define MT_S2_FWB_NORMAL 6 > > #define

Re: [PATCH v3 05/23] arm64: Extract parts of el2_setup into a macro

2020-12-01 Thread David Brazdil
Hey Mark, > In the head.S code, this was under an ifdef CONFIG_ARM_GIC_V3, but that > ifdef wasn't carried into the macro here, or into its use below. I'm not > sure of the impact, but that does seem to be a functional change. > > > + > > +.macro __init_el2_hstr > > + msr hstr_el2, xzr

Re: [PATCH v3 19/23] kvm: arm64: Intercept host's CPU_ON SMCs

2020-12-01 Thread David Brazdil
Hey Sudeep, > > +static unsigned int find_cpu_id(u64 mpidr) > > +{ > > + unsigned int i; > > + > > + /* Reject invalid MPIDRs */ > > + if (mpidr & ~MPIDR_HWID_BITMASK) > > + return INVALID_CPU_ID; > > + > > + for (i = 0; i < NR_CPUS; i++) { > > I may not have understood the

Re: [PATCH v3 16/23] kvm: arm64: Forward safe PSCI SMCs coming from host

2020-12-01 Thread David Brazdil
On Fri, Nov 27, 2020 at 04:51:59PM +, Sudeep Holla wrote: > On Thu, Nov 26, 2020 at 03:54:14PM +0000, David Brazdil wrote: > > Forward the following PSCI SMCs issued by host to EL3 as they do not > > require the hypervisor's intervention. This assumes that EL3 correctly > >

Re: [PATCH v3 06/23] kvm: arm64: Add kvm-arm.protected early kernel parameter

2020-12-01 Thread David Brazdil
Hey Sudeep, > > diff --git a/Documentation/admin-guide/kernel-parameters.txt > > b/Documentation/admin-guide/kernel-parameters.txt > > index 526d65d8573a..06c89975c29c 100644 > > --- a/Documentation/admin-guide/kernel-parameters.txt > > +++ b/Documentation/admin-guide/kernel-parameters.txt > >

Re: [PATCH 2/2] KVM: arm64: Advertise ID_AA64PFR0_EL1.CSV3=1 if the CPUs are Meltdown-safe

2020-11-30 Thread David Brazdil
> @@ -1227,9 +1229,16 @@ static int set_id_aa64pfr0_el1(struct kvm_vcpu *vcpu, > (csv2 && arm64_get_spectre_v2_state() != SPECTRE_UNAFFECTED)) > return -EINVAL; > > - /* We can only differ with CSV2, and anything else is an error */ > + /* Same thing for CSV3 */ >

[PATCH v3 04/23] arm64: Move MAIR_EL1_SET to asm/memory.h

2020-11-26 Thread David Brazdil
KVM currently initializes MAIR_EL2 to the value of MAIR_EL1. In preparation for initializing MAIR_EL2 before MAIR_EL1, move the constant into a shared header file. Since it is used for EL1 and EL2, rename to MAIR_ELx_SET. Signed-off-by: David Brazdil --- arch/arm64/include/asm/memory.h | 13

[PATCH v3 06/23] kvm: arm64: Add kvm-arm.protected early kernel parameter

2020-11-26 Thread David Brazdil
SMCs. Capability ARM64_PROTECTED_KVM is set if the param is passed, CONFIG_KVM is enabled and the kernel was not booted with VHE. Signed-off-by: David Brazdil --- .../admin-guide/kernel-parameters.txt | 5 arch/arm64/include/asm/cpucaps.h | 3 +- arch/arm64/include/asm

[PATCH v3 12/23] kvm: arm64: Create nVHE copy of cpu_logical_map

2020-11-26 Thread David Brazdil
features were not checked against the finalized capabilities. Signed-off-by: David Brazdil --- arch/arm64/kvm/arm.c | 19 +++ arch/arm64/kvm/hyp/nvhe/hyp-smp.c | 16 2 files changed, 35 insertions(+) diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm

[PATCH v3 11/23] kvm: arm64: Support per_cpu_ptr in nVHE hyp code

2020-11-26 Thread David Brazdil
only this_cpu_ptr() was supported by setting TPIDR_EL2. Signed-off-by: David Brazdil --- arch/arm64/include/asm/percpu.h | 6 ++ arch/arm64/kernel/image-vars.h| 3 +++ arch/arm64/kvm/hyp/nvhe/Makefile | 3 ++- arch/arm64/kvm/hyp/nvhe/hyp-smp.c | 24 4 files

[PATCH v3 10/23] kvm: arm64: Add .hyp.data..ro_after_init ELF section

2020-11-26 Thread David Brazdil
in the section and they are never changed by hyp afterwards. Signed-off-by: David Brazdil --- arch/arm64/include/asm/sections.h | 1 + arch/arm64/kernel/vmlinux.lds.S | 10 ++ arch/arm64/kvm/arm.c | 8 arch/arm64/kvm/hyp/nvhe/hyp.lds.S | 1 + 4 files changed, 20 insertions

[PATCH v3 09/23] kvm: arm64: Move hyp-init params to a per-CPU struct

2020-11-26 Thread David Brazdil
. Refactor __do_hyp_init to accept its parameters in a struct. This prepares the code for KVM booting cores as well as removes any limits on the number of __do_hyp_init arguments. Signed-off-by: David Brazdil --- arch/arm64/include/asm/kvm_asm.h | 6 ++ arch/arm64/include/asm/kvm_hyp.h | 2

[PATCH v3 21/23] kvm: arm64: Keep nVHE EL2 vector installed

2020-11-26 Thread David Brazdil
KVM by default keeps the stub vector installed and installs the nVHE vector only briefly for init and later on demand. Change this policy to install the vector at init and then never uninstall it if the kernel was given the protected KVM command line parameter. Signed-off-by: David Brazdil

[PATCH v3 08/23] kvm: arm64: Remove vector_ptr param of hyp-init

2020-11-26 Thread David Brazdil
. Signed-off-by: David Brazdil --- arch/arm64/include/asm/kvm_asm.h | 2 -- arch/arm64/include/asm/kvm_mmu.h | 26 +- arch/arm64/kvm/arm.c | 4 +--- arch/arm64/kvm/hyp/nvhe/hyp-init.S | 9 ++--- 4 files changed, 32 insertions(+), 9 deletions(-) diff

[PATCH v3 07/23] kvm: arm64: Initialize MAIR_EL2 using a constant

2020-11-26 Thread David Brazdil
. Signed-off-by: David Brazdil --- arch/arm64/kvm/hyp/nvhe/hyp-init.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-init.S b/arch/arm64/kvm/hyp/nvhe/hyp-init.S index b11a9d7db677..17b58dbc3a2f 100644 --- a/arch/arm64/kvm/hyp/nvhe/hyp-init.S +++ b/arch

[PATCH v3 18/23] kvm: arm64: Add function to enter host from KVM nVHE hyp code

2020-11-26 Thread David Brazdil
code after the trap handler would have returned. Signed-off-by: David Brazdil --- arch/arm64/kvm/hyp/nvhe/host.S | 9 + 1 file changed, 9 insertions(+) diff --git a/arch/arm64/kvm/hyp/nvhe/host.S b/arch/arm64/kvm/hyp/nvhe/host.S index 2b56f0bdf874..a820dfdc9c25 100644 --- a/arch/arm64/kvm

[PATCH v3 02/23] psci: Accessor for configured PSCI function IDs

2020-11-26 Thread David Brazdil
Function IDs used by PSCI are configurable for v0.1 via DT/APCI. If the host is using PSCI v0.1, KVM's host PSCI proxy needs to use the same IDs. Expose the array holding the information with a read-only accessor. Signed-off-by: David Brazdil --- drivers/firmware/psci/psci.c | 16

[PATCH v3 01/23] psci: Support psci_ops.get_version for v0.1

2020-11-26 Thread David Brazdil
is currently unused so this has no effect on existing functionality. Signed-off-by: David Brazdil --- drivers/firmware/psci/psci.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 00af99b6f97c..213c68418a65 100644 --- a/drivers

[PATCH v3 14/23] kvm: arm64: Bootstrap PSCI SMC handler in nVHE EL2

2020-11-26 Thread David Brazdil
+), the SMC is handled by the PSCI handler. For now, all SMCs return PSCI_RET_NOT_SUPPORTED. Signed-off-by: David Brazdil --- arch/arm64/include/asm/kvm_hyp.h | 2 + arch/arm64/kvm/arm.c | 29 - .../arm64/kvm/hyp/include/nvhe/trap_handler.h | 18 +++ arch

[PATCH v3 20/23] kvm: arm64: Intercept host's CPU_SUSPEND PSCI SMCs

2020-11-26 Thread David Brazdil
racing them for the same boot args struct, CPU_SUSPEND uses a different struct instance and entry point. Each entry point selects the corresponding struct to restore host boot args from. This avoids the need for locking in CPU_SUSPEND. Signed-off-by: David Brazdil --- arch/arm64/kvm/hyp/nvhe/hyp

[PATCH v3 19/23] kvm: arm64: Intercept host's CPU_ON SMCs

2020-11-26 Thread David Brazdil
returning ERET to the provided PC in EL1. There is a simple atomic lock around the boot args struct. If it is already locked, CPU_ON will return PENDING_ON error code. Signed-off-by: David Brazdil --- arch/arm64/kvm/hyp/nvhe/hyp-init.S | 30 arch/arm64/kvm/hyp/nvhe/psci-relay.c | 109

Re: [PATCH v2 04/24] arm64: Move MAIR_EL1_SET to asm/memory.h

2020-11-25 Thread David Brazdil
> > > > +/* > > > > + * Memory types available. > > > > + * > > > > + * IMPORTANT: MT_NORMAL must be index 0 since vm_get_page_prot() may > > > > 'or' in > > > > + * the MT_NORMAL_TAGGED memory type for PROT_MTE mappings. > > > > Note > > > > + * that protection_map[] only

Re: [PATCH v2 15/24] kvm: arm64: Extract parts of el2_setup into a macro

2020-11-25 Thread David Brazdil
On Mon, Nov 23, 2020 at 03:27:01PM +, Marc Zyngier wrote: > On Mon, 16 Nov 2020 20:43:09 +, > David Brazdil wrote: > > > > When the a CPU is booted in EL2, the kernel checks for VHE support and > > initializes the CPU core accordingly. For nVHE it also insta

Re: [PATCH v2 06/24] kvm: arm64: Move hyp-init params to a per-CPU struct

2020-11-25 Thread David Brazdil
On Mon, Nov 23, 2020 at 02:20:07PM +, Marc Zyngier wrote: > On Mon, 16 Nov 2020 20:43:00 +, > David Brazdil wrote: > > > > Once we start initializing KVM on newly booted cores before the rest of > > the kernel, parameters to __do_hyp_init will need to be provide

Re: [PATCH v2 04/24] arm64: Move MAIR_EL1_SET to asm/memory.h

2020-11-25 Thread David Brazdil
On Mon, Nov 23, 2020 at 01:52:54PM +, Marc Zyngier wrote: > On Mon, 16 Nov 2020 20:42:58 +, > David Brazdil wrote: > > > > KVM currently initializes MAIR_EL2 to the value of MAIR_EL1. In > > preparation for initializing MAIR_EL2 before MAIR_EL1, move the constant

Re: [RFC PATCH 09/27] KVM: arm64: Allow using kvm_nvhe_sym() in hyp code

2020-11-23 Thread David Brazdil
On Mon, Nov 23, 2020 at 02:02:50PM +, 'Quentin Perret' via kernel-team wrote: > On Monday 23 Nov 2020 at 12:57:23 (+), David Brazdil wrote: > > > diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c > > > index 882eb383bd75..391cf6753a13 100644 > > &

Re: [RFC PATCH 13/27] KVM: arm64: Enable access to sanitized CPU features at EL2

2020-11-23 Thread David Brazdil
> +int copy_ftr_reg(u32 id, struct arm64_ftr_reg *dst) > +{ > + struct arm64_ftr_reg *regp = get_arm64_ftr_reg(id); > + > + if (!regp) > + return -EINVAL; > + > + memcpy(dst, regp, sizeof(*regp)); > + > + return 0; > +} > + > #define read_sysreg_case(r) \ > case

Re: [RFC PATCH 09/27] KVM: arm64: Allow using kvm_nvhe_sym() in hyp code

2020-11-23 Thread David Brazdil
On Tue, Nov 17, 2020 at 06:15:49PM +, 'Quentin Perret' via kernel-team wrote: > In order to allow the usage of code shared by the host and the hyp in > static inline library function, allow the usage of kvm_nvhe_sym() at el2 > by defaulting to the raw symbol name. > > Signed-off-by: Quentin

  1   2   3   4   >