Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1530406

Re: [PATCH] KVM: x86: restrict maximal physical address

From Radim Krčmář <rkrcmar@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH] KVM: x86: restrict maximal physical address
Date 2016-11-25 17:20 +0100
Message-ID <sHroe-2Rp-35@gated-at.bofh.it> (permalink)
References <sHq8N-1SA-23@gated-at.bofh.it> <sHqsa-2er-17@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


2016-11-25 16:11+0100, David Hildenbrand:
> Am 25.11.2016 um 15:51 schrieb Radim Krčmář:
>> The guest could have configured a maximal physical address that exceeds
>> the host.  Prevent that situation as it could easily lead to a bug.
>> 
>> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
>> ---
>>  arch/x86/kvm/cpuid.c | 8 +++++++-
>>  1 file changed, 7 insertions(+), 1 deletion(-)
>> 
>> diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
>> index 25f0f15fab1a..aed910e9fbed 100644
>> --- a/arch/x86/kvm/cpuid.c
>> +++ b/arch/x86/kvm/cpuid.c
>> @@ -136,7 +136,13 @@ int kvm_update_cpuid(struct kvm_vcpu *vcpu)
>>  		((best->eax & 0xff00) >> 8) != 0)
>>  		return -EINVAL;
>> 
>> -	/* Update physical-address width */
>> +
>> +	/*
>> +	 * Update physical-address width.
>> +	 * Make sure that it does not exceed hardware capabilities.
>> +	 */
>> +	if (cpuid_query_maxphyaddr(vcpu) > boot_cpu_data.x86_phys_bits)
> 
> The name maxphyaddr is really misleading. But that is a different story.

Yes, I'll rename it, thanks.

> This check is correct.
> 
> However, I wonder if there is any way for user space to query this property?

Do you mean boot_cpu_data.x86_phys_bits?
Userspace can execute CPUID instruction and read the value; QEMU does.

> On s390x, there is a kvm capability to export this information to user
> space. So QEMU can fail (e.g. migration) with a nice error message about
> missing hardware support.
> 
> (most probably we still want to block this case, as migration will seem to
> work but than simply fail due to missing hardware support I guess). Maybe
> there is also already a nice check in QEMU that I am not yet aware of :)

This patch is bad.  It would break QEMU on all old machines, because
QEMU sets 40 by default.

Heh, QEMU doesn't check at all -- it even allows migration with
"host-phys-bits" feature and will happily change phys-bits when
migrating to another machine.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] KVM: x86: restrict maximal physical address Radim Krčmář <rkrcmar@redhat.com> - 2016-11-25 16:00 +0100
  Re: [PATCH] KVM: x86: restrict maximal physical address David Hildenbrand <david@redhat.com> - 2016-11-25 16:20 +0100
    Re: [PATCH] KVM: x86: restrict maximal physical address Radim Krčmář <rkrcmar@redhat.com> - 2016-11-25 17:20 +0100
      Re: [PATCH] KVM: x86: restrict maximal physical address David Hildenbrand <david@redhat.com> - 2016-11-25 17:50 +0100
        Re: [PATCH] KVM: x86: restrict maximal physical address Radim Krčmář <rkrcmar@redhat.com> - 2016-11-29 18:00 +0100
  Re: [PATCH] KVM: x86: restrict maximal physical address Paolo Bonzini <pbonzini@redhat.com> - 2016-11-25 17:20 +0100
    Re: [PATCH] KVM: x86: restrict maximal physical address Radim Krčmář <rkrcmar@redhat.com> - 2016-11-25 18:00 +0100
      Re: [PATCH] KVM: x86: restrict maximal physical address Paolo Bonzini <pbonzini@redhat.com> - 2016-11-25 18:30 +0100

csiph-web