sfc: Ensure MCDI buffers, but not lengths, are dword aligned
We currently require that MCDI request and response lengths are multiples of 4 bytes, because we will copy dwords in and out of shared memory and we want to be sure we won't read or write out of bounds. But all we really need to know is that there is sufficient padding for that. Also, we should ensure that buffers are dword-aligned, as on some architectures misaligned access will result in data corruption or a crash. Change the buffer type to array-of-efx_dword_t and remove the requirement that the lengths are multiples of 4. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
This commit is contained in:
@@ -571,9 +571,8 @@ static int efx_ptp_xmit_skb(struct efx_nic *efx, struct sk_buff *skb)
|
||||
struct efx_ptp_data *ptp_data = efx->ptp_data;
|
||||
struct skb_shared_hwtstamps timestamps;
|
||||
int rc = -EIO;
|
||||
/* MCDI driver requires word aligned lengths */
|
||||
size_t len = ALIGN(MC_CMD_PTP_IN_TRANSMIT_LEN(skb->len), 4);
|
||||
MCDI_DECLARE_BUF(txtime, MC_CMD_PTP_OUT_TRANSMIT_LEN);
|
||||
size_t len;
|
||||
|
||||
MCDI_SET_DWORD(ptp_data->txbuf, PTP_IN_OP, MC_CMD_PTP_OP_TRANSMIT);
|
||||
MCDI_SET_DWORD(ptp_data->txbuf, PTP_IN_TRANSMIT_LENGTH, skb->len);
|
||||
@@ -591,9 +590,10 @@ static int efx_ptp_xmit_skb(struct efx_nic *efx, struct sk_buff *skb)
|
||||
skb_copy_from_linear_data(skb,
|
||||
MCDI_PTR(ptp_data->txbuf,
|
||||
PTP_IN_TRANSMIT_PACKET),
|
||||
len);
|
||||
rc = efx_mcdi_rpc(efx, MC_CMD_PTP, ptp_data->txbuf, len, txtime,
|
||||
sizeof(txtime), &len);
|
||||
skb->len);
|
||||
rc = efx_mcdi_rpc(efx, MC_CMD_PTP,
|
||||
ptp_data->txbuf, MC_CMD_PTP_IN_TRANSMIT_LEN(skb->len),
|
||||
txtime, sizeof(txtime), &len);
|
||||
if (rc != 0)
|
||||
goto fail;
|
||||
|
||||
|
Reference in New Issue
Block a user