Lines Matching refs:tdmr
395 static inline u64 tdmr_end(struct tdmr_info *tdmr) in tdmr_end() argument
397 return tdmr->base + tdmr->size; in tdmr_end()
422 struct tdmr_info *tdmr = tdmr_entry(tdmr_list, tdmr_idx); in fill_out_tdmrs() local
432 if (tdmr->size) { in fill_out_tdmrs()
437 if (end <= tdmr_end(tdmr)) in fill_out_tdmrs()
441 if (start < tdmr_end(tdmr)) in fill_out_tdmrs()
442 start = tdmr_end(tdmr); in fill_out_tdmrs()
454 tdmr = tdmr_entry(tdmr_list, tdmr_idx); in fill_out_tdmrs()
457 tdmr->base = start; in fill_out_tdmrs()
458 tdmr->size = end - start; in fill_out_tdmrs()
482 static unsigned long tdmr_get_pamt_sz(struct tdmr_info *tdmr, int pgsz, in tdmr_get_pamt_sz() argument
489 nr_pamt_entries = tdmr->size >> PAGE_SHIFT; in tdmr_get_pamt_sz()
492 nr_pamt_entries = tdmr->size >> PMD_SHIFT; in tdmr_get_pamt_sz()
495 nr_pamt_entries = tdmr->size >> PUD_SHIFT; in tdmr_get_pamt_sz()
514 static int tdmr_get_nid(struct tdmr_info *tdmr, struct list_head *tmb_list) in tdmr_get_nid() argument
525 if (tmb->end_pfn > PHYS_PFN(tdmr->base)) in tdmr_get_nid()
535 tdmr->base, tdmr_end(tdmr)); in tdmr_get_nid()
543 static int tdmr_set_up_pamt(struct tdmr_info *tdmr, in tdmr_set_up_pamt() argument
554 nid = tdmr_get_nid(tdmr, tmb_list); in tdmr_set_up_pamt()
562 pamt_size[pgsz] = tdmr_get_pamt_sz(tdmr, pgsz, in tdmr_set_up_pamt()
587 tdmr->pamt_4k_base = pamt_base[TDX_PS_4K]; in tdmr_set_up_pamt()
588 tdmr->pamt_4k_size = pamt_size[TDX_PS_4K]; in tdmr_set_up_pamt()
589 tdmr->pamt_2m_base = pamt_base[TDX_PS_2M]; in tdmr_set_up_pamt()
590 tdmr->pamt_2m_size = pamt_size[TDX_PS_2M]; in tdmr_set_up_pamt()
591 tdmr->pamt_1g_base = pamt_base[TDX_PS_1G]; in tdmr_set_up_pamt()
592 tdmr->pamt_1g_size = pamt_size[TDX_PS_1G]; in tdmr_set_up_pamt()
597 static void tdmr_get_pamt(struct tdmr_info *tdmr, unsigned long *pamt_base, in tdmr_get_pamt() argument
606 pamt_bs = tdmr->pamt_4k_base; in tdmr_get_pamt()
607 pamt_sz = tdmr->pamt_4k_size + tdmr->pamt_2m_size + tdmr->pamt_1g_size; in tdmr_get_pamt()
615 static void tdmr_do_pamt_func(struct tdmr_info *tdmr, in tdmr_do_pamt_func() argument
620 tdmr_get_pamt(tdmr, &pamt_base, &pamt_size); in tdmr_do_pamt_func()
637 static void tdmr_free_pamt(struct tdmr_info *tdmr) in tdmr_free_pamt() argument
639 tdmr_do_pamt_func(tdmr, free_pamt); in tdmr_free_pamt()
692 static void tdmr_reset_pamt(struct tdmr_info *tdmr) in tdmr_reset_pamt() argument
694 tdmr_do_pamt_func(tdmr, reset_tdx_pages); in tdmr_reset_pamt()
720 static int tdmr_add_rsvd_area(struct tdmr_info *tdmr, int *p_idx, u64 addr, in tdmr_add_rsvd_area() argument
723 struct tdmr_reserved_area *rsvd_areas = tdmr->reserved_areas; in tdmr_add_rsvd_area()
732 tdmr->base, tdmr_end(tdmr)); in tdmr_add_rsvd_area()
741 rsvd_areas[idx].offset = addr - tdmr->base; in tdmr_add_rsvd_area()
755 struct tdmr_info *tdmr, in tdmr_populate_rsvd_holes() argument
767 prev_end = tdmr->base; in tdmr_populate_rsvd_holes()
775 if (start >= tdmr_end(tdmr)) in tdmr_populate_rsvd_holes()
779 if (end < tdmr->base) in tdmr_populate_rsvd_holes()
792 ret = tdmr_add_rsvd_area(tdmr, rsvd_idx, prev_end, in tdmr_populate_rsvd_holes()
802 if (prev_end < tdmr_end(tdmr)) { in tdmr_populate_rsvd_holes()
803 ret = tdmr_add_rsvd_area(tdmr, rsvd_idx, prev_end, in tdmr_populate_rsvd_holes()
804 tdmr_end(tdmr) - prev_end, in tdmr_populate_rsvd_holes()
819 struct tdmr_info *tdmr, in tdmr_populate_rsvd_pamts() argument
835 if ((pamt_end <= tdmr->base) || in tdmr_populate_rsvd_pamts()
836 (pamt_base >= tdmr_end(tdmr))) in tdmr_populate_rsvd_pamts()
840 if (pamt_base < tdmr->base) in tdmr_populate_rsvd_pamts()
841 pamt_base = tdmr->base; in tdmr_populate_rsvd_pamts()
842 if (pamt_end > tdmr_end(tdmr)) in tdmr_populate_rsvd_pamts()
843 pamt_end = tdmr_end(tdmr); in tdmr_populate_rsvd_pamts()
845 ret = tdmr_add_rsvd_area(tdmr, rsvd_idx, pamt_base, in tdmr_populate_rsvd_pamts()
875 static int tdmr_populate_rsvd_areas(struct tdmr_info *tdmr, in tdmr_populate_rsvd_areas() argument
882 ret = tdmr_populate_rsvd_holes(tmb_list, tdmr, &rsvd_idx, in tdmr_populate_rsvd_areas()
887 ret = tdmr_populate_rsvd_pamts(tdmr_list, tdmr, &rsvd_idx, in tdmr_populate_rsvd_areas()
893 sort(tdmr->reserved_areas, rsvd_idx, sizeof(struct tdmr_reserved_area), in tdmr_populate_rsvd_areas()
1049 static int init_tdmr(struct tdmr_info *tdmr) in init_tdmr() argument
1060 .rcx = tdmr->base, in init_tdmr()
1075 } while (next < tdmr->base + tdmr->size); in init_tdmr()