[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] kvm: add stubs for kvm_vcpu_id_is_valid() and k
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH] kvm: add stubs for kvm_vcpu_id_is_valid() and kvm_arch_vcpu_id() |
Date: |
Sat, 17 Feb 2018 09:50:32 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 |
On 16/02/2018 19:11, Greg Kurz wrote:
> These two functions are essentially called by code that is only
> compiled when CONFIG_KVM=y, with the notable exception of the
> two users in the sPAPR code:
>
> $ git grep -E -l 'kvm_arch_vcpu_id|kvm_vcpu_id_is_valid'
> accel/kvm/kvm-all.c
> hw/intc/openpic_kvm.c
> hw/intc/xics_kvm.c
> hw/ppc/spapr.c
> include/sysemu/kvm.h
> target/arm/kvm.c
> target/i386/kvm.c
> target/mips/kvm.c
> target/ppc/kvm.c
> target/s390x/kvm.c
>
> In hw/ppc/spapr.c:
>
> if (kvm_enabled()) {
> return kvm_arch_vcpu_id(cs);
> } else {
> return cs->cpu_index;
> }
>
> and
>
> if (kvm_enabled() && !kvm_vcpu_id_is_valid(cpu->vcpu_id)) {
> ...
> }
>
> This code happens to compile without CONFIG_KVM=y simply because
> kvm_enabled() expands to (0) and the compiler optimizes the dead
> code away. Unless this was done on purpose
Yes, it is. There are more examples, the first I saw is:
uint32_t tbfreq = kvm_enabled() ? kvmppc_get_tbfreq()
: SPAPR_TIMEBASE_FREQ;
uint32_t cpufreq = kvm_enabled() ? kvmppc_get_clockfreq() : 1000000000;
> to indicate no stubs
> are required, and we'd rather break the build if calling these
> from KVM agnostic code
That's the idea. :)
Paolo