From: Jack Morgenstein <jackm@dev.mellanox.co.il>
To: David Laight <David.Laight@ACULAB.COM>
Cc: 'Amir Vadai' <amirv@mellanox.com>,
"David S. Miller" <davem@davemloft.net>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
Or Gerlitz <ogerlitz@mellanox.com>,
Yevgeny Petrilin <yevgenyp@mellanox.com>
Subject: Re: [PATCH net-next 06/10] net/mlx4_core: Fix struct mlx4_vhcr_cmd to make implicit padding explicit
Date: Tue, 27 Jan 2015 15:00:27 +0200 [thread overview]
Message-ID: <20150127150027.184ba5e8@jpm-OptiPlex-GX620> (raw)
In-Reply-To: <063D6719AE5E284EB5DD2968C1650D6D1CAD3B01@AcuExch.aculab.com>
On Tue, 27 Jan 2015 09:43:27 +0000
David Laight <David.Laight@ACULAB.COM> wrote:
> From: Amir Vadai
> > From: Jack Morgenstein <jackm@dev.mellanox.co.il>
> >
> > Struct mlx4_vhcr was implicitly padded by the gcc compiler.
> > This commit makes that padding explicit, to prevent issues with
> > changing compilers. Note that we added the padding dword (rather
> > than simply packing the structure) in order to maintain
> > compatibility with previous kernels.
>
> It isn't a 'compiler' option, but depends on the architecture.
>
> > Reported-by: Alexander Schmidt <alexs@linux.vnet.ibm.com>
> > Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
> > Signed-off-by: Amir Vadai <amirv@mellanox.com>
> > ---
> > drivers/net/ethernet/mellanox/mlx4/mlx4.h | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4.h
> > b/drivers/net/ethernet/mellanox/mlx4/mlx4.h index 096a81c..595e18a
> > 100644 --- a/drivers/net/ethernet/mellanox/mlx4/mlx4.h
> > +++ b/drivers/net/ethernet/mellanox/mlx4/mlx4.h
> > @@ -196,13 +196,14 @@ struct mlx4_vhcr {
> > struct mlx4_vhcr_cmd {
> > __be64 in_param;
> > __be32 in_modifier;
> > + u32 reserved1;
>
> Adding a pad here changes the alignment on most 32bit architectures
> (eg i386) where 64bit integers are only aligned to 4 byte boundaries.
> So you are not 'maintaining compatibility with previous kernels'.
You are correct. However, this structure is used ONLY for communication
between a Host and a Guest on that host. In the current code (before
this fix), it was not possible to run a 32-bit Guest over a 64-bit Host,
because of the implicit padding that occurred on the 64-bit Host
and did not occur on the 32-bit Guest.
With this fix, a 32-bit Guest (with the fix) will be able to run over a
64-bit Host (with or without the fix).
The padding dword thus serves to maintain 64-bit Host (old or
new) compatibility with 64-bit Guests (old or new), while allowing
64-bit Hosts to support new 32-bit Guests.
I'll fix the changelog for the next submission.
>
> > __be64 out_param;
> > __be16 token;
> > u16 reserved;
> > u8 status;
> > u8 flags;
> > __be16 opcode;
> > -};
> > +} __packed;
>
> Don't add '__packed' unless you expect the structure to be misaligned
> in memory.
> On systems that fault mis-aligned memory requests you've requested the
> compiler generate code to read/write everything using byte sized
> memory accesses and a lot of shifting and masking.
OK, I'll remove the "packed" in the next submission, since with the
padding dword 64-bit arch and 32-bit arch compilers should produce the
same offsets.
>
> David
>
Thanks for the review!
-Jack
next prev parent reply other threads:[~2015-01-27 12:59 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-27 9:32 [PATCH net-next 00/10] Mellanox ethernet driver updates Jan-27-2015 Amir Vadai
2015-01-27 9:32 ` [PATCH net-next 01/10] net/mlx4_core: Add bad-cable event support Amir Vadai
2015-01-27 9:32 ` [PATCH net-next 02/10] net/mlx4_core: Add reserved lkey for VFs to QUERY_FUNC_CAP Amir Vadai
2015-01-27 9:32 ` [PATCH net-next 03/10] net/mlx4_core: Fix mem leak in SRIOV mlx4_init_one error flow Amir Vadai
2015-01-27 9:32 ` [PATCH net-next 04/10] net/mlx4_core: Adjust command timeouts to conform to the firmware spec Amir Vadai
2015-01-27 9:32 ` [PATCH net-next 05/10] net/mlx4_core: Fix HW2SW_EQ " Amir Vadai
2015-01-27 9:32 ` [PATCH net-next 06/10] net/mlx4_core: Fix struct mlx4_vhcr_cmd to make implicit padding explicit Amir Vadai
2015-01-27 9:43 ` David Laight
2015-01-27 13:00 ` Jack Morgenstein [this message]
2015-01-27 13:38 ` David Laight
2015-01-27 14:43 ` Jack Morgenstein
2015-01-27 19:13 ` David Miller
2015-01-27 19:50 ` Jack Morgenstein
2015-01-28 15:16 ` Jack Morgenstein
2015-01-27 9:32 ` [PATCH net-next 07/10] net/mlx4_core: Remove duplicate code line from procedure mlx4_bf_alloc Amir Vadai
2015-01-27 9:32 ` [PATCH net-next 08/10] net/mlx4_en: Use ethtool cmd->autoneg as a hint for ethtool set settings Amir Vadai
2015-01-27 9:32 ` [PATCH net-next 09/10] net/mlx4: Fix memory corruption in mlx4_MAD_IFC_wrapper Amir Vadai
2015-01-27 9:32 ` [PATCH net-next 10/10] net/mlx4_core: Fix device capabilities dumping Amir Vadai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150127150027.184ba5e8@jpm-OptiPlex-GX620 \
--to=jackm@dev.mellanox.co.il \
--cc=David.Laight@ACULAB.COM \
--cc=amirv@mellanox.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=ogerlitz@mellanox.com \
--cc=yevgenyp@mellanox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox