Skip to content

Commit

Permalink
xen p2m: transparently change the p2m mappings in the m2p override
Browse files Browse the repository at this point in the history
In m2p_add_override store the original mfn into page->index and then
change the p2m mapping, setting mfns as FOREIGN_FRAME.

In m2p_remove_override restore the original mapping.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
  • Loading branch information
Stefano Stabellini authored and Konrad Rzeszutek Wilk committed Jan 11, 2011
1 parent f0a70c8 commit 9b705f0
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions arch/x86/xen/p2m.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,11 @@ static unsigned long mfn_hash(unsigned long mfn)
void m2p_add_override(unsigned long mfn, struct page *page)
{
unsigned long flags;
unsigned long pfn = page_to_pfn(page);
page->private = mfn;
page->index = pfn_to_mfn(pfn);

__set_phys_to_machine(pfn, FOREIGN_FRAME(mfn));
spin_lock_irqsave(&m2p_override_lock, flags);
list_add(&page->lru, &m2p_overrides[mfn_hash(mfn)]);
spin_unlock_irqrestore(&m2p_override_lock, flags);
Expand All @@ -417,9 +420,18 @@ void m2p_add_override(unsigned long mfn, struct page *page)
void m2p_remove_override(struct page *page)
{
unsigned long flags;
unsigned long mfn;
unsigned long pfn;

pfn = page_to_pfn(page);
mfn = get_phys_to_machine(pfn);
if (mfn == INVALID_P2M_ENTRY || !(mfn & FOREIGN_FRAME_BIT))
return;

spin_lock_irqsave(&m2p_override_lock, flags);
list_del(&page->lru);
spin_unlock_irqrestore(&m2p_override_lock, flags);
__set_phys_to_machine(pfn, page->index);
}

struct page *m2p_find_override(unsigned long mfn)
Expand Down

0 comments on commit 9b705f0

Please sign in to comment.