Received: by 2002:a17:90a:88:0:0:0:0 with SMTP id a8csp4594231pja; Thu, 21 Nov 2019 22:30:24 -0800 (PST) X-Google-Smtp-Source: APXvYqy8awCPpepzwSl505vsdnskyr9QNj+M2h7OuuHOeeBHJGwR3vPaF6n4FKZn0/oo902BAFYk X-Received: by 2002:a17:906:d96e:: with SMTP id rp14mr19539725ejb.14.1574404224376; Thu, 21 Nov 2019 22:30:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574404224; cv=none; d=google.com; s=arc-20160816; b=GQB3b58dpEa/ZCGnsh4ao6NvcMpaOLHxB0Ka5IwH6aqtsHqLl+WMqMtDsBF/K0GlHm iFbq8PwcOOzQ0xMiVy1zVmqOmQ3UI8FZtvemEprLPXyx/tmxNzK1TZCGZc3EbAZAho4v oAXOqB8rCIQbhzVbnEdAIyEGvtDCXfM44JhpIbg4hho34NrFO0TKTVc8/H94TZPkOCw6 X8by4aF2vekeRYs7UNzsbYX5Np8MskvK7gnrwI1UhKO/V+7e06ege/Ugb7HwZxib+d/V b0eCossUXfct+ESjR+VxFEbymP7Rh9pFdjeSaKeCREdYgrS3PU/BE//EXHcgP83WqhTu t1Zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7xsEbwOHbk0s9w8hnM0GIdKy/wyg2Wd/0M743C48Xac=; b=Z9Vcyt78qM7vg6bvUqmDLDKmys63kxUL/niyx4FlzNUcWyOEsgqqF7PMJrTKwJI2Rw 3R/9AzNh/zY4lDbS93fKkuMRlTHOdYO9VhXnVUEaegFYjTm1Y3wacWCZCT7xqiIvr+WD 5pmvdesNuQR1RUpAutBwrC70gx7NQqFw62aKe7pYY8UxHDPY1k0eNFn/9w08w01a48Sy t526IN4jevS9+Cq67kDOMRUtcXMC6JbaxpbSymq7xEKdhu9S9uowiJ5KG3X35ZChoxRF 9QJ/bdhFYt4+7ckHPwrE8gnmigJM3R5tjr9Wmee+R7p1b5U41DrrcomtCB+uotVYSpKz wYvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ew6YzckO; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g17si3822980edq.176.2019.11.21.22.30.01; Thu, 21 Nov 2019 22:30:24 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=ew6YzckO; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727667AbfKVFuY (ORCPT + 99 others); Fri, 22 Nov 2019 00:50:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:54884 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727641AbfKVFuX (ORCPT ); Fri, 22 Nov 2019 00:50:23 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3AC032071F; Fri, 22 Nov 2019 05:50:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574401822; bh=aIreNybQBUOhPhlkhTivozD7PYWy/npCatGkOK+9Qts=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ew6YzckOKUir05Fd/7CbZiZtz3PGIb1sRz3aac4KJDMGasJa6r2uB1JcLPbuqR9L6 On/ziIcFYJQd4MjOFEWLElRveQAPQCHGhKt7C2IPqYvLC47GXHa8aLWhOttjYWpBrl fAd8Y6BS3t0Ou9CPr2NXMm/OucnNBqiS3TwxY2zc= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jim Mattson , Peter Shier , Marc Orr , Liran Alon , Sean Christopherson , Paolo Bonzini , Sasha Levin , kvm@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 065/219] kvm: vmx: Set IA32_TSC_AUX for legacy mode guests Date: Fri, 22 Nov 2019 00:46:37 -0500 Message-Id: <20191122054911.1750-58-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191122054911.1750-1-sashal@kernel.org> References: <20191122054911.1750-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jim Mattson [ Upstream commit 0023ef39dc35c773c436eaa46ca539a26b308b55 ] RDTSCP is supported in legacy mode as well as long mode. The IA32_TSC_AUX MSR should be set to the correct guest value before entering any guest that supports RDTSCP. Fixes: 4e47c7a6d714 ("KVM: VMX: Add instruction rdtscp support for guest") Signed-off-by: Jim Mattson Reviewed-by: Peter Shier Reviewed-by: Marc Orr Reviewed-by: Liran Alon Reviewed-by: Sean Christopherson Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin --- arch/x86/kvm/vmx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 4eda2a9c234a6..b892f345f6317 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -3404,9 +3404,6 @@ static void setup_msrs(struct vcpu_vmx *vmx) index = __find_msr_index(vmx, MSR_CSTAR); if (index >= 0) move_msr_up(vmx, index, save_nmsrs++); - index = __find_msr_index(vmx, MSR_TSC_AUX); - if (index >= 0 && guest_cpuid_has(&vmx->vcpu, X86_FEATURE_RDTSCP)) - move_msr_up(vmx, index, save_nmsrs++); /* * MSR_STAR is only needed on long mode guests, and only * if efer.sce is enabled. @@ -3419,6 +3416,9 @@ static void setup_msrs(struct vcpu_vmx *vmx) index = __find_msr_index(vmx, MSR_EFER); if (index >= 0 && update_transition_efer(vmx, index)) move_msr_up(vmx, index, save_nmsrs++); + index = __find_msr_index(vmx, MSR_TSC_AUX); + if (index >= 0 && guest_cpuid_has(&vmx->vcpu, X86_FEATURE_RDTSCP)) + move_msr_up(vmx, index, save_nmsrs++); vmx->save_nmsrs = save_nmsrs; vmx->guest_msrs_dirty = true; -- 2.20.1