From patchwork Fri Nov 9 17:34:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Mattson X-Patchwork-Id: 10676371 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 20A1613B0 for ; Fri, 9 Nov 2018 17:34:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 072692ED38 for ; Fri, 9 Nov 2018 17:34:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EE2142EE08; Fri, 9 Nov 2018 17:34:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 915072ED38 for ; Fri, 9 Nov 2018 17:34:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728183AbeKJDQE (ORCPT ); Fri, 9 Nov 2018 22:16:04 -0500 Received: from mail-ot1-f73.google.com ([209.85.210.73]:33762 "EHLO mail-ot1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727995AbeKJDQE (ORCPT ); Fri, 9 Nov 2018 22:16:04 -0500 Received: by mail-ot1-f73.google.com with SMTP id s3so1505177otb.0 for ; Fri, 09 Nov 2018 09:34:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=jdAUXu5lNXycMnC8J4rezRDwYrRhTRudIDMqEjmZt8w=; b=hbwBB4oROH82Dv+zwPb2qSM+EFChJ7Yrm4blZe4Ak5jEgmrbvxeOiDH57COCaeIxVq Yts1zvXn0wyDcCyyCvzZwL+Y2Vd7Z7NcvAMw5OWwIIxZP7gqjXbb/PEtR/eycd3iM/tM EOhmlRrxjzSQW0dkHE4nHpl1EVlmlG6HSFZ1+Q0PSv8q+64jO2IbTHJbnnwnr8RN+Mxo ozjl+1tKynsBRv//e4z/5fWQ3H0CPOxWl3u6Mt+0+Y2Hjgjgg0KAzdAvVvG1yvAxx7A/ 2aYetwNx296m7O3P4VK1oc5wnfQBKR9MMh2yyq3gUKGTIG+SkOrvF2civJFclr5Lps8N hpmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=jdAUXu5lNXycMnC8J4rezRDwYrRhTRudIDMqEjmZt8w=; b=RmZOjXABY0ciAW2s4Y4LU+qOM90dV2yR+hiqzpUniPLHeZquKighKWpH4e91Al2Pyv U5Mvz/TpyAFPtdaUH3HrjE05g0OwOTprg8oApsvkz01r8OgJ7+wzlK/VwHWZvnCev7Wz hFpXdV1j3eRmeRIL6JP1KZ9fD0IjPkWq5jAZD1GI/yB2Z44vDnT1f6fQcb+ZcqIiN4u9 yo2LRmZC2wpITQ/1gSmzIOBx0TjhzvyAqQidjF6ii9VsN4T2zW8IXHi1q5n0oA2QApF2 ihVvdm9B+D8oScGl28Ina9GrCnrlNJHsx0Az1+XggeuJMpChpQUyZhjtb1kre7n+CkAR 43Uw== X-Gm-Message-State: AGRZ1gI6dNmSqDfDhbpMT+UoPYu+J5+dcI6sTmWNWjQqB9WpMWN8kFy1 scJ4ICBKk9FZrLEvKIW5ZPtw3YsZuvW3hMZssc2UDI/QzL/KnBLQEKIUgysasfxq7t0qqniWbQV BDfNPMLB2PJMLvzdnvveA8nsG96qMuQgWBQajDTvCKjTbLxr5QQBbAvLra0Msa6c= X-Google-Smtp-Source: AJdET5dhKgJkoAufn0aiPpXeZM6Ya9Fjh8/UV2wAjm9YbDben0qLHkEK5EgemUueIVwsaSSSk8bVKbUyD1XkjA== X-Received: by 2002:a9d:fb0:: with SMTP id d45mr6957250otd.59.1541784870166; Fri, 09 Nov 2018 09:34:30 -0800 (PST) Date: Fri, 9 Nov 2018 09:34:21 -0800 Message-Id: <20181109173421.177250-1-jmattson@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog Subject: [PATCH] kvm: vmx: Set IA32_TSC_AUX for legacy mode guests From: Jim Mattson To: kvm@vger.kernel.org Cc: Marc Orr , Peter Shier , Jim Mattson Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 ccc6a01eb4f4..120fc97a63fc 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -3415,9 +3415,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. @@ -3430,6 +3427,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;