ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 2)
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 3) /*
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 4) * Xen memory reservation utilities.
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 5) *
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 6) * Copyright (c) 2003, B Dragovic
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 7) * Copyright (c) 2003-2004, M Williamson, K Fraser
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 8) * Copyright (c) 2005 Dan M. Smith, IBM Corporation
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 9) * Copyright (c) 2010 Daniel Kiper
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 10) * Copyright (c) 2018 Oleksandr Andrushchenko, EPAM Systems Inc.
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 11) */
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 12)
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 13) #ifndef _XENMEM_RESERVATION_H
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 14) #define _XENMEM_RESERVATION_H
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 15)
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 16) #include <linux/highmem.h>
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 17)
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 18) #include <xen/page.h>
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 19)
197ecb3802c04 (Marek Marczykowski-Górecki 2018-09-07 18:49:08 +0200 20) extern bool xen_scrub_pages;
197ecb3802c04 (Marek Marczykowski-Górecki 2018-09-07 18:49:08 +0200 21)
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 22) static inline void xenmem_reservation_scrub_page(struct page *page)
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 23) {
197ecb3802c04 (Marek Marczykowski-Górecki 2018-09-07 18:49:08 +0200 24) if (xen_scrub_pages)
197ecb3802c04 (Marek Marczykowski-Górecki 2018-09-07 18:49:08 +0200 25) clear_highpage(page);
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 26) }
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 27)
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 28) #ifdef CONFIG_XEN_HAVE_PVMMU
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 29) void __xenmem_reservation_va_mapping_update(unsigned long count,
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 30) struct page **pages,
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 31) xen_pfn_t *frames);
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 32)
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 33) void __xenmem_reservation_va_mapping_reset(unsigned long count,
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 34) struct page **pages);
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 35) #endif
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 36)
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 37) static inline void xenmem_reservation_va_mapping_update(unsigned long count,
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 38) struct page **pages,
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 39) xen_pfn_t *frames)
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 40) {
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 41) #ifdef CONFIG_XEN_HAVE_PVMMU
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 42) if (!xen_feature(XENFEAT_auto_translated_physmap))
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 43) __xenmem_reservation_va_mapping_update(count, pages, frames);
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 44) #endif
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 45) }
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 46)
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 47) static inline void xenmem_reservation_va_mapping_reset(unsigned long count,
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 48) struct page **pages)
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 49) {
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 50) #ifdef CONFIG_XEN_HAVE_PVMMU
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 51) if (!xen_feature(XENFEAT_auto_translated_physmap))
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 52) __xenmem_reservation_va_mapping_reset(count, pages);
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 53) #endif
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 54) }
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 55)
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 56) int xenmem_reservation_increase(int count, xen_pfn_t *frames);
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 57)
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 58) int xenmem_reservation_decrease(int count, xen_pfn_t *frames);
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 59)
ae4c51a50c990 (Oleksandr Andrushchenko 2018-07-20 12:01:44 +0300 60) #endif