Skip to content

Commit 9c38c7e

Browse files
committed
Merge branch 'x86-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'x86-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: x86: fix 27-rc crash on vsmp due to paravirt during module load x86, oprofile: BUG scheduling while atomic AMD IOMMU: protect completion wait loop with iommu lock AMD IOMMU: set iommu sunc flag after command queuing
2 parents e002bcc + 05e12e1 commit 9c38c7e

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

arch/x86/kernel/amd_iommu.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,21 +101,23 @@ static int iommu_queue_command(struct amd_iommu *iommu, struct iommu_cmd *cmd)
101101
*/
102102
static int iommu_completion_wait(struct amd_iommu *iommu)
103103
{
104-
int ret, ready = 0;
104+
int ret = 0, ready = 0;
105105
unsigned status = 0;
106106
struct iommu_cmd cmd;
107-
unsigned long i = 0;
107+
unsigned long flags, i = 0;
108108

109109
memset(&cmd, 0, sizeof(cmd));
110110
cmd.data[0] = CMD_COMPL_WAIT_INT_MASK;
111111
CMD_SET_TYPE(&cmd, CMD_COMPL_WAIT);
112112

113113
iommu->need_sync = 0;
114114

115-
ret = iommu_queue_command(iommu, &cmd);
115+
spin_lock_irqsave(&iommu->lock, flags);
116+
117+
ret = __iommu_queue_command(iommu, &cmd);
116118

117119
if (ret)
118-
return ret;
120+
goto out;
119121

120122
while (!ready && (i < EXIT_LOOP_COUNT)) {
121123
++i;
@@ -130,6 +132,8 @@ static int iommu_completion_wait(struct amd_iommu *iommu)
130132

131133
if (unlikely((i == EXIT_LOOP_COUNT) && printk_ratelimit()))
132134
printk(KERN_WARNING "AMD IOMMU: Completion wait loop failed\n");
135+
out:
136+
spin_unlock_irqrestore(&iommu->lock, flags);
133137

134138
return 0;
135139
}
@@ -140,16 +144,19 @@ static int iommu_completion_wait(struct amd_iommu *iommu)
140144
static int iommu_queue_inv_dev_entry(struct amd_iommu *iommu, u16 devid)
141145
{
142146
struct iommu_cmd cmd;
147+
int ret;
143148

144149
BUG_ON(iommu == NULL);
145150

146151
memset(&cmd, 0, sizeof(cmd));
147152
CMD_SET_TYPE(&cmd, CMD_INV_DEV_ENTRY);
148153
cmd.data[0] = devid;
149154

155+
ret = iommu_queue_command(iommu, &cmd);
156+
150157
iommu->need_sync = 1;
151158

152-
return iommu_queue_command(iommu, &cmd);
159+
return ret;
153160
}
154161

155162
/*
@@ -159,6 +166,7 @@ static int iommu_queue_inv_iommu_pages(struct amd_iommu *iommu,
159166
u64 address, u16 domid, int pde, int s)
160167
{
161168
struct iommu_cmd cmd;
169+
int ret;
162170

163171
memset(&cmd, 0, sizeof(cmd));
164172
address &= PAGE_MASK;
@@ -171,9 +179,11 @@ static int iommu_queue_inv_iommu_pages(struct amd_iommu *iommu,
171179
if (pde) /* PDE bit - we wan't flush everything not only the PTEs */
172180
cmd.data[2] |= CMD_INV_IOMMU_PAGES_PDE_MASK;
173181

182+
ret = iommu_queue_command(iommu, &cmd);
183+
174184
iommu->need_sync = 1;
175185

176-
return iommu_queue_command(iommu, &cmd);
186+
return ret;
177187
}
178188

179189
/*

arch/x86/kernel/vsmp_64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static void vsmp_irq_enable(void)
6161
native_restore_fl((flags | X86_EFLAGS_IF) & (~X86_EFLAGS_AC));
6262
}
6363

64-
static unsigned __init vsmp_patch(u8 type, u16 clobbers, void *ibuf,
64+
static unsigned __init_or_module vsmp_patch(u8 type, u16 clobbers, void *ibuf,
6565
unsigned long addr, unsigned len)
6666
{
6767
switch (type) {

arch/x86/oprofile/nmi_int.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,12 @@ static void nmi_cpu_shutdown(void *dummy)
295295

296296
static void nmi_shutdown(void)
297297
{
298-
struct op_msrs *msrs = &get_cpu_var(cpu_msrs);
298+
struct op_msrs *msrs;
299+
299300
nmi_enabled = 0;
300301
on_each_cpu(nmi_cpu_shutdown, NULL, 1);
301302
unregister_die_notifier(&profile_exceptions_nb);
303+
msrs = &get_cpu_var(cpu_msrs);
302304
model->shutdown(msrs);
303305
free_msrs();
304306
put_cpu_var(cpu_msrs);

0 commit comments

Comments
 (0)