[PATCH v2 1/2] x86/mm: expose lookup_memtype()

From: Haozhong Zhang
Date: Tue Oct 31 2017 - 07:48:45 EST


KVM MMU will use it to get the cache mode of the host page.

Signed-off-by: Haozhong Zhang <haozhong.zhang@xxxxxxxxx>
---
arch/x86/include/asm/pat.h | 2 ++
arch/x86/mm/pat.c | 3 ++-
2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/pat.h b/arch/x86/include/asm/pat.h
index fffb2794dd89..990d955972b8 100644
--- a/arch/x86/include/asm/pat.h
+++ b/arch/x86/include/asm/pat.h
@@ -21,4 +21,6 @@ int io_reserve_memtype(resource_size_t start, resource_size_t end,

void io_free_memtype(resource_size_t start, resource_size_t end);

+enum page_cache_mode lookup_memtype(u64 paddr);
+
#endif /* _ASM_X86_PAT_H */
diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
index fe7d57a8fb60..e85987aaf5d5 100644
--- a/arch/x86/mm/pat.c
+++ b/arch/x86/mm/pat.c
@@ -650,7 +650,7 @@ int free_memtype(u64 start, u64 end)
* Returns _PAGE_CACHE_MODE_WB, _PAGE_CACHE_MODE_WC, _PAGE_CACHE_MODE_UC_MINUS
* or _PAGE_CACHE_MODE_WT.
*/
-static enum page_cache_mode lookup_memtype(u64 paddr)
+enum page_cache_mode lookup_memtype(u64 paddr)
{
enum page_cache_mode rettype = _PAGE_CACHE_MODE_WB;
struct memtype *entry;
@@ -676,6 +676,7 @@ static enum page_cache_mode lookup_memtype(u64 paddr)
spin_unlock(&memtype_lock);
return rettype;
}
+EXPORT_SYMBOL_GPL(lookup_memtype);

/**
* io_reserve_memtype - Request a memory type mapping for a region of memory
--
2.14.1