Commit 8f6abd06 authored by Gleb Natapov's avatar Gleb Natapov Committed by Avi Kivity

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: default avatarGleb Natapov <gleb@redhat.com>
Signed-off-by: default avatarMarcelo Tosatti <mtosatti@redhat.com>
parent 660c22c4
...@@ -3322,8 +3322,7 @@ int emulator_write_phys(struct kvm_vcpu *vcpu, gpa_t gpa, ...@@ -3322,8 +3322,7 @@ int emulator_write_phys(struct kvm_vcpu *vcpu, gpa_t gpa,
static int emulator_write_emulated_onepage(unsigned long addr, static int emulator_write_emulated_onepage(unsigned long addr,
const void *val, const void *val,
unsigned int bytes, unsigned int bytes,
struct kvm_vcpu *vcpu, struct kvm_vcpu *vcpu)
bool mmu_only)
{ {
gpa_t gpa; gpa_t gpa;
u32 error_code; u32 error_code;
...@@ -3339,10 +3338,6 @@ static int emulator_write_emulated_onepage(unsigned long addr, ...@@ -3339,10 +3338,6 @@ static int emulator_write_emulated_onepage(unsigned long addr,
if ((gpa & PAGE_MASK) == APIC_DEFAULT_PHYS_BASE) if ((gpa & PAGE_MASK) == APIC_DEFAULT_PHYS_BASE)
goto mmio; goto mmio;
if (mmu_only) {
kvm_mmu_pte_write(vcpu, gpa, val, bytes, 1);
return X86EMUL_CONTINUE;
}
if (emulator_write_phys(vcpu, gpa, val, bytes)) if (emulator_write_phys(vcpu, gpa, val, bytes))
return X86EMUL_CONTINUE; return X86EMUL_CONTINUE;
...@@ -3363,35 +3358,24 @@ static int emulator_write_emulated_onepage(unsigned long addr, ...@@ -3363,35 +3358,24 @@ static int emulator_write_emulated_onepage(unsigned long addr,
return X86EMUL_CONTINUE; return X86EMUL_CONTINUE;
} }
int __emulator_write_emulated(unsigned long addr, int emulator_write_emulated(unsigned long addr,
const void *val, const void *val,
unsigned int bytes, unsigned int bytes,
struct kvm_vcpu *vcpu, struct kvm_vcpu *vcpu)
bool mmu_only)
{ {
/* Crossing a page boundary? */ /* Crossing a page boundary? */
if (((addr + bytes - 1) ^ addr) & PAGE_MASK) { if (((addr + bytes - 1) ^ addr) & PAGE_MASK) {
int rc, now; int rc, now;
now = -addr & ~PAGE_MASK; now = -addr & ~PAGE_MASK;
rc = emulator_write_emulated_onepage(addr, val, now, vcpu, rc = emulator_write_emulated_onepage(addr, val, now, vcpu);
mmu_only);
if (rc != X86EMUL_CONTINUE) if (rc != X86EMUL_CONTINUE)
return rc; return rc;
addr += now; addr += now;
val += now; val += now;
bytes -= now; bytes -= now;
} }
return emulator_write_emulated_onepage(addr, val, bytes, vcpu, return emulator_write_emulated_onepage(addr, val, bytes, vcpu);
mmu_only);
}
int emulator_write_emulated(unsigned long addr,
const void *val,
unsigned int bytes,
struct kvm_vcpu *vcpu)
{
return __emulator_write_emulated(addr, val, bytes, vcpu, false);
} }
EXPORT_SYMBOL_GPL(emulator_write_emulated); EXPORT_SYMBOL_GPL(emulator_write_emulated);
...@@ -3455,7 +3439,9 @@ static int emulator_cmpxchg_emulated(unsigned long addr, ...@@ -3455,7 +3439,9 @@ static int emulator_cmpxchg_emulated(unsigned long addr,
if (!exchanged) if (!exchanged)
return X86EMUL_CMPXCHG_FAILED; return X86EMUL_CMPXCHG_FAILED;
return __emulator_write_emulated(addr, new, bytes, vcpu, true); kvm_mmu_pte_write(vcpu, gpa, new, bytes, 1);
return X86EMUL_CONTINUE;
emul_write: emul_write:
printk_once(KERN_WARNING "kvm: emulating exchange as write\n"); printk_once(KERN_WARNING "kvm: emulating exchange as write\n");
...@@ -4165,7 +4151,7 @@ int kvm_fix_hypercall(struct kvm_vcpu *vcpu) ...@@ -4165,7 +4151,7 @@ int kvm_fix_hypercall(struct kvm_vcpu *vcpu)
kvm_x86_ops->patch_hypercall(vcpu, instruction); kvm_x86_ops->patch_hypercall(vcpu, instruction);
return __emulator_write_emulated(rip, instruction, 3, vcpu, false); return emulator_write_emulated(rip, instruction, 3, vcpu);
} }
void realmode_lgdt(struct kvm_vcpu *vcpu, u16 limit, unsigned long base) void realmode_lgdt(struct kvm_vcpu *vcpu, u16 limit, unsigned long base)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment