Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 54514
b: refs/heads/master
c: 6d40fc5
h: refs/heads/master
v: v3
  • Loading branch information
Bjorn Helgaas authored and Tony Luck committed Mar 30, 2007
1 parent 960d583 commit 692cf64
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 4 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: 2cb22e23a5fcbcac2de49493aa57c7694028a06a
refs/heads/master: 6d40fc514c9ea886dc18ddd20043a411816b63d1
46 changes: 43 additions & 3 deletions trunk/arch/ia64/kernel/efi.c
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,29 @@ efi_memory_descriptor (unsigned long phys_addr)
return NULL;
}

static int
efi_memmap_intersects (unsigned long phys_addr, unsigned long size)
{
void *efi_map_start, *efi_map_end, *p;
efi_memory_desc_t *md;
u64 efi_desc_size;
unsigned long end;

efi_map_start = __va(ia64_boot_param->efi_memmap);
efi_map_end = efi_map_start + ia64_boot_param->efi_memmap_size;
efi_desc_size = ia64_boot_param->efi_memdesc_size;

end = phys_addr + size;

for (p = efi_map_start; p < efi_map_end; p += efi_desc_size) {
md = p;

if (md->phys_addr < end && efi_md_end(md) > phys_addr)
return 1;
}
return 0;
}

u32
efi_mem_type (unsigned long phys_addr)
{
Expand Down Expand Up @@ -766,11 +789,28 @@ valid_phys_addr_range (unsigned long phys_addr, unsigned long size)
int
valid_mmap_phys_addr_range (unsigned long pfn, unsigned long size)
{
unsigned long phys_addr = pfn << PAGE_SHIFT;
u64 attr;

attr = efi_mem_attribute(phys_addr, size);

/*
* MMIO regions are often missing from the EFI memory map.
* We must allow mmap of them for programs like X, so we
* currently can't do any useful validation.
* /dev/mem mmap uses normal user pages, so we don't need the entire
* granule, but the entire region we're mapping must support the same
* attribute.
*/
if (attr & EFI_MEMORY_WB || attr & EFI_MEMORY_UC)
return 1;

/*
* Intel firmware doesn't tell us about all the MMIO regions, so
* in general we have to allow mmap requests. But if EFI *does*
* tell us about anything inside this region, we should deny it.
* The user can always map a smaller region to avoid the overlap.
*/
if (efi_memmap_intersects(phys_addr, size))
return 0;

return 1;
}

Expand Down

0 comments on commit 692cf64

Please sign in to comment.