[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-ppc] [PATCH v2 1/2] kvm: check KVM_CAP_SYNC_MMU with kvm_vm_ch
From: |
David Gibson |
Subject: |
Re: [Qemu-ppc] [PATCH v2 1/2] kvm: check KVM_CAP_SYNC_MMU with kvm_vm_check_extension() |
Date: |
Fri, 22 Sep 2017 20:15:01 +1000 |
User-agent: |
Mutt/1.9.0 (2017-09-02) |
On Thu, Sep 21, 2017 at 06:00:53PM +0200, Greg Kurz wrote:
> 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 <address@hidden>
Reviewed-by: David Gibson <address@hidden>
> ---
> accel/kvm/kvm-all.c | 8 +++++---
> accel/stubs/kvm-stub.c | 4 ++--
> include/sysemu/kvm.h | 2 +-
> 3 files changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
> index b0181d722083..4d96c1fee9fe 100644
> --- a/accel/kvm/kvm-all.c
> +++ b/accel/kvm/kvm-all.c
> @@ -87,6 +87,7 @@ struct KVMState
> #endif
> int many_ioeventfds;
> int intx_set_mask;
> + bool sync_mmu;
> /* The man page (and posix) say ioctl numbers are signed int, but
> * they're not. Linux, glibc and *BSD all treat ioctl numbers as
> * unsigned, and treating them as signed here can break things */
> @@ -1665,6 +1666,8 @@ static int kvm_init(MachineState *ms)
>
> s->many_ioeventfds = kvm_check_many_ioeventfds();
>
> + s->sync_mmu = !!kvm_vm_check_extension(kvm_state, KVM_CAP_SYNC_MMU);
> +
> return 0;
>
> err:
> @@ -2131,10 +2134,9 @@ int kvm_device_access(int fd, int group, uint64_t attr,
> return err;
> }
>
> -/* Return 1 on success, 0 on failure */
> -int kvm_has_sync_mmu(void)
> +bool 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)
> diff --git a/accel/stubs/kvm-stub.c b/accel/stubs/kvm-stub.c
> index 3965c528d348..c964af3e1c97 100644
> --- a/accel/stubs/kvm-stub.c
> +++ b/accel/stubs/kvm-stub.c
> @@ -64,9 +64,9 @@ int kvm_cpu_exec(CPUState *cpu)
> abort();
> }
>
> -int kvm_has_sync_mmu(void)
> +bool kvm_has_sync_mmu(void)
> {
> - return 0;
> + return false;
> }
>
> int kvm_has_many_ioeventfds(void)
> diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
> index 3a458f50e9f4..bbf12a172339 100644
> --- a/include/sysemu/kvm.h
> +++ b/include/sysemu/kvm.h
> @@ -207,7 +207,7 @@ extern KVMState *kvm_state;
> /* external API */
>
> 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_robust_singlestep(void);
> int kvm_has_debugregs(void);
>
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
signature.asc
Description: PGP signature