Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932616AbcKYQ5z (ORCPT ); Fri, 25 Nov 2016 11:57:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57466 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932254AbcKYQ5x (ORCPT ); Fri, 25 Nov 2016 11:57:53 -0500 Date: Fri, 25 Nov 2016 17:57:50 +0100 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Paolo Bonzini Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Subject: Re: [PATCH] KVM: x86: restrict maximal physical address Message-ID: <20161125165750.GA10792@potion> References: <20161125145105.9508-1-rkrcmar@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 25 Nov 2016 16:57:53 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1457 Lines: 42 2016-11-25 17:10+0100, Paolo Bonzini: > On 25/11/2016 15:51, Radim Krčmář wrote: >> 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ář >> --- >> 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) >> + return -EINVAL; >> vcpu->arch.maxphyaddr = cpuid_query_maxphyaddr(vcpu); >> >> kvm_pmu_refresh(vcpu); >> > > Not possible unfortunately, this would break most versions of QEMU that > hard-code 40 for MAXPHYADDR. > > Also, "wider" physical addresses in the guest are actually possible with > shadow paging. We don't disable EPT in that case, though. I guess that situations where QEMU configures mem slot into high physical addresses are not hit in production ... Is any solution better than ignoring this situation?