Lines Matching refs:pfn

59  * PFN is that we could find ourselves where pfn_to_mfn(pfn)==pfn for a
60 * non-identity pfn. To protect ourselves against we elect to set (and get) the
126 static inline unsigned p2m_top_index(unsigned long pfn)
128 BUG_ON(pfn >= MAX_P2M_PFN);
129 return pfn / (P2M_MID_PER_PAGE * P2M_PER_PAGE);
132 static inline unsigned p2m_mid_index(unsigned long pfn)
134 return (pfn / P2M_PER_PAGE) % P2M_MID_PER_PAGE;
137 static inline unsigned p2m_index(unsigned long pfn)
139 return pfn % P2M_PER_PAGE;
174 static void p2m_init_identity(unsigned long *p2m, unsigned long pfn)
179 p2m[i] = IDENTITY_FRAME(pfn + i);
219 unsigned long pfn, mfn;
242 for (pfn = 0; pfn < xen_max_p2m_pfn && pfn < MAX_P2M_PFN;
243 pfn += P2M_PER_PAGE) {
244 topidx = p2m_top_index(pfn);
245 mididx = p2m_mid_index(pfn);
248 ptep = lookup_address((unsigned long)(xen_p2m_addr + pfn),
262 pfn += (P2M_MID_PER_PAGE - 1) * P2M_PER_PAGE;
297 unsigned long pfn;
302 for (pfn = xen_start_info->nr_pages; pfn < xen_p2m_size; pfn++)
303 xen_p2m_addr[pfn] = INVALID_P2M_ENTRY;
313 static int xen_p2m_elem_type(unsigned long pfn)
317 if (pfn >= xen_p2m_size)
320 mfn = xen_p2m_addr[pfn];
334 unsigned long pfn;
356 for (pfn = 0; pfn < xen_max_p2m_pfn; pfn += chunk) {
367 chunk = (pfn & (P2M_PER_PAGE * P2M_MID_PER_PAGE - 1)) ?
370 type = xen_p2m_elem_type(pfn);
374 if (xen_p2m_elem_type(pfn + i) != type)
383 copy_page(mfns, xen_p2m_addr + pfn);
384 ptep = populate_extra_pte((unsigned long)(p2m + pfn));
394 ptep = populate_extra_pte((unsigned long)(p2m + pfn));
405 (unsigned long)(p2m + pfn) + i * PMD_SIZE);
435 unsigned long get_phys_to_machine(unsigned long pfn)
440 if (unlikely(pfn >= xen_p2m_size)) {
441 if (pfn < xen_max_p2m_pfn)
442 return xen_chk_extra_mem(pfn);
444 return IDENTITY_FRAME(pfn);
447 ptep = lookup_address((unsigned long)(xen_p2m_addr + pfn), &level);
456 return IDENTITY_FRAME(pfn);
458 return xen_p2m_addr[pfn];
525 * Fully allocate the p2m structure for a given pfn. We need to check
531 int xen_alloc_p2m_entry(unsigned long pfn)
538 unsigned long addr = (unsigned long)(xen_p2m_addr + pfn);
552 if (p2m_top_mfn && pfn < MAX_P2M_PFN) {
553 topidx = p2m_top_index(pfn);
598 p2m_init_identity(p2m, pfn & ~(P2M_PER_PAGE - 1));
610 mid_mfn[p2m_mid_index(pfn)] = virt_to_mfn(p2m);
621 if (pfn >= xen_p2m_last_pfn) {
622 xen_p2m_last_pfn = ALIGN(pfn + 1, P2M_PER_PAGE);
633 unsigned long pfn;
644 for (pfn = pfn_s; pfn < pfn_e; pfn++)
645 xen_p2m_addr[pfn] = IDENTITY_FRAME(pfn);
647 return pfn - pfn_s;
650 bool __set_phys_to_machine(unsigned long pfn, unsigned long mfn)
656 if (unlikely(pfn >= xen_p2m_size))
663 if (likely(!xen_safe_write_ulong(xen_p2m_addr + pfn, mfn)))
666 ptep = lookup_address((unsigned long)(xen_p2m_addr + pfn), &level);
673 return mfn == IDENTITY_FRAME(pfn);
678 bool set_phys_to_machine(unsigned long pfn, unsigned long mfn)
680 if (unlikely(!__set_phys_to_machine(pfn, mfn))) {
683 ret = xen_alloc_p2m_entry(pfn);
687 return __set_phys_to_machine(pfn, mfn);
711 unsigned long mfn, pfn;
727 pfn = page_to_pfn(pages[i]);
729 WARN(pfn_to_mfn(pfn) != INVALID_P2M_ENTRY, "page must be ballooned");
731 if (likely(set_phys_to_machine(pfn, FOREIGN_FRAME(mfn))))
789 unsigned long pfn = page_to_pfn(pages[i]);
792 set_phys_to_machine(pfn, INVALID_P2M_ENTRY);
812 [P2M_TYPE_PFN] = "pfn",
814 unsigned long pfn, first_pfn;
820 for (pfn = 0; pfn < xen_p2m_size; pfn++) {
821 type = xen_p2m_elem_type(pfn);
823 seq_printf(m, " [0x%lx->0x%lx] %s\n", first_pfn, pfn,
826 first_pfn = pfn;
829 seq_printf(m, " [0x%lx->0x%lx] %s\n", first_pfn, pfn,