diff options
| author | Jeremy Fitzhardinge <jeremy@goop.org> | 2009-01-22 17:24:22 -0500 |
|---|---|---|
| committer | Ingo Molnar <mingo@elte.hu> | 2009-01-22 17:35:21 -0500 |
| commit | 6522869c34664dd5f05a0a327e93915b1281c90d (patch) | |
| tree | b3cacc12b649fc0b597211fab9a3355a0cce2c18 | |
| parent | ab897d2013128f470240a541b31cf5e636984e71 (diff) | |
x86: add pte_set_flags/clear_flags for pte flag manipulation
It's not necessary to deconstruct and reconstruct a pte every time its
flags are being updated. Introduce pte_set_flags and pte_clear_flags
to set and clear flags in a pte. This allows the flag manipulation
code to be inlined, and avoids calls via paravirt-ops.
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
| -rw-r--r-- | arch/x86/include/asm/pgtable.h | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index 06bbcbd66e9c..6ceaef08486f 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h | |||
| @@ -240,64 +240,78 @@ static inline int pmd_large(pmd_t pte) | |||
| 240 | (_PAGE_PSE | _PAGE_PRESENT); | 240 | (_PAGE_PSE | _PAGE_PRESENT); |
| 241 | } | 241 | } |
| 242 | 242 | ||
| 243 | static inline pte_t pte_set_flags(pte_t pte, pteval_t set) | ||
| 244 | { | ||
| 245 | pteval_t v = native_pte_val(pte); | ||
| 246 | |||
| 247 | return native_make_pte(v | set); | ||
| 248 | } | ||
| 249 | |||
| 250 | static inline pte_t pte_clear_flags(pte_t pte, pteval_t clear) | ||
| 251 | { | ||
| 252 | pteval_t v = native_pte_val(pte); | ||
| 253 | |||
| 254 | return native_make_pte(v & ~clear); | ||
| 255 | } | ||
| 256 | |||
| 243 | static inline pte_t pte_mkclean(pte_t pte) | 257 | static inline pte_t pte_mkclean(pte_t pte) |
| 244 | { | 258 | { |
| 245 | return __pte(pte_val(pte) & ~_PAGE_DIRTY); | 259 | return pte_clear_flags(pte, _PAGE_DIRTY); |
| 246 | } | 260 | } |
| 247 | 261 | ||
| 248 | static inline pte_t pte_mkold(pte_t pte) | 262 | static inline pte_t pte_mkold(pte_t pte) |
| 249 | { | 263 | { |
| 250 | return __pte(pte_val(pte) & ~_PAGE_ACCESSED); | 264 | return pte_clear_flags(pte, _PAGE_ACCESSED); |
| 251 | } | 265 | } |
| 252 | 266 | ||
| 253 | static inline pte_t pte_wrprotect(pte_t pte) | 267 | static inline pte_t pte_wrprotect(pte_t pte) |
| 254 | { | 268 | { |
| 255 | return __pte(pte_val(pte) & ~_PAGE_RW); | 269 | return pte_clear_flags(pte, _PAGE_RW); |
| 256 | } | 270 | } |
| 257 | 271 | ||
| 258 | static inline pte_t pte_mkexec(pte_t pte) | 272 | static inline pte_t pte_mkexec(pte_t pte) |
| 259 | { | 273 | { |
| 260 | return __pte(pte_val(pte) & ~_PAGE_NX); | 274 | return pte_clear_flags(pte, _PAGE_NX); |
| 261 | } | 275 | } |
| 262 | 276 | ||
| 263 | static inline pte_t pte_mkdirty(pte_t pte) | 277 | static inline pte_t pte_mkdirty(pte_t pte) |
| 264 | { | 278 | { |
| 265 | return __pte(pte_val(pte) | _PAGE_DIRTY); | 279 | return pte_set_flags(pte, _PAGE_DIRTY); |
| 266 | } | 280 | } |
| 267 | 281 | ||
| 268 | static inline pte_t pte_mkyoung(pte_t pte) | 282 | static inline pte_t pte_mkyoung(pte_t pte) |
| 269 | { | 283 | { |
| 270 | return __pte(pte_val(pte) | _PAGE_ACCESSED); | 284 | return pte_set_flags(pte, _PAGE_ACCESSED); |
| 271 | } | 285 | } |
| 272 | 286 | ||
| 273 | static inline pte_t pte_mkwrite(pte_t pte) | 287 | static inline pte_t pte_mkwrite(pte_t pte) |
| 274 | { | 288 | { |
| 275 | return __pte(pte_val(pte) | _PAGE_RW); | 289 | return pte_set_flags(pte, _PAGE_RW); |
| 276 | } | 290 | } |
| 277 | 291 | ||
| 278 | static inline pte_t pte_mkhuge(pte_t pte) | 292 | static inline pte_t pte_mkhuge(pte_t pte) |
| 279 | { | 293 | { |
| 280 | return __pte(pte_val(pte) | _PAGE_PSE); | 294 | return pte_set_flags(pte, _PAGE_PSE); |
| 281 | } | 295 | } |
| 282 | 296 | ||
| 283 | static inline pte_t pte_clrhuge(pte_t pte) | 297 | static inline pte_t pte_clrhuge(pte_t pte) |
| 284 | { | 298 | { |
| 285 | return __pte(pte_val(pte) & ~_PAGE_PSE); | 299 | return pte_clear_flags(pte, _PAGE_PSE); |
| 286 | } | 300 | } |
| 287 | 301 | ||
| 288 | static inline pte_t pte_mkglobal(pte_t pte) | 302 | static inline pte_t pte_mkglobal(pte_t pte) |
| 289 | { | 303 | { |
| 290 | return __pte(pte_val(pte) | _PAGE_GLOBAL); | 304 | return pte_set_flags(pte, _PAGE_GLOBAL); |
| 291 | } | 305 | } |
| 292 | 306 | ||
| 293 | static inline pte_t pte_clrglobal(pte_t pte) | 307 | static inline pte_t pte_clrglobal(pte_t pte) |
| 294 | { | 308 | { |
| 295 | return __pte(pte_val(pte) & ~_PAGE_GLOBAL); | 309 | return pte_clear_flags(pte, _PAGE_GLOBAL); |
| 296 | } | 310 | } |
| 297 | 311 | ||
| 298 | static inline pte_t pte_mkspecial(pte_t pte) | 312 | static inline pte_t pte_mkspecial(pte_t pte) |
| 299 | { | 313 | { |
| 300 | return __pte(pte_val(pte) | _PAGE_SPECIAL); | 314 | return pte_set_flags(pte, _PAGE_SPECIAL); |
| 301 | } | 315 | } |
| 302 | 316 | ||
| 303 | extern pteval_t __supported_pte_mask; | 317 | extern pteval_t __supported_pte_mask; |
