diff options
author | Xiao Guangrong <xiaoguangrong@cn.fujitsu.com> | 2011-07-11 15:23:20 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2011-07-24 04:50:26 -0400 |
commit | bebb106a5afa32efdf5332ed4a40bf4d6d06b56e (patch) | |
tree | b8da141e846c9d25fbe4c69b12582cada03726e3 /arch/x86/kvm/x86.c | |
parent | af7cc7d1ee422a612f6785e347a893d44cc892ea (diff) |
KVM: MMU: cache mmio info on page fault path
If the page fault is caused by mmio, we can cache the mmio info, later, we do
not need to walk guest page table and quickly know it is a mmio fault while we
emulate the mmio instruction
Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r-- | arch/x86/kvm/x86.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index a1dbd0443545..028a0f25e8a0 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -4016,6 +4016,14 @@ static int vcpu_mmio_gva_to_gpa(struct kvm_vcpu *vcpu, unsigned long gva, | |||
4016 | { | 4016 | { |
4017 | u32 access = (kvm_x86_ops->get_cpl(vcpu) == 3) ? PFERR_USER_MASK : 0; | 4017 | u32 access = (kvm_x86_ops->get_cpl(vcpu) == 3) ? PFERR_USER_MASK : 0; |
4018 | 4018 | ||
4019 | if (vcpu_match_mmio_gva(vcpu, gva) && | ||
4020 | check_write_user_access(vcpu, write, access, | ||
4021 | vcpu->arch.access)) { | ||
4022 | *gpa = vcpu->arch.mmio_gfn << PAGE_SHIFT | | ||
4023 | (gva & (PAGE_SIZE - 1)); | ||
4024 | return 1; | ||
4025 | } | ||
4026 | |||
4019 | if (write) | 4027 | if (write) |
4020 | access |= PFERR_WRITE_MASK; | 4028 | access |= PFERR_WRITE_MASK; |
4021 | 4029 | ||
@@ -4028,6 +4036,9 @@ static int vcpu_mmio_gva_to_gpa(struct kvm_vcpu *vcpu, unsigned long gva, | |||
4028 | if ((*gpa & PAGE_MASK) == APIC_DEFAULT_PHYS_BASE) | 4036 | if ((*gpa & PAGE_MASK) == APIC_DEFAULT_PHYS_BASE) |
4029 | return 1; | 4037 | return 1; |
4030 | 4038 | ||
4039 | if (vcpu_match_mmio_gpa(vcpu, *gpa)) | ||
4040 | return 1; | ||
4041 | |||
4031 | return 0; | 4042 | return 0; |
4032 | } | 4043 | } |
4033 | 4044 | ||