KVM: Simply gfn_to_page()
Mapping a guest page to a host page is a common operation. Currently, one has first to find the memory slot where the page belongs (gfn_to_memslot), then locate the page itself (gfn_to_page()). This is clumsy, and also won't work well with memory aliases. So simplify gfn_to_page() not to require memory slot translation first, and instead do it internally. Signed-off-by: Avi Kivity <avi@qumranet.com>
This commit is contained in:
@@ -443,11 +443,7 @@ void kvm_emulator_want_group7_invlpg(void);
|
||||
|
||||
extern hpa_t bad_page_address;
|
||||
|
||||
static inline struct page *gfn_to_page(struct kvm_memory_slot *slot, gfn_t gfn)
|
||||
{
|
||||
return slot->phys_mem[gfn - slot->base_gfn];
|
||||
}
|
||||
|
||||
struct page *gfn_to_page(struct kvm *kvm, gfn_t gfn);
|
||||
struct kvm_memory_slot *gfn_to_memslot(struct kvm *kvm, gfn_t gfn);
|
||||
void mark_page_dirty(struct kvm *kvm, gfn_t gfn);
|
||||
|
||||
@@ -523,12 +519,6 @@ static inline int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t gva,
|
||||
return vcpu->mmu.page_fault(vcpu, gva, error_code);
|
||||
}
|
||||
|
||||
static inline struct page *_gfn_to_page(struct kvm *kvm, gfn_t gfn)
|
||||
{
|
||||
struct kvm_memory_slot *slot = gfn_to_memslot(kvm, gfn);
|
||||
return (slot) ? slot->phys_mem[gfn - slot->base_gfn] : NULL;
|
||||
}
|
||||
|
||||
static inline int is_long_mode(struct kvm_vcpu *vcpu)
|
||||
{
|
||||
#ifdef CONFIG_X86_64
|
||||
|
Reference in New Issue
Block a user