From patchwork Tue Jul 5 19:05:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Ostrovsky X-Patchwork-Id: 9215115 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 1EB9A60752 for ; Tue, 5 Jul 2016 19:13:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0FD0C28333 for ; Tue, 5 Jul 2016 19:13:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0248F28336; Tue, 5 Jul 2016 19:13:42 +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, UNPARSEABLE_RELAY 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 7919A28333 for ; Tue, 5 Jul 2016 19:13:42 +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 1bKVl4-00049K-24; Tue, 05 Jul 2016 19:11:46 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bKVl3-00047t-60 for xen-devel@lists.xen.org; Tue, 05 Jul 2016 19:11:45 +0000 Received: from [85.158.137.68] by server-17.bemta-3.messagelabs.com id B1/12-21227-0760C775; Tue, 05 Jul 2016 19:11:44 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupkkeJIrShJLcpLzFFi42LpnVTnqpvPVhN u0DKPz2LJx8UsDoweR3f/ZgpgjGLNzEvKr0hgzfjRfpC9YDJ/xd9p/WwNjBN4uhg5OYQEWpkk Zl2K7WLkArI/M0q8PXeIHcLZwChx68xdKKeHUWLhrOtsIC1sAkYSZ49OZwSxRQSkJa59vswIU sQscItRYvvvO8wgCWGBSIkXb+6AFbEIqErc/vmJFcTmFfCSuPVuBguILSEgJ7Fj9RMmEJsTKL 6+8RULxE2eEpuenGWHqDGUOP1wG+MERr4FjAyrGDWKU4vKUot0jcz1kooy0zNKchMzc3QNDYz 1clOLixPTU3MSk4r1kvNzNzECg6WegYFxB2PLXr9DjJIcTEqivCzfqsOF+JLyUyozEosz4otK c1KLDzHKcHAoSfAKsdaECwkWpaanVqRl5gDDFiYtwcGjJMLrB5LmLS5IzC3OTIdInWLU5diy4 MZaJiGWvPy8VClxXi2QIgGQoozSPLgRsBi6xCgrJczLyMDAIMRTkFqUm1mCKv+KUZyDUUmYNw 1kCk9mXgncpldARzABHfHTpRrkiJJEhJRUA6MJD1fHnWbr1cvO/znvEPbJpvTcrTW5s7fV1a1 vsn8lYpvn9zqxQZXfmKMxJXjb7FKj6wdWn/Zs9KwWWFhqFuH/7OcdrgVtwVlHghcWJZ2ZuCV3 xeZ/9+YbRzx/uu/OF/eJU9SuRe3p59NnCPs5P/B2cUv9QYdGR/a4Qz/WaNiI/1ry+t49GQsll uKMREMt5qLiRAAoCRbjnAIAAA== X-Env-Sender: boris.ostrovsky@oracle.com X-Msg-Ref: server-14.tower-31.messagelabs.com!1467745901!49012345!1 X-Originating-IP: [141.146.126.69] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTQxLjE0Ni4xMjYuNjkgPT4gMjc3MjE4\n X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 24133 invoked from network); 5 Jul 2016 19:11:42 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by server-14.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 5 Jul 2016 19:11:42 -0000 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u65JBReA009093 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 5 Jul 2016 19:11:28 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.13.8/8.13.8) with ESMTP id u65JBREh005867 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 5 Jul 2016 19:11:27 GMT Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by userv0121.oracle.com (8.13.8/8.13.8) with ESMTP id u65JBQQC009092; Tue, 5 Jul 2016 19:11:26 GMT Received: from ovs104.us.oracle.com (/10.149.76.204) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 05 Jul 2016 19:11:26 +0000 From: Boris Ostrovsky To: xen-devel@lists.xen.org Date: Tue, 5 Jul 2016 15:05:14 -0400 Message-Id: <1467745519-9868-16-git-send-email-boris.ostrovsky@oracle.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1467745519-9868-1-git-send-email-boris.ostrovsky@oracle.com> References: <1467745519-9868-1-git-send-email-boris.ostrovsky@oracle.com> X-Source-IP: userv0021.oracle.com [156.151.31.71] Cc: wei.liu2@citrix.com, andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com, julien.grall@arm.com, jbeulich@suse.com, zhaoshenglong@huawei.com, boris.ostrovsky@oracle.com, roger.pau@citrix.com Subject: [Xen-devel] [PATCH v1 15/20] x86: Add more checks verifying that PIT/PIC/IOAPIC are emulated 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: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Boris Ostrovsky Reviewed-by: Jan Beulich --- Changes in v1: * More checks, in more approriate places xen/arch/x86/hvm/vlapic.c | 12 ++++++++++-- xen/arch/x86/hvm/vpt.c | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/hvm/vlapic.c b/xen/arch/x86/hvm/vlapic.c index e2f4450..a3855c8 100644 --- a/xen/arch/x86/hvm/vlapic.c +++ b/xen/arch/x86/hvm/vlapic.c @@ -1115,7 +1115,12 @@ static int __vlapic_accept_pic_intr(struct vcpu *v) struct domain *d = v->domain; struct vlapic *vlapic = vcpu_vlapic(v); uint32_t lvt0 = vlapic_get_reg(vlapic, APIC_LVT0); - union vioapic_redir_entry redir0 = domain_vioapic(d)->redirtbl[0]; + union vioapic_redir_entry redir0; + + if ( !has_vioapic(d) || !has_vpic(d) ) + return 0; + + redir0 = domain_vioapic(d)->redirtbl[0]; /* We deliver 8259 interrupts to the appropriate CPU as follows. */ return ((/* IOAPIC pin0 is unmasked and routing to this LAPIC? */ @@ -1131,7 +1136,7 @@ static int __vlapic_accept_pic_intr(struct vcpu *v) int vlapic_accept_pic_intr(struct vcpu *v) { - if ( vlapic_hw_disabled(vcpu_vlapic(v)) ) + if ( vlapic_hw_disabled(vcpu_vlapic(v)) || !has_vpic(v->domain) ) return 0; TRACE_2D(TRC_HVM_EMUL_LAPIC_PIC_INTR, @@ -1146,6 +1151,9 @@ void vlapic_adjust_i8259_target(struct domain *d) { struct vcpu *v; + if ( !has_vpic(d) ) + return; + for_each_vcpu ( d, v ) if ( __vlapic_accept_pic_intr(v) ) goto found; diff --git a/xen/arch/x86/hvm/vpt.c b/xen/arch/x86/hvm/vpt.c index 358ec57..c90aa95 100644 --- a/xen/arch/x86/hvm/vpt.c +++ b/xen/arch/x86/hvm/vpt.c @@ -496,7 +496,7 @@ void pt_adjust_global_vcpu_target(struct vcpu *v) struct pl_time *pl_time; int i; - if ( v == NULL ) + if ( v == NULL || !has_vpit(v->domain) ) return; vpit = &v->domain->arch.vpit;