Re: [RFC v2][PATCH 1/1] intel_txt: Intel(R) TXT and tboot kernel support II

From: Andi Kleen
Date: Sat Apr 18 2009 - 16:47:21 EST


Andi Kleen <andi@xxxxxxxxxxxxxx> writes:
>> + set_pte_at(&tboot_mm, vaddr, pte, pfn_pte(pfn, prot));
>> + pte_unmap(pte);
>> + return 0;
>> +}
>> +
>> +static int map_pages_for_tboot(unsigned long vaddr, unsigned long start_pfn,
>> + unsigned long nr)
>> +{
>> + /* Reuse the original kernel mapping */
>> + tboot_pg_dir = pgd_alloc(&tboot_mm);
>
> That puts the PGD into the pgd_list and then pageattr.c will actually
> walk that list and change ptes, assuming it's a standard kernel
> mapping. Can you tolerate that? It seems dangerous. Better to use
> a pgd_alloc_kernel(). There's none, but you could add one.

Thought some more about this. I think you're ok on 64bit at least
because the kernel mappings are elsewhere from the identity map and
keeping them in sync with pageattr makes sense and avoids illegal
cache attribute aliases.

But on 32bit it could be potentially a problem in general. e.g.
what happens when the tboot shared page is in the area the kernel
is running? You would crash during the window where you run
in that pgd.

It would be probably safer to use a low memory trampoline supplied
by the kernel too that then loads the new pgd.

-Andi

--
ak@xxxxxxxxxxxxxxx -- Speaking for myself only.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/