diff options
author | Stefano Stabellini <stefano.stabellini@eu.citrix.com> | 2010-12-10 09:52:45 -0500 |
---|---|---|
committer | Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> | 2011-01-11 14:31:53 -0500 |
commit | 9b705f0e98c489b18ba22a6eab9d694b546c8552 (patch) | |
tree | e8e017032a3e433c7c637c9121eb7fbe5ee8567e /arch | |
parent | f0a70c882ea546bbd802643990ceded32c39facc (diff) |
xen p2m: transparently change the p2m mappings in the m2p override
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>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/xen/p2m.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/arch/x86/xen/p2m.c b/arch/x86/xen/p2m.c index 8db19d50c467..b3b19d43b951 100644 --- a/arch/x86/xen/p2m.c +++ b/arch/x86/xen/p2m.c | |||
@@ -407,8 +407,11 @@ static unsigned long mfn_hash(unsigned long mfn) | |||
407 | void m2p_add_override(unsigned long mfn, struct page *page) | 407 | void m2p_add_override(unsigned long mfn, struct page *page) |
408 | { | 408 | { |
409 | unsigned long flags; | 409 | unsigned long flags; |
410 | unsigned long pfn = page_to_pfn(page); | ||
410 | page->private = mfn; | 411 | page->private = mfn; |
412 | page->index = pfn_to_mfn(pfn); | ||
411 | 413 | ||
414 | __set_phys_to_machine(pfn, FOREIGN_FRAME(mfn)); | ||
412 | spin_lock_irqsave(&m2p_override_lock, flags); | 415 | spin_lock_irqsave(&m2p_override_lock, flags); |
413 | list_add(&page->lru, &m2p_overrides[mfn_hash(mfn)]); | 416 | list_add(&page->lru, &m2p_overrides[mfn_hash(mfn)]); |
414 | spin_unlock_irqrestore(&m2p_override_lock, flags); | 417 | spin_unlock_irqrestore(&m2p_override_lock, flags); |
@@ -417,9 +420,18 @@ void m2p_add_override(unsigned long mfn, struct page *page) | |||
417 | void m2p_remove_override(struct page *page) | 420 | void m2p_remove_override(struct page *page) |
418 | { | 421 | { |
419 | unsigned long flags; | 422 | unsigned long flags; |
423 | unsigned long mfn; | ||
424 | unsigned long pfn; | ||
425 | |||
426 | pfn = page_to_pfn(page); | ||
427 | mfn = get_phys_to_machine(pfn); | ||
428 | if (mfn == INVALID_P2M_ENTRY || !(mfn & FOREIGN_FRAME_BIT)) | ||
429 | return; | ||
430 | |||
420 | spin_lock_irqsave(&m2p_override_lock, flags); | 431 | spin_lock_irqsave(&m2p_override_lock, flags); |
421 | list_del(&page->lru); | 432 | list_del(&page->lru); |
422 | spin_unlock_irqrestore(&m2p_override_lock, flags); | 433 | spin_unlock_irqrestore(&m2p_override_lock, flags); |
434 | __set_phys_to_machine(pfn, page->index); | ||
423 | } | 435 | } |
424 | 436 | ||
425 | struct page *m2p_find_override(unsigned long mfn) | 437 | struct page *m2p_find_override(unsigned long mfn) |