Skip to content

Commit

Permalink
x86, PAT: Change order of cpa and free in set_memory_wb
Browse files Browse the repository at this point in the history
To be free of aliasing due to races, set_memory_* interfaces should
follow ordering of reserving, changing memtype to UC/WC, changing
memtype back to WB followed by free.

Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
LKML-Reference: <20090409212708.512280000@intel.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
venkatesh.pallipadi@intel.com authored and Ingo Molnar committed Apr 10, 2009
1 parent 43a432b commit a5593e0
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions arch/x86/mm/pageattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1021,15 +1021,19 @@ int _set_memory_wb(unsigned long addr, int numpages)

int set_memory_wb(unsigned long addr, int numpages)
{
int ret = _set_memory_wb(addr, numpages);
free_memtype(__pa(addr), __pa(addr) + numpages * PAGE_SIZE);

return _set_memory_wb(addr, numpages);
return ret;
}
EXPORT_SYMBOL(set_memory_wb);

int set_memory_array_wb(unsigned long *addr, int addrinarray)
{
int i;
int ret;

ret = change_page_attr_clear(addr, addrinarray,
__pgprot(_PAGE_CACHE_MASK), 1);

for (i = 0; i < addrinarray; i++) {
unsigned long start = __pa(addr[i]);
Expand All @@ -1042,8 +1046,7 @@ int set_memory_array_wb(unsigned long *addr, int addrinarray)
}
free_memtype(start, end);
}
return change_page_attr_clear(addr, addrinarray,
__pgprot(_PAGE_CACHE_MASK), 1);
return ret;
}
EXPORT_SYMBOL(set_memory_array_wb);

Expand Down

0 comments on commit a5593e0

Please sign in to comment.