diff mbox

[v4,01/16] KVM: Extend struct pi_desc for VT-d Posted-Interrupts

Message ID 1434019912-15423-2-git-send-email-feng.wu@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wu, Feng June 11, 2015, 10:51 a.m. UTC
Extend struct pi_desc for VT-d Posted-Interrupts.

Signed-off-by: Feng Wu <feng.wu@intel.com>
---
 arch/x86/kvm/vmx.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

Comments

Paolo Bonzini June 23, 2015, 3:49 p.m. UTC | #1
On 11/06/2015 12:51, Feng Wu wrote:
> +	union {
> +		struct {
> +				/* bit 256 - Outstanding Notification */
> +			u64	on	: 1,
> +				/* bit 257 - Suppress Notification */
> +				sn	: 1,
> +				/* bit 271:258 - Reserved */
> +				rsvd_1	: 14,
> +				/* bit 279:272 - Notification Vector */
> +				nv	: 8,
> +				/* bit 287:280 - Reserved */
> +				rsvd_2	: 8,
> +				/* bit 319:288 - Notification Destination */
> +				ndst	: 32;

Please do not use bitfields, Linus doesn't like them.  Use static
inlines instead to extract or set the fields from the control field.

Paolo

> +		};
> +		u64 control;
> +	};
> +	u32 rsvd[6];
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Wu, Feng June 24, 2015, 5:42 a.m. UTC | #2
> -----Original Message-----
> From: Paolo Bonzini [mailto:pbonzini@redhat.com]
> Sent: Tuesday, June 23, 2015 11:50 PM
> To: Wu, Feng; kvm@vger.kernel.org; linux-kernel@vger.kernel.org
> Cc: mtosatti@redhat.com; alex.williamson@redhat.com;
> eric.auger@linaro.org
> Subject: Re: [v4 01/16] KVM: Extend struct pi_desc for VT-d Posted-Interrupts
> 
> 
> 
> On 11/06/2015 12:51, Feng Wu wrote:
> > +	union {
> > +		struct {
> > +				/* bit 256 - Outstanding Notification */
> > +			u64	on	: 1,
> > +				/* bit 257 - Suppress Notification */
> > +				sn	: 1,
> > +				/* bit 271:258 - Reserved */
> > +				rsvd_1	: 14,
> > +				/* bit 279:272 - Notification Vector */
> > +				nv	: 8,
> > +				/* bit 287:280 - Reserved */
> > +				rsvd_2	: 8,
> > +				/* bit 319:288 - Notification Destination */
> > +				ndst	: 32;
> 
> Please do not use bitfields, Linus doesn't like them.  Use static
> inlines instead to extract or set the fields from the control field.

Do you mean we don't use bitfields at all, or the following format is
acceptable, in which, we use bitfileds as less as possible?

    union {
        struct
        {
        u16 on     : 1,  /* bit 256 - Outstanding Notification */
            sn     : 1,  /* bit 257 - Suppress Notification */
            rsvd_1 : 14; /* bit 271:258 - Reserved */
        u8  nv;          /* bit 279:272 - Notification Vector */
        u8  rsvd_2;      /* bit 287:280 - Reserved */
        u32 ndst;        /* bit 319:288 - Notification Destination */
        };
        u64 control;
    };

Thanks,
Feng

> 
> Paolo
> 
> > +		};
> > +		u64 control;
> > +	};
> > +	u32 rsvd[6];
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Paolo Bonzini June 24, 2015, 8:46 a.m. UTC | #3
On 24/06/2015 07:42, Wu, Feng wrote:
> Do you mean we don't use bitfields at all, or the following format is
> acceptable, in which, we use bitfileds as less as possible?

>     union {
>         struct
>         {
>         u16 on     : 1,  /* bit 256 - Outstanding Notification */
>             sn     : 1,  /* bit 257 - Suppress Notification */
>             rsvd_1 : 14; /* bit 271:258 - Reserved */
>         u8  nv;          /* bit 279:272 - Notification Vector */
>         u8  rsvd_2;      /* bit 287:280 - Reserved */
>         u32 ndst;        /* bit 319:288 - Notification Destination */
>         };
>         u64 control;

This is okay.

Paolo
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index f7b6168..bd26501 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -446,8 +446,24 @@  struct nested_vmx {
 /* Posted-Interrupt Descriptor */
 struct pi_desc {
 	u32 pir[8];     /* Posted interrupt requested */
-	u32 control;	/* bit 0 of control is outstanding notification bit */
-	u32 rsvd[7];
+	union {
+		struct {
+				/* bit 256 - Outstanding Notification */
+			u64	on	: 1,
+				/* bit 257 - Suppress Notification */
+				sn	: 1,
+				/* bit 271:258 - Reserved */
+				rsvd_1	: 14,
+				/* bit 279:272 - Notification Vector */
+				nv	: 8,
+				/* bit 287:280 - Reserved */
+				rsvd_2	: 8,
+				/* bit 319:288 - Notification Destination */
+				ndst	: 32;
+		};
+		u64 control;
+	};
+	u32 rsvd[6];
 } __aligned(64);
 
 static bool pi_test_and_set_on(struct pi_desc *pi_desc)