[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] mm: introduce a helper to get the memory type of a page
commit 7f855b514146478dfdd1f796ed5578a138164d11 Author: Roger Pau Monné <roger.pau@xxxxxxxxxx> AuthorDate: Fri Sep 7 11:08:00 2018 +0200 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Wed Sep 12 16:32:06 2018 +0200 mm: introduce a helper to get the memory type of a page Returns all the memory types applicable to a page. This function is unimplemented for ARM. Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx> Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx> --- xen/arch/x86/mm.c | 42 ++++++++++++++++++++++++++++++++++++++++++ xen/include/xen/mm.h | 3 +++ 2 files changed, 45 insertions(+) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index baea2f5e63..d37eea53d1 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -430,6 +430,48 @@ int page_is_ram_type(unsigned long mfn, unsigned long mem_type) return 0; } +unsigned int page_get_ram_type(mfn_t mfn) +{ + uint64_t last = 0, maddr = mfn_to_maddr(mfn); + unsigned int i, type = 0; + + for ( i = 0; i < e820.nr_map; + last = e820.map[i].addr + e820.map[i].size, i++ ) + { + if ( (maddr + PAGE_SIZE) > last && maddr < e820.map[i].addr ) + type |= RAM_TYPE_UNKNOWN; + + if ( (maddr + PAGE_SIZE) <= e820.map[i].addr || + maddr >= (e820.map[i].addr + e820.map[i].size) ) + continue; + + switch ( e820.map[i].type ) + { + case E820_RAM: + type |= RAM_TYPE_CONVENTIONAL; + break; + + case E820_RESERVED: + type |= RAM_TYPE_RESERVED; + break; + + case E820_UNUSABLE: + type |= RAM_TYPE_UNUSABLE; + break; + + case E820_ACPI: + case E820_NVS: + type |= RAM_TYPE_ACPI; + break; + + default: + ASSERT_UNREACHABLE(); + } + } + + return type ?: RAM_TYPE_UNKNOWN; +} + unsigned long domain_get_maximum_gpfn(struct domain *d) { if ( is_hvm_domain(d) ) diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index 24654e8e22..b3d46ab56b 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -595,8 +595,11 @@ int __must_check donate_page(struct domain *d, struct page_info *page, #define RAM_TYPE_RESERVED 0x00000002 #define RAM_TYPE_UNUSABLE 0x00000004 #define RAM_TYPE_ACPI 0x00000008 +#define RAM_TYPE_UNKNOWN 0x00000010 /* TRUE if the whole page at @mfn is of the requested RAM type(s) above. */ int page_is_ram_type(unsigned long mfn, unsigned long mem_type); +/* Returns the page type(s). */ +unsigned int page_get_ram_type(mfn_t mfn); /* Prepare/destroy a ring for a dom0 helper. Helper with talk * with Xen on behalf of this domain. */ -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |