[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <31cd6a37f565e07f3890027b3b3305a225f84956.camel@redhat.com>
Date: Tue, 28 Nov 2023 09:39:49 +0200
From: Maxim Levitsky <mlevitsk@...hat.com>
To: Nicolas Saenz Julienne <nsaenz@...zon.com>, kvm@...r.kernel.org
Cc: linux-kernel@...r.kernel.org, linux-hyperv@...r.kernel.org,
pbonzini@...hat.com, seanjc@...gle.com, vkuznets@...hat.com,
anelkz@...zon.com, graf@...zon.com, dwmw@...zon.co.uk,
jgowans@...zon.com, corbert@....net, kys@...rosoft.com,
haiyangz@...rosoft.com, decui@...rosoft.com, x86@...nel.org,
linux-doc@...r.kernel.org
Subject: Re: [RFC 17/33] KVM: x86/mmu: Allow setting memory attributes if
VSM enabled
On Wed, 2023-11-08 at 11:17 +0000, Nicolas Saenz Julienne wrote:
> VSM is also a user of memory attributes, so let it use
> kvm_set_mem_attributes().
>
> Signed-off-by: Nicolas Saenz Julienne <nsaenz@...zon.com>
> ---
> arch/x86/kvm/mmu/mmu.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
> index feca077c0210..a1fbb905258b 100644
> --- a/arch/x86/kvm/mmu/mmu.c
> +++ b/arch/x86/kvm/mmu/mmu.c
> @@ -7265,7 +7265,8 @@ bool kvm_arch_pre_set_memory_attributes(struct kvm *kvm,
> * Zapping SPTEs in this case ensures KVM will reassess whether or not
> * a hugepage can be used for affected ranges.
> */
> - if (WARN_ON_ONCE(!kvm_arch_has_private_mem(kvm)))
> + if (WARN_ON_ONCE(!kvm_arch_has_private_mem(kvm) &&
> + !kvm_hv_vsm_enabled(kvm)))
> return false;
IMHO on the long term, memory attributes should either be always enabled,
or the above check should became more generic.
But otherwise this patch looks reasonable.
>
> return kvm_unmap_gfn_range(kvm, range);
> @@ -7322,7 +7323,8 @@ bool kvm_arch_post_set_memory_attributes(struct kvm *kvm,
> * a range that has PRIVATE GFNs, and conversely converting a range to
> * SHARED may now allow hugepages.
> */
> - if (WARN_ON_ONCE(!kvm_arch_has_private_mem(kvm)))
> + if (WARN_ON_ONCE(!kvm_arch_has_private_mem(kvm) &&
> + !kvm_hv_vsm_enabled(kvm)))
> return false;
>
> /*
Best regards,
Maxim Levitsky
Powered by blists - more mailing lists