From patchwork Tue Sep 27 15:57:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 9352183 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 9672260757 for ; Tue, 27 Sep 2016 16:00:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8926F2928A for ; Tue, 27 Sep 2016 16:00:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7DDA429295; Tue, 27 Sep 2016 16:00:50 +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 7514C2928A for ; Tue, 27 Sep 2016 16:00:45 +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 1bouln-0007Ru-TC; Tue, 27 Sep 2016 15:58:11 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1boull-0007QZ-Sk for xen-devel@lists.xenproject.org; Tue, 27 Sep 2016 15:58:09 +0000 Received: from [85.158.143.35] by server-10.bemta-6.messagelabs.com id 07/89-21986-1179AE75; Tue, 27 Sep 2016 15:58:09 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrOIsWRWlGSWpSXmKPExsXitHRDpK7A9Ff hBv8n6Fh83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBlr55cUdAhUNC5az9TA+Ie7i5GTQ0LAX2Ji 60cmEJtNQEfi4tydbF2MHBwiAioSt/cadDFycTALbGCUmP74NitIjbBAgsTy3b/YQGwWAVWJk ytXMoLYvAKuErv3T2CHmKkr8fDcb7B6TqB4b9sCsPlCAi4Sd2d+ZIWoF5Q4OfMJC4jNLKAp0b r9NzuELS/RvHU2M0S9okT/vAdg90gIcEv87bafwMg/C0n3LCTds5B0L2BkXsWoUZxaVJZapGt krJdUlJmeUZKbmJmja2hgppebWlycmJ6ak5hUrJecn7uJERiADECwg/HP/MBDjJIcTEqivBrt r8KF+JLyUyozEosz4otKc1KLDzHKcHAoSfB6TAXKCRalpqdWpGXmAGMBJi3BwaMkwssJkuYtL kjMLc5Mh0idYlSUEudtAEkIgCQySvPg2mDxd4lRVkqYlxHoECGegtSi3MwSVPlXjOIcjErCvC IgU3gy80rgpr8CWswEtHjpiRcgi0sSEVJSDYzd/v7LlV6cm6m+/8nqp4wO5zMmXgjqWMB7Iff dqum35ipnNC34Fce3dO0E3olG/Q1n7RreTIgSXmzAtVamerZxprt0MUub2uSI8x15Fyx9lvzS 8Enbs+c3U/exvHntsXkbbOacK1mduCXdfZqM1SG34qikIgGP/SZ9tmJymWd/Sbltcvqr7qPEU pyRaKjFXFScCADu4Py+ugIAAA== X-Env-Sender: prvs=071b8e69e=roger.pau@citrix.com X-Msg-Ref: server-4.tower-21.messagelabs.com!1474991877!29175510!5 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 15225 invoked from network); 27 Sep 2016 15:58:08 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-4.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 27 Sep 2016 15:58:08 -0000 X-IronPort-AV: E=Sophos;i="5.30,405,1470700800"; d="scan'208";a="380934347" From: Roger Pau Monne To: Date: Tue, 27 Sep 2016 17:57:05 +0200 Message-ID: <1474991845-27962-11-git-send-email-roger.pau@citrix.com> X-Mailer: git-send-email 2.7.4 (Apple Git-66) In-Reply-To: <1474991845-27962-1-git-send-email-roger.pau@citrix.com> References: <1474991845-27962-1-git-send-email-roger.pau@citrix.com> MIME-Version: 1.0 X-DLP: MIA1 Cc: Andrew Cooper , boris.ostrovsky@oracle.com, Roger Pau Monne , Jan Beulich Subject: [Xen-devel] [PATCH v2 10/30] xen/x86: allow the emulated APICs to be enbled for the hardware domain 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 Allow the use of both the emulated local APIC and IO APIC for the hardware domain. Signed-off-by: Roger Pau Monné --- Cc: Jan Beulich Cc: Andrew Cooper --- Changes since RFC: - Move the emulation flags check to a separate helper. --- xen/arch/x86/domain.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 3c4b094..332e7f0 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -509,6 +509,29 @@ void vcpu_destroy(struct vcpu *v) xfree(v->arch.pv_vcpu.trap_ctxt); } +static bool emulation_flags_ok(const struct domain *d, uint32_t emflags) +{ + + if ( is_hvm_domain(d) ) + { + if ( is_hardware_domain(d) && + emflags != (XEN_X86_EMU_PIT|XEN_X86_EMU_LAPIC|XEN_X86_EMU_IOAPIC)) + return false; + if ( !is_hardware_domain(d) && + emflags != XEN_X86_EMU_ALL && emflags != 0 ) + return false; + } + else + { + /* PV or classic PVH. */ + if ( is_hardware_domain(d) && emflags != XEN_X86_EMU_PIT ) + return false; + if ( !is_hardware_domain(d) && emflags != 0 ) + return false; + } + return true; +} + int arch_domain_create(struct domain *d, unsigned int domcr_flags, struct xen_arch_domainconfig *config) { @@ -553,9 +576,8 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags, } if ( is_hardware_domain(d) ) config->emulation_flags |= XEN_X86_EMU_PIT; - if ( config->emulation_flags != 0 && - (config->emulation_flags != - (is_hvm_domain(d) ? XEN_X86_EMU_ALL : XEN_X86_EMU_PIT)) ) + + if ( !emulation_flags_ok(d, config->emulation_flags) ) { printk(XENLOG_G_ERR "d%d: Xen does not allow %s domain creation " "with the current selection of emulators: %#x\n",