* [PATCH] pvcalls-front: 64-bit align flags
@ 2018-02-27 19:54 Stefano Stabellini
2018-02-27 21:19 ` Boris Ostrovsky
` (3 more replies)
0 siblings, 4 replies; 12+ messages in thread
From: Stefano Stabellini @ 2018-02-27 19:54 UTC (permalink / raw)
To: jgross, boris.ostrovsky; +Cc: sstabellini, xen-devel, linux-kernel
We are using test_and_* operations on the status and flag fields of
struct sock_mapping. However, these functions require the operand to be
64-bit aligned on arm64. Currently, only status is 64-bit aligned.
Make flags 64-bit aligned by introducing an explicit padding field.
Signed-off-by: Stefano Stabellini <stefano@aporeto.com>
diff --git a/drivers/xen/pvcalls-front.c b/drivers/xen/pvcalls-front.c
index ca5b773..aa07b2a 100644
--- a/drivers/xen/pvcalls-front.c
+++ b/drivers/xen/pvcalls-front.c
@@ -78,6 +78,7 @@ struct sock_mapping {
#define PVCALLS_STATUS_BIND 1
#define PVCALLS_STATUS_LISTEN 2
uint8_t status;
+ uint8_t pad[7];
/*
* Internal state-machine flags.
* Only one accept operation can be inflight for a socket.
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH] pvcalls-front: 64-bit align flags
2018-02-27 19:54 [PATCH] pvcalls-front: 64-bit align flags Stefano Stabellini
@ 2018-02-27 21:19 ` Boris Ostrovsky
2018-02-27 21:32 ` Stefano Stabellini
2018-02-27 21:32 ` Stefano Stabellini
2018-02-27 21:19 ` Boris Ostrovsky
` (2 subsequent siblings)
3 siblings, 2 replies; 12+ messages in thread
From: Boris Ostrovsky @ 2018-02-27 21:19 UTC (permalink / raw)
To: Stefano Stabellini, jgross; +Cc: xen-devel, linux-kernel
On 02/27/2018 02:54 PM, Stefano Stabellini wrote:
> We are using test_and_* operations on the status and flag fields of
> struct sock_mapping. However, these functions require the operand to be
> 64-bit aligned on arm64. Currently, only status is 64-bit aligned.
>
> Make flags 64-bit aligned by introducing an explicit padding field.
>
> Signed-off-by: Stefano Stabellini <stefano@aporeto.com>
>
> diff --git a/drivers/xen/pvcalls-front.c b/drivers/xen/pvcalls-front.c
> index ca5b773..aa07b2a 100644
> --- a/drivers/xen/pvcalls-front.c
> +++ b/drivers/xen/pvcalls-front.c
> @@ -78,6 +78,7 @@ struct sock_mapping {
> #define PVCALLS_STATUS_BIND 1
> #define PVCALLS_STATUS_LISTEN 2
> uint8_t status;
> + uint8_t pad[7];
Does this guarantee alignment (for either status or flag)?
-boris
> /*
> * Internal state-machine flags.
> * Only one accept operation can be inflight for a socket.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] pvcalls-front: 64-bit align flags
2018-02-27 19:54 [PATCH] pvcalls-front: 64-bit align flags Stefano Stabellini
2018-02-27 21:19 ` Boris Ostrovsky
@ 2018-02-27 21:19 ` Boris Ostrovsky
2018-02-28 9:06 ` David Laight
2018-02-28 9:06 ` David Laight
3 siblings, 0 replies; 12+ messages in thread
From: Boris Ostrovsky @ 2018-02-27 21:19 UTC (permalink / raw)
To: Stefano Stabellini, jgross; +Cc: xen-devel, linux-kernel
On 02/27/2018 02:54 PM, Stefano Stabellini wrote:
> We are using test_and_* operations on the status and flag fields of
> struct sock_mapping. However, these functions require the operand to be
> 64-bit aligned on arm64. Currently, only status is 64-bit aligned.
>
> Make flags 64-bit aligned by introducing an explicit padding field.
>
> Signed-off-by: Stefano Stabellini <stefano@aporeto.com>
>
> diff --git a/drivers/xen/pvcalls-front.c b/drivers/xen/pvcalls-front.c
> index ca5b773..aa07b2a 100644
> --- a/drivers/xen/pvcalls-front.c
> +++ b/drivers/xen/pvcalls-front.c
> @@ -78,6 +78,7 @@ struct sock_mapping {
> #define PVCALLS_STATUS_BIND 1
> #define PVCALLS_STATUS_LISTEN 2
> uint8_t status;
> + uint8_t pad[7];
Does this guarantee alignment (for either status or flag)?
-boris
> /*
> * Internal state-machine flags.
> * Only one accept operation can be inflight for a socket.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] pvcalls-front: 64-bit align flags
2018-02-27 21:19 ` Boris Ostrovsky
2018-02-27 21:32 ` Stefano Stabellini
@ 2018-02-27 21:32 ` Stefano Stabellini
2018-02-27 21:45 ` Boris Ostrovsky
2018-02-27 21:45 ` Boris Ostrovsky
1 sibling, 2 replies; 12+ messages in thread
From: Stefano Stabellini @ 2018-02-27 21:32 UTC (permalink / raw)
To: Boris Ostrovsky; +Cc: Stefano Stabellini, jgross, xen-devel, linux-kernel
On Tue, 27 Feb 2018, Boris Ostrovsky wrote:
> On 02/27/2018 02:54 PM, Stefano Stabellini wrote:
> > We are using test_and_* operations on the status and flag fields of
> > struct sock_mapping. However, these functions require the operand to be
> > 64-bit aligned on arm64. Currently, only status is 64-bit aligned.
> >
> > Make flags 64-bit aligned by introducing an explicit padding field.
> >
> > Signed-off-by: Stefano Stabellini <stefano@aporeto.com>
> >
> > diff --git a/drivers/xen/pvcalls-front.c b/drivers/xen/pvcalls-front.c
> > index ca5b773..aa07b2a 100644
> > --- a/drivers/xen/pvcalls-front.c
> > +++ b/drivers/xen/pvcalls-front.c
> > @@ -78,6 +78,7 @@ struct sock_mapping {
> > #define PVCALLS_STATUS_BIND 1
> > #define PVCALLS_STATUS_LISTEN 2
> > uint8_t status;
> > + uint8_t pad[7];
>
> Does this guarantee alignment (for either status or flag)?
Yes: status is part of a struct and a union. Unions and structs have the
alignment of their most aligned type. In this case they are 64-bit
aligned, as some of the fields are pointers.
The padding makes sure that flags is 1+7 bytes from it.
> > /*
> > * Internal state-machine flags.
> > * Only one accept operation can be inflight for a socket.
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] pvcalls-front: 64-bit align flags
2018-02-27 21:19 ` Boris Ostrovsky
@ 2018-02-27 21:32 ` Stefano Stabellini
2018-02-27 21:32 ` Stefano Stabellini
1 sibling, 0 replies; 12+ messages in thread
From: Stefano Stabellini @ 2018-02-27 21:32 UTC (permalink / raw)
To: Boris Ostrovsky; +Cc: jgross, xen-devel, Stefano Stabellini, linux-kernel
On Tue, 27 Feb 2018, Boris Ostrovsky wrote:
> On 02/27/2018 02:54 PM, Stefano Stabellini wrote:
> > We are using test_and_* operations on the status and flag fields of
> > struct sock_mapping. However, these functions require the operand to be
> > 64-bit aligned on arm64. Currently, only status is 64-bit aligned.
> >
> > Make flags 64-bit aligned by introducing an explicit padding field.
> >
> > Signed-off-by: Stefano Stabellini <stefano@aporeto.com>
> >
> > diff --git a/drivers/xen/pvcalls-front.c b/drivers/xen/pvcalls-front.c
> > index ca5b773..aa07b2a 100644
> > --- a/drivers/xen/pvcalls-front.c
> > +++ b/drivers/xen/pvcalls-front.c
> > @@ -78,6 +78,7 @@ struct sock_mapping {
> > #define PVCALLS_STATUS_BIND 1
> > #define PVCALLS_STATUS_LISTEN 2
> > uint8_t status;
> > + uint8_t pad[7];
>
> Does this guarantee alignment (for either status or flag)?
Yes: status is part of a struct and a union. Unions and structs have the
alignment of their most aligned type. In this case they are 64-bit
aligned, as some of the fields are pointers.
The padding makes sure that flags is 1+7 bytes from it.
> > /*
> > * Internal state-machine flags.
> > * Only one accept operation can be inflight for a socket.
>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] pvcalls-front: 64-bit align flags
2018-02-27 21:32 ` Stefano Stabellini
2018-02-27 21:45 ` Boris Ostrovsky
@ 2018-02-27 21:45 ` Boris Ostrovsky
2018-02-27 21:50 ` Stefano Stabellini
2018-02-27 21:50 ` Stefano Stabellini
1 sibling, 2 replies; 12+ messages in thread
From: Boris Ostrovsky @ 2018-02-27 21:45 UTC (permalink / raw)
To: Stefano Stabellini; +Cc: jgross, xen-devel, linux-kernel
On 02/27/2018 04:32 PM, Stefano Stabellini wrote:
> On Tue, 27 Feb 2018, Boris Ostrovsky wrote:
>> On 02/27/2018 02:54 PM, Stefano Stabellini wrote:
>>> We are using test_and_* operations on the status and flag fields of
>>> struct sock_mapping. However, these functions require the operand to be
>>> 64-bit aligned on arm64. Currently, only status is 64-bit aligned.
>>>
>>> Make flags 64-bit aligned by introducing an explicit padding field.
>>>
>>> Signed-off-by: Stefano Stabellini <stefano@aporeto.com>
>>>
>>> diff --git a/drivers/xen/pvcalls-front.c b/drivers/xen/pvcalls-front.c
>>> index ca5b773..aa07b2a 100644
>>> --- a/drivers/xen/pvcalls-front.c
>>> +++ b/drivers/xen/pvcalls-front.c
>>> @@ -78,6 +78,7 @@ struct sock_mapping {
>>> #define PVCALLS_STATUS_BIND 1
>>> #define PVCALLS_STATUS_LISTEN 2
>>> uint8_t status;
>>> + uint8_t pad[7];
>> Does this guarantee alignment (for either status or flag)?
> Yes: status is part of a struct and a union. Unions and structs have the
> alignment of their most aligned type. In this case they are 64-bit
> aligned, as some of the fields are pointers.
>
> The padding makes sure that flags is 1+7 bytes from it.
OK.
What about adding __attribute__((aligned(8))) to both (with a comment
explaining reasoning)?
-boris
>
>
>>> /*
>>> * Internal state-machine flags.
>>> * Only one accept operation can be inflight for a socket.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] pvcalls-front: 64-bit align flags
2018-02-27 21:32 ` Stefano Stabellini
@ 2018-02-27 21:45 ` Boris Ostrovsky
2018-02-27 21:45 ` Boris Ostrovsky
1 sibling, 0 replies; 12+ messages in thread
From: Boris Ostrovsky @ 2018-02-27 21:45 UTC (permalink / raw)
To: Stefano Stabellini; +Cc: jgross, xen-devel, linux-kernel
On 02/27/2018 04:32 PM, Stefano Stabellini wrote:
> On Tue, 27 Feb 2018, Boris Ostrovsky wrote:
>> On 02/27/2018 02:54 PM, Stefano Stabellini wrote:
>>> We are using test_and_* operations on the status and flag fields of
>>> struct sock_mapping. However, these functions require the operand to be
>>> 64-bit aligned on arm64. Currently, only status is 64-bit aligned.
>>>
>>> Make flags 64-bit aligned by introducing an explicit padding field.
>>>
>>> Signed-off-by: Stefano Stabellini <stefano@aporeto.com>
>>>
>>> diff --git a/drivers/xen/pvcalls-front.c b/drivers/xen/pvcalls-front.c
>>> index ca5b773..aa07b2a 100644
>>> --- a/drivers/xen/pvcalls-front.c
>>> +++ b/drivers/xen/pvcalls-front.c
>>> @@ -78,6 +78,7 @@ struct sock_mapping {
>>> #define PVCALLS_STATUS_BIND 1
>>> #define PVCALLS_STATUS_LISTEN 2
>>> uint8_t status;
>>> + uint8_t pad[7];
>> Does this guarantee alignment (for either status or flag)?
> Yes: status is part of a struct and a union. Unions and structs have the
> alignment of their most aligned type. In this case they are 64-bit
> aligned, as some of the fields are pointers.
>
> The padding makes sure that flags is 1+7 bytes from it.
OK.
What about adding __attribute__((aligned(8))) to both (with a comment
explaining reasoning)?
-boris
>
>
>>> /*
>>> * Internal state-machine flags.
>>> * Only one accept operation can be inflight for a socket.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] pvcalls-front: 64-bit align flags
2018-02-27 21:45 ` Boris Ostrovsky
2018-02-27 21:50 ` Stefano Stabellini
@ 2018-02-27 21:50 ` Stefano Stabellini
1 sibling, 0 replies; 12+ messages in thread
From: Stefano Stabellini @ 2018-02-27 21:50 UTC (permalink / raw)
To: Boris Ostrovsky; +Cc: Stefano Stabellini, jgross, xen-devel, linux-kernel
On Tue, 27 Feb 2018, Boris Ostrovsky wrote:
> On 02/27/2018 04:32 PM, Stefano Stabellini wrote:
> > On Tue, 27 Feb 2018, Boris Ostrovsky wrote:
> >> On 02/27/2018 02:54 PM, Stefano Stabellini wrote:
> >>> We are using test_and_* operations on the status and flag fields of
> >>> struct sock_mapping. However, these functions require the operand to be
> >>> 64-bit aligned on arm64. Currently, only status is 64-bit aligned.
> >>>
> >>> Make flags 64-bit aligned by introducing an explicit padding field.
> >>>
> >>> Signed-off-by: Stefano Stabellini <stefano@aporeto.com>
> >>>
> >>> diff --git a/drivers/xen/pvcalls-front.c b/drivers/xen/pvcalls-front.c
> >>> index ca5b773..aa07b2a 100644
> >>> --- a/drivers/xen/pvcalls-front.c
> >>> +++ b/drivers/xen/pvcalls-front.c
> >>> @@ -78,6 +78,7 @@ struct sock_mapping {
> >>> #define PVCALLS_STATUS_BIND 1
> >>> #define PVCALLS_STATUS_LISTEN 2
> >>> uint8_t status;
> >>> + uint8_t pad[7];
> >> Does this guarantee alignment (for either status or flag)?
> > Yes: status is part of a struct and a union. Unions and structs have the
> > alignment of their most aligned type. In this case they are 64-bit
> > aligned, as some of the fields are pointers.
> >
> > The padding makes sure that flags is 1+7 bytes from it.
>
> OK.
>
> What about adding __attribute__((aligned(8))) to both (with a comment
> explaining reasoning)?
That's fine by me
> >
> >
> >>> /*
> >>> * Internal state-machine flags.
> >>> * Only one accept operation can be inflight for a socket.
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] pvcalls-front: 64-bit align flags
2018-02-27 21:45 ` Boris Ostrovsky
@ 2018-02-27 21:50 ` Stefano Stabellini
2018-02-27 21:50 ` Stefano Stabellini
1 sibling, 0 replies; 12+ messages in thread
From: Stefano Stabellini @ 2018-02-27 21:50 UTC (permalink / raw)
To: Boris Ostrovsky; +Cc: jgross, xen-devel, Stefano Stabellini, linux-kernel
On Tue, 27 Feb 2018, Boris Ostrovsky wrote:
> On 02/27/2018 04:32 PM, Stefano Stabellini wrote:
> > On Tue, 27 Feb 2018, Boris Ostrovsky wrote:
> >> On 02/27/2018 02:54 PM, Stefano Stabellini wrote:
> >>> We are using test_and_* operations on the status and flag fields of
> >>> struct sock_mapping. However, these functions require the operand to be
> >>> 64-bit aligned on arm64. Currently, only status is 64-bit aligned.
> >>>
> >>> Make flags 64-bit aligned by introducing an explicit padding field.
> >>>
> >>> Signed-off-by: Stefano Stabellini <stefano@aporeto.com>
> >>>
> >>> diff --git a/drivers/xen/pvcalls-front.c b/drivers/xen/pvcalls-front.c
> >>> index ca5b773..aa07b2a 100644
> >>> --- a/drivers/xen/pvcalls-front.c
> >>> +++ b/drivers/xen/pvcalls-front.c
> >>> @@ -78,6 +78,7 @@ struct sock_mapping {
> >>> #define PVCALLS_STATUS_BIND 1
> >>> #define PVCALLS_STATUS_LISTEN 2
> >>> uint8_t status;
> >>> + uint8_t pad[7];
> >> Does this guarantee alignment (for either status or flag)?
> > Yes: status is part of a struct and a union. Unions and structs have the
> > alignment of their most aligned type. In this case they are 64-bit
> > aligned, as some of the fields are pointers.
> >
> > The padding makes sure that flags is 1+7 bytes from it.
>
> OK.
>
> What about adding __attribute__((aligned(8))) to both (with a comment
> explaining reasoning)?
That's fine by me
> >
> >
> >>> /*
> >>> * Internal state-machine flags.
> >>> * Only one accept operation can be inflight for a socket.
>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [PATCH] pvcalls-front: 64-bit align flags
2018-02-27 19:54 [PATCH] pvcalls-front: 64-bit align flags Stefano Stabellini
` (2 preceding siblings ...)
2018-02-28 9:06 ` David Laight
@ 2018-02-28 9:06 ` David Laight
3 siblings, 0 replies; 12+ messages in thread
From: David Laight @ 2018-02-28 9:06 UTC (permalink / raw)
To: 'Stefano Stabellini', jgross, boris.ostrovsky
Cc: xen-devel, linux-kernel
From: Stefano Stabellini
> Sent: 27 February 2018 19:55
>
> We are using test_and_* operations on the status and flag fields of
> struct sock_mapping. However, these functions require the operand to be
> 64-bit aligned on arm64. Currently, only status is 64-bit aligned.
That sounds like a big accident just waiting to happen...
If the operand is required to be 64bit aligned why isn't it a type
that requires 64bit alignment?
> Make flags 64-bit aligned by introducing an explicit padding field.
At some point such padding will always go wrong...
David
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] pvcalls-front: 64-bit align flags
2018-02-27 19:54 [PATCH] pvcalls-front: 64-bit align flags Stefano Stabellini
2018-02-27 21:19 ` Boris Ostrovsky
2018-02-27 21:19 ` Boris Ostrovsky
@ 2018-02-28 9:06 ` David Laight
2018-02-28 9:06 ` David Laight
3 siblings, 0 replies; 12+ messages in thread
From: David Laight @ 2018-02-28 9:06 UTC (permalink / raw)
To: 'Stefano Stabellini', jgross, boris.ostrovsky
Cc: xen-devel, linux-kernel
From: Stefano Stabellini
> Sent: 27 February 2018 19:55
>
> We are using test_and_* operations on the status and flag fields of
> struct sock_mapping. However, these functions require the operand to be
> 64-bit aligned on arm64. Currently, only status is 64-bit aligned.
That sounds like a big accident just waiting to happen...
If the operand is required to be 64bit aligned why isn't it a type
that requires 64bit alignment?
> Make flags 64-bit aligned by introducing an explicit padding field.
At some point such padding will always go wrong...
David
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH] pvcalls-front: 64-bit align flags
@ 2018-02-27 19:54 Stefano Stabellini
0 siblings, 0 replies; 12+ messages in thread
From: Stefano Stabellini @ 2018-02-27 19:54 UTC (permalink / raw)
To: jgross, boris.ostrovsky; +Cc: xen-devel, sstabellini, linux-kernel
We are using test_and_* operations on the status and flag fields of
struct sock_mapping. However, these functions require the operand to be
64-bit aligned on arm64. Currently, only status is 64-bit aligned.
Make flags 64-bit aligned by introducing an explicit padding field.
Signed-off-by: Stefano Stabellini <stefano@aporeto.com>
diff --git a/drivers/xen/pvcalls-front.c b/drivers/xen/pvcalls-front.c
index ca5b773..aa07b2a 100644
--- a/drivers/xen/pvcalls-front.c
+++ b/drivers/xen/pvcalls-front.c
@@ -78,6 +78,7 @@ struct sock_mapping {
#define PVCALLS_STATUS_BIND 1
#define PVCALLS_STATUS_LISTEN 2
uint8_t status;
+ uint8_t pad[7];
/*
* Internal state-machine flags.
* Only one accept operation can be inflight for a socket.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply related [flat|nested] 12+ messages in thread
end of thread, other threads:[~2018-02-28 9:05 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-27 19:54 [PATCH] pvcalls-front: 64-bit align flags Stefano Stabellini
2018-02-27 21:19 ` Boris Ostrovsky
2018-02-27 21:32 ` Stefano Stabellini
2018-02-27 21:32 ` Stefano Stabellini
2018-02-27 21:45 ` Boris Ostrovsky
2018-02-27 21:45 ` Boris Ostrovsky
2018-02-27 21:50 ` Stefano Stabellini
2018-02-27 21:50 ` Stefano Stabellini
2018-02-27 21:19 ` Boris Ostrovsky
2018-02-28 9:06 ` David Laight
2018-02-28 9:06 ` David Laight
2018-02-27 19:54 Stefano Stabellini
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.