* [PATCH] KVM: x86: tweak types of fields in kvm_lapic_irq
@ 2015-04-21 17:01 Paolo Bonzini
2015-04-22 9:35 ` Radim Krčmář
0 siblings, 1 reply; 3+ messages in thread
From: Paolo Bonzini @ 2015-04-21 17:01 UTC (permalink / raw)
To: linux-kernel, kvm; +Cc: rkrcmar
Change to u16 if they only contain data in the low 16 bits.
Change the level field to bool, since we assign 1 sometimes, but
just mask icr_low with APIC_INT_ASSERT in apic_send_ipi.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
arch/x86/include/asm/kvm_host.h | 8 ++++----
arch/x86/kvm/lapic.c | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 3a19e30f0be0..dc83b43d0850 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -689,10 +689,10 @@ struct msr_data {
struct kvm_lapic_irq {
u32 vector;
- u32 delivery_mode;
- u32 dest_mode;
- u32 level;
- u32 trig_mode;
+ u16 delivery_mode;
+ u16 dest_mode;
+ bool level;
+ u16 trig_mode;
u32 shorthand;
u32 dest_id;
};
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index abf165330881..ba585d0c42c5 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -914,7 +914,7 @@ static void apic_send_ipi(struct kvm_lapic *apic)
irq.vector = icr_low & APIC_VECTOR_MASK;
irq.delivery_mode = icr_low & APIC_MODE_MASK;
irq.dest_mode = icr_low & APIC_DEST_MASK;
- irq.level = icr_low & APIC_INT_ASSERT;
+ irq.level = (icr_low & APIC_INT_ASSERT) != 0;
irq.trig_mode = icr_low & APIC_INT_LEVELTRIG;
irq.shorthand = icr_low & APIC_SHORT_MASK;
if (apic_x2apic_mode(apic))
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] KVM: x86: tweak types of fields in kvm_lapic_irq
2015-04-21 17:01 [PATCH] KVM: x86: tweak types of fields in kvm_lapic_irq Paolo Bonzini
@ 2015-04-22 9:35 ` Radim Krčmář
2015-04-22 10:27 ` Paolo Bonzini
0 siblings, 1 reply; 3+ messages in thread
From: Radim Krčmář @ 2015-04-22 9:35 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: linux-kernel, kvm
2015-04-21 19:01+0200, Paolo Bonzini:
> Change to u16 if they only contain data in the low 16 bits.
>
> Change the level field to bool, since we assign 1 sometimes, but
> just mask icr_low with APIC_INT_ASSERT in apic_send_ipi.
Would be more consistent to change that assignment instead ...
If we dropped the idea that struct kvm_lapic_irq fields can be bitORed
to get the ICR, we could also easily change trig_mode/dest_mode to bool
level_trig/logical_dest. (I can do a followup patch.)
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> arch/x86/include/asm/kvm_host.h | 8 ++++----
> arch/x86/kvm/lapic.c | 2 +-
> 2 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
> index 3a19e30f0be0..dc83b43d0850 100644
> --- a/arch/x86/include/asm/kvm_host.h
> +++ b/arch/x86/include/asm/kvm_host.h
> @@ -689,10 +689,10 @@ struct msr_data {
>
> struct kvm_lapic_irq {
> u32 vector;
Vector can be u8.
> - u32 delivery_mode;
> - u32 dest_mode;
> - u32 level;
> - u32 trig_mode;
> + u16 delivery_mode;
> + u16 dest_mode;
> + bool level;
> + u16 trig_mode;
I'd prefer to have the u8 vector as well, but it works,
Reviewed-by: Radim Krčmář <rkrcmar@redhat.com>
> u32 shorthand;
> u32 dest_id;
> };
> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> index abf165330881..ba585d0c42c5 100644
> --- a/arch/x86/kvm/lapic.c
> +++ b/arch/x86/kvm/lapic.c
> @@ -914,7 +914,7 @@ static void apic_send_ipi(struct kvm_lapic *apic)
> irq.vector = icr_low & APIC_VECTOR_MASK;
> irq.delivery_mode = icr_low & APIC_MODE_MASK;
> irq.dest_mode = icr_low & APIC_DEST_MASK;
> - irq.level = icr_low & APIC_INT_ASSERT;
> + irq.level = (icr_low & APIC_INT_ASSERT) != 0;
> irq.trig_mode = icr_low & APIC_INT_LEVELTRIG;
> irq.shorthand = icr_low & APIC_SHORT_MASK;
> if (apic_x2apic_mode(apic))
> --
> 1.8.3.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] KVM: x86: tweak types of fields in kvm_lapic_irq
2015-04-22 9:35 ` Radim Krčmář
@ 2015-04-22 10:27 ` Paolo Bonzini
0 siblings, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2015-04-22 10:27 UTC (permalink / raw)
To: Radim Krčmář; +Cc: linux-kernel, kvm
On 22/04/2015 11:35, Radim Krčmář wrote:
> > Change the level field to bool, since we assign 1 sometimes, but
> > just mask icr_low with APIC_INT_ASSERT in apic_send_-ipi.
>
> Would be more consistent to change that assignment instead ...
> If we dropped the idea that struct kvm_lapic_irq fields can be bitORed
> to get the ICR, we could also easily change trig_mode/dest_mode to bool
> level_trig/logical_dest. (I can do a followup patch.)
Right, I thought of both. However, level is something that has an
obviously understandable meaning as a bool, while trig_mode/dest_mode as
you said have to be renamed as well.
You're right on the u8 type for vector, too. But I probably will end up
not committing this patch at all...
Paolo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-04-22 10:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-21 17:01 [PATCH] KVM: x86: tweak types of fields in kvm_lapic_irq Paolo Bonzini
2015-04-22 9:35 ` Radim Krčmář
2015-04-22 10:27 ` Paolo Bonzini
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).