From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752675AbdHNQkZ (ORCPT ); Mon, 14 Aug 2017 12:40:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57750 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752339AbdHNQkW (ORCPT ); Mon, 14 Aug 2017 12:40:22 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9196E7E424 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=pbonzini@redhat.com Subject: Re: [PATCH v1 1/4] KVM: MMU: check guest CR3 reserved bits based on its physical address width. To: Jim Mattson , Yu Zhang Cc: kvm list , LKML , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , xiaoguangrong@tencent.com, Joerg Roedel 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> From: Paolo Bonzini Message-ID: Date: Mon, 14 Aug 2017 18:40:17 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 14 Aug 2017 16:40:22 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? Paolo