From: Wei Liu Date: Sun, 26 Aug 2018 12:19:43 +0000 (+0100) Subject: x86/pt: split out HVM functions from vtd.c X-Git-Tag: archive/raspbian/4.14.0+80-gd101b417b7-1+rpi1^2~63^2~3364 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=aed19fb5370df48527fba82c88c6b7411776283a;p=xen.git x86/pt: split out HVM functions from vtd.c Functions are moved to hvm.c. Reorder makefile items while at it. Signed-off-by: Wei Liu Reviewed-by: Kevin Tian --- diff --git a/xen/drivers/passthrough/vtd/x86/Makefile b/xen/drivers/passthrough/vtd/x86/Makefile index df4509db40..4ef00a4c5b 100644 --- a/xen/drivers/passthrough/vtd/x86/Makefile +++ b/xen/drivers/passthrough/vtd/x86/Makefile @@ -1,2 +1,3 @@ -obj-y += vtd.o obj-y += ats.o +obj-$(CONFIG_HVM) += hvm.o +obj-y += vtd.o diff --git a/xen/drivers/passthrough/vtd/x86/hvm.c b/xen/drivers/passthrough/vtd/x86/hvm.c new file mode 100644 index 0000000000..6675dca027 --- /dev/null +++ b/xen/drivers/passthrough/vtd/x86/hvm.c @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2008, Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; If not, see . + * + * Copyright (C) Allen Kay + * Copyright (C) Weidong Han + */ + +#include +#include +#include + +static int _hvm_dpci_isairq_eoi(struct domain *d, + struct hvm_pirq_dpci *pirq_dpci, void *arg) +{ + struct hvm_irq *hvm_irq = hvm_domain_irq(d); + unsigned int isairq = (long)arg; + const struct dev_intx_gsi_link *digl; + + list_for_each_entry ( digl, &pirq_dpci->digl_list, list ) + { + unsigned int link = hvm_pci_intx_link(digl->device, digl->intx); + + if ( hvm_irq->pci_link.route[link] == isairq ) + { + hvm_pci_intx_deassert(d, digl->device, digl->intx); + if ( --pirq_dpci->pending == 0 ) + { + stop_timer(&pirq_dpci->timer); + pirq_guest_eoi(dpci_pirq(pirq_dpci)); + } + } + } + + return 0; +} + +void hvm_dpci_isairq_eoi(struct domain *d, unsigned int isairq) +{ + struct hvm_irq_dpci *dpci = NULL; + + ASSERT(isairq < NR_ISAIRQS); + if ( !iommu_enabled ) + return; + + spin_lock(&d->event_lock); + + dpci = domain_get_irq_dpci(d); + + if ( dpci && test_bit(isairq, dpci->isairq_map) ) + { + /* Multiple mirq may be mapped to one isa irq */ + pt_pirq_iterate(d, _hvm_dpci_isairq_eoi, (void *)(long)isairq); + } + spin_unlock(&d->event_lock); +} diff --git a/xen/drivers/passthrough/vtd/x86/vtd.c b/xen/drivers/passthrough/vtd/x86/vtd.c index 00a9891005..ac653eea0e 100644 --- a/xen/drivers/passthrough/vtd/x86/vtd.c +++ b/xen/drivers/passthrough/vtd/x86/vtd.c @@ -63,51 +63,6 @@ void flush_all_cache() wbinvd(); } -static int _hvm_dpci_isairq_eoi(struct domain *d, - struct hvm_pirq_dpci *pirq_dpci, void *arg) -{ - struct hvm_irq *hvm_irq = hvm_domain_irq(d); - unsigned int isairq = (long)arg; - const struct dev_intx_gsi_link *digl; - - list_for_each_entry ( digl, &pirq_dpci->digl_list, list ) - { - unsigned int link = hvm_pci_intx_link(digl->device, digl->intx); - - if ( hvm_irq->pci_link.route[link] == isairq ) - { - hvm_pci_intx_deassert(d, digl->device, digl->intx); - if ( --pirq_dpci->pending == 0 ) - { - stop_timer(&pirq_dpci->timer); - pirq_guest_eoi(dpci_pirq(pirq_dpci)); - } - } - } - - return 0; -} - -void hvm_dpci_isairq_eoi(struct domain *d, unsigned int isairq) -{ - struct hvm_irq_dpci *dpci = NULL; - - ASSERT(isairq < NR_ISAIRQS); - if ( !iommu_enabled) - return; - - spin_lock(&d->event_lock); - - dpci = domain_get_irq_dpci(d); - - if ( dpci && test_bit(isairq, dpci->isairq_map) ) - { - /* Multiple mirq may be mapped to one isa irq */ - pt_pirq_iterate(d, _hvm_dpci_isairq_eoi, (void *)(long)isairq); - } - spin_unlock(&d->event_lock); -} - void __hwdom_init vtd_set_hwdom_mapping(struct domain *d) { unsigned long i, top, max_pfn;