Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1542899 > unrolled thread
| Started by | Radim Krčmář <rkrcmar@redhat.com> |
|---|---|
| First post | 2016-12-15 18:10 +0100 |
| Last post | 2016-12-19 16:00 +0100 |
| Articles | 5 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH v3 3/4] KVM: x86: make interrupt delivery fast and slow path behave the same Radim Krčmář <rkrcmar@redhat.com> - 2016-12-15 18:10 +0100
Re: [PATCH v3 3/4] KVM: x86: make interrupt delivery fast and slow path behave the same David Hildenbrand <david@redhat.com> - 2016-12-16 17:50 +0100
Re: [PATCH v3 3/4] KVM: x86: make interrupt delivery fast and slow path behave the same Paolo Bonzini <pbonzini@redhat.com> - 2016-12-16 18:00 +0100
[PATCH v4 3/4] KVM: x86: make interrupt delivery fast and slow path behave the same Radim Krčmář <rkrcmar@redhat.com> - 2016-12-16 18:10 +0100
Re: [PATCH v4 3/4] KVM: x86: make interrupt delivery fast and slow path behave the same David Hildenbrand <david@redhat.com> - 2016-12-19 16:00 +0100
| From | Radim Krčmář <rkrcmar@redhat.com> |
|---|---|
| Date | 2016-12-15 18:10 +0100 |
| Subject | [PATCH v3 3/4] KVM: x86: make interrupt delivery fast and slow path behave the same |
| Message-ID | <sOHHA-8tl-29@gated-at.bofh.it> |
Slow path tried to prevent IPIs from x2APIC VCPUs from being delivered
to xAPIC VCPUs and vice-versa. Make slow path behave like fast path,
which never distinguished that.
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
---
arch/x86/kvm/lapic.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 81cc93580c40..519b72bbf947 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -606,7 +606,7 @@ static bool kvm_apic_match_physical_addr(struct kvm_lapic *apic, u32 mda)
if (apic_x2apic_mode(apic))
return mda == kvm_x2apic_id(apic);
- return mda == SET_APIC_DEST_FIELD(kvm_xapic_id(apic));
+ return mda == kvm_xapic_id(apic);
}
static bool kvm_apic_match_logical_addr(struct kvm_lapic *apic, u32 mda)
@@ -623,7 +623,6 @@ static bool kvm_apic_match_logical_addr(struct kvm_lapic *apic, u32 mda)
&& (logical_id & mda & 0xffff) != 0;
logical_id = GET_APIC_LOGICAL_ID(logical_id);
- mda = GET_APIC_DEST_FIELD(mda);
switch (kvm_lapic_get_reg(apic, APIC_DFR)) {
case APIC_DFR_FLAT:
@@ -640,9 +639,9 @@ static bool kvm_apic_match_logical_addr(struct kvm_lapic *apic, u32 mda)
/* The KVM local APIC implementation has two quirks:
*
- * - the xAPIC MDA stores the destination at bits 24-31, while this
- * is not true of struct kvm_lapic_irq's dest_id field. This is
- * just a quirk in the API and is not problematic.
+ * - Real hardware delivers interrupts destined to x2APIC ID > 0xff to LAPICs
+ * in xAPIC mode if the "destination & 0xff" matches its xAPIC ID.
+ * KVM doesn't do that aliasing.
*
* - in-kernel IOAPIC messages have to be delivered directly to
* x2APIC, because the kernel does not support interrupt remapping.
@@ -658,13 +657,12 @@ static u32 kvm_apic_mda(struct kvm_vcpu *vcpu, unsigned int dest_id,
struct kvm_lapic *source, struct kvm_lapic *target)
{
bool ipi = source != NULL;
- bool x2apic_mda = apic_x2apic_mode(ipi ? source : target);
if (!vcpu->kvm->arch.x2apic_broadcast_quirk_disabled &&
- !ipi && dest_id == APIC_BROADCAST && x2apic_mda)
+ !ipi && dest_id == APIC_BROADCAST && apic_x2apic_mode(target))
return X2APIC_BROADCAST;
- return x2apic_mda ? dest_id : SET_APIC_DEST_FIELD(dest_id);
+ return dest_id;
}
bool kvm_apic_match_dest(struct kvm_vcpu *vcpu, struct kvm_lapic *source,
--
2.11.0
[toc] | [next] | [standalone]
| From | David Hildenbrand <david@redhat.com> |
|---|---|
| Date | 2016-12-16 17:50 +0100 |
| Subject | Re: [PATCH v3 3/4] KVM: x86: make interrupt delivery fast and slow path behave the same |
| Message-ID | <sP3RM-69y-19@gated-at.bofh.it> |
| In reply to | #1542899 |
Am 15.12.2016 um 18:06 schrieb Radim Krčmář: > Slow path tried to prevent IPIs from x2APIC VCPUs from being delivered > to xAPIC VCPUs and vice-versa. Make slow path behave like fast path, > which never distinguished that. > > Signed-off-by: Radim Krčmář <rkrcmar@redhat.com> Just to verify: The GET_APIC_DEST_FIELD(mda) == APIC_BROADCAST is still correct in kvm_apic_broadcast() ? Apart from that thing confusing me, this looks good to me :) -- David
[toc] | [prev] | [next] | [standalone]
| From | Paolo Bonzini <pbonzini@redhat.com> |
|---|---|
| Date | 2016-12-16 18:00 +0100 |
| Subject | Re: [PATCH v3 3/4] KVM: x86: make interrupt delivery fast and slow path behave the same |
| Message-ID | <sP41r-6cL-15@gated-at.bofh.it> |
| In reply to | #1543587 |
On 16/12/2016 17:41, David Hildenbrand wrote: > > Just to verify: > > The GET_APIC_DEST_FIELD(mda) == APIC_BROADCAST is still correct in > kvm_apic_broadcast() ? No, it seems wrong. Paolo
[toc] | [prev] | [next] | [standalone]
| From | Radim Krčmář <rkrcmar@redhat.com> |
|---|---|
| Date | 2016-12-16 18:10 +0100 |
| Subject | [PATCH v4 3/4] KVM: x86: make interrupt delivery fast and slow path behave the same |
| Message-ID | <sP4b7-6vt-19@gated-at.bofh.it> |
| In reply to | #1543591 |
2016-12-16 17:53+0100, Paolo Bonzini:
> On 16/12/2016 17:41, David Hildenbrand wrote:
>>
>> Just to verify:
>>
>> The GET_APIC_DEST_FIELD(mda) == APIC_BROADCAST is still correct in
>> kvm_apic_broadcast() ?
>
> No, it seems wrong.
Definitely, sending v4 of this patch.
I'll also add broadcast address check into kvm-unit-tests ...
---8<---
Slow path tried to prevent IPIs from x2APIC VCPUs from being delivered
to xAPIC VCPUs and vice-versa. Make slow path behave like fast path,
which never distinguished that.
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
---
v4: fix xAPIC broadcast address detection [David]
---
arch/x86/kvm/lapic.c | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 81cc93580c40..dba19cb82c3e 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -592,10 +592,8 @@ static void apic_set_tpr(struct kvm_lapic *apic, u32 tpr)
static bool kvm_apic_broadcast(struct kvm_lapic *apic, u32 mda)
{
- if (apic_x2apic_mode(apic))
- return mda == X2APIC_BROADCAST;
-
- return GET_APIC_DEST_FIELD(mda) == APIC_BROADCAST;
+ return mda == (apic_x2apic_mode(apic) ?
+ X2APIC_BROADCAST : APIC_BROADCAST);
}
static bool kvm_apic_match_physical_addr(struct kvm_lapic *apic, u32 mda)
@@ -606,7 +604,7 @@ static bool kvm_apic_match_physical_addr(struct kvm_lapic *apic, u32 mda)
if (apic_x2apic_mode(apic))
return mda == kvm_x2apic_id(apic);
- return mda == SET_APIC_DEST_FIELD(kvm_xapic_id(apic));
+ return mda == kvm_xapic_id(apic);
}
static bool kvm_apic_match_logical_addr(struct kvm_lapic *apic, u32 mda)
@@ -623,7 +621,6 @@ static bool kvm_apic_match_logical_addr(struct kvm_lapic *apic, u32 mda)
&& (logical_id & mda & 0xffff) != 0;
logical_id = GET_APIC_LOGICAL_ID(logical_id);
- mda = GET_APIC_DEST_FIELD(mda);
switch (kvm_lapic_get_reg(apic, APIC_DFR)) {
case APIC_DFR_FLAT:
@@ -640,9 +637,9 @@ static bool kvm_apic_match_logical_addr(struct kvm_lapic *apic, u32 mda)
/* The KVM local APIC implementation has two quirks:
*
- * - the xAPIC MDA stores the destination at bits 24-31, while this
- * is not true of struct kvm_lapic_irq's dest_id field. This is
- * just a quirk in the API and is not problematic.
+ * - Real hardware delivers interrupts destined to x2APIC ID > 0xff to LAPICs
+ * in xAPIC mode if the "destination & 0xff" matches its xAPIC ID.
+ * KVM doesn't do that aliasing.
*
* - in-kernel IOAPIC messages have to be delivered directly to
* x2APIC, because the kernel does not support interrupt remapping.
@@ -658,13 +655,12 @@ static u32 kvm_apic_mda(struct kvm_vcpu *vcpu, unsigned int dest_id,
struct kvm_lapic *source, struct kvm_lapic *target)
{
bool ipi = source != NULL;
- bool x2apic_mda = apic_x2apic_mode(ipi ? source : target);
if (!vcpu->kvm->arch.x2apic_broadcast_quirk_disabled &&
- !ipi && dest_id == APIC_BROADCAST && x2apic_mda)
+ !ipi && dest_id == APIC_BROADCAST && apic_x2apic_mode(target))
return X2APIC_BROADCAST;
- return x2apic_mda ? dest_id : SET_APIC_DEST_FIELD(dest_id);
+ return dest_id;
}
bool kvm_apic_match_dest(struct kvm_vcpu *vcpu, struct kvm_lapic *source,
--
2.11.0
[toc] | [prev] | [next] | [standalone]
| From | David Hildenbrand <david@redhat.com> |
|---|---|
| Date | 2016-12-19 16:00 +0100 |
| Subject | Re: [PATCH v4 3/4] KVM: x86: make interrupt delivery fast and slow path behave the same |
| Message-ID | <sQ7zY-ML-25@gated-at.bofh.it> |
| In reply to | #1543601 |
Am 16.12.2016 um 18:07 schrieb Radim Krčmář: > 2016-12-16 17:53+0100, Paolo Bonzini: >> On 16/12/2016 17:41, David Hildenbrand wrote: >>> >>> Just to verify: >>> >>> The GET_APIC_DEST_FIELD(mda) == APIC_BROADCAST is still correct in >>> kvm_apic_broadcast() ? >> >> No, it seems wrong. > > Definitely, sending v4 of this patch. > I'll also add broadcast address check into kvm-unit-tests ... > ---8<--- > Slow path tried to prevent IPIs from x2APIC VCPUs from being delivered > to xAPIC VCPUs and vice-versa. Make slow path behave like fast path, > which never distinguished that. > > Signed-off-by: Radim Krčmář <rkrcmar@redhat.com> > --- > v4: fix xAPIC broadcast address detection [David] > --- > arch/x86/kvm/lapic.c | 20 ++++++++------------ > 1 file changed, 8 insertions(+), 12 deletions(-) > Looks good to me. Reviewed-by: David Hildenbrand <david@redhat.com> -- David
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web