From patchwork Thu Mar 23 11:47:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 9640909 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 45270602D6 for ; Thu, 23 Mar 2017 11:49:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 33148284C2 for ; Thu, 23 Mar 2017 11:49:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 26C2C284D4; Thu, 23 Mar 2017 11:49:23 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A9E1C284C2 for ; Thu, 23 Mar 2017 11:49:22 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cr1D9-0003OD-HB; Thu, 23 Mar 2017 11:47:23 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cr1D7-0003Nc-Sq for xen-devel@lists.xenproject.org; Thu, 23 Mar 2017 11:47:21 +0000 Received: from [85.158.137.68] by server-12.bemta-3.messagelabs.com id 1B/F4-12861-9C5B3D85; Thu, 23 Mar 2017 11:47:21 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpmkeJIrShJLcpLzFFi42JxWrrBXvfE1ss RBhduG1t83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBkT395lKnjFWfH4xg3WBsZr7F2MHBwSAv4S exc7dTFycrAJGEismH6VESQsIqAicXuvAUiYWaBa4lFbKyOILSwQLDHh7nZWEJtFQFXi9Z6Db CA2r4CdxP9HP8DiEgLyEos2zWABsTkF7CVut75hB7GFgGoWfm9gg7DVJG4sXMYC0SsocXLmEx aIXRISB1+8YJ7AyDsLSWoWktQCRqZVjBrFqUVlqUW6hkZ6SUWZ6RkluYmZObqGBsZ6uanFxYn pqTmJScV6yfm5mxiBgcMABDsYX3U7H2KU5GBSEuUt/3EiQogvKT+lMiOxOCO+qDQntfgQowwH h5IErzJITrAoNT21Ii0zBxjCMGkJDh4lEd7LIGne4oLE3OLMdIjUKUZFKXFeGZCEAEgiozQPr g0WN5cYZaWEeRmBDhHiKUgtys0sQZV/xSjOwagkzJsKMoUnM68EbvoroMVMQIvffgBbXJKIkJ JqYMwI1vnktY3jTtL0WfYr3SKn3KpepnN0D/fi15vO+U3yKfoSoaxzLbf5pfS5rUkvDBTnmuR Er9pZ7aZ3wMjDJP1m+erJXXwGsYoLPvgnhR/5UL53c+w/ud3bJgayPz16VFFxVvSL5K5vK5+q rti4dtLmjt0shnorhKasfFNj/uLO3aqPAYFn51orsRRnJBpqMRcVJwIAAjGRs5YCAAA= X-Env-Sender: prvs=248b8503f=anthony.perard@citrix.com X-Msg-Ref: server-13.tower-31.messagelabs.com!1490269638!91062029!2 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 39361 invoked from network); 23 Mar 2017 11:47:20 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-13.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 23 Mar 2017 11:47:20 -0000 X-IronPort-AV: E=Sophos;i="5.36,209,1486425600"; d="scan'208";a="424361831" From: Anthony PERARD To: Date: Thu, 23 Mar 2017 11:47:01 +0000 Message-ID: <20170323114701.25207-4-anthony.perard@citrix.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170323114701.25207-1-anthony.perard@citrix.com> References: <20170323114701.25207-1-anthony.perard@citrix.com> MIME-Version: 1.0 Cc: Anthony PERARD , Andrew Cooper , Jan Beulich Subject: [Xen-devel] [PATCH 3/3] x86/vlapic: Reset LAPIC Timer only on TSC Deadline mode change X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP For the LAPIC timer, switching between periodic and one-shot does not reset anything on real-hardward, but switching from TSC deadline or to it does reset the timer, according to Intel manual. Signed-off-by: Anthony PERARD --- I'm not sure that TMICT should be reset, but the manuel said that in tsc-deadline, write to TMICT are ignored. --- xen/arch/x86/hvm/vlapic.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/hvm/vlapic.c b/xen/arch/x86/hvm/vlapic.c index f70a25f5b9..18247bd8bb 100644 --- a/xen/arch/x86/hvm/vlapic.c +++ b/xen/arch/x86/hvm/vlapic.c @@ -839,9 +839,11 @@ static void vlapic_reg_write(struct vcpu *v, break; case APIC_LVTT: /* LVT Timer Reg */ - if ( (vlapic_get_reg(vlapic, offset) & APIC_TIMER_MODE_MASK) != - (val & APIC_TIMER_MODE_MASK) ) + /* Switching between tdt and periodic|one-shot reset the other mode */ + if ( vlapic_lvtt_tdt(vlapic) != + ((val & APIC_TIMER_MODE_MASK) == APIC_TIMER_MODE_TSC_DEADLINE)) { + vlapic_set_reg(vlapic, APIC_TMICT, 0); vlapic->hw.tdt_msr = 0; } vlapic->pt.irq = val & APIC_VECTOR_MASK;