From patchwork Wed Jan 13 12:32:18 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: 8024631 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 642AF9F744 for ; Wed, 13 Jan 2016 12:36:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 828AF20458 for ; Wed, 13 Jan 2016 12:36:19 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B88D4202F0 for ; Wed, 13 Jan 2016 12:36:18 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aJKbz-00054a-0v; Wed, 13 Jan 2016 12:33:15 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aJKbx-000543-CV for xen-devel@lists.xenproject.org; Wed, 13 Jan 2016 12:33:13 +0000 Received: from [85.158.137.68] by server-1.bemta-3.messagelabs.com id 52/92-02745-80446965; Wed, 13 Jan 2016 12:33:12 +0000 X-Env-Sender: prvs=81391bf32=roger.pau@citrix.com X-Msg-Ref: server-8.tower-31.messagelabs.com!1452688388!15713307!3 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: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 29959 invoked from network); 13 Jan 2016 12:33:11 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-8.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 13 Jan 2016 12:33:11 -0000 X-IronPort-AV: E=Sophos;i="5.22,288,1449532800"; d="scan'208";a="324707624" From: Roger Pau Monne To: Date: Wed, 13 Jan 2016 13:32:18 +0100 Message-ID: <1452688338-70075-6-git-send-email-roger.pau@citrix.com> X-Mailer: git-send-email 1.9.5 (Apple Git-50.3) In-Reply-To: <1452688338-70075-1-git-send-email-roger.pau@citrix.com> References: <1452688338-70075-1-git-send-email-roger.pau@citrix.com> MIME-Version: 1.0 X-DLP: MIA1 Cc: Andrew Cooper , Jan Beulich , Roger Pau Monne Subject: [Xen-devel] [PATCH 5/5] x86/HVM: don't setup an intercept handler for IO port 0xcf8 unconditionally X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Only intercept accesses to IO port 0xcf8 if there's at least one IOREQ server, otherwise it makes no sense since the only code that uses the value stored by hvm_access_cf8 is the IOREQ server. Signed-off-by: Roger Pau Monné --- Cc: Jan Beulich Cc: Andrew Cooper --- xen/arch/x86/hvm/hvm.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 28c6cd9..24c3d46 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -1141,6 +1141,13 @@ static int hvm_create_ioreq_server(struct domain *d, domid_t domid, if ( rc ) goto fail3; + /* + * We cannot fail after this point, or we risk registering the handler + * multiple times (there's no unregister function yet). + */ + if ( list_empty(&d->arch.hvm_domain.ioreq_server.list) ) + register_portio_handler(d, 0xcf8, 4, hvm_access_cf8); + list_add(&s->list_entry, &d->arch.hvm_domain.ioreq_server.list); @@ -1625,7 +1632,6 @@ int hvm_domain_initialise(struct domain *d) pit_init(d, cpu_khz); register_portio_handler(d, 0xe9, 1, hvm_print_line); - register_portio_handler(d, 0xcf8, 4, hvm_access_cf8); rc = hvm_funcs.domain_initialise(d); if ( rc != 0 )