diff options
author | Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> | 2010-08-27 16:42:04 -0400 |
---|---|---|
committer | Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> | 2010-10-22 15:57:25 -0400 |
commit | c3798062f100c3e1d4ae1241bc536f3b1f28a6ca (patch) | |
tree | c62ab3fb20be784991f6988cd46382d669110c43 /arch/x86 | |
parent | 58e05027b530ff081ecea68e38de8d59db8f87e0 (diff) |
xen: add return value to set_phys_to_machine()
set_phys_to_machine() can return false on failure, which means a memory
allocation failure for the p2m structure. It can only fail if setting
the mfn for a pfn in previously unused address space. It is guaranteed
to succeed if you're setting a mapping to INVALID_P2M_ENTRY or updating
the mfn for an existing pfn.
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/include/asm/xen/page.h | 2 | ||||
-rw-r--r-- | arch/x86/xen/mmu.c | 13 |
2 files changed, 9 insertions, 6 deletions
diff --git a/arch/x86/include/asm/xen/page.h b/arch/x86/include/asm/xen/page.h index bf5f7d32bd08..e40ca6e67bb5 100644 --- a/arch/x86/include/asm/xen/page.h +++ b/arch/x86/include/asm/xen/page.h | |||
@@ -37,7 +37,7 @@ typedef struct xpaddr { | |||
37 | 37 | ||
38 | 38 | ||
39 | extern unsigned long get_phys_to_machine(unsigned long pfn); | 39 | extern unsigned long get_phys_to_machine(unsigned long pfn); |
40 | extern void set_phys_to_machine(unsigned long pfn, unsigned long mfn); | 40 | extern bool set_phys_to_machine(unsigned long pfn, unsigned long mfn); |
41 | 41 | ||
42 | static inline unsigned long pfn_to_mfn(unsigned long pfn) | 42 | static inline unsigned long pfn_to_mfn(unsigned long pfn) |
43 | { | 43 | { |
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c index d4c7265cf0a0..b96513437236 100644 --- a/arch/x86/xen/mmu.c +++ b/arch/x86/xen/mmu.c | |||
@@ -282,7 +282,7 @@ static void p2m_init(unsigned long *p2m) | |||
282 | */ | 282 | */ |
283 | void xen_build_mfn_list_list(void) | 283 | void xen_build_mfn_list_list(void) |
284 | { | 284 | { |
285 | unsigned pfn, i; | 285 | unsigned pfn; |
286 | 286 | ||
287 | /* Pre-initialize p2m_top_mfn to be completely missing */ | 287 | /* Pre-initialize p2m_top_mfn to be completely missing */ |
288 | if (p2m_top_mfn == NULL) { | 288 | if (p2m_top_mfn == NULL) { |
@@ -496,19 +496,22 @@ bool __set_phys_to_machine(unsigned long pfn, unsigned long mfn) | |||
496 | return true; | 496 | return true; |
497 | } | 497 | } |
498 | 498 | ||
499 | void set_phys_to_machine(unsigned long pfn, unsigned long mfn) | 499 | bool set_phys_to_machine(unsigned long pfn, unsigned long mfn) |
500 | { | 500 | { |
501 | if (unlikely(xen_feature(XENFEAT_auto_translated_physmap))) { | 501 | if (unlikely(xen_feature(XENFEAT_auto_translated_physmap))) { |
502 | BUG_ON(pfn != mfn && mfn != INVALID_P2M_ENTRY); | 502 | BUG_ON(pfn != mfn && mfn != INVALID_P2M_ENTRY); |
503 | return; | 503 | return true; |
504 | } | 504 | } |
505 | 505 | ||
506 | if (unlikely(!__set_phys_to_machine(pfn, mfn))) { | 506 | if (unlikely(!__set_phys_to_machine(pfn, mfn))) { |
507 | WARN(!alloc_p2m(pfn), "Can't allocate p2m for %lx, %lx", pfn, mfn); | 507 | if (!alloc_p2m(pfn)) |
508 | return false; | ||
508 | 509 | ||
509 | if (!__set_phys_to_machine(pfn, mfn)) | 510 | if (!__set_phys_to_machine(pfn, mfn)) |
510 | BUG(); | 511 | return false; |
511 | } | 512 | } |
513 | |||
514 | return true; | ||
512 | } | 515 | } |
513 | 516 | ||
514 | unsigned long arbitrary_virt_to_mfn(void *vaddr) | 517 | unsigned long arbitrary_virt_to_mfn(void *vaddr) |