···27 int flushtlb;28};2930-enum {31- CPA_NO_SPLIT = 0,32- CPA_SPLIT,33-};34-35static inline int36within(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;262263 /*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;273274 spin_lock_irqsave(&pgd_lock, flags);275 /*···292 break;293#endif294 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 }345346out_unlock:347 spin_unlock_irqrestore(&pgd_lock, flags);348349- return res;350}351352static int split_large_page(pte_t *kpte, unsigned long address)···424static 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;429430repeat:···475 * Check, whether we can keep the large page intact476 * and just change the pte:477 */478- res = try_preserve_large_page(kpte, address, cpa);479- if (res < 0)480- return res;481482 /*483 * When the range fits into the existing large page,484 * return. cp->numpages and cpa->tlbflush have been updated in485 * try_large_page:486 */487- if (res == CPA_NO_SPLIT)488 return 0;489490 /*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;0497 goto repeat;498}499
···27 int flushtlb;28};290000030static inline int31within(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;267268 /*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;278279 spin_lock_irqsave(&pgd_lock, flags);280 /*···297 break;298#endif299 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 }350351out_unlock:352 spin_unlock_irqrestore(&pgd_lock, flags);353354+ return do_split;355}356357static int split_large_page(pte_t *kpte, unsigned long address)···429static 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;434435repeat:···480 * Check, whether we can keep the large page intact481 * 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;486487 /*488 * When the range fits into the existing large page,489 * return. cp->numpages and cpa->tlbflush have been updated in490 * try_large_page:491 */492+ if (do_split == 0)493 return 0;494495 /*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