Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1060448ybi; Tue, 16 Jul 2019 09:04:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqxpNwUqreD4ANgTNAp0qRp+iAMCjLTqM9PCH69pEYR5eTyDgmiLVrD9g5PrQbd63wxKCJm8 X-Received: by 2002:a63:714a:: with SMTP id b10mr36095529pgn.25.1563293079777; Tue, 16 Jul 2019 09:04:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563293079; cv=none; d=google.com; s=arc-20160816; b=Xf1NDtCw9Wm0L2SpfSptjAFyHRk9v2ZCj3pNKFKEpzOn0GNV3v+n2Xy3d+wVq0fg4g 19eDTVS+NrQ+L1I4AYviJJmjZTsaxqFkR0gKl03mQ7LJ7O0O3x6hGZL6cRZqKg9loqAN fPMOTfPVnkDKXcGwvCYrmYmdB0A7kbD00zIic92NbJKeTwVm1LtEVdUvMJulGbClWR+k F4TlFZV6rkwbHE++FSHERkUIKFvqEGlfsePZ22RKpV8INe4Cew+ymnBcgj+2e1dQwH/v a+UvINMttEo7dVbRCW/dtpp7+8yIm2gZvss0AyEJbH99rIU5FpB0YliDKF63HTka+1YP xE+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=byaZaSR4VYz4Cm1aSzng8FL9hQeCJK309gV4HrF4A/4=; b=jDwtKps9/MflRP+LQ4HAb5bHW/sqIbbwP+AEgeL6DLm1TB2OjMdVc5JEUpt3D6d+zL /8qfNmDlvQG/A4gdwJ+kN2TcvvH/Dm3djsgdarURc3tg6skXIhupSg2hoDI7HjMY/FAM MZ2Xespj2LRVAr/rlPI5ERVS3x1zd/+z0mJmFGIHq3ZAKgyi3xSOsu/fGSZFll+1Lqca SJpZuwysmrN8PFewnO40V3zHdqDW9rxdJG/HF/5puP2fc5nN9HUQ3F4wPmKROfZ6R323 +dXHwLkr/zWyhoC6bFFpaCz1KRsXXRYSwaN6hwGFApIZ3pYAUzWinX3LAm5Dqlo+nka4 OoFw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c139si22570864pfb.140.2019.07.16.09.04.21; Tue, 16 Jul 2019 09:04:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730452AbfGPQEB (ORCPT + 99 others); Tue, 16 Jul 2019 12:04:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:11647 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728121AbfGPQEB (ORCPT ); Tue, 16 Jul 2019 12:04:01 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A00283082A9C; Tue, 16 Jul 2019 16:04:00 +0000 (UTC) Received: from localhost (ovpn-116-109.gru2.redhat.com [10.97.116.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0EC3119D7D; Tue, 16 Jul 2019 16:03:59 +0000 (UTC) Date: Tue, 16 Jul 2019 13:03:58 -0300 From: Eduardo Habkost To: Tao Xu Cc: pbonzini@redhat.com, rkrcmar@redhat.com, corbet@lwn.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, sean.j.christopherson@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, fenghua.yu@intel.com, xiaoyao.li@linux.intel.com, jingqi.liu@intel.com Subject: Re: [PATCH v7 2/3] KVM: vmx: Emulate MSR IA32_UMWAIT_CONTROL Message-ID: <20190716160358.GE26800@habkost.net> References: <20190712082907.29137-1-tao3.xu@intel.com> <20190712082907.29137-3-tao3.xu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190712082907.29137-3-tao3.xu@intel.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Tue, 16 Jul 2019 16:04:00 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 12, 2019 at 04:29:06PM +0800, Tao Xu wrote: > UMWAIT and TPAUSE instructions use IA32_UMWAIT_CONTROL at MSR index E1H > to determines the maximum time in TSC-quanta that the processor can reside > in either C0.1 or C0.2. > > This patch emulates MSR IA32_UMWAIT_CONTROL in guest and differentiate > IA32_UMWAIT_CONTROL between host and guest. The variable > mwait_control_cached in arch/x86/power/umwait.c caches the MSR value, so > this patch uses it to avoid frequently rdmsr of IA32_UMWAIT_CONTROL. > > Co-developed-by: Jingqi Liu > Signed-off-by: Jingqi Liu > Signed-off-by: Tao Xu > --- [...] > +static void atomic_switch_umwait_control_msr(struct vcpu_vmx *vmx) > +{ > + if (!vmx_has_waitpkg(vmx)) > + return; > + > + if (vmx->msr_ia32_umwait_control != umwait_control_cached) > + add_atomic_switch_msr(vmx, MSR_IA32_UMWAIT_CONTROL, > + vmx->msr_ia32_umwait_control, > + umwait_control_cached, false); How exactly do we ensure NR_AUTOLOAD_MSRS (8) is still large enough? I see 3 existing add_atomic_switch_msr() calls, but the one at atomic_switch_perf_msrs() is in a loop. Are we absolutely sure that perf_guest_get_msrs() will never return more than 5 MSRs? > + else > + clear_atomic_switch_msr(vmx, MSR_IA32_UMWAIT_CONTROL); > +} > + > static void vmx_arm_hv_timer(struct vcpu_vmx *vmx, u32 val) > { > vmcs_write32(VMX_PREEMPTION_TIMER_VALUE, val); [...] -- Eduardo