mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 10:11:27 +01:00
The hypervisor side changes for XSA-46 require the tool stack to now always map the guest pIRQ before granting access permission to the underlying host IRQ (GSI). This in particular requires that pciif.py no longer can skip this step (assuming qemu would do it) for HVM guests. This in turn exposes, however, an inconsistency between xend and qemu: The former wants to always establish 1:1 mappings between pIRQ and host IRQ (for non-MSI only of course), while the latter always wants to allocate an arbitrary mapping. Since the whole tool stack obviously should always agree on the mapping model, make libxc enforce the 1:1 mapping as the more natural one (as well as being the one that allows for easier debugging, since there no need to find out the extra mapping). Users of libxc that want to establish a particular (rather than an allocated) mapping are still free to do so, as well as tool stacks not based on libxc wanting to implement an allocation based model (which is why it's not the hypervisor that's being changed to enforce either model). Since libxl, like xend, already uses a 1:1 model, it's unaffected by the libxc change (and it being unaffected by the original hypervisor side changes is - afaict - simply due to qemu getting spawned at a later point in time compared to the xend event flow). Signed-off-by: Jan Beulich <jbeulich@suse.com> Tested-by: Andreas Falck <falck.andreas.lists@gmail.com> (on 4.1) Tested-by: Gordan Bobic <gordan@bobich.net> (on 4.2) Acked-by: Ian Campbell <ian.campbell@citrix.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
111 lines
3.0 KiB
C
111 lines
3.0 KiB
C
/******************************************************************************
|
|
* xc_physdev.c
|
|
*
|
|
* API for manipulating physical-device access permissions.
|
|
*
|
|
* Copyright (c) 2004, Rolf Neugebauer (Intel Research Cambridge)
|
|
* Copyright (c) 2004, K A Fraser (University of Cambridge)
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation;
|
|
* version 2.1 of the License.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
#include "xc_private.h"
|
|
|
|
int xc_physdev_pci_access_modify(xc_interface *xch,
|
|
uint32_t domid,
|
|
int bus,
|
|
int dev,
|
|
int func,
|
|
int enable)
|
|
{
|
|
errno = ENOSYS;
|
|
return -1;
|
|
}
|
|
|
|
int xc_physdev_map_pirq(xc_interface *xch,
|
|
int domid,
|
|
int index,
|
|
int *pirq)
|
|
{
|
|
int rc;
|
|
struct physdev_map_pirq map;
|
|
|
|
if ( !pirq )
|
|
return -EINVAL;
|
|
|
|
memset(&map, 0, sizeof(struct physdev_map_pirq));
|
|
map.domid = domid;
|
|
map.type = MAP_PIRQ_TYPE_GSI;
|
|
map.index = index;
|
|
map.pirq = *pirq < 0 ? index : *pirq;
|
|
|
|
rc = do_physdev_op(xch, PHYSDEVOP_map_pirq, &map, sizeof(map));
|
|
|
|
if ( !rc )
|
|
*pirq = map.pirq;
|
|
|
|
return rc;
|
|
}
|
|
|
|
int xc_physdev_map_pirq_msi(xc_interface *xch,
|
|
int domid,
|
|
int index,
|
|
int *pirq,
|
|
int devfn,
|
|
int bus,
|
|
int entry_nr,
|
|
uint64_t table_base)
|
|
{
|
|
int rc;
|
|
struct physdev_map_pirq map;
|
|
|
|
if ( !pirq )
|
|
return -EINVAL;
|
|
|
|
memset(&map, 0, sizeof(struct physdev_map_pirq));
|
|
map.domid = domid;
|
|
map.type = MAP_PIRQ_TYPE_MSI;
|
|
map.index = index;
|
|
map.pirq = *pirq;
|
|
map.bus = bus;
|
|
map.devfn = devfn;
|
|
map.entry_nr = entry_nr;
|
|
map.table_base = table_base;
|
|
|
|
rc = do_physdev_op(xch, PHYSDEVOP_map_pirq, &map, sizeof(map));
|
|
|
|
if ( !rc )
|
|
*pirq = map.pirq;
|
|
|
|
return rc;
|
|
}
|
|
|
|
int xc_physdev_unmap_pirq(xc_interface *xch,
|
|
int domid,
|
|
int pirq)
|
|
{
|
|
int rc;
|
|
struct physdev_unmap_pirq unmap;
|
|
|
|
memset(&unmap, 0, sizeof(struct physdev_unmap_pirq));
|
|
unmap.domid = domid;
|
|
unmap.pirq = pirq;
|
|
|
|
rc = do_physdev_op(xch, PHYSDEVOP_unmap_pirq, &unmap, sizeof(unmap));
|
|
|
|
return rc;
|
|
}
|
|
|