linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: SVM: compile out AVIC if !CONFIG_X86_LOCAL_APIC
@ 2016-06-14 16:40 Paolo Bonzini
  2016-06-14 18:20 ` Suravee Suthikulanit
  0 siblings, 1 reply; 6+ messages in thread
From: Paolo Bonzini @ 2016-06-14 16:40 UTC (permalink / raw)
  To: linux-kernel, kvm; +Cc: Suravee Suthikulpanit, rkrcmar

AVIC needs __default_cpu_present_to_apicid.  Stub out all functions
that use it, and disable the module parameter, if Linux is
compiled without local APIC support.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 arch/x86/kvm/svm.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 1163e8173e5a..b70bc98269f0 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -238,7 +238,9 @@ module_param(nested, int, S_IRUGO);
 
 /* enable / disable AVIC */
 static int avic;
+#ifdef CONFIG_X86_LOCAL_APIC
 module_param(avic, int, S_IRUGO);
+#endif
 
 static void svm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0);
 static void svm_flush_tlb(struct kvm_vcpu *vcpu);
@@ -1323,6 +1325,7 @@ free_avic:
  */
 static void avic_set_running(struct kvm_vcpu *vcpu, bool is_run)
 {
+#ifdef CONFIG_X86_LOCAL_APIC
 	u64 entry;
 	int h_physical_id = __default_cpu_present_to_apicid(vcpu->cpu);
 	struct vcpu_svm *svm = to_svm(vcpu);
@@ -1343,10 +1346,12 @@ static void avic_set_running(struct kvm_vcpu *vcpu, bool is_run)
 	if (is_run)
 		entry |= AVIC_PHYSICAL_ID_ENTRY_IS_RUNNING_MASK;
 	WRITE_ONCE(*(svm->avic_physical_id_cache), entry);
+#endif
 }
 
 static void avic_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
 {
+#ifdef CONFIG_X86_LOCAL_APIC
 	u64 entry;
 	/* ID = 0xff (broadcast), ID > 0xff (reserved) */
 	int h_physical_id = __default_cpu_present_to_apicid(cpu);
@@ -1369,10 +1374,12 @@ static void avic_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
 		entry |= AVIC_PHYSICAL_ID_ENTRY_IS_RUNNING_MASK;
 
 	WRITE_ONCE(*(svm->avic_physical_id_cache), entry);
+#endif
 }
 
 static void avic_vcpu_put(struct kvm_vcpu *vcpu)
 {
+#ifdef CONFIG_X86_LOCAL_APIC
 	u64 entry;
 	struct vcpu_svm *svm = to_svm(vcpu);
 
@@ -1382,6 +1389,7 @@ static void avic_vcpu_put(struct kvm_vcpu *vcpu)
 	entry = READ_ONCE(*(svm->avic_physical_id_cache));
 	entry &= ~AVIC_PHYSICAL_ID_ENTRY_IS_RUNNING_MASK;
 	WRITE_ONCE(*(svm->avic_physical_id_cache), entry);
+#endif
 }
 
 static void svm_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event)
@@ -4231,6 +4239,7 @@ static void svm_sync_pir_to_irr(struct kvm_vcpu *vcpu)
 
 static void svm_deliver_avic_intr(struct kvm_vcpu *vcpu, int vec)
 {
+#ifdef CONFIG_X86_LOCAL_APIC
 	kvm_lapic_set_irr(vec, vcpu->arch.apic);
 	smp_mb__after_atomic();
 
@@ -4239,6 +4248,9 @@ static void svm_deliver_avic_intr(struct kvm_vcpu *vcpu, int vec)
 		       __default_cpu_present_to_apicid(vcpu->cpu));
 	else
 		kvm_vcpu_wake_up(vcpu);
+#else
+	WARN_ON_ONCE(1);
+#endif
 }
 
 static int svm_nmi_allowed(struct kvm_vcpu *vcpu)
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] KVM: SVM: compile out AVIC if !CONFIG_X86_LOCAL_APIC
  2016-06-14 16:40 [PATCH] KVM: SVM: compile out AVIC if !CONFIG_X86_LOCAL_APIC Paolo Bonzini
@ 2016-06-14 18:20 ` Suravee Suthikulanit
  2016-06-14 21:22   ` Paolo Bonzini
  0 siblings, 1 reply; 6+ messages in thread
From: Suravee Suthikulanit @ 2016-06-14 18:20 UTC (permalink / raw)
  To: Paolo Bonzini, linux-kernel, kvm; +Cc: rkrcmar

Hi Paolo,

On 6/14/2016 11:40 AM, Paolo Bonzini wrote:
> AVIC needs __default_cpu_present_to_apicid.  Stub out all functions
> that use it, and disable the module parameter, if Linux is
> compiled without local APIC support.

I think you are right that we should disable AVIC #ifndef 
CONFIG_X86_LOCAL_APIC. However, do you think we should just use 
default_cpu_present_to_apicid() instead of the 
__default_cpu_present_to_apicid()?  This way, we can avoid having #ifdef 
CONFIG_X86_LOCAL_APIC in multiple places.

As for disabling AVIC, I think we can also do:

     if (!IS_ENABLED(CONFIG_X86_LOCAL_APIC))
         avic = false;

What do you think?

Thanks,
Suravee

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] KVM: SVM: compile out AVIC if !CONFIG_X86_LOCAL_APIC
  2016-06-14 18:20 ` Suravee Suthikulanit
@ 2016-06-14 21:22   ` Paolo Bonzini
  2016-06-14 21:44     ` Suravee Suthikulanit
  0 siblings, 1 reply; 6+ messages in thread
From: Paolo Bonzini @ 2016-06-14 21:22 UTC (permalink / raw)
  To: Suravee Suthikulanit; +Cc: linux-kernel, kvm, rkrcmar



----- Original Message -----
> From: "Suravee Suthikulanit" <suravee.suthikulpanit@amd.com>
> To: "Paolo Bonzini" <pbonzini@redhat.com>, linux-kernel@vger.kernel.org, kvm@vger.kernel.org
> Cc: rkrcmar@redhat.com
> Sent: Tuesday, June 14, 2016 8:20:30 PM
> Subject: Re: [PATCH] KVM: SVM: compile out AVIC if !CONFIG_X86_LOCAL_APIC
> 
> Hi Paolo,
> 
> On 6/14/2016 11:40 AM, Paolo Bonzini wrote:
> > AVIC needs __default_cpu_present_to_apicid.  Stub out all functions
> > that use it, and disable the module parameter, if Linux is
> > compiled without local APIC support.
> 
> I think you are right that we should disable AVIC #ifndef
> CONFIG_X86_LOCAL_APIC. However, do you think we should just use
> default_cpu_present_to_apicid() instead of the
> __default_cpu_present_to_apicid()?

I'm not sure why that would help?  default_cpu_present_to_apicid
is also declared only if CONFIG_X86_LOCAL_APIC is defined.

> As for disabling AVIC, I think we can also do:
> 
>      if (!IS_ENABLED(CONFIG_X86_LOCAL_APIC))
>          avic = false;

Yes, we'll need to do that once AVIC is enabled by default; or

static bool avic = IS_ENABLED(CONFIG_X86_LOCAL_APIC);

In any case the module parameter must be hidden if there's no
support in the kernel for the local APIC.

Paolo

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] KVM: SVM: compile out AVIC if !CONFIG_X86_LOCAL_APIC
  2016-06-14 21:22   ` Paolo Bonzini
@ 2016-06-14 21:44     ` Suravee Suthikulanit
  2016-06-14 22:01       ` Paolo Bonzini
  0 siblings, 1 reply; 6+ messages in thread
From: Suravee Suthikulanit @ 2016-06-14 21:44 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: linux-kernel, kvm, rkrcmar

On 6/14/2016 4:22 PM, Paolo Bonzini wrote:
> ----- Original Message -----
>> From: "Suravee Suthikulanit" <suravee.suthikulpanit@amd.com>
>> To: "Paolo Bonzini" <pbonzini@redhat.com>, linux-kernel@vger.kernel.org, kvm@vger.kernel.org
>> Cc: rkrcmar@redhat.com
>> Sent: Tuesday, June 14, 2016 8:20:30 PM
>> Subject: Re: [PATCH] KVM: SVM: compile out AVIC if !CONFIG_X86_LOCAL_APIC
>>
>> Hi Paolo,
>>
>> On 6/14/2016 11:40 AM, Paolo Bonzini wrote:
>>> AVIC needs __default_cpu_present_to_apicid.  Stub out all functions
>>> that use it, and disable the module parameter, if Linux is
>>> compiled without local APIC support.
>>
>> I think you are right that we should disable AVIC #ifndef
>> CONFIG_X86_LOCAL_APIC. However, do you think we should just use
>> default_cpu_present_to_apicid() instead of the
>> __default_cpu_present_to_apicid()?
>
> I'm not sure why that would help?  default_cpu_present_to_apicid
> is also declared only if CONFIG_X86_LOCAL_APIC is defined.

Actually, I also meant to include the change that I sent out 
(https://lkml.org/lkml/2016/6/13/898), which declares a dummy for the 
case #ifndef CONFIG_X86_LOCAL_APIC.  That should help with the issue here.

>> As for disabling AVIC, I think we can also do:
>>
>>      if (!IS_ENABLED(CONFIG_X86_LOCAL_APIC))
>>          avic = false;
>
> Yes, we'll need to do that once AVIC is enabled by default; or
>
> static bool avic = IS_ENABLED(CONFIG_X86_LOCAL_APIC);
>
> In any case the module parameter must be hidden if there's no
> support in the kernel for the local APIC.
>
> Paolo
>

Agree.

If you okay with using default_cpu_present_to_apicid(), I can send out 
the v2 of the "[PATCH] x86/SVM: Fix implicit declaration issue for 
__default_cpu_present_to_apicid()" with changes that you suggested here.

Thanks,
Suravee

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] KVM: SVM: compile out AVIC if !CONFIG_X86_LOCAL_APIC
  2016-06-14 21:44     ` Suravee Suthikulanit
@ 2016-06-14 22:01       ` Paolo Bonzini
  2016-06-14 22:09         ` Suravee Suthikulanit
  0 siblings, 1 reply; 6+ messages in thread
From: Paolo Bonzini @ 2016-06-14 22:01 UTC (permalink / raw)
  To: Suravee Suthikulanit; +Cc: linux-kernel, kvm, rkrcmar



On 14/06/2016 23:44, Suravee Suthikulanit wrote:
> On 6/14/2016 4:22 PM, Paolo Bonzini wrote:
>> ----- Original Message -----
>>> From: "Suravee Suthikulanit" <suravee.suthikulpanit@amd.com>
>>> To: "Paolo Bonzini" <pbonzini@redhat.com>,
>>> linux-kernel@vger.kernel.org, kvm@vger.kernel.org
>>> Cc: rkrcmar@redhat.com
>>> Sent: Tuesday, June 14, 2016 8:20:30 PM
>>> Subject: Re: [PATCH] KVM: SVM: compile out AVIC if
>>> !CONFIG_X86_LOCAL_APIC
>>>
>>> Hi Paolo,
>>>
>>> On 6/14/2016 11:40 AM, Paolo Bonzini wrote:
>>>> AVIC needs __default_cpu_present_to_apicid.  Stub out all functions
>>>> that use it, and disable the module parameter, if Linux is
>>>> compiled without local APIC support.
>>>
>>> I think you are right that we should disable AVIC #ifndef
>>> CONFIG_X86_LOCAL_APIC. However, do you think we should just use
>>> default_cpu_present_to_apicid() instead of the
>>> __default_cpu_present_to_apicid()?
>>
>> I'm not sure why that would help?  default_cpu_present_to_apicid
>> is also declared only if CONFIG_X86_LOCAL_APIC is defined.
> 
> Actually, I also meant to include the change that I sent out
> (https://lkml.org/lkml/2016/6/13/898), which declares a dummy for the
> case #ifndef CONFIG_X86_LOCAL_APIC.  That should help with the issue here.

I think it is by design that default_cpu_present_to_apicid() is absent.

Perhaps you could create a kvm_cpu_get_apicid() function that is either
__default_cpu_present_to_apicid() or WARN_ON_ONCE(1)+return 0?

Paolo

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] KVM: SVM: compile out AVIC if !CONFIG_X86_LOCAL_APIC
  2016-06-14 22:01       ` Paolo Bonzini
@ 2016-06-14 22:09         ` Suravee Suthikulanit
  0 siblings, 0 replies; 6+ messages in thread
From: Suravee Suthikulanit @ 2016-06-14 22:09 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: linux-kernel, kvm, rkrcmar

On 6/14/2016 5:01 PM, Paolo Bonzini wrote:
>
> On 14/06/2016 23:44, Suravee Suthikulanit wrote:
>> > On 6/14/2016 4:22 PM, Paolo Bonzini wrote:
>>> >> ----- Original Message -----
>>>> >>> From: "Suravee Suthikulanit" <suravee.suthikulpanit@amd.com>
>>>> >>> To: "Paolo Bonzini" <pbonzini@redhat.com>,
>>>> >>> linux-kernel@vger.kernel.org, kvm@vger.kernel.org
>>>> >>> Cc: rkrcmar@redhat.com
>>>> >>> Sent: Tuesday, June 14, 2016 8:20:30 PM
>>>> >>> Subject: Re: [PATCH] KVM: SVM: compile out AVIC if
>>>> >>> !CONFIG_X86_LOCAL_APIC
>>>> >>>
>>>> >>> Hi Paolo,
>>>> >>>
>>>> >>> On 6/14/2016 11:40 AM, Paolo Bonzini wrote:
>>>>> >>>> AVIC needs __default_cpu_present_to_apicid.  Stub out all functions
>>>>> >>>> that use it, and disable the module parameter, if Linux is
>>>>> >>>> compiled without local APIC support.
>>>> >>>
>>>> >>> I think you are right that we should disable AVIC #ifndef
>>>> >>> CONFIG_X86_LOCAL_APIC. However, do you think we should just use
>>>> >>> default_cpu_present_to_apicid() instead of the
>>>> >>> __default_cpu_present_to_apicid()?
>>> >>
>>> >> I'm not sure why that would help?  default_cpu_present_to_apicid
>>> >> is also declared only if CONFIG_X86_LOCAL_APIC is defined.
>> >
>> > Actually, I also meant to include the change that I sent out
>> > (https://lkml.org/lkml/2016/6/13/898), which declares a dummy for the
>> > case #ifndef CONFIG_X86_LOCAL_APIC.  That should help with the issue here.
> I think it is by design that default_cpu_present_to_apicid() is absent.
>
> Perhaps you could create a kvm_cpu_get_apicid() function that is either
> __default_cpu_present_to_apicid() or WARN_ON_ONCE(1)+return 0?
>
> Paolo

Ok, I'll do that and send out V2.

Thanks,
Suravee

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-06-14 22:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-14 16:40 [PATCH] KVM: SVM: compile out AVIC if !CONFIG_X86_LOCAL_APIC Paolo Bonzini
2016-06-14 18:20 ` Suravee Suthikulanit
2016-06-14 21:22   ` Paolo Bonzini
2016-06-14 21:44     ` Suravee Suthikulanit
2016-06-14 22:01       ` Paolo Bonzini
2016-06-14 22:09         ` Suravee Suthikulanit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).