diff options
author | Gleb Natapov <gleb@redhat.com> | 2010-04-13 03:21:56 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2010-05-17 05:17:43 -0400 |
commit | 8f6abd06f521112a0a3bc906df273fa3ce0a9387 (patch) | |
tree | 5f7c453b6cfeed776c6387d78a516dbd37c8ab0c /arch | |
parent | 660c22c425cbe14badfb3b0a0206862577701ab7 (diff) |
KVM: x86: get rid of mmu_only parameter in emulator_write_emulated()
We can call kvm_mmu_pte_write() directly from
emulator_cmpxchg_emulated() instead of passing mmu_only down to
emulator_write_emulated_onepage() and call it there.
Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/kvm/x86.c | 36 |
1 files changed, 11 insertions, 25 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 09dccac2df7e..40991527f54a 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -3322,8 +3322,7 @@ int emulator_write_phys(struct kvm_vcpu *vcpu, gpa_t gpa, | |||
3322 | static int emulator_write_emulated_onepage(unsigned long addr, | 3322 | static int emulator_write_emulated_onepage(unsigned long addr, |
3323 | const void *val, | 3323 | const void *val, |
3324 | unsigned int bytes, | 3324 | unsigned int bytes, |
3325 | struct kvm_vcpu *vcpu, | 3325 | struct kvm_vcpu *vcpu) |
3326 | bool mmu_only) | ||
3327 | { | 3326 | { |
3328 | gpa_t gpa; | 3327 | gpa_t gpa; |
3329 | u32 error_code; | 3328 | u32 error_code; |
@@ -3339,10 +3338,6 @@ static int emulator_write_emulated_onepage(unsigned long addr, | |||
3339 | if ((gpa & PAGE_MASK) == APIC_DEFAULT_PHYS_BASE) | 3338 | if ((gpa & PAGE_MASK) == APIC_DEFAULT_PHYS_BASE) |
3340 | goto mmio; | 3339 | goto mmio; |
3341 | 3340 | ||
3342 | if (mmu_only) { | ||
3343 | kvm_mmu_pte_write(vcpu, gpa, val, bytes, 1); | ||
3344 | return X86EMUL_CONTINUE; | ||
3345 | } | ||
3346 | if (emulator_write_phys(vcpu, gpa, val, bytes)) | 3341 | if (emulator_write_phys(vcpu, gpa, val, bytes)) |
3347 | return X86EMUL_CONTINUE; | 3342 | return X86EMUL_CONTINUE; |
3348 | 3343 | ||
@@ -3363,35 +3358,24 @@ mmio: | |||
3363 | return X86EMUL_CONTINUE; | 3358 | return X86EMUL_CONTINUE; |
3364 | } | 3359 | } |
3365 | 3360 | ||
3366 | int __emulator_write_emulated(unsigned long addr, | 3361 | int emulator_write_emulated(unsigned long addr, |
3367 | const void *val, | 3362 | const void *val, |
3368 | unsigned int bytes, | 3363 | unsigned int bytes, |
3369 | struct kvm_vcpu *vcpu, | 3364 | struct kvm_vcpu *vcpu) |
3370 | bool mmu_only) | ||
3371 | { | 3365 | { |
3372 | /* Crossing a page boundary? */ | 3366 | /* Crossing a page boundary? */ |
3373 | if (((addr + bytes - 1) ^ addr) & PAGE_MASK) { | 3367 | if (((addr + bytes - 1) ^ addr) & PAGE_MASK) { |
3374 | int rc, now; | 3368 | int rc, now; |
3375 | 3369 | ||
3376 | now = -addr & ~PAGE_MASK; | 3370 | now = -addr & ~PAGE_MASK; |
3377 | rc = emulator_write_emulated_onepage(addr, val, now, vcpu, | 3371 | rc = emulator_write_emulated_onepage(addr, val, now, vcpu); |
3378 | mmu_only); | ||
3379 | if (rc != X86EMUL_CONTINUE) | 3372 | if (rc != X86EMUL_CONTINUE) |
3380 | return rc; | 3373 | return rc; |
3381 | addr += now; | 3374 | addr += now; |
3382 | val += now; | 3375 | val += now; |
3383 | bytes -= now; | 3376 | bytes -= now; |
3384 | } | 3377 | } |
3385 | return emulator_write_emulated_onepage(addr, val, bytes, vcpu, | 3378 | return emulator_write_emulated_onepage(addr, val, bytes, vcpu); |
3386 | mmu_only); | ||
3387 | } | ||
3388 | |||
3389 | int emulator_write_emulated(unsigned long addr, | ||
3390 | const void *val, | ||
3391 | unsigned int bytes, | ||
3392 | struct kvm_vcpu *vcpu) | ||
3393 | { | ||
3394 | return __emulator_write_emulated(addr, val, bytes, vcpu, false); | ||
3395 | } | 3379 | } |
3396 | EXPORT_SYMBOL_GPL(emulator_write_emulated); | 3380 | EXPORT_SYMBOL_GPL(emulator_write_emulated); |
3397 | 3381 | ||
@@ -3455,7 +3439,9 @@ static int emulator_cmpxchg_emulated(unsigned long addr, | |||
3455 | if (!exchanged) | 3439 | if (!exchanged) |
3456 | return X86EMUL_CMPXCHG_FAILED; | 3440 | return X86EMUL_CMPXCHG_FAILED; |
3457 | 3441 | ||
3458 | return __emulator_write_emulated(addr, new, bytes, vcpu, true); | 3442 | kvm_mmu_pte_write(vcpu, gpa, new, bytes, 1); |
3443 | |||
3444 | return X86EMUL_CONTINUE; | ||
3459 | 3445 | ||
3460 | emul_write: | 3446 | emul_write: |
3461 | printk_once(KERN_WARNING "kvm: emulating exchange as write\n"); | 3447 | printk_once(KERN_WARNING "kvm: emulating exchange as write\n"); |
@@ -4165,7 +4151,7 @@ int kvm_fix_hypercall(struct kvm_vcpu *vcpu) | |||
4165 | 4151 | ||
4166 | kvm_x86_ops->patch_hypercall(vcpu, instruction); | 4152 | kvm_x86_ops->patch_hypercall(vcpu, instruction); |
4167 | 4153 | ||
4168 | return __emulator_write_emulated(rip, instruction, 3, vcpu, false); | 4154 | return emulator_write_emulated(rip, instruction, 3, vcpu); |
4169 | } | 4155 | } |
4170 | 4156 | ||
4171 | void realmode_lgdt(struct kvm_vcpu *vcpu, u16 limit, unsigned long base) | 4157 | void realmode_lgdt(struct kvm_vcpu *vcpu, u16 limit, unsigned long base) |