Lines Matching refs:iter
471 static bool mtrr_lookup_fixed_start(struct mtrr_iter *iter) in mtrr_lookup_fixed_start() argument
475 if (!fixed_mtrr_is_enabled(iter->mtrr_state)) in mtrr_lookup_fixed_start()
478 seg = fixed_mtrr_addr_to_seg(iter->start); in mtrr_lookup_fixed_start()
482 iter->fixed = true; in mtrr_lookup_fixed_start()
483 index = fixed_mtrr_addr_seg_to_range_index(iter->start, seg); in mtrr_lookup_fixed_start()
484 iter->index = index; in mtrr_lookup_fixed_start()
485 iter->seg = seg; in mtrr_lookup_fixed_start()
489 static bool match_var_range(struct mtrr_iter *iter, in match_var_range() argument
495 if (!(start >= iter->end || end <= iter->start)) { in match_var_range()
496 iter->range = range; in match_var_range()
503 iter->partial_map |= iter->start_max < start; in match_var_range()
506 iter->start_max = max(iter->start_max, end); in match_var_range()
513 static void __mtrr_lookup_var_next(struct mtrr_iter *iter) in __mtrr_lookup_var_next() argument
515 struct kvm_mtrr *mtrr_state = iter->mtrr_state; in __mtrr_lookup_var_next()
517 list_for_each_entry_continue(iter->range, &mtrr_state->head, node) in __mtrr_lookup_var_next()
518 if (match_var_range(iter, iter->range)) in __mtrr_lookup_var_next()
521 iter->range = NULL; in __mtrr_lookup_var_next()
522 iter->partial_map |= iter->start_max < iter->end; in __mtrr_lookup_var_next()
525 static void mtrr_lookup_var_start(struct mtrr_iter *iter) in mtrr_lookup_var_start() argument
527 struct kvm_mtrr *mtrr_state = iter->mtrr_state; in mtrr_lookup_var_start()
529 iter->fixed = false; in mtrr_lookup_var_start()
530 iter->start_max = iter->start; in mtrr_lookup_var_start()
531 iter->range = NULL; in mtrr_lookup_var_start()
532 iter->range = list_prepare_entry(iter->range, &mtrr_state->head, node); in mtrr_lookup_var_start()
534 __mtrr_lookup_var_next(iter); in mtrr_lookup_var_start()
537 static void mtrr_lookup_fixed_next(struct mtrr_iter *iter) in mtrr_lookup_fixed_next() argument
540 if (fixed_mtrr_range_end_addr(iter->seg, iter->index) >= iter->end) { in mtrr_lookup_fixed_next()
541 iter->fixed = false; in mtrr_lookup_fixed_next()
542 iter->range = NULL; in mtrr_lookup_fixed_next()
546 iter->index++; in mtrr_lookup_fixed_next()
549 if (iter->index >= ARRAY_SIZE(iter->mtrr_state->fixed_ranges)) in mtrr_lookup_fixed_next()
550 return mtrr_lookup_var_start(iter); in mtrr_lookup_fixed_next()
553 if (iter->index > fixed_mtrr_seg_end_range_index(iter->seg)) in mtrr_lookup_fixed_next()
554 iter->seg++; in mtrr_lookup_fixed_next()
557 static void mtrr_lookup_var_next(struct mtrr_iter *iter) in mtrr_lookup_var_next() argument
559 __mtrr_lookup_var_next(iter); in mtrr_lookup_var_next()
562 static void mtrr_lookup_start(struct mtrr_iter *iter) in mtrr_lookup_start() argument
564 if (!mtrr_is_enabled(iter->mtrr_state)) { in mtrr_lookup_start()
565 iter->mtrr_disabled = true; in mtrr_lookup_start()
569 if (!mtrr_lookup_fixed_start(iter)) in mtrr_lookup_start()
570 mtrr_lookup_var_start(iter); in mtrr_lookup_start()
573 static void mtrr_lookup_init(struct mtrr_iter *iter, in mtrr_lookup_init() argument
576 iter->mtrr_state = mtrr_state; in mtrr_lookup_init()
577 iter->start = start; in mtrr_lookup_init()
578 iter->end = end; in mtrr_lookup_init()
579 iter->mtrr_disabled = false; in mtrr_lookup_init()
580 iter->partial_map = false; in mtrr_lookup_init()
581 iter->fixed = false; in mtrr_lookup_init()
582 iter->range = NULL; in mtrr_lookup_init()
584 mtrr_lookup_start(iter); in mtrr_lookup_init()
587 static bool mtrr_lookup_okay(struct mtrr_iter *iter) in mtrr_lookup_okay() argument
589 if (iter->fixed) { in mtrr_lookup_okay()
590 iter->mem_type = iter->mtrr_state->fixed_ranges[iter->index]; in mtrr_lookup_okay()
594 if (iter->range) { in mtrr_lookup_okay()
595 iter->mem_type = iter->range->base & 0xff; in mtrr_lookup_okay()
602 static void mtrr_lookup_next(struct mtrr_iter *iter) in mtrr_lookup_next() argument
604 if (iter->fixed) in mtrr_lookup_next()
605 mtrr_lookup_fixed_next(iter); in mtrr_lookup_next()
607 mtrr_lookup_var_next(iter); in mtrr_lookup_next()
617 struct mtrr_iter iter; in kvm_mtrr_get_guest_memory_type() local
626 mtrr_for_each_mem_type(&iter, mtrr_state, start, end) { in kvm_mtrr_get_guest_memory_type()
627 int curr_type = iter.mem_type; in kvm_mtrr_get_guest_memory_type()
673 if (iter.mtrr_disabled) in kvm_mtrr_get_guest_memory_type()
684 WARN_ON(iter.partial_map); in kvm_mtrr_get_guest_memory_type()
694 struct mtrr_iter iter; in kvm_mtrr_check_gfn_range_consistency() local
700 mtrr_for_each_mem_type(&iter, mtrr_state, start, end) { in kvm_mtrr_check_gfn_range_consistency()
702 type = iter.mem_type; in kvm_mtrr_check_gfn_range_consistency()
706 if (type != iter.mem_type) in kvm_mtrr_check_gfn_range_consistency()
710 if (iter.mtrr_disabled) in kvm_mtrr_check_gfn_range_consistency()
713 if (!iter.partial_map) in kvm_mtrr_check_gfn_range_consistency()