/* If current_page is non-NULL, pc must have been increased exactly by 1. */ static u8 *map_code_page(const struct guest_paging_structures *pg_structs, unsigned long pc, u8 *current_page) { /* If page offset is 0, previous pc was pointing to a different page, * and we have to map a new one now. */ if (current_page && ((pc & ~PAGE_MASK) != 0)) return current_page; return paging_get_guest_pages(pg_structs, pc, 1, PAGE_READONLY_FLAGS); }
const u8 *vcpu_map_inst(const struct guest_paging_structures *pg_structs, unsigned long pc, unsigned int *size) { unsigned short bytes_avail; u8 *page = NULL; if (!*size) goto out_err; page = paging_get_guest_pages(pg_structs, pc, 1, PAGE_READONLY_FLAGS); if (!page) goto out_err; /* Number of bytes available before page boundary */ bytes_avail = PAGE_SIZE - (pc & PAGE_OFFS_MASK); if (*size > bytes_avail) *size = bytes_avail; return &page[pc & PAGE_OFFS_MASK]; out_err: return NULL; }