RE: [PATCH 2/2] ntb_hw_switchtec: Check for alignment of the buffer in mw_set_trans()
From: Allen Hubbe
Date: Mon Dec 11 2017 - 14:18:12 EST
From: Logan Gunthorpe
> mw_get_align doesn't communicate the fact that the buffer has to be
> aligned by its size.
Is that not the purpose of the addr_align out parameter of ntb_mw_get_align()?
> It may also be that all hardware does not have this
> restriction (ie. if the hardware adds to the base address instead of
> just replacing the lower bits).
>
> There is definitely a need to print this error somewhere as I hit this
> case and it caused very weird behavior. It was a huge pain to debug.
> Also, it's a security issue and huge bug if we end up mapping the memory
> we didn't think we were mapping.
Of course the driver should validate its parameters not allow bad mappings. I was only commenting on the dev_err() message to the console.
What makes best sense for client drivers with regards to ntb api changes is a fair argument. Let's see what others say.
> I don't think it's a good idea for us
> to require clients to check this as that requires a number of checks and
> a client author may forget to add it to their driver. I'd maybe go with
> a check in ntb_mw_set_trans before calling the driver, but that only
> makes sense if all hardware has the same requirement.
>
> Logan