Lines Matching refs:iter
472 static bool mtrr_lookup_fixed_start(struct mtrr_iter *iter) in mtrr_lookup_fixed_start() argument
476 if (!fixed_mtrr_is_enabled(iter->mtrr_state)) in mtrr_lookup_fixed_start()
479 seg = fixed_mtrr_addr_to_seg(iter->start); in mtrr_lookup_fixed_start()
483 iter->fixed = true; in mtrr_lookup_fixed_start()
484 index = fixed_mtrr_addr_seg_to_range_index(iter->start, seg); in mtrr_lookup_fixed_start()
485 iter->index = index; in mtrr_lookup_fixed_start()
486 iter->seg = seg; in mtrr_lookup_fixed_start()
490 static bool match_var_range(struct mtrr_iter *iter, in match_var_range() argument
496 if (!(start >= iter->end || end <= iter->start)) { in match_var_range()
497 iter->range = range; in match_var_range()
504 iter->partial_map |= iter->start_max < start; in match_var_range()
507 iter->start_max = max(iter->start_max, end); in match_var_range()
514 static void __mtrr_lookup_var_next(struct mtrr_iter *iter) in __mtrr_lookup_var_next() argument
516 struct kvm_mtrr *mtrr_state = iter->mtrr_state; in __mtrr_lookup_var_next()
518 list_for_each_entry_continue(iter->range, &mtrr_state->head, node) in __mtrr_lookup_var_next()
519 if (match_var_range(iter, iter->range)) in __mtrr_lookup_var_next()
522 iter->range = NULL; in __mtrr_lookup_var_next()
523 iter->partial_map |= iter->start_max < iter->end; in __mtrr_lookup_var_next()
526 static void mtrr_lookup_var_start(struct mtrr_iter *iter) in mtrr_lookup_var_start() argument
528 struct kvm_mtrr *mtrr_state = iter->mtrr_state; in mtrr_lookup_var_start()
530 iter->fixed = false; in mtrr_lookup_var_start()
531 iter->start_max = iter->start; in mtrr_lookup_var_start()
532 iter->range = NULL; in mtrr_lookup_var_start()
533 iter->range = list_prepare_entry(iter->range, &mtrr_state->head, node); in mtrr_lookup_var_start()
535 __mtrr_lookup_var_next(iter); in mtrr_lookup_var_start()
538 static void mtrr_lookup_fixed_next(struct mtrr_iter *iter) in mtrr_lookup_fixed_next() argument
541 if (fixed_mtrr_range_end_addr(iter->seg, iter->index) >= iter->end) { in mtrr_lookup_fixed_next()
542 iter->fixed = false; in mtrr_lookup_fixed_next()
543 iter->range = NULL; in mtrr_lookup_fixed_next()
547 iter->index++; in mtrr_lookup_fixed_next()
550 if (iter->index >= ARRAY_SIZE(iter->mtrr_state->fixed_ranges)) in mtrr_lookup_fixed_next()
551 return mtrr_lookup_var_start(iter); in mtrr_lookup_fixed_next()
554 if (iter->index > fixed_mtrr_seg_end_range_index(iter->seg)) in mtrr_lookup_fixed_next()
555 iter->seg++; in mtrr_lookup_fixed_next()
558 static void mtrr_lookup_var_next(struct mtrr_iter *iter) in mtrr_lookup_var_next() argument
560 __mtrr_lookup_var_next(iter); in mtrr_lookup_var_next()
563 static void mtrr_lookup_start(struct mtrr_iter *iter) in mtrr_lookup_start() argument
565 if (!mtrr_is_enabled(iter->mtrr_state)) { in mtrr_lookup_start()
566 iter->mtrr_disabled = true; in mtrr_lookup_start()
570 if (!mtrr_lookup_fixed_start(iter)) in mtrr_lookup_start()
571 mtrr_lookup_var_start(iter); in mtrr_lookup_start()
574 static void mtrr_lookup_init(struct mtrr_iter *iter, in mtrr_lookup_init() argument
577 iter->mtrr_state = mtrr_state; in mtrr_lookup_init()
578 iter->start = start; in mtrr_lookup_init()
579 iter->end = end; in mtrr_lookup_init()
580 iter->mtrr_disabled = false; in mtrr_lookup_init()
581 iter->partial_map = false; in mtrr_lookup_init()
582 iter->fixed = false; in mtrr_lookup_init()
583 iter->range = NULL; in mtrr_lookup_init()
585 mtrr_lookup_start(iter); in mtrr_lookup_init()
588 static bool mtrr_lookup_okay(struct mtrr_iter *iter) in mtrr_lookup_okay() argument
590 if (iter->fixed) { in mtrr_lookup_okay()
591 iter->mem_type = iter->mtrr_state->fixed_ranges[iter->index]; in mtrr_lookup_okay()
595 if (iter->range) { in mtrr_lookup_okay()
596 iter->mem_type = iter->range->base & 0xff; in mtrr_lookup_okay()
603 static void mtrr_lookup_next(struct mtrr_iter *iter) in mtrr_lookup_next() argument
605 if (iter->fixed) in mtrr_lookup_next()
606 mtrr_lookup_fixed_next(iter); in mtrr_lookup_next()
608 mtrr_lookup_var_next(iter); in mtrr_lookup_next()
618 struct mtrr_iter iter; in kvm_mtrr_get_guest_memory_type() local
627 mtrr_for_each_mem_type(&iter, mtrr_state, start, end) { in kvm_mtrr_get_guest_memory_type()
628 int curr_type = iter.mem_type; in kvm_mtrr_get_guest_memory_type()
674 if (iter.mtrr_disabled) in kvm_mtrr_get_guest_memory_type()
685 WARN_ON(iter.partial_map); in kvm_mtrr_get_guest_memory_type()
695 struct mtrr_iter iter; in kvm_mtrr_check_gfn_range_consistency() local
701 mtrr_for_each_mem_type(&iter, mtrr_state, start, end) { in kvm_mtrr_check_gfn_range_consistency()
703 type = iter.mem_type; in kvm_mtrr_check_gfn_range_consistency()
707 if (type != iter.mem_type) in kvm_mtrr_check_gfn_range_consistency()
711 if (iter.mtrr_disabled) in kvm_mtrr_check_gfn_range_consistency()
714 if (!iter.partial_map) in kvm_mtrr_check_gfn_range_consistency()