Skip to contentSkip to conversation

x86/cpa: make sure cpa is safe to call in lazy mmu mode

PATCH Applied Jeremy Fitzhardinge 2 participants 2 messages Feb 11, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/cpa: make sure cpa is safe to call in lazy mmu mode

[ Ingo, this needs to go upstream and -stable. -J ]

commit 2193cee29f66b873b9f8ac2cebb2c7b755ec73a3

Author: Jeremy Fitzhardinge <[email protected]>
Date:   Tue Feb 10 14:15:52 2009 -0800

x86/cpa: make sure cpa is safe to call in lazy mmu mode

Impact: fix race leading to crash under KVM and Xen

The CPA code may be called while we're in lazy mmu update mode - for example, when using DEBUG_PAGE_ALLOC and doing a slab allocation in an interrupt handler which interrupted a lazy mmu update. In this case, the in-memory pagetable state may be out of date due to pending queued updates. We need to flush any pending updates before inspecting the page table. Similarly, we must explicitly flush any modifications CPA may have made (which comes down to flushing queued operations when flushing the TLB).

arch/x86/mm/pageattr.c +0 -0
index 84ba748..fb12f06 100644
@@ -576,6 +576,13 @@ static int __change_page_attr(struct cpa_data *cpa, int primary)
	else
		address = *cpa->vaddr;

+ /*
+ * If we're called with lazy mmu updates enabled, the
+ * in-memory pte state may be stale. Flush pending updates to
+ * bring them up to date.
+ */
+ arch_flush_lazy_mmu_mode();
+
repeat:

	kpte = lookup_address(address, &level);
	if (!kpte)
@@ -854,6 +861,13 @@ static int change_page_attr_set_clr(unsigned long *addr, int numpages,
	} else
		cpa_flush_all(cache);

+ /* + * If we've been called with lazy mmu updates enabled, then
+ * make sure that everything gets flushed out before we
+ * return.
+ */
+ arch_flush_lazy_mmu_mode();
+
out:

	return ret;
}
Applied
#1 lore raw
Quoted 17 lines · Jeremy Fitzhardinge

[ Ingo, this needs to go upstream and -stable. -J ]

commit 2193cee29f66b873b9f8ac2cebb2c7b755ec73a3

Author: Jeremy Fitzhardinge <[email protected]>
Date:   Tue Feb 10 14:15:52 2009 -0800

x86/cpa: make sure cpa is safe to call in lazy mmu mode
Impact: fix race leading to crash under KVM and Xen

The CPA code may be called while we're in lazy mmu update mode - for example, when using DEBUG_PAGE_ALLOC and doing a slab allocation in an interrupt handler which interrupted a lazy mmu update. In this case, the in-memory pagetable state may be out of date due to pending queued updates. We need to flush any pending updates before inspecting the page table. Similarly, we must explicitly flush any modifications CPA may have made (which comes down to flushing queued operations when flushing the TLB).

Quoted 2 lines

applied to tip:x86/urgent, thanks Jeremy!

Ingo