[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 07 Jul 2021 13:28:10 +0300
From: Maxim Levitsky <mlevitsk@...hat.com>
To: Vitaly Kuznetsov <vkuznets@...hat.com>, kvm@...r.kernel.org,
Paolo Bonzini <pbonzini@...hat.com>
Cc: Sean Christopherson <seanjc@...gle.com>,
Wanpeng Li <wanpengli@...cent.com>,
Jim Mattson <jmattson@...gle.com>,
Cathy Avery <cavery@...hat.com>,
Emanuele Giuseppe Esposito <eesposit@...hat.com>,
Tom Lendacky <thomas.lendacky@....com>,
Michael Roth <mdroth@...ux.vnet.ibm.com>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/6] KVM: nSVM: Check the value written to
MSR_VM_HSAVE_PA
On Mon, 2021-06-28 at 12:44 +0200, Vitaly Kuznetsov wrote:
> APM states that #GP is raised upon write to MSR_VM_HSAVE_PA when
> the supplied address is not page-aligned or is outside of "maximum
> supported physical address for this implementation".
> page_address_valid() check seems suitable. Also, forcefully page-align
> the address when it's written from VMM.
Minor nitpick: I would have checked the host provided value as well,
just in case since there is no reason why it won't pass the same check,
and fail if the value is not aligned.
Other than that:
Reviewed-by: Maxim Levitsky <mlevitsk@...hat.com>
Best regards,
Maxim Levitsky
>
> Signed-off-by: Vitaly Kuznetsov <vkuznets@...hat.com>
> ---
> arch/x86/kvm/svm/svm.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
> index 8834822c00cd..b6f85fd19f96 100644
> --- a/arch/x86/kvm/svm/svm.c
> +++ b/arch/x86/kvm/svm/svm.c
> @@ -2941,7 +2941,10 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr)
> svm_disable_lbrv(vcpu);
> break;
> case MSR_VM_HSAVE_PA:
> - svm->nested.hsave_msr = data;
> + if (!msr->host_initiated && !page_address_valid(vcpu, data))
> + return 1;
> +
> + svm->nested.hsave_msr = data & PAGE_MASK;
> break;
> case MSR_VM_CR:
> return svm_set_vm_cr(vcpu, data);
Powered by blists - more mailing lists