[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4e75a1a0b67e7b3ccaf6b140b08a5f2080aedbdb.camel@intel.com>
Date: Wed, 18 Jan 2023 00:20:59 +0000
From: "Huang, Kai" <kai.huang@...el.com>
To: "kvm@...r.kernel.org" <kvm@...r.kernel.org>,
"michael.roth@....com" <michael.roth@....com>
CC: "tglx@...utronix.de" <tglx@...utronix.de>,
"tobin@....com" <tobin@....com>,
"srinivas.pandruvada@...ux.intel.com"
<srinivas.pandruvada@...ux.intel.com>,
"Luck, Tony" <tony.luck@...el.com>,
"jmattson@...gle.com" <jmattson@...gle.com>,
"Lutomirski, Andy" <luto@...nel.org>,
"ak@...ux.intel.com" <ak@...ux.intel.com>,
"pbonzini@...hat.com" <pbonzini@...hat.com>,
"pgonda@...gle.com" <pgonda@...gle.com>,
"rientjes@...gle.com" <rientjes@...gle.com>,
"slp@...hat.com" <slp@...hat.com>,
"dovmurik@...ux.ibm.com" <dovmurik@...ux.ibm.com>,
"alpergun@...gle.com" <alpergun@...gle.com>,
"peterz@...radead.org" <peterz@...radead.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"thomas.lendacky@....com" <thomas.lendacky@....com>,
"harald@...fian.com" <harald@...fian.com>,
"x86@...nel.org" <x86@...nel.org>, "bp@...en8.de" <bp@...en8.de>,
"dgilbert@...hat.com" <dgilbert@...hat.com>,
"Christopherson,, Sean" <seanjc@...gle.com>,
"vkuznets@...hat.com" <vkuznets@...hat.com>,
"marcorr@...gle.com" <marcorr@...gle.com>,
"vbabka@...e.cz" <vbabka@...e.cz>,
"ashish.kalra@....com" <ashish.kalra@....com>,
"nikunj@....com" <nikunj@....com>,
"linux-coco@...ts.linux.dev" <linux-coco@...ts.linux.dev>,
"wanpengli@...cent.com" <wanpengli@...cent.com>,
"Rodel, Jorg" <jroedel@...e.de>,
"mingo@...hat.com" <mingo@...hat.com>,
"sathyanarayanan.kuppuswamy@...ux.intel.com"
<sathyanarayanan.kuppuswamy@...ux.intel.com>,
"hpa@...or.com" <hpa@...or.com>,
"kirill@...temov.name" <kirill@...temov.name>,
"jarkko@...nel.org" <jarkko@...nel.org>,
"ardb@...nel.org" <ardb@...nel.org>,
"linux-crypto@...r.kernel.org" <linux-crypto@...r.kernel.org>,
"linux-mm@...ck.org" <linux-mm@...ck.org>,
"dave.hansen@...ux.intel.com" <dave.hansen@...ux.intel.com>
Subject: Re: [PATCH RFC v7 03/64] KVM: SVM: Advertise private memory support
to KVM
On Wed, 2022-12-14 at 13:39 -0600, Michael Roth wrote:
> From: Nikunj A Dadhania <nikunj@....com>
>
> KVM should use private memory for guests that have upm_mode flag set.
>
> Add a kvm_x86_ops hook for determining UPM support that accounts for
> this situation by only enabling UPM test mode in the case of non-SEV
> guests.
>
> Signed-off-by: Nikunj A Dadhania <nikunj@....com>
> [mdr: add x86 hook for determining restricted/private memory support]
> Signed-off-by: Michael Roth <michael.roth@....com>
> ---
> arch/x86/include/asm/kvm-x86-ops.h | 1 +
> arch/x86/include/asm/kvm_host.h | 1 +
> arch/x86/kvm/svm/svm.c | 10 ++++++++++
> arch/x86/kvm/x86.c | 8 ++++++++
> 4 files changed, 20 insertions(+)
>
> diff --git a/arch/x86/include/asm/kvm-x86-ops.h b/arch/x86/include/asm/kvm-x86-ops.h
> index abccd51dcfca..f530a550c092 100644
> --- a/arch/x86/include/asm/kvm-x86-ops.h
> +++ b/arch/x86/include/asm/kvm-x86-ops.h
> @@ -131,6 +131,7 @@ KVM_X86_OP(msr_filter_changed)
> KVM_X86_OP(complete_emulated_msr)
> KVM_X86_OP(vcpu_deliver_sipi_vector)
> KVM_X86_OP_OPTIONAL_RET0(vcpu_get_apicv_inhibit_reasons);
> +KVM_X86_OP_OPTIONAL_RET0(private_mem_enabled);
>
> #undef KVM_X86_OP
> #undef KVM_X86_OP_OPTIONAL
> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
> index 2b6244525107..9317abffbf68 100644
> --- a/arch/x86/include/asm/kvm_host.h
> +++ b/arch/x86/include/asm/kvm_host.h
> @@ -1635,6 +1635,7 @@ struct kvm_x86_ops {
>
> void (*load_mmu_pgd)(struct kvm_vcpu *vcpu, hpa_t root_hpa,
> int root_level);
> + int (*private_mem_enabled)(struct kvm *kvm);
>
> bool (*has_wbinvd_exit)(void);
>
> diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
> index 91352d692845..7f3e4d91c0c6 100644
> --- a/arch/x86/kvm/svm/svm.c
> +++ b/arch/x86/kvm/svm/svm.c
> @@ -4694,6 +4694,14 @@ static int svm_vm_init(struct kvm *kvm)
> return 0;
> }
>
> +static int svm_private_mem_enabled(struct kvm *kvm)
> +{
> + if (sev_guest(kvm))
> + return kvm->arch.upm_mode ? 1 : 0;
> +
> + return IS_ENABLED(CONFIG_HAVE_KVM_PRIVATE_MEM_TESTING) ? 1 : 0;
> +}
> +
Is this new callback really needed? Shouldn't kvm->arch.upm_mode be sufficient
enough to indicate whether the private memory will be used or not?
Probably the CONFIG_HAVE_KVM_PRIVATE_MEM_TESTING is the concern here. But this
Kconfig option is not even x86-specific, so shouldn't the handling of it be done
in common code too?
For instance, can we explicitly set 'kvm->arch.upm_mode' to 'true' at some point
of creating the VM if we see CONFIG_HAVE_KVM_PRIVATE_MEM_TESTING is true?
[snip]
Powered by blists - more mailing lists