Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
368d06cd
Commit
368d06cd
authored
Sep 05, 2016
by
Joerg Roedel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'x86/amd-avic' into x86/amd
parents
395adae4
d98de49a
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
801 additions
and
66 deletions
+801
-66
Documentation/kernel-parameters.txt
Documentation/kernel-parameters.txt
+9
-0
drivers/iommu/amd_iommu.c
drivers/iommu/amd_iommu.c
+427
-57
drivers/iommu/amd_iommu_init.c
drivers/iommu/amd_iommu_init.c
+175
-6
drivers/iommu/amd_iommu_proto.h
drivers/iommu/amd_iommu_proto.h
+1
-0
drivers/iommu/amd_iommu_types.h
drivers/iommu/amd_iommu_types.h
+149
-0
include/linux/amd-iommu.h
include/linux/amd-iommu.h
+40
-3
No files found.
Documentation/kernel-parameters.txt
View file @
368d06cd
...
...
@@ -460,6 +460,15 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
driver will print ACPI tables for AMD IOMMU during
IOMMU initialization.
amd_iommu_intr= [HW,X86-64]
Specifies one of the following AMD IOMMU interrupt
remapping modes:
legacy - Use legacy interrupt remapping mode.
vapic - Use virtual APIC mode, which allows IOMMU
to inject interrupts directly into guest.
This mode requires kvm-amd.avic=1.
(Default when IOMMU HW support is present.)
amijoy.map= [HW,JOY] Amiga joystick support
Map of devices attached to JOY0DAT and JOY1DAT
Format: <a>,<b>
...
...
drivers/iommu/amd_iommu.c
View file @
368d06cd
This diff is collapsed.
Click to expand it.
drivers/iommu/amd_iommu_init.c
View file @
368d06cd
...
...
@@ -84,6 +84,7 @@
#define ACPI_DEVFLAG_LINT1 0x80
#define ACPI_DEVFLAG_ATSDIS 0x10000000
#define LOOP_TIMEOUT 100000
/*
* ACPI table definitions
*
...
...
@@ -145,6 +146,8 @@ struct ivmd_header {
bool
amd_iommu_dump
;
bool
amd_iommu_irq_remap
__read_mostly
;
int
amd_iommu_guest_ir
=
AMD_IOMMU_GUEST_IR_VAPIC
;
static
bool
amd_iommu_detected
;
static
bool
__initdata
amd_iommu_disabled
;
static
int
amd_iommu_target_ivhd_type
;
...
...
@@ -386,6 +389,10 @@ static void iommu_disable(struct amd_iommu *iommu)
iommu_feature_disable
(
iommu
,
CONTROL_EVT_INT_EN
);
iommu_feature_disable
(
iommu
,
CONTROL_EVT_LOG_EN
);
/* Disable IOMMU GA_LOG */
iommu_feature_disable
(
iommu
,
CONTROL_GALOG_EN
);
iommu_feature_disable
(
iommu
,
CONTROL_GAINT_EN
);
/* Disable IOMMU hardware itself */
iommu_feature_disable
(
iommu
,
CONTROL_IOMMU_EN
);
}
...
...
@@ -671,6 +678,99 @@ static void __init free_ppr_log(struct amd_iommu *iommu)
free_pages
((
unsigned
long
)
iommu
->
ppr_log
,
get_order
(
PPR_LOG_SIZE
));
}
static
void
free_ga_log
(
struct
amd_iommu
*
iommu
)
{
#ifdef CONFIG_IRQ_REMAP
if
(
iommu
->
ga_log
)
free_pages
((
unsigned
long
)
iommu
->
ga_log
,
get_order
(
GA_LOG_SIZE
));
if
(
iommu
->
ga_log_tail
)
free_pages
((
unsigned
long
)
iommu
->
ga_log_tail
,
get_order
(
8
));
#endif
}
static
int
iommu_ga_log_enable
(
struct
amd_iommu
*
iommu
)
{
#ifdef CONFIG_IRQ_REMAP
u32
status
,
i
;
if
(
!
iommu
->
ga_log
)
return
-
EINVAL
;
status
=
readl
(
iommu
->
mmio_base
+
MMIO_STATUS_OFFSET
);
/* Check if already running */
if
(
status
&
(
MMIO_STATUS_GALOG_RUN_MASK
))
return
0
;
iommu_feature_enable
(
iommu
,
CONTROL_GAINT_EN
);
iommu_feature_enable
(
iommu
,
CONTROL_GALOG_EN
);
for
(
i
=
0
;
i
<
LOOP_TIMEOUT
;
++
i
)
{
status
=
readl
(
iommu
->
mmio_base
+
MMIO_STATUS_OFFSET
);
if
(
status
&
(
MMIO_STATUS_GALOG_RUN_MASK
))
break
;
}
if
(
i
>=
LOOP_TIMEOUT
)
return
-
EINVAL
;
#endif
/* CONFIG_IRQ_REMAP */
return
0
;
}
#ifdef CONFIG_IRQ_REMAP
static
int
iommu_init_ga_log
(
struct
amd_iommu
*
iommu
)
{
u64
entry
;
if
(
!
AMD_IOMMU_GUEST_IR_VAPIC
(
amd_iommu_guest_ir
))
return
0
;
iommu
->
ga_log
=
(
u8
*
)
__get_free_pages
(
GFP_KERNEL
|
__GFP_ZERO
,
get_order
(
GA_LOG_SIZE
));
if
(
!
iommu
->
ga_log
)
goto
err_out
;
iommu
->
ga_log_tail
=
(
u8
*
)
__get_free_pages
(
GFP_KERNEL
|
__GFP_ZERO
,
get_order
(
8
));
if
(
!
iommu
->
ga_log_tail
)
goto
err_out
;
entry
=
(
u64
)
virt_to_phys
(
iommu
->
ga_log
)
|
GA_LOG_SIZE_512
;
memcpy_toio
(
iommu
->
mmio_base
+
MMIO_GA_LOG_BASE_OFFSET
,
&
entry
,
sizeof
(
entry
));
entry
=
((
u64
)
virt_to_phys
(
iommu
->
ga_log
)
&
0xFFFFFFFFFFFFFULL
)
&
~
7ULL
;
memcpy_toio
(
iommu
->
mmio_base
+
MMIO_GA_LOG_TAIL_OFFSET
,
&
entry
,
sizeof
(
entry
));
writel
(
0x00
,
iommu
->
mmio_base
+
MMIO_GA_HEAD_OFFSET
);
writel
(
0x00
,
iommu
->
mmio_base
+
MMIO_GA_TAIL_OFFSET
);
return
0
;
err_out:
free_ga_log
(
iommu
);
return
-
EINVAL
;
}
#endif
/* CONFIG_IRQ_REMAP */
static
int
iommu_init_ga
(
struct
amd_iommu
*
iommu
)
{
int
ret
=
0
;
#ifdef CONFIG_IRQ_REMAP
/* Note: We have already checked GASup from IVRS table.
* Now, we need to make sure that GAMSup is set.
*/
if
(
AMD_IOMMU_GUEST_IR_VAPIC
(
amd_iommu_guest_ir
)
&&
!
iommu_feature
(
iommu
,
FEATURE_GAM_VAPIC
))
amd_iommu_guest_ir
=
AMD_IOMMU_GUEST_IR_LEGACY_GA
;
ret
=
iommu_init_ga_log
(
iommu
);
#endif
/* CONFIG_IRQ_REMAP */
return
ret
;
}
static
void
iommu_enable_gt
(
struct
amd_iommu
*
iommu
)
{
if
(
!
iommu_feature
(
iommu
,
FEATURE_GT
))
...
...
@@ -1144,6 +1244,7 @@ static void __init free_iommu_one(struct amd_iommu *iommu)
free_command_buffer
(
iommu
);
free_event_buffer
(
iommu
);
free_ppr_log
(
iommu
);
free_ga_log
(
iommu
);
iommu_unmap_mmio_space
(
iommu
);
}
...
...
@@ -1258,6 +1359,8 @@ static int __init init_iommu_one(struct amd_iommu *iommu, struct ivhd_header *h)
iommu
->
mmio_phys_end
=
MMIO_REG_END_OFFSET
;
else
iommu
->
mmio_phys_end
=
MMIO_CNTR_CONF_OFFSET
;
if
(((
h
->
efr_attr
&
(
0x1
<<
IOMMU_FEAT_GASUP_SHIFT
))
==
0
))
amd_iommu_guest_ir
=
AMD_IOMMU_GUEST_IR_LEGACY
;
break
;
case
0x11
:
case
0x40
:
...
...
@@ -1265,6 +1368,8 @@ static int __init init_iommu_one(struct amd_iommu *iommu, struct ivhd_header *h)
iommu
->
mmio_phys_end
=
MMIO_REG_END_OFFSET
;
else
iommu
->
mmio_phys_end
=
MMIO_CNTR_CONF_OFFSET
;
if
(((
h
->
efr_reg
&
(
0x1
<<
IOMMU_EFR_GASUP_SHIFT
))
==
0
))
amd_iommu_guest_ir
=
AMD_IOMMU_GUEST_IR_LEGACY
;
break
;
default:
return
-
EINVAL
;
...
...
@@ -1432,6 +1537,7 @@ static int iommu_init_pci(struct amd_iommu *iommu)
{
int
cap_ptr
=
iommu
->
cap_ptr
;
u32
range
,
misc
,
low
,
high
;
int
ret
;
iommu
->
dev
=
pci_get_bus_and_slot
(
PCI_BUS_NUM
(
iommu
->
devid
),
iommu
->
devid
&
0xff
);
...
...
@@ -1488,6 +1594,10 @@ static int iommu_init_pci(struct amd_iommu *iommu)
if
(
iommu_feature
(
iommu
,
FEATURE_PPR
)
&&
alloc_ppr_log
(
iommu
))
return
-
ENOMEM
;
ret
=
iommu_init_ga
(
iommu
);
if
(
ret
)
return
ret
;
if
(
iommu
->
cap
&
(
1UL
<<
IOMMU_CAP_NPCACHE
))
amd_iommu_np_cache
=
true
;
...
...
@@ -1545,16 +1655,24 @@ static void print_iommu_info(void)
dev_name
(
&
iommu
->
dev
->
dev
),
iommu
->
cap_ptr
);
if
(
iommu
->
cap
&
(
1
<<
IOMMU_CAP_EFR
))
{
pr_info
(
"AMD-Vi: Extended features: "
);
pr_info
(
"AMD-Vi: Extended features (%#llx):
\n
"
,
iommu
->
features
);
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
feat_str
);
++
i
)
{
if
(
iommu_feature
(
iommu
,
(
1ULL
<<
i
)))
pr_cont
(
" %s"
,
feat_str
[
i
]);
}
if
(
iommu
->
features
&
FEATURE_GAM_VAPIC
)
pr_cont
(
" GA_vAPIC"
);
pr_cont
(
"
\n
"
);
}
}
if
(
irq_remapping_enabled
)
if
(
irq_remapping_enabled
)
{
pr_info
(
"AMD-Vi: Interrupt remapping enabled
\n
"
);
if
(
AMD_IOMMU_GUEST_IR_VAPIC
(
amd_iommu_guest_ir
))
pr_info
(
"AMD-Vi: virtual APIC enabled
\n
"
);
}
}
static
int
__init
amd_iommu_init_pci
(
void
)
...
...
@@ -1645,6 +1763,8 @@ static int iommu_init_msi(struct amd_iommu *iommu)
if
(
iommu
->
ppr_log
!=
NULL
)
iommu_feature_enable
(
iommu
,
CONTROL_PPFINT_EN
);
iommu_ga_log_enable
(
iommu
);
return
0
;
}
...
...
@@ -1862,6 +1982,24 @@ static void iommu_apply_resume_quirks(struct amd_iommu *iommu)
iommu
->
stored_addr_lo
|
1
);
}
static
void
iommu_enable_ga
(
struct
amd_iommu
*
iommu
)
{
#ifdef CONFIG_IRQ_REMAP
switch
(
amd_iommu_guest_ir
)
{
case
AMD_IOMMU_GUEST_IR_VAPIC
:
iommu_feature_enable
(
iommu
,
CONTROL_GAM_EN
);
/* Fall through */
case
AMD_IOMMU_GUEST_IR_LEGACY_GA
:
iommu_feature_enable
(
iommu
,
CONTROL_GA_EN
);
iommu
->
irte_ops
=
&
irte_128_ops
;
break
;
default:
iommu
->
irte_ops
=
&
irte_32_ops
;
break
;
}
#endif
}
/*
* This function finally enables all IOMMUs found in the system after
* they have been initialized
...
...
@@ -1877,9 +2015,15 @@ static void early_enable_iommus(void)
iommu_enable_command_buffer
(
iommu
);
iommu_enable_event_buffer
(
iommu
);
iommu_set_exclusion_range
(
iommu
);
iommu_enable_ga
(
iommu
);
iommu_enable
(
iommu
);
iommu_flush_all_caches
(
iommu
);
}
#ifdef CONFIG_IRQ_REMAP
if
(
AMD_IOMMU_GUEST_IR_VAPIC
(
amd_iommu_guest_ir
))
amd_iommu_irq_ops
.
capability
|=
(
1
<<
IRQ_POSTING_CAP
);
#endif
}
static
void
enable_iommus_v2
(
void
)
...
...
@@ -1905,6 +2049,11 @@ static void disable_iommus(void)
for_each_iommu
(
iommu
)
iommu_disable
(
iommu
);
#ifdef CONFIG_IRQ_REMAP
if
(
AMD_IOMMU_GUEST_IR_VAPIC
(
amd_iommu_guest_ir
))
amd_iommu_irq_ops
.
capability
&=
~
(
1
<<
IRQ_POSTING_CAP
);
#endif
}
/*
...
...
@@ -2059,7 +2208,7 @@ static int __init early_amd_iommu_init(void)
struct
acpi_table_header
*
ivrs_base
;
acpi_size
ivrs_size
;
acpi_status
status
;
int
i
,
ret
=
0
;
int
i
,
re
map_cache_sz
,
re
t
=
0
;
if
(
!
amd_iommu_detected
)
return
-
ENODEV
;
...
...
@@ -2157,10 +2306,14 @@ static int __init early_amd_iommu_init(void)
* remapping tables.
*/
ret
=
-
ENOMEM
;
if
(
!
AMD_IOMMU_GUEST_IR_GA
(
amd_iommu_guest_ir
))
remap_cache_sz
=
MAX_IRQS_PER_TABLE
*
sizeof
(
u32
);
else
remap_cache_sz
=
MAX_IRQS_PER_TABLE
*
(
sizeof
(
u64
)
*
2
);
amd_iommu_irq_cache
=
kmem_cache_create
(
"irq_remap_cache"
,
MAX_IRQS_PER_TABLE
*
sizeof
(
u32
)
,
IRQ_TABLE_ALIGNMENT
,
0
,
NULL
);
remap_cache_sz
,
IRQ_TABLE_ALIGNMENT
,
0
,
NULL
);
if
(
!
amd_iommu_irq_cache
)
goto
out
;
...
...
@@ -2413,6 +2566,21 @@ static int __init parse_amd_iommu_dump(char *str)
return
1
;
}
static
int
__init
parse_amd_iommu_intr
(
char
*
str
)
{
for
(;
*
str
;
++
str
)
{
if
(
strncmp
(
str
,
"legacy"
,
6
)
==
0
)
{
amd_iommu_guest_ir
=
AMD_IOMMU_GUEST_IR_LEGACY
;
break
;
}
if
(
strncmp
(
str
,
"vapic"
,
5
)
==
0
)
{
amd_iommu_guest_ir
=
AMD_IOMMU_GUEST_IR_VAPIC
;
break
;
}
}
return
1
;
}
static
int
__init
parse_amd_iommu_options
(
char
*
str
)
{
for
(;
*
str
;
++
str
)
{
...
...
@@ -2521,6 +2689,7 @@ static int __init parse_ivrs_acpihid(char *str)
__setup
(
"amd_iommu_dump"
,
parse_amd_iommu_dump
);
__setup
(
"amd_iommu="
,
parse_amd_iommu_options
);
__setup
(
"amd_iommu_intr="
,
parse_amd_iommu_intr
);
__setup
(
"ivrs_ioapic"
,
parse_ivrs_ioapic
);
__setup
(
"ivrs_hpet"
,
parse_ivrs_hpet
);
__setup
(
"ivrs_acpihid"
,
parse_ivrs_acpihid
);
...
...
drivers/iommu/amd_iommu_proto.h
View file @
368d06cd
...
...
@@ -38,6 +38,7 @@ extern int amd_iommu_enable(void);
extern
void
amd_iommu_disable
(
void
);
extern
int
amd_iommu_reenable
(
int
);
extern
int
amd_iommu_enable_faulting
(
void
);
extern
int
amd_iommu_guest_ir
;
/* IOMMUv2 specific functions */
struct
iommu_domain
;
...
...
drivers/iommu/amd_iommu_types.h
View file @
368d06cd
...
...
@@ -22,6 +22,7 @@
#include <linux/types.h>
#include <linux/mutex.h>
#include <linux/msi.h>
#include <linux/list.h>
#include <linux/spinlock.h>
#include <linux/pci.h>
...
...
@@ -69,6 +70,8 @@
#define MMIO_EXCL_LIMIT_OFFSET 0x0028
#define MMIO_EXT_FEATURES 0x0030
#define MMIO_PPR_LOG_OFFSET 0x0038
#define MMIO_GA_LOG_BASE_OFFSET 0x00e0
#define MMIO_GA_LOG_TAIL_OFFSET 0x00e8
#define MMIO_CMD_HEAD_OFFSET 0x2000
#define MMIO_CMD_TAIL_OFFSET 0x2008
#define MMIO_EVT_HEAD_OFFSET 0x2010
...
...
@@ -76,6 +79,8 @@
#define MMIO_STATUS_OFFSET 0x2020
#define MMIO_PPR_HEAD_OFFSET 0x2030
#define MMIO_PPR_TAIL_OFFSET 0x2038
#define MMIO_GA_HEAD_OFFSET 0x2040
#define MMIO_GA_TAIL_OFFSET 0x2048
#define MMIO_CNTR_CONF_OFFSET 0x4000
#define MMIO_CNTR_REG_OFFSET 0x40000
#define MMIO_REG_END_OFFSET 0x80000
...
...
@@ -92,6 +97,7 @@
#define FEATURE_GA (1ULL<<7)
#define FEATURE_HE (1ULL<<8)
#define FEATURE_PC (1ULL<<9)
#define FEATURE_GAM_VAPIC (1ULL<<21)
#define FEATURE_PASID_SHIFT 32
#define FEATURE_PASID_MASK (0x1fULL << FEATURE_PASID_SHIFT)
...
...
@@ -110,6 +116,9 @@
#define MMIO_STATUS_EVT_INT_MASK (1 << 1)
#define MMIO_STATUS_COM_WAIT_INT_MASK (1 << 2)
#define MMIO_STATUS_PPR_INT_MASK (1 << 6)
#define MMIO_STATUS_GALOG_RUN_MASK (1 << 8)
#define MMIO_STATUS_GALOG_OVERFLOW_MASK (1 << 9)
#define MMIO_STATUS_GALOG_INT_MASK (1 << 10)
/* event logging constants */
#define EVENT_ENTRY_SIZE 0x10
...
...
@@ -146,6 +155,10 @@
#define CONTROL_PPFINT_EN 0x0eULL
#define CONTROL_PPR_EN 0x0fULL
#define CONTROL_GT_EN 0x10ULL
#define CONTROL_GA_EN 0x11ULL
#define CONTROL_GAM_EN 0x19ULL
#define CONTROL_GALOG_EN 0x1CULL
#define CONTROL_GAINT_EN 0x1DULL
#define CTRL_INV_TO_MASK (7 << CONTROL_INV_TIMEOUT)
#define CTRL_INV_TO_NONE 0
...
...
@@ -224,6 +237,19 @@
#define PPR_REQ_FAULT 0x01
/* Constants for GA Log handling */
#define GA_LOG_ENTRIES 512
#define GA_LOG_SIZE_SHIFT 56
#define GA_LOG_SIZE_512 (0x8ULL << GA_LOG_SIZE_SHIFT)
#define GA_ENTRY_SIZE 8
#define GA_LOG_SIZE (GA_ENTRY_SIZE * GA_LOG_ENTRIES)
#define GA_TAG(x) (u32)(x & 0xffffffffULL)
#define GA_DEVID(x) (u16)(((x) >> 32) & 0xffffULL)
#define GA_REQ_TYPE(x) (((x) >> 60) & 0xfULL)
#define GA_GUEST_NR 0x1
#define PAGE_MODE_NONE 0x00
#define PAGE_MODE_1_LEVEL 0x01
#define PAGE_MODE_2_LEVEL 0x02
...
...
@@ -329,6 +355,12 @@
#define IOMMU_CAP_NPCACHE 26
#define IOMMU_CAP_EFR 27
/* IOMMU Feature Reporting Field (for IVHD type 10h */
#define IOMMU_FEAT_GASUP_SHIFT 6
/* IOMMU Extended Feature Register (EFR) */
#define IOMMU_EFR_GASUP_SHIFT 7
#define MAX_DOMAIN_ID 65536
/* Protection domain flags */
...
...
@@ -400,6 +432,7 @@ struct amd_iommu_fault {
struct
iommu_domain
;
struct
irq_domain
;
struct
amd_irte_ops
;
/*
* This structure contains generic data for IOMMU protection domains
...
...
@@ -490,6 +523,12 @@ struct amd_iommu {
/* Base of the PPR log, if present */
u8
*
ppr_log
;
/* Base of the GA log, if present */
u8
*
ga_log
;
/* Tail of the GA log, if present */
u8
*
ga_log_tail
;
/* true if interrupts for this IOMMU are already enabled */
bool
int_enabled
;
...
...
@@ -523,6 +562,8 @@ struct amd_iommu {
#ifdef CONFIG_IRQ_REMAP
struct
irq_domain
*
ir_domain
;
struct
irq_domain
*
msi_domain
;
struct
amd_irte_ops
*
irte_ops
;
#endif
};
...
...
@@ -681,4 +722,112 @@ static inline int get_hpet_devid(int id)
return
-
EINVAL
;
}
enum
amd_iommu_intr_mode_type
{
AMD_IOMMU_GUEST_IR_LEGACY
,
/* This mode is not visible to users. It is used when
* we cannot fully enable vAPIC and fallback to only support
* legacy interrupt remapping via 128-bit IRTE.
*/
AMD_IOMMU_GUEST_IR_LEGACY_GA
,
AMD_IOMMU_GUEST_IR_VAPIC
,
};
#define AMD_IOMMU_GUEST_IR_GA(x) (x == AMD_IOMMU_GUEST_IR_VAPIC || \
x == AMD_IOMMU_GUEST_IR_LEGACY_GA)
#define AMD_IOMMU_GUEST_IR_VAPIC(x) (x == AMD_IOMMU_GUEST_IR_VAPIC)
union
irte
{
u32
val
;
struct
{
u32
valid
:
1
,
no_fault
:
1
,
int_type
:
3
,
rq_eoi
:
1
,
dm
:
1
,
rsvd_1
:
1
,
destination
:
8
,
vector
:
8
,
rsvd_2
:
8
;
}
fields
;
};
union
irte_ga_lo
{
u64
val
;
/* For int remapping */
struct
{
u64
valid
:
1
,
no_fault
:
1
,
/* ------ */
int_type
:
3
,
rq_eoi
:
1
,
dm
:
1
,
/* ------ */
guest_mode
:
1
,
destination
:
8
,
rsvd
:
48
;
}
fields_remap
;
/* For guest vAPIC */
struct
{
u64
valid
:
1
,
no_fault
:
1
,
/* ------ */
ga_log_intr
:
1
,
rsvd1
:
3
,
is_run
:
1
,
/* ------ */
guest_mode
:
1
,
destination
:
8
,
rsvd2
:
16
,
ga_tag
:
32
;
}
fields_vapic
;
};
union
irte_ga_hi
{
u64
val
;
struct
{
u64
vector
:
8
,
rsvd_1
:
4
,
ga_root_ptr
:
40
,
rsvd_2
:
12
;
}
fields
;
};
struct
irte_ga
{
union
irte_ga_lo
lo
;
union
irte_ga_hi
hi
;
};
struct
irq_2_irte
{
u16
devid
;
/* Device ID for IRTE table */
u16
index
;
/* Index into IRTE table*/
};
struct
amd_ir_data
{
u32
cached_ga_tag
;
struct
irq_2_irte
irq_2_irte
;
struct
msi_msg
msi_entry
;
void
*
entry
;
/* Pointer to union irte or struct irte_ga */
void
*
ref
;
/* Pointer to the actual irte */
};
struct
amd_irte_ops
{
void
(
*
prepare
)(
void
*
,
u32
,
u32
,
u8
,
u32
,
int
);
void
(
*
activate
)(
void
*
,
u16
,
u16
);
void
(
*
deactivate
)(
void
*
,
u16
,
u16
);
void
(
*
set_affinity
)(
void
*
,
u16
,
u16
,
u8
,
u32
);
void
*
(
*
get
)(
struct
irq_remap_table
*
,
int
);
void
(
*
set_allocated
)(
struct
irq_remap_table
*
,
int
);
bool
(
*
is_allocated
)(
struct
irq_remap_table
*
,
int
);
void
(
*
clear_allocated
)(
struct
irq_remap_table
*
,
int
);
};
#ifdef CONFIG_IRQ_REMAP
extern
struct
amd_irte_ops
irte_32_ops
;
extern
struct
amd_irte_ops
irte_128_ops
;
#endif
#endif
/* _ASM_X86_AMD_IOMMU_TYPES_H */
include/linux/amd-iommu.h
View file @
368d06cd
...
...
@@ -22,6 +22,20 @@
#include <linux/types.h>
/*
* This is mainly used to communicate information back-and-forth
* between SVM and IOMMU for setting up and tearing down posted
* interrupt
*/
struct
amd_iommu_pi_data
{
u32
ga_tag
;
u32
prev_ga_tag
;
u64
base
;
bool
is_guest_mode
;
struct
vcpu_data
*
vcpu_data
;
void
*
ir_data
;
};
#ifdef CONFIG_AMD_IOMMU
struct
task_struct
;
...
...
@@ -168,11 +182,34 @@ typedef void (*amd_iommu_invalidate_ctx)(struct pci_dev *pdev, int pasid);
extern
int
amd_iommu_set_invalidate_ctx_cb
(
struct
pci_dev
*
pdev
,
amd_iommu_invalidate_ctx
cb
);
#else
#else
/* CONFIG_AMD_IOMMU */
static
inline
int
amd_iommu_detect
(
void
)
{
return
-
ENODEV
;
}
#endif
#endif
/* CONFIG_AMD_IOMMU */
#if defined(CONFIG_AMD_IOMMU) && defined(CONFIG_IRQ_REMAP)
/* IOMMU AVIC Function */
extern
int
amd_iommu_register_ga_log_notifier
(
int
(
*
notifier
)(
u32
));
extern
int
amd_iommu_update_ga
(
int
cpu
,
bool
is_run
,
void
*
data
);
#else
/* defined(CONFIG_AMD_IOMMU) && defined(CONFIG_IRQ_REMAP) */
static
inline
int
amd_iommu_register_ga_log_notifier
(
int
(
*
notifier
)(
u32
))
{
return
0
;
}
static
inline
int
amd_iommu_update_ga
(
int
cpu
,
bool
is_run
,
void
*
data
)
{
return
0
;
}
#endif
/* defined(CONFIG_AMD_IOMMU) && defined(CONFIG_IRQ_REMAP) */
#endif
/* _ASM_X86_AMD_IOMMU_H */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment