From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97F4BC3F2D1 for ; Tue, 3 Mar 2020 16:38:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6923320863 for ; Tue, 3 Mar 2020 16:38:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730349AbgCCQie (ORCPT ); Tue, 3 Mar 2020 11:38:34 -0500 Received: from mga06.intel.com ([134.134.136.31]:35796 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728311AbgCCQie (ORCPT ); Tue, 3 Mar 2020 11:38:34 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Mar 2020 08:38:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,511,1574150400"; d="scan'208";a="274268961" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.202]) by fmsmga002.fm.intel.com with ESMTP; 03 Mar 2020 08:38:33 -0800 Date: Tue, 3 Mar 2020 08:38:33 -0800 From: Sean Christopherson To: Paolo Bonzini Cc: Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Jan Kiszka , Xiaoyao Li Subject: Re: [PATCH 0/6] KVM: x86: CPUID emulation and tracing fixes Message-ID: <20200303163833.GK1439@linux.intel.com> References: <20200302195736.24777-1-sean.j.christopherson@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 03, 2020 at 09:48:44AM +0100, Paolo Bonzini wrote: > On 02/03/20 20:57, Sean Christopherson wrote: > > Two fixes related to out-of-range CPUID emulation and related cleanup on > > top. > > > > I have a unit test and also manually verified a few interesting cases. > > I'm not planning on posting the unit test at this time because I haven't > > figured out how to avoid false positives, e.g. if a random in-bounds > > leaf just happens to match the output of a max basic leaf. It might be > > doable by hardcoding the cpu model? > > It would be best suited for selftests rather than kvm-unit-tests. But I > don't really see the benefit of anything more than just Gotta save those stack bytes? I got a bit confused by the "max" variable; I thought it would hold the max basic leaf, not CPUID.0x0. Removing it seemed easier than trying to come up with a better name :-) > diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c > index b1c469446b07..c1abf5de4461 100644 > --- a/arch/x86/kvm/cpuid.c > +++ b/arch/x86/kvm/cpuid.c > @@ -1001,6 +1001,7 @@ bool kvm_cpuid(struct kvm_vcpu *vcpu, u32 *eax, u32 *ebx, > u32 *ecx, u32 *edx, bool check_limit) > { > u32 function = *eax, index = *ecx; > + u32 orig_function = function; > struct kvm_cpuid_entry2 *entry; > struct kvm_cpuid_entry2 *max; > bool found; > @@ -1049,7 +1050,7 @@ bool kvm_cpuid(struct kvm_vcpu *vcpu, u32 *eax, u32 *ebx, > } > } > } > - trace_kvm_cpuid(function, *eax, *ebx, *ecx, *edx, found); > + trace_kvm_cpuid(orig_function, *eax, *ebx, *ecx, *edx, found); > return found; > } > EXPORT_SYMBOL_GPL(kvm_cpuid); >