Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 113227
b: refs/heads/master
c: a05d2eb
h: refs/heads/master
i:
  113225: 3cff87a
  113223: 3835ba5
v: v3
  • Loading branch information
Jeremy Fitzhardinge authored and Ingo Molnar committed Jul 28, 2008
1 parent 455c026 commit 9054da4
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 11 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: 64f53a0492b4bc11868307990bb8f7c1e0764f89
refs/heads/master: a05d2ebab28011c2f3f520833f4bfdd2fd1b9c02
51 changes: 41 additions & 10 deletions trunk/arch/x86/xen/enlighten.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,24 +325,55 @@ static unsigned long xen_store_tr(void)
return 0;
}

/*
* If 'v' is a vmalloc mapping, then find the linear mapping of the
* page (if any) and also set its protections to match:
*/
static void set_aliased_prot(void *v, pgprot_t prot)
{
int level;
pte_t *ptep;
pte_t pte;
unsigned long pfn;
struct page *page;

ptep = lookup_address((unsigned long)v, &level);
BUG_ON(ptep == NULL);

pfn = pte_pfn(*ptep);
page = pfn_to_page(pfn);

pte = pfn_pte(pfn, prot);

if (HYPERVISOR_update_va_mapping((unsigned long)v, pte, 0))
BUG();

if (!PageHighMem(page)) {
void *av = __va(PFN_PHYS(pfn));

if (av != v)
if (HYPERVISOR_update_va_mapping((unsigned long)av, pte, 0))
BUG();
} else
kmap_flush_unused();
}

static void xen_alloc_ldt(struct desc_struct *ldt, unsigned entries)
{
unsigned pages = roundup(entries * LDT_ENTRY_SIZE, PAGE_SIZE);
void *v = ldt;
const unsigned entries_per_page = PAGE_SIZE / LDT_ENTRY_SIZE;
int i;

for(i = 0; i < pages; i += PAGE_SIZE)
make_lowmem_page_readonly(v + i);
for(i = 0; i < entries; i += entries_per_page)
set_aliased_prot(ldt + i, PAGE_KERNEL_RO);
}

static void xen_free_ldt(struct desc_struct *ldt, unsigned entries)
{
unsigned pages = roundup(entries * LDT_ENTRY_SIZE, PAGE_SIZE);
void *v = ldt;
const unsigned entries_per_page = PAGE_SIZE / LDT_ENTRY_SIZE;
int i;

for(i = 0; i < pages; i += PAGE_SIZE)
make_lowmem_page_readwrite(v + i);
for(i = 0; i < entries; i += entries_per_page)
set_aliased_prot(ldt + i, PAGE_KERNEL);
}

static void xen_set_ldt(const void *addr, unsigned entries)
Expand Down Expand Up @@ -446,7 +477,7 @@ static void xen_write_ldt_entry(struct desc_struct *dt, int entrynum,
const void *ptr)
{
unsigned long lp = (unsigned long)&dt[entrynum];
xmaddr_t mach_lp = virt_to_machine(lp);
xmaddr_t mach_lp = arbitrary_virt_to_machine(lp);
u64 entry = *(u64 *)ptr;

preempt_disable();
Expand Down Expand Up @@ -579,7 +610,7 @@ static void xen_write_gdt_entry(struct desc_struct *dt, int entry,
}

static void xen_load_sp0(struct tss_struct *tss,
struct thread_struct *thread)
struct thread_struct *thread)
{
struct multicall_space mcs = xen_mc_entry(0);
MULTI_stack_switch(mcs.mc, __KERNEL_DS, thread->sp0);
Expand Down

0 comments on commit 9054da4

Please sign in to comment.