x86/pv: Minor improvements to guest_get_eff_{,kern}_l1e()

* These functions work in terms of linear addresses, not virtual addresses.
   Update the comments and parameter names.
 * Drop unnecessary inlines.
 * Drop vcpu parameter from guest_get_eff_kern_l1e().  Its sole caller passes
   current, and its callee strictly operates on current.
 * Switch guest_get_eff_kern_l1e()'s parameter from void * to l1_pgentry_t *.
   Both its caller and callee already use the correct type already.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
This commit is contained in:
Andrew Cooper committed 2017-08-25 16:16:01 +01:00
1 parent f343f66759
commit cb7a030a22
1 file changed
+11 -11
+11 -11
View File
@@ -567,15 +567,15 @@ static inline void guest_unmap_l1e(void *p)
unmap_domain_page(p);
}
/* Read a PV guest's l1e that maps this virtual address. */
static inline void guest_get_eff_l1e(unsigned long addr, l1_pgentry_t *eff_l1e)
/* Read a PV guest's l1e that maps this linear address. */
static void guest_get_eff_l1e(unsigned long linear, l1_pgentry_t *eff_l1e)
{
ASSERT(!paging_mode_translate(current->domain));
ASSERT(!paging_mode_external(current->domain));
if ( unlikely(!__addr_ok(addr)) ||
if ( unlikely(!__addr_ok(linear)) ||
__copy_from_user(eff_l1e,
&__linear_l1_table[l1_linear_offset(addr)],
&__linear_l1_table[l1_linear_offset(linear)],
sizeof(l1_pgentry_t)) )
*eff_l1e = l1e_empty();
}
@@ -584,18 +584,18 @@ static inline void guest_get_eff_l1e(unsigned long addr, l1_pgentry_t *eff_l1e)
* Read the guest's l1e that maps this address, from the kernel-mode
* page tables.
*/
static inline void guest_get_eff_kern_l1e(struct vcpu *v, unsigned long addr,
void *eff_l1e)
static void guest_get_eff_kern_l1e(unsigned long linear, l1_pgentry_t *eff_l1e)
{
const bool user_mode = !(v->arch.flags & TF_kernel_mode);
struct vcpu *curr = current;
const bool user_mode = !(curr->arch.flags & TF_kernel_mode);
if ( user_mode )
toggle_guest_mode(v);
toggle_guest_mode(curr);
guest_get_eff_l1e(addr, eff_l1e);
guest_get_eff_l1e(linear, eff_l1e);
if ( user_mode )
toggle_guest_mode(v);
toggle_guest_mode(curr);
}
static inline void page_set_tlbflush_timestamp(struct page_info *page)
@@ -682,7 +682,7 @@ int map_ldt_shadow_page(unsigned int off)
if ( is_pv_32bit_domain(d) )
gva = (u32)gva;
guest_get_eff_kern_l1e(v, gva, &l1e);
guest_get_eff_kern_l1e(gva, &l1e);
if ( unlikely(!(l1e_get_flags(l1e) & _PAGE_PRESENT)) )
return 0;
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.