Re: [Xen-devel] [PATCH 2/2] x86: add pte_set_flags/clear_flags for pteflag manipulation

From: Jan Beulich
Date: Fri Jan 23 2009 - 03:13:48 EST


>>> Jeremy Fitzhardinge <jeremy@xxxxxxxx> 22.01.09 23:24 >>>
>+static inline pte_t pte_set_flags(pte_t pte, pteval_t set)
>+{
>+ pteval_t v = native_pte_val(pte);
>+
>+ return native_make_pte(v | set);
>+}
>+
>+static inline pte_t pte_clear_flags(pte_t pte, pteval_t clear)
>+{
>+ pteval_t v = native_pte_val(pte);
>+
>+ return native_make_pte(v & ~clear);
>+}

I think a comment (or event a BUG_ON()) should be added here to make
clear that this absolutely must not be used to toggle the present bit. I
even view toggling _PAGE_PSE as dangerous this way.

And alternative would be to make these macros and #undef them (or keep
them inline functions but add destructive #define-s) after all their users.

Jan

--
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/