Re: [RFC/PATCH 1/5] context tracking: conditionalize guest support based on CONFIG_KVM

From: Kevin Hilman
Date: Tue Feb 26 2013 - 14:30:06 EST


Frederic Weisbecker <fweisbec@xxxxxxxxx> writes:

> On Wed, Feb 20, 2013 at 11:41:38AM -0800, Kevin Hilman wrote:
>> So that it can build on !KVM systems too.
>>
>> Signed-off-by: Kevin Hilman <khilman@xxxxxxxxxx>
>> ---
>> kernel/context_tracking.c | 4 ++++
>> 1 file changed, 4 insertions(+)
>>
>> diff --git a/kernel/context_tracking.c b/kernel/context_tracking.c
>> index 74f68f4..6fe96b1 100644
>> --- a/kernel/context_tracking.c
>> +++ b/kernel/context_tracking.c
>> @@ -1,5 +1,7 @@
>> #include <linux/context_tracking.h>
>> +#ifdef CONFIG_KVM
>> #include <linux/kvm_host.h>
>> +#endif
>
> The header should take care of the off-case, no need to ifdef its inclusion.

In their current form, the headers will not build on platforms without
KVM support. For example, these platforms (like ARM) don't even have
<asm/kvm.h> or <asm/kvm_host.h>.

>> #include <linux/rcupdate.h>
>> #include <linux/sched.h>
>> #include <linux/hardirq.h>
>> @@ -62,6 +64,7 @@ void user_exit(void)
>> local_irq_restore(flags);
>> }
>>
>> +#ifdef CONFIG_KVM
>> void guest_enter(void)
>> {
>> if (vtime_accounting_enabled())
>> @@ -79,6 +82,7 @@ void guest_exit(void)
>> __guest_exit();
>> }
>> EXPORT_SYMBOL_GPL(guest_exit);
>> +#endif
>
> Kvm might be built as a module so we can't actually do this unfortunately.

Ah, right. How bout using

#if defined(CONFIG_KVM) || defined(CONFIG_KVM_MODULE)

for both conditionals above? Updated patch below.

Kevin