x86: cpa, eliminate CPA_ enum

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

+15 -19
+15 -19
arch/x86/mm/pageattr.c
··· 27 int flushtlb; 28 }; 29 30 - enum { 31 - CPA_NO_SPLIT = 0, 32 - CPA_SPLIT, 33 - }; 34 - 35 static inline int 36 within(unsigned long addr, unsigned long start, unsigned long end) 37 { ··· 258 unsigned long nextpage_addr, numpages, pmask, psize, flags; 259 pte_t new_pte, old_pte, *tmp; 260 pgprot_t old_prot, new_prot; 261 - int level, res = CPA_SPLIT; 262 263 /* 264 * An Athlon 64 X2 showed hard hangs if we tried to preserve ··· 269 * disable this code until the hang can be debugged: 270 */ 271 if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) 272 - return res; 273 274 spin_lock_irqsave(&pgd_lock, flags); 275 /* ··· 292 break; 293 #endif 294 default: 295 - res = -EINVAL; 296 goto out_unlock; 297 } 298 ··· 320 * above: 321 */ 322 if (pgprot_val(new_prot) == pgprot_val(old_prot)) { 323 - res = CPA_NO_SPLIT; 324 goto out_unlock; 325 } 326 ··· 340 new_pte = pfn_pte(pte_pfn(old_pte), canon_pgprot(new_prot)); 341 __set_pmd_pte(kpte, address, new_pte); 342 cpa->flushtlb = 1; 343 - res = CPA_NO_SPLIT; 344 } 345 346 out_unlock: 347 spin_unlock_irqrestore(&pgd_lock, flags); 348 349 - return res; 350 } 351 352 static int split_large_page(pte_t *kpte, unsigned long address) ··· 424 static int __change_page_attr(unsigned long address, struct cpa_data *cpa) 425 { 426 struct page *kpte_page; 427 - int level, res; 428 pte_t *kpte; 429 430 repeat: ··· 475 * Check, whether we can keep the large page intact 476 * and just change the pte: 477 */ 478 - res = try_preserve_large_page(kpte, address, cpa); 479 - if (res < 0) 480 - return res; 481 482 /* 483 * When the range fits into the existing large page, 484 * return. cp->numpages and cpa->tlbflush have been updated in 485 * try_large_page: 486 */ 487 - if (res == CPA_NO_SPLIT) 488 return 0; 489 490 /* 491 * We have to split the large page: 492 */ 493 - res = split_large_page(kpte, address); 494 - if (res) 495 - return res; 496 cpa->flushtlb = 1; 497 goto repeat; 498 } 499
··· 27 int flushtlb; 28 }; 29 30 static inline int 31 within(unsigned long addr, unsigned long start, unsigned long end) 32 { ··· 263 unsigned long nextpage_addr, numpages, pmask, psize, flags; 264 pte_t new_pte, old_pte, *tmp; 265 pgprot_t old_prot, new_prot; 266 + int level, do_split = 1; 267 268 /* 269 * An Athlon 64 X2 showed hard hangs if we tried to preserve ··· 274 * disable this code until the hang can be debugged: 275 */ 276 if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) 277 + return 1; 278 279 spin_lock_irqsave(&pgd_lock, flags); 280 /* ··· 297 break; 298 #endif 299 default: 300 + do_split = -EINVAL; 301 goto out_unlock; 302 } 303 ··· 325 * above: 326 */ 327 if (pgprot_val(new_prot) == pgprot_val(old_prot)) { 328 + do_split = 0; 329 goto out_unlock; 330 } 331 ··· 345 new_pte = pfn_pte(pte_pfn(old_pte), canon_pgprot(new_prot)); 346 __set_pmd_pte(kpte, address, new_pte); 347 cpa->flushtlb = 1; 348 + do_split = 0; 349 } 350 351 out_unlock: 352 spin_unlock_irqrestore(&pgd_lock, flags); 353 354 + return do_split; 355 } 356 357 static int split_large_page(pte_t *kpte, unsigned long address) ··· 429 static int __change_page_attr(unsigned long address, struct cpa_data *cpa) 430 { 431 struct page *kpte_page; 432 + int level, do_split; 433 pte_t *kpte; 434 435 repeat: ··· 480 * Check, whether we can keep the large page intact 481 * and just change the pte: 482 */ 483 + do_split = try_preserve_large_page(kpte, address, cpa); 484 + if (do_split < 0) 485 + return do_split; 486 487 /* 488 * When the range fits into the existing large page, 489 * return. cp->numpages and cpa->tlbflush have been updated in 490 * try_large_page: 491 */ 492 + if (do_split == 0) 493 return 0; 494 495 /* 496 * We have to split the large page: 497 */ 498 + do_split = split_large_page(kpte, address); 499 + if (do_split) 500 + return do_split; 501 cpa->flushtlb = 1; 502 + 503 goto repeat; 504 } 505