Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 129652
b: refs/heads/master
c: b5db0e3
h: refs/heads/master
v: v3
  • Loading branch information
Linus Torvalds committed Jan 16, 2009
1 parent 8b347ba commit 8469933
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 39 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 647df5189fecb2c2fa811421a3f28bf9034e3a70
refs/heads/master: b5db0e38653bfada34a92f360b4111566ede3842
10 changes: 4 additions & 6 deletions trunk/arch/x86/mm/pageattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -555,12 +555,10 @@ static int __change_page_attr(struct cpa_data *cpa, int primary)
if (!pte_val(old_pte)) {
if (!primary)
return 0;

/*
* Special error value returned, indicating that the mapping
* did not exist at this address.
*/
return -EFAULT;
WARN(1, KERN_WARNING "CPA: called for zero pte. "
"vaddr = %lx cpa->vaddr = %lx\n", address,
*cpa->vaddr);
return -EINVAL;
}

if (level == PG_LEVEL_4K) {
Expand Down
45 changes: 13 additions & 32 deletions trunk/arch/x86/mm/pat.c
Original file line number Diff line number Diff line change
Expand Up @@ -505,35 +505,6 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
}
#endif /* CONFIG_STRICT_DEVMEM */

/*
* Change the memory type for the physial address range in kernel identity
* mapping space if that range is a part of identity map.
*/
static int kernel_map_sync_memtype(u64 base, unsigned long size,
unsigned long flags)
{
unsigned long id_sz;
int ret;

if (!pat_enabled || base >= __pa(high_memory))
return 0;

id_sz = (__pa(high_memory) < base + size) ?
__pa(high_memory) - base :
size;

ret = ioremap_change_attr((unsigned long)__va(base), id_sz, flags);
/*
* -EFAULT return means that the addr was not valid and did not have
* any identity mapping. That case is a success for
* kernel_map_sync_memtype.
*/
if (ret == -EFAULT)
ret = 0;

return ret;
}

int phys_mem_access_prot_allowed(struct file *file, unsigned long pfn,
unsigned long size, pgprot_t *vma_prot)
{
Expand Down Expand Up @@ -584,7 +555,9 @@ int phys_mem_access_prot_allowed(struct file *file, unsigned long pfn,
if (retval < 0)
return 0;

if (kernel_map_sync_memtype(offset, size, flags)) {
if (((pfn < max_low_pfn_mapped) ||
(pfn >= (1UL<<(32 - PAGE_SHIFT)) && pfn < max_pfn_mapped)) &&
ioremap_change_attr((unsigned long)__va(offset), size, flags) < 0) {
free_memtype(offset, offset + size);
printk(KERN_INFO
"%s:%d /dev/mem ioremap_change_attr failed %s for %Lx-%Lx\n",
Expand Down Expand Up @@ -632,7 +605,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
int strict_prot)
{
int is_ram = 0;
int ret;
int id_sz, ret;
unsigned long flags;
unsigned long want_flags = (pgprot_val(*vma_prot) & _PAGE_CACHE_MASK);

Expand Down Expand Up @@ -673,7 +646,15 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
flags);
}

if (kernel_map_sync_memtype(paddr, size, flags)) {
/* Need to keep identity mapping in sync */
if (paddr >= __pa(high_memory))
return 0;

id_sz = (__pa(high_memory) < paddr + size) ?
__pa(high_memory) - paddr :
size;

if (ioremap_change_attr((unsigned long)__va(paddr), id_sz, flags) < 0) {
free_memtype(paddr, paddr + size);
printk(KERN_ERR
"%s:%d reserve_pfn_range ioremap_change_attr failed %s "
Expand Down

0 comments on commit 8469933

Please sign in to comment.