From: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
To: arjan@linux.intel.com, mingo@elte.hu, tglx@linutronix.de,
hpa@zytor.com, andi@firstfloor.org
Cc: linux-kernel@vger.kernel.org,
Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>,
Suresh Siddha <suresh.b.siddha@intel.com>
Subject: [patch 2/2] x86: Handle error returns in set_memory_*
Date: Fri, 12 Sep 2008 17:00:05 -0700 [thread overview]
Message-ID: <20080913000051.970641000@linux-os.sc.intel.com> (raw)
In-Reply-To: 20080913000003.732756000@linux-os.sc.intel.com
[-- Attachment #1: set_memory_errors.patch --]
[-- Type: text/plain, Size: 2676 bytes --]
Correctly handle the error returns from set_memory_*. We have to free memtype
on error return path.
Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
---
arch/x86/mm/pageattr.c | 35 ++++++++++++++++++++++++++++-------
1 file changed, 28 insertions(+), 7 deletions(-)
Index: tip/arch/x86/mm/pageattr.c
===================================================================
--- tip.orig/arch/x86/mm/pageattr.c 2008-09-12 16:03:36.000000000 -0700
+++ tip/arch/x86/mm/pageattr.c 2008-09-12 16:31:12.000000000 -0700
@@ -929,6 +929,8 @@ int _set_memory_uc(unsigned long addr, i
int set_memory_uc(unsigned long addr, int numpages)
{
+ int ret;
+
/*
* for now UC MINUS. see comments in ioremap_nocache()
*/
@@ -936,13 +938,19 @@ int set_memory_uc(unsigned long addr, in
_PAGE_CACHE_UC_MINUS, NULL))
return -EINVAL;
- return _set_memory_uc(addr, numpages);
+ ret = _set_memory_uc(addr, numpages);
+ if (ret)
+ free_memtype(__pa(addr), __pa(addr) + numpages * PAGE_SIZE);
+
+ return ret;
}
EXPORT_SYMBOL(set_memory_uc);
int set_memory_array_uc(unsigned long *addr, int addrinarray)
{
- unsigned long start;
+ int ret;
+ int reserve_fail = 0;
+ unsigned long start = 0;
unsigned long end;
int i;
/*
@@ -955,17 +963,24 @@ int set_memory_array_uc(unsigned long *a
break;
i++;
}
- if (reserve_memtype(start, end, _PAGE_CACHE_UC_MINUS, NULL))
+ if (reserve_memtype(start, end, _PAGE_CACHE_UC_MINUS, NULL)) {
+ ret = -EINVAL;
+ reserve_fail = 1;
goto out;
+ }
}
- return change_page_attr_set(addr, addrinarray,
+ ret = change_page_attr_set(addr, addrinarray,
__pgprot(_PAGE_CACHE_UC_MINUS), 1);
+
+ if (!ret)
+ return ret;
+
out:
for (i = 0; i < addrinarray; i++) {
unsigned long tmp = __pa(addr[i]);
- if (tmp == start)
+ if (reserve_fail && tmp == start)
break;
for (end = tmp + PAGE_SIZE; i < addrinarray - 1; end += PAGE_SIZE) {
if (end != __pa(addr[i + 1]))
@@ -974,7 +989,7 @@ out:
}
free_memtype(tmp, end);
}
- return -EINVAL;
+ return ret;
}
EXPORT_SYMBOL(set_memory_array_uc);
@@ -986,6 +1001,8 @@ int _set_memory_wc(unsigned long addr, i
int set_memory_wc(unsigned long addr, int numpages)
{
+ int ret;
+
if (!pat_enabled)
return set_memory_uc(addr, numpages);
@@ -993,7 +1010,11 @@ int set_memory_wc(unsigned long addr, in
_PAGE_CACHE_WC, NULL))
return -EINVAL;
- return _set_memory_wc(addr, numpages);
+ ret = _set_memory_wc(addr, numpages);
+ if (ret)
+ free_memtype(__pa(addr), __pa(addr) + numpages * PAGE_SIZE);
+
+ return ret;
}
EXPORT_SYMBOL(set_memory_wc);
--
next prev parent reply other threads:[~2008-09-13 0:11 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-13 0:00 [patch 0/2] PAT fix/optimization Venkatesh Pallipadi
2008-09-13 0:00 ` [patch 1/2] x86: track memtype for RAM in page struct Venkatesh Pallipadi
2008-09-13 17:03 ` Jeremy Fitzhardinge
2008-09-14 13:29 ` Ingo Molnar
2008-09-14 14:18 ` Jeremy Fitzhardinge
2008-09-14 14:22 ` Ingo Molnar
2008-09-23 21:46 ` Venki Pallipadi
2008-09-23 21:59 ` Christoph Lameter
2008-09-24 15:53 ` [patch 1/2] x86: track memtype for RAM in page struct - v3 Venki Pallipadi
2008-09-27 17:59 ` Ingo Molnar
2008-09-30 7:28 ` Nick Piggin
2008-09-30 11:21 ` Ingo Molnar
2008-09-30 21:14 ` Suresh Siddha
2008-10-01 9:29 ` Ingo Molnar
2008-10-02 2:27 ` Nick Piggin
2008-09-13 17:24 ` [patch 1/2] x86: track memtype for RAM in page struct Frans Pop
2008-09-14 14:12 ` Ingo Molnar
2008-09-23 21:48 ` Pallipadi, Venkatesh
2008-09-13 0:00 ` Venkatesh Pallipadi [this message]
2008-09-14 13:27 ` [patch 2/2] x86: Handle error returns in set_memory_* Ingo Molnar
2008-09-14 14:35 ` Frans Pop
2008-09-14 14:10 ` Ingo Molnar
2008-09-30 8:36 ` Frans Pop
2008-09-30 21:29 ` Suresh Siddha
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080913000051.970641000@linux-os.sc.intel.com \
--to=venkatesh.pallipadi@intel.com \
--cc=andi@firstfloor.org \
--cc=arjan@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=suresh.b.siddha@intel.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.