From patchwork Mon Oct 24 10:23:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wanpeng Li X-Patchwork-Id: 9391865 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C26EE60762 for ; Mon, 24 Oct 2016 10:25:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B171E28942 for ; Mon, 24 Oct 2016 10:25:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A16B828A69; Mon, 24 Oct 2016 10:25:45 +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=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 6A69C28942 for ; Mon, 24 Oct 2016 10:25:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757396AbcJXKZZ (ORCPT ); Mon, 24 Oct 2016 06:25:25 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:33129 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751606AbcJXKX5 (ORCPT ); Mon, 24 Oct 2016 06:23:57 -0400 Received: by mail-pf0-f196.google.com with SMTP id i85so16235147pfa.0; Mon, 24 Oct 2016 03:23:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zx3CswmFMcTC9aSwl5HoJ1QO/wTjJsOiaVMcLp1zt1w=; b=GX6CizvMfST15ozCv0UdGg8/vBPcuxjNhMg8IsvVdrJ+3J8WQ5zOiMvcukNmWjxylq p36+RWx2JutMvgGjCLCKdlK3yMnSwlFyReYzRFAIp4gWgIKmivdqE0fTpk0uKI2zNCLk sAHfGiHqf66AnZE62R10t7eAwqz6U5Bc2FzQd0KpQILxfFc8vzyE98Xl7WvpQL2qBhXB u9b9KZP37/3PooiUO1txfnfqHFKMWmaXCJozY1nkOM15KPtSL1npQCXFMdjKJTPa2kZ0 lhRsIJYtJf5/2kECF3/XIiErXvEUg9GiI9bADYocOd5d3mfUNsCdOg2pJLIBYXg3Q+qM zSPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zx3CswmFMcTC9aSwl5HoJ1QO/wTjJsOiaVMcLp1zt1w=; b=ZaZdCAdIBj8CFmXRqEf/sCJV8F9jWdhWDSOufgxqgKJlx0xIN0OZzNYNSUzQdtUIaa wDXihJ+6kr7LXlreCssiZkkFhbG7sEHd4yeH8D9BEphalcMD+ilLYoMQew4HMmyG+e6U eCrVouvi7VpwZyM77Yq08Nno45/R/BTmOtrWhYA4iClDA2lsF+J1z4t4jMn3w3PjmKvZ O8r/vKGWTBg4yTHiWEetUqWgrYj3lLV0EZHh21Z/HdDcSdqf8/shvCy1OEXXWu9RXGTS beQRBZEjcJPXb7yT/BWSNQzDBrA2dKtwmXjbanvW5DmAYLHhsrwetUAOcv/UrSHcESV7 wTug== X-Gm-Message-State: ABUngveLAFhcRn1mCh8z9uxmcohhBK9FNBG6HMn2LHuBEmqgpUM5HHPQqHJ1pD6zODooMQ== X-Received: by 10.98.12.208 with SMTP id 77mr27260007pfm.14.1477304636706; Mon, 24 Oct 2016 03:23:56 -0700 (PDT) Received: from kernel.kingsoft.cn ([114.255.44.132]) by smtp.gmail.com with ESMTPSA id h5sm24146322pfg.86.2016.10.24.03.23.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Oct 2016 03:23:55 -0700 (PDT) From: Wanpeng Li X-Google-Original-From: Wanpeng Li To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Yunhong Jiang , Wanpeng Li Subject: [PATCH v3 2/5] KVM: LAPIC: guarantee the timer is in tsc-deadline mode Date: Mon, 24 Oct 2016 18:23:10 +0800 Message-Id: <1477304593-3453-3-git-send-email-wanpeng.li@hotmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1477304593-3453-1-git-send-email-wanpeng.li@hotmail.com> References: <1477304593-3453-1-git-send-email-wanpeng.li@hotmail.com> MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Wanpeng Li Check apic_lvtt_tscdeadline() mode directly instead of apic_lvtt_oneshot() and apic_lvtt_period() to guarantee the timer is in tsc-deadline mode when rdmsr MSR_IA32_TSCDEADLINE. Suggested-by: Radim Krčmář Cc: Paolo Bonzini Cc: Radim Krčmář Cc: Yunhong Jiang Signed-off-by: Wanpeng Li --- arch/x86/kvm/lapic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index dad743e..dce6c0b 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -1711,8 +1711,8 @@ u64 kvm_get_lapic_tscdeadline_msr(struct kvm_vcpu *vcpu) { struct kvm_lapic *apic = vcpu->arch.apic; - if (!lapic_in_kernel(vcpu) || apic_lvtt_oneshot(apic) || - apic_lvtt_period(apic)) + if (!lapic_in_kernel(vcpu) || + !apic_lvtt_tscdeadline(apic)) return 0; return apic->lapic_timer.tscdeadline;