Re: [PATCH] x86: create array based interface to change page attribute

Thomas Hellström
2008-04-02T17:58:40Z

Arjan van de Ven wrote:
> Thomas Hellström wrote:
>
> > to fix the long standing uc/wc aliasing issue, provided we
>
> I'm not opposed to a real fix. I am opposed to a bad hack.
>
Great. So a real clean fix involves setting all "default" kernel
mappings either to WC (which will require PAT) or
Unmapped, for a pool of pages used in the graphics tables.

To reduce the number of attribute changes for mappings that are
frequently switched, and also to reduce the number of clflushes, and to
avoid waiting for upcoming wc versions of set_memory_xx, I have a strong
preference for unmapping the pages.

Now is where I need some guidance, because interface design is not my
strong side. I see three possible ways to do this.

1) Use set_memory_np(). Not desirable since we want to be able to use
that function on a single mapping, and not imply other semantics.
2) Have the driver try to find out which "default" mappings the kernel
has set up on a page and call set_memory_np() on each one of them. This
seems very fragile and ugly even to me.
3) Have code in x86/pageattr.c decide which "default" mappings are
present on the given pages and set them all as non-present.
In fact, there is already such a function in pageattr.c:

kernel_map_pages(struct page *pages, int numpages, bool enable);

But it's for debugging purposes only, could we use and export a variant
of this?

I guess I need a hint as to what's considered allowable here, to avoid
spending a lot of time on something that will in the end get rejected
anyway.

Thanks,

Thomas