From mboxrd@z Thu Jan 1 00:00:00 1970 From: Radim =?utf-8?B?S3LEjW3DocWZ?= Subject: Re: [PATCH] KVM: x86: tweak types of fields in kvm_lapic_irq Date: Wed, 22 Apr 2015 11:35:43 +0200 Message-ID: <20150422093542.GA30285@potion.brq.redhat.com> References: <1429635686-82328-1-git-send-email-pbonzini@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org To: Paolo Bonzini Return-path: Content-Disposition: inline In-Reply-To: <1429635686-82328-1-git-send-email-pbonzini@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org 2015-04-21 19:01+0200, Paolo Bonzini: > Change to u16 if they only contain data in the low 16 bits. >=20 > 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 > --- > arch/x86/include/asm/kvm_host.h | 8 ++++---- > arch/x86/kvm/lapic.c | 2 +- > 2 files changed, 5 insertions(+), 5 deletions(-) >=20 > diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/k= vm_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 { > =20 > 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=C4=8Dm=C3=A1=C5=99 > 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 =3D icr_low & APIC_VECTOR_MASK; > irq.delivery_mode =3D icr_low & APIC_MODE_MASK; > irq.dest_mode =3D icr_low & APIC_DEST_MASK; > - irq.level =3D icr_low & APIC_INT_ASSERT; > + irq.level =3D (icr_low & APIC_INT_ASSERT) !=3D 0; > irq.trig_mode =3D icr_low & APIC_INT_LEVELTRIG; > irq.shorthand =3D icr_low & APIC_SHORT_MASK; > if (apic_x2apic_mode(apic)) > --=20 > 1.8.3.1 >=20