Re: [PATCH] PM / EM: Inefficient OPPs detection

2021-04-15 Thread Quentin Perret
On Thursday 15 Apr 2021 at 16:32:31 (+0100), Lukasz Luba wrote: > Are you sure that the 'policy' can be accessed from compute_energy()? > It can be from schedutil freq switch path, but I'm not use about our > feec().. Right, I was just looking at cpufreq_cpu_get() and we'll have locking issue in

Re: [PATCH] PM / EM: Inefficient OPPs detection

2021-04-15 Thread Quentin Perret
On Thursday 15 Apr 2021 at 16:14:46 (+0100), Vincent Donnefort wrote: > On Thu, Apr 15, 2021 at 02:59:54PM +0000, Quentin Perret wrote: > > On Thursday 15 Apr 2021 at 15:34:53 (+0100), Vincent Donnefort wrote: > > > On Thu, Apr 15, 2021 at 01:16:35PM +0000, Qu

Re: [PATCH] PM / EM: Inefficient OPPs detection

2021-04-15 Thread Quentin Perret
On Thursday 15 Apr 2021 at 14:59:54 (+), Quentin Perret wrote: > On Thursday 15 Apr 2021 at 15:34:53 (+0100), Vincent Donnefort wrote: > > On Thu, Apr 15, 2021 at 01:16:35PM +, Quentin Perret wrote: > > > On Thursday 08 Apr 2021 at 18:10:29 (+0100), Vince

Re: [PATCH] PM / EM: Inefficient OPPs detection

2021-04-15 Thread Quentin Perret
On Thursday 15 Apr 2021 at 15:12:08 (+0100), Vincent Donnefort wrote: > On Thu, Apr 15, 2021 at 01:12:05PM +0000, Quentin Perret wrote: > > Hi Vincent, > > > > On Thursday 08 Apr 2021 at 18:10:29 (+0100), Vincent Donnefort wrote: > > > Some SoCs, such as the s

Re: [PATCH] PM / EM: Inefficient OPPs detection

2021-04-15 Thread Quentin Perret
On Thursday 15 Apr 2021 at 15:34:53 (+0100), Vincent Donnefort wrote: > On Thu, Apr 15, 2021 at 01:16:35PM +0000, Quentin Perret wrote: > > On Thursday 08 Apr 2021 at 18:10:29 (+0100), Vincent Donnefort wrote: > > > --- a/kernel/sched/cpufreq_schedutil.c > &

Re: [PATCH] PM / EM: Inefficient OPPs detection

2021-04-15 Thread Quentin Perret
On Thursday 08 Apr 2021 at 18:10:29 (+0100), Vincent Donnefort wrote: > --- a/kernel/sched/cpufreq_schedutil.c > +++ b/kernel/sched/cpufreq_schedutil.c > @@ -10,6 +10,7 @@ > > #include "sched.h" > > +#include > #include > #include > > @@ -164,6 +165,9 @@ static unsigned int

Re: [PATCH] PM / EM: Inefficient OPPs detection

2021-04-15 Thread Quentin Perret
Hi Vincent, On Thursday 08 Apr 2021 at 18:10:29 (+0100), Vincent Donnefort wrote: > Some SoCs, such as the sd855 have OPPs within the same performance domain, > whose cost is higher than others with a higher frequency. Even though > those OPPs are interesting from a cooling perspective, it makes

Re: [PATCH -next] sched/topology: Make some symbols static

2021-04-13 Thread Quentin Perret
On Thursday 08 Apr 2021 at 21:12:17 (+0800), Peng Wu wrote: > The sparse tool complains as follows: > > kernel/sched/topology.c:211:1: warning: > symbol 'sched_energy_mutex' was not declared. Should it be static? > kernel/sched/topology.c:212:6: warning: > symbol 'sched_energy_update' was not

Re: [PATCH v4 1/2] KVM: arm64: Move CMOs from user_mem_abort to the fault handlers

2021-04-09 Thread Quentin Perret
Hi Yanan, On Friday 09 Apr 2021 at 11:36:51 (+0800), Yanan Wang wrote: > diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c > +static void stage2_invalidate_icache(void *addr, u64 size) > +{ > + if (icache_is_aliasing()) { > + /* Flush any kind of VIPT icache

[PATCH] export: Make CRCs robust to symbol trimming

2021-04-08 Thread Quentin Perret
to symbol trimming. Signed-off-by: Quentin Perret --- include/linux/export.h | 5 + 1 file changed, 5 insertions(+) diff --git a/include/linux/export.h b/include/linux/export.h index 6271a5d9c988..27d848712b90 100644 --- a/include/linux/export.h +++ b/include/linux/export.h @@ -140,7 +140,12

Re: [PATCH] cgroup: Relax restrictions on kernel threads moving out of root cpu cgroup

2021-04-06 Thread Quentin Perret
Hi Pavan, On Tuesday 06 Apr 2021 at 16:29:13 (+0530), Pavankumar Kondeti wrote: > In Android GKI, CONFIG_FAIR_GROUP_SCHED is enabled [1] to help prioritize > important work. Given that CPU shares of root cgroup can't be changed, > leaving the tasks inside root cgroup will give them higher share >

Re: [PATCH] sched/fair: use signed long when compute energy delta in eas

2021-03-30 Thread Quentin Perret
Hi, On Tuesday 30 Mar 2021 at 13:21:54 (+0800), Xuewen Yan wrote: > From: Xuewen Yan > > now the energy delta compute as follow: > > base_energy_pd = compute_energy(p, -1, pd); > --->Traverse all CPUs in pd > --->em_pd_energy() >

Re: [PATCH v2 3/3] KVM: arm64: Drop the CPU_FTR_REG_HYP_COPY infrastructure

2021-03-23 Thread Quentin Perret
hat the hypervisor need. > > Signed-off-by: Marc Zyngier Reviewed-by: Quentin Perret Thanks, Quentin

Re: [PATCH 2/3] KVM: arm64: Generate final CTR_EL0 value when running in Protected mode

2021-03-23 Thread Quentin Perret
Hi Marc, On Monday 22 Mar 2021 at 18:37:14 (+), Marc Zyngier wrote: > Can't say I'm keen on the yucky bit, but here's an alternative (ha!) > for you: > > diff --git a/arch/arm64/include/asm/assembler.h > b/arch/arm64/include/asm/assembler.h > index 1a4cee7eb3c9..7582c3bd2f05 100644 > ---

Re: [PATCH 2/3] KVM: arm64: Generate final CTR_EL0 value when running in Protected mode

2021-03-22 Thread Quentin Perret
That would be marginally better as that would cover _all_ users of read_ctr and not just __flush_dcache_area, but that first movz is a bit yuck (but necessary to keep generate_mov_q() happy I think?), so I'll leave the decision to you. No objection from me for the current implementation, and if you decide to go with it: Reviewed-by: Quentin Perret Thanks, Quentin

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

2021-03-22 Thread Quentin Perret
Hey Marc, On Monday 22 Mar 2021 at 13:44:38 (+), Marc Zyngier wrote: > I can't say I'm thrilled with this. Actually, it is fair to say that I > don't like it at all! ;-) :-) > Copying whole structures with pointers that > make no sense at EL2 feels... wrong. And I don't disagree at all. I

[PATCH v6 37/38] KVM: arm64: Disable PMU support in protected mode

2021-03-19 Thread Quentin Perret
-by: Quentin Perret --- arch/arm64/kvm/perf.c | 3 ++- arch/arm64/kvm/pmu.c | 8 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/arm64/kvm/perf.c b/arch/arm64/kvm/perf.c index 739164324afe..8f860ae56bb7 100644 --- a/arch/arm64/kvm/perf.c +++ b/arch/arm64/kvm/perf.c @@ -55,7

[PATCH v6 38/38] KVM: arm64: Protect the .hyp sections from the host

2021-03-19 Thread Quentin Perret
to the .hyp sections directly. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/include/asm/kvm_asm.h | 1 + arch/arm64/kvm/arm.c | 46 +++ arch/arm64/kvm/hyp/include/nvhe/mem_protect.h | 2 + arch/arm64/kvm/hyp/nvhe/hyp

[PATCH v6 35/38] KVM: arm64: Wrap the host with a stage 2

2021-03-19 Thread Quentin Perret
int on, memory accesses from the host to protected memory regions (e.g. not 'owned' by the host) are fatal and lead to hyp_panic(). Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/include/asm/kvm_asm.h | 1 + arch/arm64/kernel/image-vars.h|

[PATCH v6 36/38] KVM: arm64: Page-align the .hyp sections

2021-03-19 Thread Quentin Perret
We will soon unmap the .hyp sections from the host stage 2 in Protected nVHE mode, which obviously works with at least page granularity, so make sure to align them correctly. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/kernel/vmlinux.lds.S | 22 +- 1

[PATCH v6 32/38] KVM: arm64: Introduce KVM_PGTABLE_S2_NOFWB stage 2 flag

2021-03-19 Thread Quentin Perret
In order to further configure stage 2 page-tables, pass flags to the init function using a new enum. The first of these flags allows to disable FWB even if the hardware supports it as we will need to do so for the host stage 2. Signed-off-by: Quentin Perret --- arch/arm64/include/asm

[PATCH v6 33/38] KVM: arm64: Introduce KVM_PGTABLE_S2_IDMAP stage 2 flag

2021-03-19 Thread Quentin Perret
Introduce a new stage 2 configuration flag to specify that all mappings in a given page-table will be identity-mapped, as will be the case for the host. This allows to introduce sanity checks in the map path and to avoid programming errors. Suggested-by: Will Deacon Signed-off-by: Quentin Perret

[PATCH v6 31/38] KVM: arm64: Add kvm_pgtable_stage2_find_range()

2021-03-19 Thread Quentin Perret
of available IPA space. This will be used in the host memory abort path to greedily idmap large portion of the PA space. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/include/asm/kvm_pgtable.h | 29 + arch/arm64/kvm/hyp/pgtable.c | 89 ++-- 2

[PATCH v6 34/38] KVM: arm64: Provide sanitized mmfr* registers at EL2

2021-03-19 Thread Quentin Perret
We will need to read sanitized values of mmfr{0,1}_el1 at EL2 soon, so add them to the list of copied variables. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/include/asm/kvm_cpufeature.h | 2 ++ arch/arm64/kvm/hyp/nvhe/hyp-smp.c | 2 ++ arch/arm64/kvm/sys_regs.c

[PATCH v6 30/38] KVM: arm64: Refactor the *_map_set_prot_attr() helpers

2021-03-19 Thread Quentin Perret
In order to ease their re-use in other code paths, refactor the *_map_set_prot_attr() helpers to not depend on a map_data struct. No functional change intended. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/kvm/hyp/pgtable.c | 16 1 file changed, 8

[PATCH v6 25/38] KVM: arm64: Make memcache anonymous in pgtable allocator

2021-03-19 Thread Quentin Perret
they need to. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/include/asm/kvm_pgtable.h | 6 +++--- arch/arm64/kvm/hyp/pgtable.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/arm64/include/asm/kvm_pgtable.h b/arch/arm64/include/asm

[PATCH v6 24/38] KVM: arm64: Refactor __populate_fault_info()

2021-03-19 Thread Quentin Perret
Refactor __populate_fault_info() to introduce __get_fault_info() which will be used once the host is wrapped in a stage 2. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/kvm/hyp/include/hyp/switch.h | 28 +++-- 1 file changed, 17 insertions(+), 11

[PATCH v6 27/38] KVM: arm64: Sort the hypervisor memblocks

2021-03-19 Thread Quentin Perret
We will soon need to check if a Physical Address belongs to a memblock at EL2, so make sure to sort them so this can be done efficiently. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/kvm/hyp/reserved_mem.c | 19 +++ 1 file changed, 19 insertions(+) diff

[PATCH v6 26/38] KVM: arm64: Reserve memory for host stage 2

2021-03-19 Thread Quentin Perret
Extend the memory pool allocated for the hypervisor to include enough pages to map all of memory at page granularity for the host stage 2. While at it, also reserve some memory for device mappings. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/kvm/hyp/include/nvhe/mm.h

[PATCH v6 23/38] KVM: arm64: Refactor __load_guest_stage2()

2021-03-19 Thread Quentin Perret
Refactor __load_guest_stage2() to introduce __load_stage2() which will be re-used when loading the host stage 2. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/include/asm/kvm_mmu.h | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/arm64

[PATCH v6 28/38] KVM: arm64: Always zero invalid PTEs

2021-03-19 Thread Quentin Perret
Suggested-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/kvm/hyp/pgtable.c | 26 -- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c index 15de1708cfcd..0a674010afb6 100644 --- a/arch

[PATCH v6 29/38] KVM: arm64: Use page-table to track page ownership

2021-03-19 Thread Quentin Perret
do refcount as we now need to count invalid mappings when they are used for ownership tracking. Signed-off-by: Quentin Perret --- arch/arm64/include/asm/kvm_pgtable.h | 20 + arch/arm64/kvm/hyp/pgtable.c | 126 ++- 2 files changed, 122 insertions(+), 24

[PATCH v6 21/38] KVM: arm64: Set host stage 2 using kvm_nvhe_init_params

2021-03-19 Thread Quentin Perret
Move the registers relevant to host stage 2 enablement to kvm_nvhe_init_params to prepare the ground for enabling it in later patches. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/include/asm/kvm_asm.h | 3 +++ arch/arm64/kernel/asm-offsets.c| 3 +++ arch/arm64

[PATCH v6 20/38] KVM: arm64: Use kvm_arch in kvm_s2_mmu

2021-03-19 Thread Quentin Perret
In order to make use of the stage 2 pgtable code for the host stage 2, change kvm_s2_mmu to use a kvm_arch pointer in lieu of the kvm pointer, as the host will have the former but not the latter. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/include/asm/kvm_host.h | 2

[PATCH v6 22/38] KVM: arm64: Refactor kvm_arm_setup_stage2()

2021-03-19 Thread Quentin Perret
In order to re-use some of the stage 2 setup code at EL2, factor parts of kvm_arm_setup_stage2() out into separate functions. No functional change intended. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/include/asm/kvm_pgtable.h | 26 + arch/arm64/kvm/hyp

[PATCH v6 19/38] KVM: arm64: Use kvm_arch for stage 2 pgtable

2021-03-19 Thread Quentin Perret
In order to make use of the stage 2 pgtable code for the host stage 2, use struct kvm_arch in lieu of struct kvm as the host will have the former but not the latter. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/include/asm/kvm_pgtable.h | 5 +++-- arch/arm64/kvm/hyp

[PATCH v6 18/38] KVM: arm64: Elevate hypervisor mappings creation at EL2

2021-03-19 Thread Quentin Perret
tables directly. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/include/asm/kvm_mmu.h | 2 +- arch/arm64/kvm/arm.c | 87 +--- arch/arm64/kvm/mmu.c | 43 ++-- 3 files changed, 120 insertions(+), 12 deletions

[PATCH v6 17/38] KVM: arm64: Prepare the creation of s1 mappings at EL2

2021-03-19 Thread Quentin Perret
to Will for __pkvm_init_switch_pgd. Acked-by: Will Deacon Co-authored-by: Will Deacon Signed-off-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/include/asm/kvm_asm.h | 4 + arch/arm64/include/asm/kvm_host.h| 7 + arch/arm64/include/asm/kvm_hyp.h | 8 ++ arch/arm64/include/asm

[PATCH v6 13/38] KVM: arm64: Enable access to sanitized CPU features at EL2

2021-03-19 Thread Quentin Perret
together with the name of the nVHE variable that will hold the copy. This introduces only the infrastructure enabling this copy. The first users will follow shortly. Signed-off-by: Quentin Perret --- arch/arm64/include/asm/cpufeature.h | 1 + arch/arm64/include/asm/kvm_cpufeature.h | 22

[PATCH v6 15/38] KVM: arm64: Factor out vector address calculation

2021-03-19 Thread Quentin Perret
In order to re-map the guest vectors at EL2 when pKVM is enabled, refactor __kvm_vector_slot2idx() and kvm_init_vector_slot() to move all the address calculation logic in a static inline function. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/include/asm/kvm_mmu.h | 8

[PATCH v6 14/38] KVM: arm64: Provide __flush_dcache_area at EL2

2021-03-19 Thread Quentin Perret
We will need to do cache maintenance at EL2 soon, so compile a copy of __flush_dcache_area at EL2, and provide a copy of arm64_ftr_reg_ctrel0 as it is needed by the read_ctr macro. Signed-off-by: Quentin Perret --- arch/arm64/include/asm/kvm_cpufeature.h | 2 ++ arch/arm64/kvm/hyp/nvhe

[PATCH v6 12/38] KVM: arm64: Introduce a Hyp buddy page allocator

2021-03-19 Thread Quentin Perret
in the kernel. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/kvm/hyp/include/nvhe/gfp.h| 68 arch/arm64/kvm/hyp/include/nvhe/memory.h | 28 arch/arm64/kvm/hyp/nvhe/Makefile | 2 +- arch/arm64/kvm/hyp/nvhe/page_alloc.c | 195

[PATCH v6 16/38] arm64: asm: Provide set_sctlr_el2 macro

2021-03-19 Thread Quentin Perret
We will soon need to turn the EL2 stage 1 MMU on and off in nVHE protected mode, so refactor the set_sctlr_el1 macro to make it usable for that purpose. Acked-by: Will Deacon Suggested-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/include/asm/assembler.h | 14 +++--- 1

[PATCH v6 09/38] KVM: arm64: Allow using kvm_nvhe_sym() in hyp code

2021-03-19 Thread Quentin Perret
In order to allow the usage of code shared by the host and the hyp in static inline library functions, allow the usage of kvm_nvhe_sym() at EL2 by defaulting to the raw symbol name. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/include/asm/hyp_image.h | 4 1 file

[PATCH v6 10/38] KVM: arm64: Introduce an early Hyp page allocator

2021-03-19 Thread Quentin Perret
a full-fledged page allocator after init. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/kvm/hyp/include/nvhe/early_alloc.h | 14 + arch/arm64/kvm/hyp/include/nvhe/memory.h | 24 + arch/arm64/kvm/hyp/nvhe/Makefile | 2 +- arch/arm64/kvm/hyp/nvhe

[PATCH v6 11/38] KVM: arm64: Stub CONFIG_DEBUG_LIST at Hyp

2021-03-19 Thread Quentin Perret
In order to use the kernel list library at EL2, introduce stubs for the CONFIG_DEBUG_LIST out-of-lines calls. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/kvm/hyp/nvhe/Makefile | 2 +- arch/arm64/kvm/hyp/nvhe/stub.c | 22 ++ 2 files changed, 23

[PATCH v6 07/38] KVM: arm64: Introduce a BSS section for use at Hyp

2021-03-19 Thread Quentin Perret
pages, and create the appropriate RW hyp mappings during KVM init. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/include/asm/sections.h | 1 + arch/arm64/kernel/vmlinux.lds.S | 52 --- arch/arm64/kvm/arm.c | 14 - arch/arm64

[PATCH v6 08/38] KVM: arm64: Make kvm_call_hyp() a function call at Hyp

2021-03-19 Thread Quentin Perret
() in .hyp.text. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/include/asm/kvm_host.h | 6 ++ 1 file changed, 6 insertions(+) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 08f500b2551a..6a2031af9562 100644 --- a/arch/arm64

[PATCH v6 05/38] KVM: arm64: Avoid free_page() in page-table allocator

2021-03-19 Thread Quentin Perret
used by the page-table code. This will ease factoring out page-allocation from pgtable.c, which is a pre-requisite to creating page-tables at EL2. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/kvm/hyp/pgtable.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions

[PATCH v6 06/38] KVM: arm64: Factor memory allocation out of pgtable.c

2021-03-19 Thread Quentin Perret
In preparation for enabling the creation of page-tables at EL2, factor all memory allocation out of the page-table code, hence making it re-usable with any compatible memory allocator. No functional changes intended. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/include

[PATCH v6 02/38] KVM: arm64: Link position-independent string routines into .hyp.text

2021-03-19 Thread Quentin Perret
-off-by: Quentin Perret --- arch/arm64/include/asm/hyp_image.h | 3 +++ arch/arm64/kernel/image-vars.h | 11 +++ arch/arm64/kvm/hyp/nvhe/Makefile | 4 3 files changed, 18 insertions(+) diff --git a/arch/arm64/include/asm/hyp_image.h b/arch/arm64/include/asm/hyp_image.h index

[PATCH v6 04/38] KVM: arm64: Initialize kvm_nvhe_init_params early

2021-03-19 Thread Quentin Perret
the replacement of host-provided page-table by the one the hypervisor will create for itself. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/kvm/arm.c | 30 ++ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/arch/arm64/kvm/arm.c b/arch

[PATCH v6 03/38] arm64: kvm: Add standalone ticket spinlock implementation for use at hyp

2021-03-19 Thread Quentin Perret
ed heavily on the code removed by commit c11090474d70 ("arm64: locking: Replace ticket lock implementation with qspinlock"). Signed-off-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/kvm/hyp/include/nvhe/spinlock.h | 92 ++ 1 file changed, 92 insertions(+)

[PATCH v6 00/38] KVM: arm64: Stage-2 for the host

2021-03-19 Thread Quentin Perret
-...@kernel.org/ Quentin Perret (35): KVM: arm64: Initialize kvm_nvhe_init_params early KVM: arm64: Avoid free_page() in page-table allocator KVM: arm64: Factor memory allocation out of pgtable.c KVM: arm64: Introduce a BSS section for use at Hyp KVM: arm64: Make kvm_call_hyp() a function

[PATCH v6 01/38] arm64: lib: Annotate {clear,copy}_page() as position-independent

2021-03-19 Thread Quentin Perret
From: Will Deacon clear_page() and copy_page() are suitable for use outside of the kernel address space, so annotate them as position-independent code. Signed-off-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/lib/clear_page.S | 4 ++-- arch/arm64/lib/copy_page.S | 4 ++-- 2

Re: [PATCH 1/2] KVM: arm64: Introduce KVM_PGTABLE_S2_NOFWB Stage-2 flag

2021-03-17 Thread Quentin Perret
On Wednesday 17 Mar 2021 at 14:42:46 (+), Will Deacon wrote: > On Wed, Mar 17, 2021 at 02:17:13PM +0000, Quentin Perret wrote: > > In order to further configure stage-2 page-tables, pass flags to the > > init function using a new enum. > > > > The first of these

Re: [PATCH 1/2] KVM: arm64: Introduce KVM_PGTABLE_S2_NOFWB Stage-2 flag

2021-03-17 Thread Quentin Perret
On Wednesday 17 Mar 2021 at 14:41:31 (+), Marc Zyngier wrote: > Hi Quentin, > > On Wed, 17 Mar 2021 14:17:13 +, > Quentin Perret wrote: > > > > In order to further configure stage-2 page-tables, pass flags to the > > init function using a new enum. >

[PATCH 2/2] KVM: arm64: Disable FWB in host stage-2

2021-03-17 Thread Quentin Perret
We need the host to be in control of cacheability of its own mappings, so let's disable FWB altogether in its stage 2. Signed-off-by: Quentin Perret --- Obviously this will have to be folded in the relevant patch for v6, but I kept it separate for the sake of review. --- arch/arm64/kvm/hyp

[PATCH 0/2] Fixes for FWB

2021-03-17 Thread Quentin Perret
, and propagating it down where needed. It's a bit more intrusive, but cleaner conceptually. Thoughts? Thanks, Quentin Quentin Perret (2): KVM: arm64: Introduce KVM_PGTABLE_S2_NOFWB Stage-2 flag KVM: arm64: Disable FWB in host stage-2 arch/arm64/include/asm/kvm_pgtable.h | 19 +-- arch/arm64

[PATCH 1/2] KVM: arm64: Introduce KVM_PGTABLE_S2_NOFWB Stage-2 flag

2021-03-17 Thread Quentin Perret
In order to further configure stage-2 page-tables, pass flags to the init function using a new enum. The first of these flags allows to disable FWB even if the hardware supports it as we will need to do so for the host stage-2. Signed-off-by: Quentin Perret --- One question is, do we want

Re: [PATCH v5 33/36] KVM: arm64: Wrap the host with a stage 2

2021-03-17 Thread Quentin Perret
On Wednesday 17 Mar 2021 at 09:41:09 (+0100), Mate Toth-Pal wrote: > On 2021-03-16 18:46, Quentin Perret wrote: > > On Tuesday 16 Mar 2021 at 16:16:18 (+0100), Mate Toth-Pal wrote: > > > On 2021-03-16 15:29, Quentin Perret wrote: > > > > On Tuesday 16 Mar 2021 at 12

Re: [PATCH v5 33/36] KVM: arm64: Wrap the host with a stage 2

2021-03-16 Thread Quentin Perret
On Tuesday 16 Mar 2021 at 16:16:18 (+0100), Mate Toth-Pal wrote: > On 2021-03-16 15:29, Quentin Perret wrote: > > On Tuesday 16 Mar 2021 at 12:53:53 (+), Quentin Perret wrote: > > > On Tuesday 16 Mar 2021 at 13:28:42 (+0100), Mate Toth-Pal wrote: > > > > Changing

Re: [PATCH v5 33/36] KVM: arm64: Wrap the host with a stage 2

2021-03-16 Thread Quentin Perret
On Tuesday 16 Mar 2021 at 12:53:53 (+), Quentin Perret wrote: > On Tuesday 16 Mar 2021 at 13:28:42 (+0100), Mate Toth-Pal wrote: > > Changing the value of MT_S2_FWB_NORMAL to 7 would change this behavior, and > > the resulting memory type would be device. > > Sounds like

Re: [PATCH v5 33/36] KVM: arm64: Wrap the host with a stage 2

2021-03-16 Thread Quentin Perret
On Tuesday 16 Mar 2021 at 13:28:42 (+0100), Mate Toth-Pal wrote: > Testing the latest version of the patchset, we seem to have found another > thing related to FEAT_S2FWB. Argh! I wish I could put my hands on hardware with FWB. Thanks again for the report. > This function always sets Normal

Re: [PATCH v5 14/36] KVM: arm64: Provide __flush_dcache_area at EL2

2021-03-15 Thread Quentin Perret
On Monday 15 Mar 2021 at 16:33:23 (+), Will Deacon wrote: > On Mon, Mar 15, 2021 at 02:35:14PM +0000, Quentin Perret wrote: > > We will need to do cache maintenance at EL2 soon, so compile a copy of > > __flush_dcache_area at EL2, and provide a copy of arm64_ftr_reg_ctrel0 >

Re: [PATCH v5 29/36] KVM: arm64: Use page-table to track page ownership

2021-03-15 Thread Quentin Perret
On Monday 15 Mar 2021 at 16:36:19 (+), Will Deacon wrote: > On Mon, Mar 15, 2021 at 02:35:29PM +0000, Quentin Perret wrote: > > As the host stage 2 will be identity mapped, all the .hyp memory regions > > and/or memory pages donated to protected guestis will have to mar

[PATCH v5 32/36] KVM: arm64: Provide sanitized mmfr* registers at EL2

2021-03-15 Thread Quentin Perret
We will need to read sanitized values of mmfr{0,1}_el1 at EL2 soon, so add them to the list of copied variables. Signed-off-by: Quentin Perret --- arch/arm64/include/asm/kvm_cpufeature.h | 2 ++ arch/arm64/kvm/sys_regs.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/arch

[PATCH v5 07/36] KVM: arm64: Introduce a BSS section for use at Hyp

2021-03-15 Thread Quentin Perret
pages, and create the appropriate RW hyp mappings during KVM init. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/include/asm/sections.h | 1 + arch/arm64/kernel/vmlinux.lds.S | 52 --- arch/arm64/kvm/arm.c | 14 - arch/arm64

[PATCH v5 30/36] KVM: arm64: Refactor the *_map_set_prot_attr() helpers

2021-03-15 Thread Quentin Perret
In order to ease their re-use in other code paths, refactor the *_map_set_prot_attr() helpers to not depend on a map_data struct. No functional change intended. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/kvm/hyp/pgtable.c | 16 1 file changed, 8

[PATCH v5 06/36] KVM: arm64: Factor memory allocation out of pgtable.c

2021-03-15 Thread Quentin Perret
In preparation for enabling the creation of page-tables at EL2, factor all memory allocation out of the page-table code, hence making it re-usable with any compatible memory allocator. No functional changes intended. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/include

[PATCH v5 29/36] KVM: arm64: Use page-table to track page ownership

2021-03-15 Thread Quentin Perret
do refcount as we now need to count invalid mappings when they are used for ownership tracking. Signed-off-by: Quentin Perret --- arch/arm64/include/asm/kvm_pgtable.h | 21 + arch/arm64/kvm/hyp/pgtable.c | 127 ++- 2 files changed, 124 insertions(+), 24

[PATCH v5 12/36] KVM: arm64: Introduce a Hyp buddy page allocator

2021-03-15 Thread Quentin Perret
in the kernel. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/kvm/hyp/include/nvhe/gfp.h| 68 arch/arm64/kvm/hyp/include/nvhe/memory.h | 28 arch/arm64/kvm/hyp/nvhe/Makefile | 2 +- arch/arm64/kvm/hyp/nvhe/page_alloc.c | 195

[PATCH v5 31/36] KVM: arm64: Add kvm_pgtable_stage2_find_range()

2021-03-15 Thread Quentin Perret
of available IPA space. This will be used in the host memory abort path to greedily idmap large portion of the PA space. Signed-off-by: Quentin Perret --- arch/arm64/include/asm/kvm_pgtable.h | 29 + arch/arm64/kvm/hyp/pgtable.c | 89 ++-- 2 files changed, 114

[PATCH v5 14/36] KVM: arm64: Provide __flush_dcache_area at EL2

2021-03-15 Thread Quentin Perret
We will need to do cache maintenance at EL2 soon, so compile a copy of __flush_dcache_area at EL2, and provide a copy of arm64_ftr_reg_ctrel0 as it is needed by the read_ctr macro. Signed-off-by: Quentin Perret --- arch/arm64/include/asm/kvm_cpufeature.h | 2 ++ arch/arm64/kvm/hyp/nvhe

[PATCH v5 33/36] KVM: arm64: Wrap the host with a stage 2

2021-03-15 Thread Quentin Perret
int on, memory accesses from the host to protected memory regions (e.g. not 'owned' by the host) are fatal and lead to hyp_panic(). Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/include/asm/kvm_asm.h | 1 + arch/arm64/kernel/image-vars.h|

[PATCH v5 05/36] KVM: arm64: Avoid free_page() in page-table allocator

2021-03-15 Thread Quentin Perret
used by the page-table code. This will ease factoring out page-allocation from pgtable.c, which is a pre-requisite to creating page-tables at EL2. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/kvm/hyp/pgtable.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions

[PATCH v5 11/36] KVM: arm64: Stub CONFIG_DEBUG_LIST at Hyp

2021-03-15 Thread Quentin Perret
In order to use the kernel list library at EL2, introduce stubs for the CONFIG_DEBUG_LIST out-of-lines calls. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/kvm/hyp/nvhe/Makefile | 2 +- arch/arm64/kvm/hyp/nvhe/stub.c | 22 ++ 2 files changed, 23

[PATCH v5 34/36] KVM: arm64: Page-align the .hyp sections

2021-03-15 Thread Quentin Perret
We will soon unmap the .hyp sections from the host stage 2 in Protected nVHE mode, which obviously works with at least page granularity, so make sure to align them correctly. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/kernel/vmlinux.lds.S | 22 +- 1

[PATCH v5 35/36] KVM: arm64: Disable PMU support in protected mode

2021-03-15 Thread Quentin Perret
-by: Quentin Perret --- arch/arm64/kvm/perf.c | 3 ++- arch/arm64/kvm/pmu.c | 8 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/arm64/kvm/perf.c b/arch/arm64/kvm/perf.c index 739164324afe..8f860ae56bb7 100644 --- a/arch/arm64/kvm/perf.c +++ b/arch/arm64/kvm/perf.c @@ -55,7

[PATCH v5 09/36] KVM: arm64: Allow using kvm_nvhe_sym() in hyp code

2021-03-15 Thread Quentin Perret
In order to allow the usage of code shared by the host and the hyp in static inline library functions, allow the usage of kvm_nvhe_sym() at EL2 by defaulting to the raw symbol name. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/include/asm/hyp_image.h | 4 1 file

[PATCH v5 10/36] KVM: arm64: Introduce an early Hyp page allocator

2021-03-15 Thread Quentin Perret
a full-fledged page allocator after init. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/kvm/hyp/include/nvhe/early_alloc.h | 14 + arch/arm64/kvm/hyp/include/nvhe/memory.h | 24 + arch/arm64/kvm/hyp/nvhe/Makefile | 2 +- arch/arm64/kvm/hyp/nvhe

[PATCH v5 28/36] KVM: arm64: Always zero invalid PTEs

2021-03-15 Thread Quentin Perret
Suggested-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/kvm/hyp/pgtable.c | 26 -- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c index bdd6e3d4eeb6..f37b4179b880 100644 --- a/arch

[PATCH v5 24/36] KVM: arm64: Refactor __populate_fault_info()

2021-03-15 Thread Quentin Perret
Refactor __populate_fault_info() to introduce __get_fault_info() which will be used once the host is wrapped in a stage 2. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/kvm/hyp/include/hyp/switch.h | 34 + 1 file changed, 18 insertions(+), 16

[PATCH v5 36/36] KVM: arm64: Protect the .hyp sections from the host

2021-03-15 Thread Quentin Perret
to the .hyp sections directly. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/include/asm/kvm_asm.h | 1 + arch/arm64/kvm/arm.c | 46 +++ arch/arm64/kvm/hyp/include/nvhe/mem_protect.h | 2 + arch/arm64/kvm/hyp/nvhe/hyp

[PATCH v5 23/36] KVM: arm64: Refactor __load_guest_stage2()

2021-03-15 Thread Quentin Perret
Refactor __load_guest_stage2() to introduce __load_stage2() which will be re-used when loading the host stage 2. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/include/asm/kvm_mmu.h | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/arm64

[PATCH v5 27/36] KVM: arm64: Sort the hypervisor memblocks

2021-03-15 Thread Quentin Perret
We will soon need to check if a Physical Address belongs to a memblock at EL2, so make sure to sort them so this can be done efficiently. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/kvm/hyp/reserved_mem.c | 19 +++ 1 file changed, 19 insertions(+) diff

[PATCH v5 25/36] KVM: arm64: Make memcache anonymous in pgtable allocator

2021-03-15 Thread Quentin Perret
they need to. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/include/asm/kvm_pgtable.h | 6 +++--- arch/arm64/kvm/hyp/pgtable.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/arm64/include/asm/kvm_pgtable.h b/arch/arm64/include/asm

[PATCH v5 26/36] KVM: arm64: Reserve memory for host stage 2

2021-03-15 Thread Quentin Perret
Extend the memory pool allocated for the hypervisor to include enough pages to map all of memory at page granularity for the host stage 2. While at it, also reserve some memory for device mappings. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/kvm/hyp/include/nvhe/mm.h

[PATCH v5 18/36] KVM: arm64: Elevate hypervisor mappings creation at EL2

2021-03-15 Thread Quentin Perret
tables directly. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/include/asm/kvm_mmu.h | 2 +- arch/arm64/kvm/arm.c | 87 +--- arch/arm64/kvm/mmu.c | 43 ++-- 3 files changed, 120 insertions(+), 12 deletions

[PATCH v5 17/36] KVM: arm64: Prepare the creation of s1 mappings at EL2

2021-03-15 Thread Quentin Perret
to Will for __pkvm_init_switch_pgd. Acked-by: Will Deacon Co-authored-by: Will Deacon Signed-off-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/include/asm/kvm_asm.h | 4 + arch/arm64/include/asm/kvm_host.h| 7 + arch/arm64/include/asm/kvm_hyp.h | 8 ++ arch/arm64/include/asm

[PATCH v5 15/36] KVM: arm64: Factor out vector address calculation

2021-03-15 Thread Quentin Perret
In order to re-map the guest vectors at EL2 when pKVM is enabled, refactor __kvm_vector_slot2idx() and kvm_init_vector_slot() to move all the address calculation logic in a static inline function. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/include/asm/kvm_mmu.h | 8

[PATCH v5 19/36] KVM: arm64: Use kvm_arch for stage 2 pgtable

2021-03-15 Thread Quentin Perret
In order to make use of the stage 2 pgtable code for the host stage 2, use struct kvm_arch in lieu of struct kvm as the host will have the former but not the latter. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/include/asm/kvm_pgtable.h | 5 +++-- arch/arm64/kvm/hyp

[PATCH v5 20/36] KVM: arm64: Use kvm_arch in kvm_s2_mmu

2021-03-15 Thread Quentin Perret
In order to make use of the stage 2 pgtable code for the host stage 2, change kvm_s2_mmu to use a kvm_arch pointer in lieu of the kvm pointer, as the host will have the former but not the latter. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/include/asm/kvm_host.h | 2

[PATCH v5 16/36] arm64: asm: Provide set_sctlr_el2 macro

2021-03-15 Thread Quentin Perret
We will soon need to turn the EL2 stage 1 MMU on and off in nVHE protected mode, so refactor the set_sctlr_el1 macro to make it usable for that purpose. Acked-by: Will Deacon Suggested-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/include/asm/assembler.h | 14 +++--- 1

[PATCH v5 22/36] KVM: arm64: Refactor kvm_arm_setup_stage2()

2021-03-15 Thread Quentin Perret
In order to re-use some of the stage 2 setup code at EL2, factor parts of kvm_arm_setup_stage2() out into separate functions. No functional change intended. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/include/asm/kvm_pgtable.h | 26 + arch/arm64/kvm/hyp

[PATCH v5 21/36] KVM: arm64: Set host stage 2 using kvm_nvhe_init_params

2021-03-15 Thread Quentin Perret
Move the registers relevant to host stage 2 enablement to kvm_nvhe_init_params to prepare the ground for enabling it in later patches. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/include/asm/kvm_asm.h | 3 +++ arch/arm64/kernel/asm-offsets.c| 3 +++ arch/arm64

[PATCH v5 13/36] KVM: arm64: Enable access to sanitized CPU features at EL2

2021-03-15 Thread Quentin Perret
together with the name of the nVHE variable that will hold the copy. This introduces only the infrastructure enabling this copy. The first users will follow shortly. Signed-off-by: Quentin Perret --- arch/arm64/include/asm/cpufeature.h | 1 + arch/arm64/include/asm/kvm_cpufeature.h | 15

[PATCH v5 08/36] KVM: arm64: Make kvm_call_hyp() a function call at Hyp

2021-03-15 Thread Quentin Perret
() in .hyp.text. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/include/asm/kvm_host.h | 6 ++ 1 file changed, 6 insertions(+) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 3d10e6527f7d..06ca4828005f 100644 --- a/arch/arm64

[PATCH v5 02/36] KVM: arm64: Link position-independent string routines into .hyp.text

2021-03-15 Thread Quentin Perret
-off-by: Quentin Perret --- arch/arm64/include/asm/hyp_image.h | 3 +++ arch/arm64/kernel/image-vars.h | 11 +++ arch/arm64/kvm/hyp/nvhe/Makefile | 4 3 files changed, 18 insertions(+) diff --git a/arch/arm64/include/asm/hyp_image.h b/arch/arm64/include/asm/hyp_image.h index

[PATCH v5 03/36] arm64: kvm: Add standalone ticket spinlock implementation for use at hyp

2021-03-15 Thread Quentin Perret
ed heavily on the code removed by commit c11090474d70 ("arm64: locking: Replace ticket lock implementation with qspinlock"). Signed-off-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/kvm/hyp/include/nvhe/spinlock.h | 92 ++ 1 file changed, 92 insertions(+)

  1   2   3   4   5   6   7   8   9   10   >