Re: [PATCH v5 02/13] KVM: x86: Refactor tsc synchronization code

2021-08-03 Thread Oliver Upton
On Fri, Jul 30, 2021 at 11:08 AM Sean Christopherson wrote: > > On Thu, Jul 29, 2021, Oliver Upton wrote: > > Refactor kvm_synchronize_tsc to make a new function that allows callers > > to specify TSC parameters (offset, value, nanoseconds, etc.) explicitly > > for the sake of participating in

Re: [PATCH v3] memblock: make memblock_find_in_range method private

2021-08-03 Thread Mike Rapoport
On Tue, Aug 03, 2021 at 07:05:26PM +0100, Catalin Marinas wrote: > On Tue, Aug 03, 2021 at 09:42:18AM +0300, Mike Rapoport wrote: > > diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c > > index 8490ed2917ff..0bffd2d1854f 100644 > > --- a/arch/arm64/mm/init.c > > +++ b/arch/arm64/mm/init.c >

Re: [PATCH v3] memblock: make memblock_find_in_range method private

2021-08-03 Thread Catalin Marinas
On Tue, Aug 03, 2021 at 09:42:18AM +0300, Mike Rapoport wrote: > diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c > index 8490ed2917ff..0bffd2d1854f 100644 > --- a/arch/arm64/mm/init.c > +++ b/arch/arm64/mm/init.c > @@ -74,6 +74,7 @@ phys_addr_t arm64_dma_phys_limit __ro_after_init; >

RE: [PATCH v3 4/4] KVM: arm64: Clear active_vmids on vCPU schedule out

2021-08-03 Thread Shameerali Kolothum Thodi
> -Original Message- > From: Will Deacon [mailto:w...@kernel.org] > Sent: 03 August 2021 16:31 > To: Shameerali Kolothum Thodi > Cc: linux-arm-ker...@lists.infradead.org; kvmarm@lists.cs.columbia.edu; > linux-ker...@vger.kernel.org; m...@kernel.org; catalin.mari...@arm.com; >

Re: [PATCH v3 10/15] KVM: arm64: Guest exit handlers for nVHE hyp

2021-08-03 Thread Will Deacon
On Mon, Jul 19, 2021 at 05:03:41PM +0100, Fuad Tabba wrote: > Add an array of pointers to handlers for various trap reasons in > nVHE code. > > The current code selects how to fixup a guest on exit based on a > series of if/else statements. Future patches will also require > different handling

Re: [PATCH v3 4/4] KVM: arm64: Clear active_vmids on vCPU schedule out

2021-08-03 Thread Will Deacon
On Tue, Aug 03, 2021 at 12:55:25PM +, Shameerali Kolothum Thodi wrote: > > > diff --git a/arch/arm64/kvm/vmid.c b/arch/arm64/kvm/vmid.c > > > index 5584e84aed95..5fd51f5445c1 100644 > > > --- a/arch/arm64/kvm/vmid.c > > > +++ b/arch/arm64/kvm/vmid.c > > > @@ -116,6 +116,12 @@ static u64

Re: [PATCH v3 17/21] KVM: arm64: Mark host bss and rodata section as shared

2021-08-03 Thread Fuad Tabba
Hi Quentin, > > > + ret = pkvm_create_mappings(__hyp_bss_end, __bss_stop, prot); > > > > nit: for clarity, I wonder if it might be good to create an alias of > > __hyp_bss_end as __bss_start or something. When it's been moved here, > > it sticks out a bit more and makes the reader wonder

Re: [PATCH v3 19/21] KVM: arm64: Refactor protected nVHE stage-1 locking

2021-08-03 Thread Fuad Tabba
Hi Quentin, > > > +int pkvm_create_mappings(void *from, void *to, enum kvm_pgtable_prot > > > prot) > > > +{ > > > + int ret; > > > + > > > + hyp_spin_lock(_pgd_lock); > > > + ret = pkvm_create_mappings_locked(from, to, prot); > > > + hyp_spin_unlock(_pgd_lock); > > > + >

Re: [PATCH v3 10/21] KVM: arm64: Enable forcing page-level stage-2 mappings

2021-08-03 Thread Fuad Tabba
Hi Quentin, > > > +static bool stage2_block_mapping_allowed(u64 addr, u64 end, u32 level, > > > +struct stage2_map_data *data) > > > +{ > > > + if (data->force_pte && (level < (KVM_PGTABLE_MAX_LEVELS - 1))) > > > + return false; > > > >

Re: [PATCH v3 20/21] KVM: arm64: Restrict EL2 stage-1 changes in protected mode

2021-08-03 Thread Quentin Perret
On Tuesday 03 Aug 2021 at 10:22:03 (+0200), Fuad Tabba wrote: > Hi Quentin, > > > diff --git a/arch/arm64/kvm/hyp/nvhe/mem_protect.c > > b/arch/arm64/kvm/hyp/nvhe/mem_protect.c > > index 0ccea58df7e0..1b67f562b6fc 100644 > > --- a/arch/arm64/kvm/hyp/nvhe/mem_protect.c > > +++

Re: [PATCH v3 19/21] KVM: arm64: Refactor protected nVHE stage-1 locking

2021-08-03 Thread Quentin Perret
Hey Fuad, On Tuesday 03 Aug 2021 at 07:31:03 (+0200), Fuad Tabba wrote: > Hi Quentin, > > On Thu, Jul 29, 2021 at 3:29 PM Quentin Perret wrote: > > > > Refactor the hypervisor stage-1 locking in nVHE protected mode to expose > > a new pkvm_create_mappings_locked() function. This will be used in

Re: [PATCH v3 17/21] KVM: arm64: Mark host bss and rodata section as shared

2021-08-03 Thread Quentin Perret
On Tuesday 03 Aug 2021 at 07:02:42 (+0200), Fuad Tabba wrote: > Hi Quentin, > > On Thu, Jul 29, 2021 at 3:29 PM Quentin Perret wrote: > > > > As the hypervisor maps the host's .bss and .rodata sections in its > > stage-1, make sure to tag them as shared in hyp and host page-tables. > > > > But

Re: [PATCH v3 16/21] KVM: arm64: Enable retrieving protections attributes of PTEs

2021-08-03 Thread Quentin Perret
On Monday 02 Aug 2021 at 16:52:49 (+0200), Fuad Tabba wrote: > Hi Quentin, > > On Thu, Jul 29, 2021 at 3:29 PM Quentin Perret wrote: > > > > Introduce helper functions in the KVM stage-2 and stage-1 page-table > > manipulation library allowing to retrieve the enum kvm_pgtable_prot of a > > PTE.

Re: [PATCH v3 15/21] KVM: arm64: Introduce addr_is_memory()

2021-08-03 Thread Quentin Perret
On Monday 02 Aug 2021 at 16:52:31 (+0200), Fuad Tabba wrote: > Hi Quentin. > > On Thu, Jul 29, 2021 at 3:28 PM Quentin Perret wrote: > > > > Introduce a helper usable in nVHE protected mode to check whether a > > physical address is in a RAM region or not. > > > > Signed-off-by: Quentin Perret

Re: [PATCH v3 13/21] KVM: arm64: Expose host stage-2 manipulation helpers

2021-08-03 Thread Quentin Perret
On Monday 02 Aug 2021 at 13:13:20 (+0200), Fuad Tabba wrote: > Hi Quentin, > > On Thu, Jul 29, 2021 at 3:28 PM Quentin Perret wrote: > > > > We will need to manipulate the host stage-2 page-table from outside > > mem_protect.c soon. Introduce two functions allowing this, and make > > them usable

Re: [PATCH v3 10/21] KVM: arm64: Enable forcing page-level stage-2 mappings

2021-08-03 Thread Quentin Perret
Hi Fuad, On Monday 02 Aug 2021 at 11:49:28 (+0200), Fuad Tabba wrote: > On Thu, Jul 29, 2021 at 3:28 PM Quentin Perret wrote: > > > > Much of the stage-2 manipulation logic relies on being able to destroy > > block mappings if e.g. installing a smaller mapping in the range. The > > rationale for

RE: [PATCH v3 4/4] KVM: arm64: Clear active_vmids on vCPU schedule out

2021-08-03 Thread Shameerali Kolothum Thodi
> -Original Message- > From: Will Deacon [mailto:w...@kernel.org] > Sent: 03 August 2021 12:41 > To: Shameerali Kolothum Thodi > Cc: linux-arm-ker...@lists.infradead.org; kvmarm@lists.cs.columbia.edu; > linux-ker...@vger.kernel.org; m...@kernel.org; catalin.mari...@arm.com; >

Re: [PATCH v3 20/21] KVM: arm64: Restrict EL2 stage-1 changes in protected mode

2021-08-03 Thread Fuad Tabba
Hi Quentin, > diff --git a/arch/arm64/kvm/hyp/nvhe/mem_protect.c > b/arch/arm64/kvm/hyp/nvhe/mem_protect.c > index 0ccea58df7e0..1b67f562b6fc 100644 > --- a/arch/arm64/kvm/hyp/nvhe/mem_protect.c > +++ b/arch/arm64/kvm/hyp/nvhe/mem_protect.c > @@ -338,6 +338,95 @@ static int host_stage2_idmap(u64

RE: [PATCH v3 1/4] KVM: arm64: Introduce a new VMID allocator for KVM

2021-08-03 Thread Shameerali Kolothum Thodi
> -Original Message- > From: Will Deacon [mailto:w...@kernel.org] > Sent: 03 August 2021 12:39 > To: Shameerali Kolothum Thodi > Cc: linux-arm-ker...@lists.infradead.org; kvmarm@lists.cs.columbia.edu; > linux-ker...@vger.kernel.org; m...@kernel.org; catalin.mari...@arm.com; >

Re: [PATCH v3 4/4] KVM: arm64: Clear active_vmids on vCPU schedule out

2021-08-03 Thread Will Deacon
On Thu, Jul 29, 2021 at 11:40:09AM +0100, Shameer Kolothum wrote: > Like ASID allocator, we copy the active_vmids into the > reserved_vmids on a rollover. But it's unlikely that > every CPU will have a vCPU as current task and we may > end up unnecessarily reserving the VMID space. > > Hence,

Re: [PATCH v3 1/4] KVM: arm64: Introduce a new VMID allocator for KVM

2021-08-03 Thread Will Deacon
On Thu, Jul 29, 2021 at 11:40:06AM +0100, Shameer Kolothum wrote: > A new VMID allocator for arm64 KVM use. This is based on > arm64 ASID allocator algorithm. > > One major deviation from the ASID allocator is the way we > flush the context. Unlike ASID allocator, we expect less > frequent

Re: [PATCH v3 19/21] KVM: arm64: Refactor protected nVHE stage-1 locking

2021-08-03 Thread Fuad Tabba
Hi Quentin, On Thu, Jul 29, 2021 at 3:29 PM Quentin Perret wrote: > > Refactor the hypervisor stage-1 locking in nVHE protected mode to expose > a new pkvm_create_mappings_locked() function. This will be used in later > patches to allow walking and changing the hypervisor stage-1 without >

Re: [PATCH v3 17/21] KVM: arm64: Mark host bss and rodata section as shared

2021-08-03 Thread Fuad Tabba
Hi Quentin, On Thu, Jul 29, 2021 at 3:29 PM Quentin Perret wrote: > > As the hypervisor maps the host's .bss and .rodata sections in its > stage-1, make sure to tag them as shared in hyp and host page-tables. > > But since the hypervisor relies on the presence of these mappings, we > cannot let

[PATCH v3] memblock: make memblock_find_in_range method private

2021-08-03 Thread Mike Rapoport
From: Mike Rapoport There are a lot of uses of memblock_find_in_range() along with memblock_reserve() from the times memblock allocation APIs did not exist. memblock_find_in_range() is the very core of memblock allocations, so any future changes to its internal behaviour would mandate updates