* [PATCH 1/2] KVM: X86: Filter the broadcast dest for IPI fastpath
@ 2020-03-27 6:23 Wanpeng Li
2020-03-27 6:24 ` [PATCH 2/2] KVM: LAPIC: Don't need to clear IPI delivery status for x2apic Wanpeng Li
2020-03-27 9:00 ` [PATCH 1/2] KVM: X86: Filter the broadcast dest for IPI fastpath Vitaly Kuznetsov
0 siblings, 2 replies; 5+ messages in thread
From: Wanpeng Li @ 2020-03-27 6:23 UTC (permalink / raw)
To: linux-kernel, kvm
Cc: Paolo Bonzini, Sean Christopherson, Vitaly Kuznetsov, Wanpeng Li,
Jim Mattson, Joerg Roedel
From: Wanpeng Li <wanpengli@tencent.com>
Except destination shorthand, a destination value 0xffffffff is used to
broadcast interrupts, let's also filter this for single target IPI fastpath.
Signed-off-by: Wanpeng Li <wanpengli@tencent.com>
---
arch/x86/kvm/lapic.c | 3 ---
arch/x86/kvm/lapic.h | 3 +++
arch/x86/kvm/x86.c | 3 ++-
3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index a38f1a8..88929b1 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -59,9 +59,6 @@
#define MAX_APIC_VECTOR 256
#define APIC_VECTORS_PER_REG 32
-#define APIC_BROADCAST 0xFF
-#define X2APIC_BROADCAST 0xFFFFFFFFul
-
static bool lapic_timer_advance_dynamic __read_mostly;
#define LAPIC_TIMER_ADVANCE_ADJUST_MIN 100 /* clock cycles */
#define LAPIC_TIMER_ADVANCE_ADJUST_MAX 10000 /* clock cycles */
diff --git a/arch/x86/kvm/lapic.h b/arch/x86/kvm/lapic.h
index bc76860..25b77a6 100644
--- a/arch/x86/kvm/lapic.h
+++ b/arch/x86/kvm/lapic.h
@@ -17,6 +17,9 @@
#define APIC_BUS_CYCLE_NS 1
#define APIC_BUS_FREQUENCY (1000000000ULL / APIC_BUS_CYCLE_NS)
+#define APIC_BROADCAST 0xFF
+#define X2APIC_BROADCAST 0xFFFFFFFFul
+
enum lapic_mode {
LAPIC_MODE_DISABLED = 0,
LAPIC_MODE_INVALID = X2APIC_ENABLE,
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index c4bb7d8..495709f 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1559,7 +1559,8 @@ static int handle_fastpath_set_x2apic_icr_irqoff(struct kvm_vcpu *vcpu, u64 data
if (((data & APIC_SHORT_MASK) == APIC_DEST_NOSHORT) &&
((data & APIC_DEST_MASK) == APIC_DEST_PHYSICAL) &&
- ((data & APIC_MODE_MASK) == APIC_DM_FIXED)) {
+ ((data & APIC_MODE_MASK) == APIC_DM_FIXED) &&
+ ((u32)(data >> 32) != X2APIC_BROADCAST)) {
data &= ~(1 << 12);
kvm_apic_send_ipi(vcpu->arch.apic, (u32)data, (u32)(data >> 32));
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] KVM: LAPIC: Don't need to clear IPI delivery status for x2apic
2020-03-27 6:23 [PATCH 1/2] KVM: X86: Filter the broadcast dest for IPI fastpath Wanpeng Li
@ 2020-03-27 6:24 ` Wanpeng Li
2020-03-27 9:06 ` Vitaly Kuznetsov
2020-03-27 9:00 ` [PATCH 1/2] KVM: X86: Filter the broadcast dest for IPI fastpath Vitaly Kuznetsov
1 sibling, 1 reply; 5+ messages in thread
From: Wanpeng Li @ 2020-03-27 6:24 UTC (permalink / raw)
To: linux-kernel, kvm
Cc: Paolo Bonzini, Sean Christopherson, Vitaly Kuznetsov, Wanpeng Li,
Jim Mattson, Joerg Roedel
From: Wanpeng Li <wanpengli@tencent.com>
IPI delivery status field is not present for x2apic, don't need
to clear IPI delivery status for x2apic.
Signed-off-by: Wanpeng Li <wanpengli@tencent.com>
---
arch/x86/kvm/lapic.c | 3 ++-
arch/x86/kvm/x86.c | 1 -
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 88929b1..f6d69e2 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -1942,7 +1942,8 @@ int kvm_lapic_reg_write(struct kvm_lapic *apic, u32 reg, u32 val)
}
case APIC_ICR:
/* No delay here, so we always clear the pending bit */
- val &= ~(1 << 12);
+ if (!apic_x2apic_mode(apic))
+ val &= ~(1 << 12);
kvm_apic_send_ipi(apic, val, kvm_lapic_get_reg(apic, APIC_ICR2));
kvm_lapic_set_reg(apic, APIC_ICR, val);
break;
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 495709f..6ced0e1 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1562,7 +1562,6 @@ static int handle_fastpath_set_x2apic_icr_irqoff(struct kvm_vcpu *vcpu, u64 data
((data & APIC_MODE_MASK) == APIC_DM_FIXED) &&
((u32)(data >> 32) != X2APIC_BROADCAST)) {
- data &= ~(1 << 12);
kvm_apic_send_ipi(vcpu->arch.apic, (u32)data, (u32)(data >> 32));
kvm_lapic_set_reg(vcpu->arch.apic, APIC_ICR2, (u32)(data >> 32));
kvm_lapic_set_reg(vcpu->arch.apic, APIC_ICR, (u32)data);
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] KVM: X86: Filter the broadcast dest for IPI fastpath
2020-03-27 6:23 [PATCH 1/2] KVM: X86: Filter the broadcast dest for IPI fastpath Wanpeng Li
2020-03-27 6:24 ` [PATCH 2/2] KVM: LAPIC: Don't need to clear IPI delivery status for x2apic Wanpeng Li
@ 2020-03-27 9:00 ` Vitaly Kuznetsov
1 sibling, 0 replies; 5+ messages in thread
From: Vitaly Kuznetsov @ 2020-03-27 9:00 UTC (permalink / raw)
To: Wanpeng Li
Cc: Paolo Bonzini, Sean Christopherson, Wanpeng Li, Jim Mattson,
Joerg Roedel, linux-kernel, kvm
Wanpeng Li <kernellwp@gmail.com> writes:
> From: Wanpeng Li <wanpengli@tencent.com>
>
> Except destination shorthand, a destination value 0xffffffff is used to
> broadcast interrupts, let's also filter this for single target IPI fastpath.
>
> Signed-off-by: Wanpeng Li <wanpengli@tencent.com>
> ---
> arch/x86/kvm/lapic.c | 3 ---
> arch/x86/kvm/lapic.h | 3 +++
> arch/x86/kvm/x86.c | 3 ++-
> 3 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> index a38f1a8..88929b1 100644
> --- a/arch/x86/kvm/lapic.c
> +++ b/arch/x86/kvm/lapic.c
> @@ -59,9 +59,6 @@
> #define MAX_APIC_VECTOR 256
> #define APIC_VECTORS_PER_REG 32
>
> -#define APIC_BROADCAST 0xFF
> -#define X2APIC_BROADCAST 0xFFFFFFFFul
> -
> static bool lapic_timer_advance_dynamic __read_mostly;
> #define LAPIC_TIMER_ADVANCE_ADJUST_MIN 100 /* clock cycles */
> #define LAPIC_TIMER_ADVANCE_ADJUST_MAX 10000 /* clock cycles */
> diff --git a/arch/x86/kvm/lapic.h b/arch/x86/kvm/lapic.h
> index bc76860..25b77a6 100644
> --- a/arch/x86/kvm/lapic.h
> +++ b/arch/x86/kvm/lapic.h
> @@ -17,6 +17,9 @@
> #define APIC_BUS_CYCLE_NS 1
> #define APIC_BUS_FREQUENCY (1000000000ULL / APIC_BUS_CYCLE_NS)
>
> +#define APIC_BROADCAST 0xFF
> +#define X2APIC_BROADCAST 0xFFFFFFFFul
> +
> enum lapic_mode {
> LAPIC_MODE_DISABLED = 0,
> LAPIC_MODE_INVALID = X2APIC_ENABLE,
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index c4bb7d8..495709f 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -1559,7 +1559,8 @@ static int handle_fastpath_set_x2apic_icr_irqoff(struct kvm_vcpu *vcpu, u64 data
>
> if (((data & APIC_SHORT_MASK) == APIC_DEST_NOSHORT) &&
> ((data & APIC_DEST_MASK) == APIC_DEST_PHYSICAL) &&
> - ((data & APIC_MODE_MASK) == APIC_DM_FIXED)) {
> + ((data & APIC_MODE_MASK) == APIC_DM_FIXED) &&
> + ((u32)(data >> 32) != X2APIC_BROADCAST)) {
>
> data &= ~(1 << 12);
> kvm_apic_send_ipi(vcpu->arch.apic, (u32)data, (u32)(data >> 32));
Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
--
Vitaly
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] KVM: LAPIC: Don't need to clear IPI delivery status for x2apic
2020-03-27 6:24 ` [PATCH 2/2] KVM: LAPIC: Don't need to clear IPI delivery status for x2apic Wanpeng Li
@ 2020-03-27 9:06 ` Vitaly Kuznetsov
2020-03-27 9:27 ` Wanpeng Li
0 siblings, 1 reply; 5+ messages in thread
From: Vitaly Kuznetsov @ 2020-03-27 9:06 UTC (permalink / raw)
To: Wanpeng Li, linux-kernel, kvm
Cc: Paolo Bonzini, Sean Christopherson, Wanpeng Li, Jim Mattson,
Joerg Roedel
Wanpeng Li <kernellwp@gmail.com> writes:
> From: Wanpeng Li <wanpengli@tencent.com>
>
> IPI delivery status field is not present for x2apic, don't need
> to clear IPI delivery status for x2apic.
>
> Signed-off-by: Wanpeng Li <wanpengli@tencent.com>
> ---
> arch/x86/kvm/lapic.c | 3 ++-
> arch/x86/kvm/x86.c | 1 -
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> index 88929b1..f6d69e2 100644
> --- a/arch/x86/kvm/lapic.c
> +++ b/arch/x86/kvm/lapic.c
> @@ -1942,7 +1942,8 @@ int kvm_lapic_reg_write(struct kvm_lapic *apic, u32 reg, u32 val)
> }
> case APIC_ICR:
> /* No delay here, so we always clear the pending bit */
'Always' in the comment above now reads a bit odd, I'd suggest modifying
it to 'Immediately clear Delivery Status field in xAPIC mode' - or just
drop it altogeter.
> - val &= ~(1 << 12);
> + if (!apic_x2apic_mode(apic))
> + val &= ~(1 << 12);
> kvm_apic_send_ipi(apic, val, kvm_lapic_get_reg(apic, APIC_ICR2));
> kvm_lapic_set_reg(apic, APIC_ICR, val);
> break;
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 495709f..6ced0e1 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -1562,7 +1562,6 @@ static int handle_fastpath_set_x2apic_icr_irqoff(struct kvm_vcpu *vcpu, u64 data
> ((data & APIC_MODE_MASK) == APIC_DM_FIXED) &&
> ((u32)(data >> 32) != X2APIC_BROADCAST)) {
>
> - data &= ~(1 << 12);
> kvm_apic_send_ipi(vcpu->arch.apic, (u32)data, (u32)(data >> 32));
> kvm_lapic_set_reg(vcpu->arch.apic, APIC_ICR2, (u32)(data >> 32));
> kvm_lapic_set_reg(vcpu->arch.apic, APIC_ICR, (u32)data);
Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
--
Vitaly
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] KVM: LAPIC: Don't need to clear IPI delivery status for x2apic
2020-03-27 9:06 ` Vitaly Kuznetsov
@ 2020-03-27 9:27 ` Wanpeng Li
0 siblings, 0 replies; 5+ messages in thread
From: Wanpeng Li @ 2020-03-27 9:27 UTC (permalink / raw)
To: Vitaly Kuznetsov
Cc: LKML, kvm, Paolo Bonzini, Sean Christopherson, Wanpeng Li,
Jim Mattson, Joerg Roedel
On Fri, 27 Mar 2020 at 17:07, Vitaly Kuznetsov <vkuznets@redhat.com> wrote:
>
> Wanpeng Li <kernellwp@gmail.com> writes:
>
> > From: Wanpeng Li <wanpengli@tencent.com>
> >
> > IPI delivery status field is not present for x2apic, don't need
> > to clear IPI delivery status for x2apic.
> >
> > Signed-off-by: Wanpeng Li <wanpengli@tencent.com>
> > ---
> > arch/x86/kvm/lapic.c | 3 ++-
> > arch/x86/kvm/x86.c | 1 -
> > 2 files changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> > index 88929b1..f6d69e2 100644
> > --- a/arch/x86/kvm/lapic.c
> > +++ b/arch/x86/kvm/lapic.c
> > @@ -1942,7 +1942,8 @@ int kvm_lapic_reg_write(struct kvm_lapic *apic, u32 reg, u32 val)
> > }
> > case APIC_ICR:
> > /* No delay here, so we always clear the pending bit */
>
> 'Always' in the comment above now reads a bit odd, I'd suggest modifying
> it to 'Immediately clear Delivery Status field in xAPIC mode' - or just
> drop it altogeter.
Thank you for your review, I guess Paolo can do it when apply.
Wanpeng
>
> > - val &= ~(1 << 12);
> > + if (!apic_x2apic_mode(apic))
> > + val &= ~(1 << 12);
> > kvm_apic_send_ipi(apic, val, kvm_lapic_get_reg(apic, APIC_ICR2));
> > kvm_lapic_set_reg(apic, APIC_ICR, val);
> > break;
> > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> > index 495709f..6ced0e1 100644
> > --- a/arch/x86/kvm/x86.c
> > +++ b/arch/x86/kvm/x86.c
> > @@ -1562,7 +1562,6 @@ static int handle_fastpath_set_x2apic_icr_irqoff(struct kvm_vcpu *vcpu, u64 data
> > ((data & APIC_MODE_MASK) == APIC_DM_FIXED) &&
> > ((u32)(data >> 32) != X2APIC_BROADCAST)) {
> >
> > - data &= ~(1 << 12);
> > kvm_apic_send_ipi(vcpu->arch.apic, (u32)data, (u32)(data >> 32));
> > kvm_lapic_set_reg(vcpu->arch.apic, APIC_ICR2, (u32)(data >> 32));
> > kvm_lapic_set_reg(vcpu->arch.apic, APIC_ICR, (u32)data);
>
> Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
>
> --
> Vitaly
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-03-27 9:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-27 6:23 [PATCH 1/2] KVM: X86: Filter the broadcast dest for IPI fastpath Wanpeng Li
2020-03-27 6:24 ` [PATCH 2/2] KVM: LAPIC: Don't need to clear IPI delivery status for x2apic Wanpeng Li
2020-03-27 9:06 ` Vitaly Kuznetsov
2020-03-27 9:27 ` Wanpeng Li
2020-03-27 9:00 ` [PATCH 1/2] KVM: X86: Filter the broadcast dest for IPI fastpath Vitaly Kuznetsov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.