Re: [PATCH 03/12] Switch build system to accompanied kernel headers

Alexander Graf
2011-06-14T11:28:45Z

On 14.06.2011, at 13:21, Jan Kiszka wrote:

> On 2011-06-14 13:11, Alexander Graf wrote:
>>
>> On 08.06.2011, at 16:10, Jan Kiszka wrote:
>>
>> This helps reducing our build-time checks for feature support in the
>> available Linux kernel headers. And it helps users that do not have
>> sufficiently recent headers installed on their build machine.
>>
>> Consequently, the patch removes and build-time checks for kvm and vhost
>> in configure, the --kerneldir switch, and KVM_CFLAGS. Kernel headers are
>> supposed to be provided by QEMU only.
>>
>> s390 needs some extra love as it carries redefinitions from kernel
>> headers.
>>
>> Yes. I was wondering if we should unconditionally include the kernel headers there. The problem I'm seeing there is that I don't know if that would work fine on non-Linux hosts, as that code definitely gets compiled there, while KVM code is not.
>>
>>
>>
>> [...]
>>
>> diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
>> index 4e5c391..b5e587f 100644
>> --- a/target-s390x/cpu.h
>> +++ b/target-s390x/cpu.h
>> @@ -313,16 +313,6 @@ CPUState *s390_cpu_addr2state(uint16_t cpu_addr);
>> /* from s390-virtio-bus */
>> extern const target_phys_addr_t virtio_size;
>>
>> -#ifndef KVM_S390_SIGP_STOP
>> -#define KVM_S390_SIGP_STOP 0
>> -#define KVM_S390_PROGRAM_INT 0
>> -#define KVM_S390_SIGP_SET_PREFIX 0
>> -#define KVM_S390_RESTART 0
>> -#define KVM_S390_INT_VIRTIO 0
>> -#define KVM_S390_INT_SERVICE 0
>> -#define KVM_S390_INT_EMERGENCY 0
>> -#endif
>> -
>> #endif
>> void cpu_lock(void);
>> void cpu_unlock(void);
>> diff --git a/target-s390x/op_helper.c b/target-s390x/op_helper.c
>> index db03a79..9429698 100644
>> --- a/target-s390x/op_helper.c
>> +++ b/target-s390x/op_helper.c
>> @@ -23,6 +23,7 @@
>> #include "helpers.h"
>> #include <string.h>
>> #include "kvm.h"
>> +#include <linux/kvm.h>
>>
>> Have you tried to compile this on non-Linux?
>
> Sorry, I don't have "non-Linux" around. :) Do you expect build problems
> with that header? Why?

Do you have a git tree handy? I can give a Mac build a try then.

> BTW, if you depend on KVM_* constants for non-KVM builds, that looks a
> bit fishy to me. Why is that code built at all in that setup?

The reason for that is that I didn't want to clutter the emulation code with #ifdefs:

static void program_interrupt(CPUState *env, uint32_t code, int ilc)
{
qemu_log("program interrupt at %#" PRIx64 "\n", env->psw.addr);

if (kvm_enabled()) {
kvm_s390_interrupt(env, KVM_S390_PROGRAM_INT, code);
} else {
env->int_pgm_code = code;
env->int_pgm_ilc = ilc;
env->exception_index = EXCP_PGM;
cpu_loop_exit();
}
}

This breaks compilation when KVM_S390_PROGRAM_INT is not defined. I'm very open to suggestions on how to improve this though :).

Alex