summaryrefslogtreecommitdiff
path: root/xen/arch/x86/include/asm/iocap.h
blob: 53d87ae8a33448f41c9bee728da6fca24e973e6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/******************************************************************************
 * iocap.h
 * 
 * Architecture-specific per-domain I/O capabilities.
 */

#ifndef __X86_IOCAP_H__
#define __X86_IOCAP_H__

#include <xen/sched.h>
#include <xen/rangeset.h>

#include <asm/p2m.h>

#define ioports_access_permitted(d, s, e)               \
    rangeset_contains_range((d)->arch.ioport_caps, s, e)

#define cache_flush_permitted(d)                        \
    (!rangeset_is_empty((d)->iomem_caps) ||             \
     !rangeset_is_empty((d)->arch.ioport_caps))

static inline int ioports_permit_access(struct domain *d, unsigned long s,
                                        unsigned long e)
{
    bool flush = cache_flush_permitted(d);
    int ret = rangeset_add_range(d->arch.ioport_caps, s, e);

    if ( !ret && !is_iommu_enabled(d) && !flush )
        /* See comment in iomem_permit_access(). */
        memory_type_changed(d);

    return ret;
}

static inline int ioports_deny_access(struct domain *d, unsigned long s,
                                      unsigned long e)
{
    int ret = rangeset_remove_range(d->arch.ioport_caps, s, e);

    if ( !ret && !is_iommu_enabled(d) && !cache_flush_permitted(d) )
        /* See comment in iomem_deny_access(). */
        memory_type_changed(d);

    return ret;
}

#endif /* __X86_IOCAP_H__ */