From 92aea447a776f10aad0a2e971b5f2b208a1161d2 Mon Sep 17 00:00:00 2001
From: Karol Herbst <nouveau@karolherbst.de>
Date: Thu, 24 Nov 2016 21:46:27 +0100
Subject: [PATCH] temp hack
---
arch/x86/mm/kmmio.c | 29 +++++++++++++++++++++++------
1 file changed, 23 insertions(+), 6 deletions(-)
@@ -97,11 +97,16 @@ static DEFINE_PER_CPU(struct kmmio_context, kmmio_ctx);
static struct kmmio_probe *get_kmmio_probe(unsigned long addr)
{
struct kmmio_probe *p;
+ struct kmmio_probe *result = NULL;
list_for_each_entry_rcu(p, &kmmio_probes, list) {
- if (addr >= p->addr && addr < (p->addr + p->len))
- return p;
+ if (addr >= p->addr && addr < (p->addr + p->len)) {
+ if (!result)
+ result = p;
+ else
+ printk(KERN_ERR " %s collision detected %lu", __FUNCTION__, addr);
+ }
}
- return NULL;
+ return result;
}
/* You must be holding RCU read lock. */
@@ -109,6 +114,7 @@ static struct kmmio_fault_page *get_kmmio_fault_page(unsigned long addr)
{
struct list_head *head;
struct kmmio_fault_page *f;
+ struct kmmio_fault_page *result = NULL;
unsigned int l;
pte_t *pte = lookup_address(addr, &l);
@@ -116,11 +122,16 @@ static struct kmmio_fault_page *get_kmmio_fault_page(unsigned long addr)
return NULL;
addr &= page_level_mask(l);
head = kmmio_page_list(addr);
+
list_for_each_entry_rcu(f, head, list) {
- if (f->addr == addr)
- return f;
+ if (f->addr == addr) {
+ if (!result)
+ return f;
+ else
+ printk(KERN_ERR " %s collision detected %lu", __FUNCTION__, addr);
+ }
}
- return NULL;
+ return result;
}
static void clear_pmd_presence(pmd_t *pmd, bool clear, pmdval_t *old)
@@ -375,6 +386,7 @@ static int add_kmmio_fault_page(unsigned long addr)
{
struct kmmio_fault_page *f;
+ printk(KERN_WARNING " %s %lx", __FUNCTION__, addr);
f = get_kmmio_fault_page(addr);
if (f) {
if (!f->count)
@@ -406,6 +418,7 @@ static void release_kmmio_fault_page(unsigned long addr,
{
struct kmmio_fault_page *f;
+ printk(KERN_WARNING " %s %lx", __FUNCTION__, addr);
f = get_kmmio_fault_page(addr);
if (!f)
return;
@@ -445,6 +458,8 @@ int register_kmmio_probe(struct kmmio_probe *p)
}
pte = lookup_address(p->addr, &l);
+ printk(KERN_WARNING " %s %lx %u", __FUNCTION__, p->addr, l);
+
if (!pte) {
ret = -EINVAL;
goto out;
@@ -537,6 +552,8 @@ void unregister_kmmio_probe(struct kmmio_probe *p)
if (!pte)
return;
+ printk(KERN_WARNING " %s %lx %u", __FUNCTION__, p->addr, l);
+
spin_lock_irqsave(&kmmio_lock, flags);
while (size < size_lim) {
release_kmmio_fault_page(p->addr + size, &release_list);
--
2.11.0.rc2