This patch rolls back some of the changes introduced by commit 121f2faca2c0a "xen/balloon: rename alloc/free_xenballooned_pages" in order to make possible to still allocate xenballooned pages if CONFIG_XEN_UNPOPULATED_ALLOC is enabled. On Arm the unpopulated pages will be allocated on top of extended regions provided by Xen via device-tree (the subsequent patches will add required bits to support unpopulated-alloc feature on Arm). The problem is that extended regions feature has been introduced into Xen quite recently (during 4.16 release cycle). So this effectively means that Linux must only use unpopulated-alloc on Arm if it is running on "new Xen" which advertises these regions. But, it will only be known after parsing the "hypervisor" node at boot time, so before doing that we cannot assume anything. In order to keep working if CONFIG_XEN_UNPOPULATED_ALLOC is enabled and the extended regions are not advertised (Linux is running on "old Xen", etc) we need the fallback to alloc_xenballooned_pages(). This way we wouldn't reduce the amount of memory usable (wasting RAM pages) for any of the external mappings anymore (and eliminate XSA-300) with "new Xen", but would be still functional ballooning out RAM pages with "old Xen". Also rename alloc(free)_xenballooned_pages to xen_alloc(free)_ballooned_pages and make xen_alloc(free)_unpopulated_pages static inline in xen.h if CONFIG_XEN_UNPOPULATED_ALLOC is disabled.
Showing the changes to include (2 of 3 files). Show all
Unified · Split
| @@ -26,6 +26,9 @@ extern struct balloon_stats balloon_stats; · 25 unmodified lines | |||
| 26 | 26 | ||
| 27 | void balloon_set_new_target(unsigned long target); | 27 | void balloon_set_new_target(unsigned long target); |
| 28 | 28 | ||
| 29 | int xen_alloc_ballooned_pages(unsigned int nr_pages, struct page **pages); | ||
| 30 | void xen_free_ballooned_pages(unsigned int nr_pages, struct page **pages); | ||
| 31 | |||
| 29 | #ifdef CONFIG_XEN_BALLOON | 32 | #ifdef CONFIG_XEN_BALLOON |
| 30 | void xen_balloon_init(void); | 33 | void xen_balloon_init(void); |
| 31 | #else | 34 | #else |
| @@ -52,7 +52,21 @@ bool xen_biovec_phys_mergeable(const struct bio_vec *vec1, · 51 unmodified lines | |||
| 52 | extern u64 xen_saved_max_mem_size; | 52 | extern u64 xen_saved_max_mem_size; |
| 53 | #endif | 53 | #endif |
| 54 | 54 | ||
| 55 | #ifdef CONFIG_XEN_UNPOPULATED_ALLOC | ||
| 55 | int xen_alloc_unpopulated_pages(unsigned int nr_pages, struct page **pages); | 56 | int xen_alloc_unpopulated_pages(unsigned int nr_pages, struct page **pages); |
| 56 | void xen_free_unpopulated_pages(unsigned int nr_pages, struct page **pages); | 57 | void xen_free_unpopulated_pages(unsigned int nr_pages, struct page **pages); |
| 58 | #else | ||
| 59 | #include <xen/balloon.h> | ||
| 60 | static inline int xen_alloc_unpopulated_pages(unsigned int nr_pages, | ||
| 61 | struct page **pages) | ||
| 62 | { | ||
| 63 | return xen_alloc_ballooned_pages(nr_pages, pages); | ||
| 64 | } | ||
| 65 | static inline void xen_free_unpopulated_pages(unsigned int nr_pages, | ||
| 66 | struct page **pages) | ||
| 67 | { | ||
| 68 | xen_free_ballooned_pages(nr_pages, pages); | ||
| 69 | } | ||
| 70 | #endif | ||
| 57 | 71 | ||
| 58 | #endif /* _XEN_XEN_H */ | 72 | #endif /* _XEN_XEN_H */ |