Changeset View
Changeset View
Standalone View
Standalone View
head/sys/x86/iommu/intel_dmar.h
Show All 32 Lines | |||||
#ifndef __X86_IOMMU_INTEL_DMAR_H | #ifndef __X86_IOMMU_INTEL_DMAR_H | ||||
#define __X86_IOMMU_INTEL_DMAR_H | #define __X86_IOMMU_INTEL_DMAR_H | ||||
#include <dev/iommu/iommu.h> | #include <dev/iommu/iommu.h> | ||||
struct dmar_unit; | struct dmar_unit; | ||||
RB_HEAD(dmar_gas_entries_tree, iommu_map_entry); | |||||
RB_PROTOTYPE(dmar_gas_entries_tree, iommu_map_entry, rb_entry, | |||||
dmar_gas_cmp_entries); | |||||
/* | /* | ||||
* Locking annotations: | * Locking annotations: | ||||
* (u) - Protected by iommu unit lock | * (u) - Protected by iommu unit lock | ||||
* (d) - Protected by domain lock | * (d) - Protected by domain lock | ||||
* (c) - Immutable after initialization | * (c) - Immutable after initialization | ||||
*/ | */ | ||||
/* | /* | ||||
Show All 10 Lines | |||||
struct dmar_domain { | struct dmar_domain { | ||||
struct iommu_domain iodom; | struct iommu_domain iodom; | ||||
int domain; /* (c) DID, written in context entry */ | int domain; /* (c) DID, written in context entry */ | ||||
int mgaw; /* (c) Real max address width */ | int mgaw; /* (c) Real max address width */ | ||||
int agaw; /* (c) Adjusted guest address width */ | int agaw; /* (c) Adjusted guest address width */ | ||||
int pglvl; /* (c) The pagelevel */ | int pglvl; /* (c) The pagelevel */ | ||||
int awlvl; /* (c) The pagelevel as the bitmask, | int awlvl; /* (c) The pagelevel as the bitmask, | ||||
to set in context entry */ | to set in context entry */ | ||||
iommu_gaddr_t end; /* (c) Highest address + 1 in | |||||
the guest AS */ | |||||
u_int ctx_cnt; /* (u) Number of contexts owned */ | u_int ctx_cnt; /* (u) Number of contexts owned */ | ||||
u_int refs; /* (u) Refs, including ctx */ | u_int refs; /* (u) Refs, including ctx */ | ||||
struct dmar_unit *dmar; /* (c) */ | struct dmar_unit *dmar; /* (c) */ | ||||
LIST_ENTRY(dmar_domain) link; /* (u) Member in the dmar list */ | LIST_ENTRY(dmar_domain) link; /* (u) Member in the dmar list */ | ||||
LIST_HEAD(, dmar_ctx) contexts; /* (u) */ | LIST_HEAD(, dmar_ctx) contexts; /* (u) */ | ||||
vm_object_t pgtbl_obj; /* (c) Page table pages */ | vm_object_t pgtbl_obj; /* (c) Page table pages */ | ||||
u_int flags; /* (u) */ | |||||
struct dmar_gas_entries_tree rb_root; /* (d) */ | |||||
struct iommu_map_entry *first_place, *last_place; /* (d) */ | |||||
u_int batch_no; | u_int batch_no; | ||||
}; | }; | ||||
struct dmar_ctx { | struct dmar_ctx { | ||||
struct iommu_ctx context; | struct iommu_ctx context; | ||||
uint16_t rid; /* (c) pci RID */ | uint16_t rid; /* (c) pci RID */ | ||||
uint64_t last_fault_rec[2]; /* Last fault reported */ | uint64_t last_fault_rec[2]; /* Last fault reported */ | ||||
LIST_ENTRY(dmar_ctx) link; /* (u) Member in the domain list */ | LIST_ENTRY(dmar_ctx) link; /* (u) Member in the domain list */ | ||||
▲ Show 20 Lines • Show All 174 Lines • ▼ Show 20 Lines | |||||
void dmar_qi_invalidate_ctx_glob_locked(struct dmar_unit *unit); | void dmar_qi_invalidate_ctx_glob_locked(struct dmar_unit *unit); | ||||
void dmar_qi_invalidate_iotlb_glob_locked(struct dmar_unit *unit); | void dmar_qi_invalidate_iotlb_glob_locked(struct dmar_unit *unit); | ||||
void dmar_qi_invalidate_iec_glob(struct dmar_unit *unit); | void dmar_qi_invalidate_iec_glob(struct dmar_unit *unit); | ||||
void dmar_qi_invalidate_iec(struct dmar_unit *unit, u_int start, u_int cnt); | void dmar_qi_invalidate_iec(struct dmar_unit *unit, u_int start, u_int cnt); | ||||
vm_object_t domain_get_idmap_pgtbl(struct dmar_domain *domain, | vm_object_t domain_get_idmap_pgtbl(struct dmar_domain *domain, | ||||
iommu_gaddr_t maxaddr); | iommu_gaddr_t maxaddr); | ||||
void put_idmap_pgtbl(vm_object_t obj); | void put_idmap_pgtbl(vm_object_t obj); | ||||
int domain_map_buf(struct dmar_domain *domain, iommu_gaddr_t base, | int domain_map_buf(struct iommu_domain *domain, iommu_gaddr_t base, | ||||
iommu_gaddr_t size, vm_page_t *ma, uint64_t pflags, int flags); | iommu_gaddr_t size, vm_page_t *ma, uint64_t pflags, int flags); | ||||
int domain_unmap_buf(struct dmar_domain *domain, iommu_gaddr_t base, | int domain_unmap_buf(struct dmar_domain *domain, iommu_gaddr_t base, | ||||
iommu_gaddr_t size, int flags); | iommu_gaddr_t size, int flags); | ||||
void domain_flush_iotlb_sync(struct dmar_domain *domain, iommu_gaddr_t base, | void domain_flush_iotlb_sync(struct dmar_domain *domain, iommu_gaddr_t base, | ||||
iommu_gaddr_t size); | iommu_gaddr_t size); | ||||
int domain_alloc_pgtbl(struct dmar_domain *domain); | int domain_alloc_pgtbl(struct dmar_domain *domain); | ||||
void domain_free_pgtbl(struct dmar_domain *domain); | void domain_free_pgtbl(struct dmar_domain *domain); | ||||
Show All 9 Lines | |||||
void dmar_free_ctx_locked(struct dmar_unit *dmar, struct dmar_ctx *ctx); | void dmar_free_ctx_locked(struct dmar_unit *dmar, struct dmar_ctx *ctx); | ||||
void dmar_free_ctx(struct dmar_ctx *ctx); | void dmar_free_ctx(struct dmar_ctx *ctx); | ||||
struct dmar_ctx *dmar_find_ctx_locked(struct dmar_unit *dmar, uint16_t rid); | struct dmar_ctx *dmar_find_ctx_locked(struct dmar_unit *dmar, uint16_t rid); | ||||
void dmar_domain_unload_entry(struct iommu_map_entry *entry, bool free); | void dmar_domain_unload_entry(struct iommu_map_entry *entry, bool free); | ||||
void dmar_domain_unload(struct dmar_domain *domain, | void dmar_domain_unload(struct dmar_domain *domain, | ||||
struct iommu_map_entries_tailq *entries, bool cansleep); | struct iommu_map_entries_tailq *entries, bool cansleep); | ||||
void dmar_domain_free_entry(struct iommu_map_entry *entry, bool free); | void dmar_domain_free_entry(struct iommu_map_entry *entry, bool free); | ||||
void dmar_gas_init_domain(struct dmar_domain *domain); | void iommu_gas_init_domain(struct iommu_domain *domain); | ||||
void dmar_gas_fini_domain(struct dmar_domain *domain); | void iommu_gas_fini_domain(struct iommu_domain *domain); | ||||
struct iommu_map_entry *dmar_gas_alloc_entry(struct dmar_domain *domain, | struct iommu_map_entry *iommu_gas_alloc_entry(struct iommu_domain *domain, | ||||
u_int flags); | u_int flags); | ||||
void dmar_gas_free_entry(struct dmar_domain *domain, | void iommu_gas_free_entry(struct iommu_domain *domain, | ||||
struct iommu_map_entry *entry); | struct iommu_map_entry *entry); | ||||
void dmar_gas_free_space(struct dmar_domain *domain, | void iommu_gas_free_space(struct iommu_domain *domain, | ||||
struct iommu_map_entry *entry); | struct iommu_map_entry *entry); | ||||
int dmar_gas_map(struct dmar_domain *domain, | int iommu_gas_map(struct iommu_domain *domain, | ||||
const struct bus_dma_tag_common *common, iommu_gaddr_t size, int offset, | const struct bus_dma_tag_common *common, iommu_gaddr_t size, int offset, | ||||
u_int eflags, u_int flags, vm_page_t *ma, struct iommu_map_entry **res); | u_int eflags, u_int flags, vm_page_t *ma, struct iommu_map_entry **res); | ||||
void dmar_gas_free_region(struct dmar_domain *domain, | void iommu_gas_free_region(struct iommu_domain *domain, | ||||
struct iommu_map_entry *entry); | struct iommu_map_entry *entry); | ||||
int dmar_gas_map_region(struct dmar_domain *domain, | int iommu_gas_map_region(struct iommu_domain *domain, | ||||
struct iommu_map_entry *entry, u_int eflags, u_int flags, vm_page_t *ma); | struct iommu_map_entry *entry, u_int eflags, u_int flags, vm_page_t *ma); | ||||
int dmar_gas_reserve_region(struct dmar_domain *domain, iommu_gaddr_t start, | int iommu_gas_reserve_region(struct iommu_domain *domain, iommu_gaddr_t start, | ||||
iommu_gaddr_t end); | iommu_gaddr_t end); | ||||
void dmar_dev_parse_rmrr(struct dmar_domain *domain, int dev_domain, | void dmar_dev_parse_rmrr(struct dmar_domain *domain, int dev_domain, | ||||
int dev_busno, const void *dev_path, int dev_path_len, | int dev_busno, const void *dev_path, int dev_path_len, | ||||
struct iommu_map_entries_tailq *rmrr_entries); | struct iommu_map_entries_tailq *rmrr_entries); | ||||
int dmar_instantiate_rmrr_ctxs(struct iommu_unit *dmar); | int dmar_instantiate_rmrr_ctxs(struct iommu_unit *dmar); | ||||
void dmar_quirks_post_ident(struct dmar_unit *dmar); | void dmar_quirks_post_ident(struct dmar_unit *dmar); | ||||
Show All 15 Lines | |||||
#define DMAR_PGF_ALLOC 0x0004 | #define DMAR_PGF_ALLOC 0x0004 | ||||
#define DMAR_PGF_NOALLOC 0x0008 | #define DMAR_PGF_NOALLOC 0x0008 | ||||
#define DMAR_PGF_OBJL 0x0010 | #define DMAR_PGF_OBJL 0x0010 | ||||
extern iommu_haddr_t dmar_high; | extern iommu_haddr_t dmar_high; | ||||
extern int haw; | extern int haw; | ||||
extern int dmar_tbl_pagecnt; | extern int dmar_tbl_pagecnt; | ||||
extern int dmar_batch_coalesce; | extern int dmar_batch_coalesce; | ||||
extern int dmar_check_free; | extern int iommu_check_free; | ||||
static inline uint32_t | static inline uint32_t | ||||
dmar_read4(const struct dmar_unit *unit, int reg) | dmar_read4(const struct dmar_unit *unit, int reg) | ||||
{ | { | ||||
return (bus_read_4(unit->regs, reg)); | return (bus_read_4(unit->regs, reg)); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 151 Lines • Show Last 20 Lines |