lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <87plim7hgc.wl-maz@kernel.org>
Date: Wed, 12 Mar 2025 08:59:15 +0000
From: Marc Zyngier <maz@...nel.org>
To: Vincent Donnefort <vdonnefort@...gle.com>
Cc: oliver.upton@...ux.dev,
	joey.gouly@....com,
	suzuki.poulose@....com,
	yuzenghui@...wei.com,
	catalin.marinas@....com,
	will@...nel.org,
	qperret@...gle.com,
	linux-arm-kernel@...ts.infradead.org,
	kvmarm@...ts.linux.dev,
	linux-kernel@...r.kernel.org,
	kernel-team@...roid.com
Subject: Re: [PATCH v3 2/3] KVM: arm64: Distinct pKVM teardown memcache for stage-2

On Fri, 07 Mar 2025 11:34:10 +0000,
Vincent Donnefort <vdonnefort@...gle.com> wrote:
> 
> In order to account for memory dedicated to the stage-2 page-tables, use
> a separated memcache when tearing down the VM.
> 
> Signed-off-by: Vincent Donnefort <vdonnefort@...gle.com>
> 
> diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
> index 12691ae23d4c..ace3969e8106 100644
> --- a/arch/arm64/include/asm/kvm_host.h
> +++ b/arch/arm64/include/asm/kvm_host.h
> @@ -246,6 +246,7 @@ typedef unsigned int pkvm_handle_t;
>  struct kvm_protected_vm {
>  	pkvm_handle_t handle;
>  	struct kvm_hyp_memcache teardown_mc;
> +	struct kvm_hyp_memcache stage2_teardown_mc;
>  	bool enabled;
>  };
>  
> diff --git a/arch/arm64/kvm/hyp/nvhe/pkvm.c b/arch/arm64/kvm/hyp/nvhe/pkvm.c
> index 3927fe52a3dd..15f8d5315959 100644
> --- a/arch/arm64/kvm/hyp/nvhe/pkvm.c
> +++ b/arch/arm64/kvm/hyp/nvhe/pkvm.c
> @@ -678,7 +678,7 @@ teardown_donated_memory(struct kvm_hyp_memcache *mc, void *addr, size_t size)
>  
>  int __pkvm_teardown_vm(pkvm_handle_t handle)
>  {
> -	struct kvm_hyp_memcache *mc;
> +	struct kvm_hyp_memcache *mc, *stage2_mc;
>  	struct pkvm_hyp_vm *hyp_vm;
>  	struct kvm *host_kvm;
>  	unsigned int idx;
> @@ -706,7 +706,8 @@ int __pkvm_teardown_vm(pkvm_handle_t handle)
>  
>  	/* Reclaim guest pages (including page-table pages) */
>  	mc = &host_kvm->arch.pkvm.teardown_mc;
> -	reclaim_guest_pages(hyp_vm, mc);
> +	stage2_mc = &host_kvm->arch.pkvm.stage2_teardown_mc;
> +	reclaim_guest_pages(hyp_vm, stage2_mc);

This looks odd. What counts as stage-2 pages here? Or is it that
reclaim_guest_pages() is very badly named?

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ