kvm: check KVM_CAP_SYNC_MMU with kvm_vm_check_extension()
On a server-class ppc host, this capability depends on the KVM type, ie, HV or PR. If both KVM are present in the kernel, we will always get the HV specific value, even if we explicitely requested PR on the command line. This can have an impact if we're using hugepages or a balloon device. Since we've already created the VM at the time any user calls kvm_has_sync_mmu(), switching to kvm_vm_check_extension() is enough to fix any potential issue. It is okay for the other archs that also implement KVM_CAP_SYNC_MMU, ie, mips, s390, x86 and arm, because they don't depend on the VM being created or not. While here, let's cache the state of this extension in a bool variable, since it has several users in the code, as suggested by Thomas Huth. Signed-off-by: Greg Kurz <groug@kaod.org> Message-Id: <150600965332.30533.14702405809647835716.stgit@bahia.lan> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
d4083f50e0
commit
62dd4edaaf
@ -87,6 +87,7 @@ struct KVMState
|
|||||||
#endif
|
#endif
|
||||||
int many_ioeventfds;
|
int many_ioeventfds;
|
||||||
int intx_set_mask;
|
int intx_set_mask;
|
||||||
|
bool sync_mmu;
|
||||||
/* The man page (and posix) say ioctl numbers are signed int, but
|
/* The man page (and posix) say ioctl numbers are signed int, but
|
||||||
* they're not. Linux, glibc and *BSD all treat ioctl numbers as
|
* they're not. Linux, glibc and *BSD all treat ioctl numbers as
|
||||||
* unsigned, and treating them as signed here can break things */
|
* unsigned, and treating them as signed here can break things */
|
||||||
@ -1664,6 +1665,8 @@ static int kvm_init(MachineState *ms)
|
|||||||
|
|
||||||
s->many_ioeventfds = kvm_check_many_ioeventfds();
|
s->many_ioeventfds = kvm_check_many_ioeventfds();
|
||||||
|
|
||||||
|
s->sync_mmu = !!kvm_vm_check_extension(kvm_state, KVM_CAP_SYNC_MMU);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
@ -2130,10 +2133,9 @@ int kvm_device_access(int fd, int group, uint64_t attr,
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return 1 on success, 0 on failure */
|
bool kvm_has_sync_mmu(void)
|
||||||
int kvm_has_sync_mmu(void)
|
|
||||||
{
|
{
|
||||||
return kvm_check_extension(kvm_state, KVM_CAP_SYNC_MMU);
|
return kvm_state->sync_mmu;
|
||||||
}
|
}
|
||||||
|
|
||||||
int kvm_has_vcpu_events(void)
|
int kvm_has_vcpu_events(void)
|
||||||
|
@ -64,9 +64,9 @@ int kvm_cpu_exec(CPUState *cpu)
|
|||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
int kvm_has_sync_mmu(void)
|
bool kvm_has_sync_mmu(void)
|
||||||
{
|
{
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int kvm_has_many_ioeventfds(void)
|
int kvm_has_many_ioeventfds(void)
|
||||||
|
@ -207,7 +207,7 @@ extern KVMState *kvm_state;
|
|||||||
/* external API */
|
/* external API */
|
||||||
|
|
||||||
bool kvm_has_free_slot(MachineState *ms);
|
bool kvm_has_free_slot(MachineState *ms);
|
||||||
int kvm_has_sync_mmu(void);
|
bool kvm_has_sync_mmu(void);
|
||||||
int kvm_has_vcpu_events(void);
|
int kvm_has_vcpu_events(void);
|
||||||
int kvm_has_robust_singlestep(void);
|
int kvm_has_robust_singlestep(void);
|
||||||
int kvm_has_debugregs(void);
|
int kvm_has_debugregs(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user