From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:35704) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TUziz-000220-95 for qemu-devel@nongnu.org; Sun, 04 Nov 2012 07:54:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TUziy-0004rV-1I for qemu-devel@nongnu.org; Sun, 04 Nov 2012 07:54:49 -0500 Received: from mout.web.de ([212.227.15.4]:55820) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TUzix-0004rR-No for qemu-devel@nongnu.org; Sun, 04 Nov 2012 07:54:47 -0500 Message-ID: <50966591.5010903@web.de> Date: Sun, 04 Nov 2012 13:54:41 +0100 From: Jan Kiszka MIME-Version: 1.0 References: <1351834702-25937-1-git-send-email-xudong.hao@intel.com> <5094F7EA.9050200@web.de> <403610A45A2B5242BD291EDAE8B37D300FEFBAF2@SHSMSX102.ccr.corp.intel.com> In-Reply-To: <403610A45A2B5242BD291EDAE8B37D300FEFBAF2@SHSMSX102.ccr.corp.intel.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig367F5667E4EBD073B4577D89" Subject: Re: [Qemu-devel] [PATCH 1/2] qemu-kvm/cpuid: fix a emulation of guest physical address space List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Hao, Xudong" Cc: "qemu-devel@nongnu.org" , "kvm@vger.kernel.org" , "avi@redhat.com" This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig367F5667E4EBD073B4577D89 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 2012-11-04 13:15, Hao, Xudong wrote: >> -----Original Message----- >> From: Jan Kiszka [mailto:jan.kiszka@web.de] >> Sent: Saturday, November 03, 2012 6:55 PM >> To: Hao, Xudong >> Cc: qemu-devel@nongnu.org; avi@redhat.com; kvm@vger.kernel.org >> Subject: Re: [PATCH 1/2] qemu-kvm/cpuid: fix a emulation of guest phys= ical >> address space >> >> On 2012-11-02 06:38, Xudong Hao wrote: >>> For 64 bit processor, emulate 40 bits physical address if the host ph= ysical >>> address space >=3D 40bits, else guest physical is same as host. >>> >>> Signed-off-by: Xudong Hao >>> --- >>> target-i386/cpu.c | 5 ++++- >>> 1 files changed, 4 insertions(+), 1 deletions(-) >>> >>> diff --git a/target-i386/cpu.c b/target-i386/cpu.c >>> index 423e009..3a78881 100644 >>> --- a/target-i386/cpu.c >>> +++ b/target-i386/cpu.c >>> @@ -1584,7 +1584,10 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t >> index, uint32_t count, >>> if (env->cpuid_ext2_features & CPUID_EXT2_LM) { >>> /* 64 bit processor */ >>> /* XXX: The physical address space is limited to 42 bits in exec.c. = */ >>> - *eax =3D 0x00003028; /* 48 bits virtual, 40 bits physica= l */ >>> +/* XXX: 40 bits physical if host physical address space >=3D 40 bits= */ >>> + uint32_t a, b, c, d; >>> + host_cpuid(0x80000008, 0, &a, &b, &c, &d); >>> + *eax =3D a < 0x00003028 ? a : 0x00003028; >> >> This variation will not only affect -cpu host, right? That can create >> problems when migrating between hosts with different address widths, a= nd >> then we will need some control knob to adjust what it reported to the = guest. >> >=20 > Oh, I did not consider migrating to different platform(addr widths). > But I think the fixed value 40 bits may cause problem: in VT-d case, wh= en a host support GAW < 40 bits, and qemu emulate 40 bits guest physical = address space, will bring bug on: >=20 > drivers/iommu/intel-iommu.c > static struct dma_pte *pfn_to_dma_pte(struct dmar_domain *domain, > unsigned long pfn, int target_level) > { > int addr_width =3D agaw_to_width(domain->agaw) - VTD_PAGE_SHIFT; > ... > BUG_ON(!domain->pgd); > BUG_ON(addr_width < BITS_PER_LONG && pfn >> addr_width); >=20 Does it mean that buggy or malicious user space can trigger a kernel bug? Then this must be fixed of course. Jan --------------enig367F5667E4EBD073B4577D89 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://www.enigmail.net/ iEYEARECAAYFAlCWZZMACgkQitSsb3rl5xRCDgCgqUb/qss50AmPSnieHs6xeno0 56EAniUxS2cFv/yRS7JcNotEpnFiGz7J =BZYg -----END PGP SIGNATURE----- --------------enig367F5667E4EBD073B4577D89--