Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751608AbdHOIMy (ORCPT ); Tue, 15 Aug 2017 04:12:54 -0400 Received: from mga14.intel.com ([192.55.52.115]:11487 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750994AbdHOIMv (ORCPT ); Tue, 15 Aug 2017 04:12:51 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,377,1498546800"; d="scan'208";a="137541377" Subject: Re: [PATCH v1 1/4] KVM: MMU: check guest CR3 reserved bits based on its physical address width. To: Paolo Bonzini , Jim Mattson References: <1502544906-1108-1-git-send-email-yu.c.zhang@linux.intel.com> <1502544906-1108-2-git-send-email-yu.c.zhang@linux.intel.com> Cc: kvm list , LKML , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , xiaoguangrong@tencent.com, Joerg Roedel From: Yu Zhang Message-ID: Date: Tue, 15 Aug 2017 15:50:36 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1287 Lines: 34 On 8/15/2017 12:40 AM, Paolo Bonzini wrote: > On 14/08/2017 18:13, Jim Mattson wrote: >>> ctxt->ops->get_msr(ctxt, MSR_EFER, &efer); >>> - if (efer & EFER_LMA) >>> - rsvd = CR3_L_MODE_RESERVED_BITS & ~CR3_PCID_INVD; >>> + if (efer & EFER_LMA) { >>> + u64 maxphyaddr; >>> + u32 eax = 0x80000008; >>> + >>> + ctxt->ops->get_cpuid(ctxt, &eax, NULL, NULL, NULL); >>> + maxphyaddr = eax * 0xff; >> What if leaf 0x80000008 is not defined? > I noticed this too, but I thought it was mitigated by being under > EFER_LMA. Unfortunately, kvm_set_efer doesn't check > guest_cpuid_has_longmode, so I guess you do have to test leaf 0x80000000 > first. Alternatively: > > 1) kvm_cpuid could return false if it's falling back to > check_cpuid_limit, and emulator_get_cpuid can then be changed to return bool > > 2) kvm_cpuid and emulator_get_cpuid could gain a new argument to disable > the check_cpuid_limit fallback. > > Yu, would you like to implement the latter? Thanks for pointing this out, Jim & Paolo. The latter choice sounds better to me. :-) I'd like to implement this in a separate patch in next version patch set. Yu > Paolo >