On Thu, Oct 21, 2021 at 11:58 AM Andy Shevchenko andy.shevchenko@gmail.com wrote:
On Thu, Oct 21, 2021 at 12:52 PM Viresh Kumar viresh.kumar@linaro.org wrote:
On 21-10-21, 12:42, Andy Shevchenko wrote:
On Thu, Oct 21, 2021 at 7:34 AM Viresh Kumar viresh.kumar@linaro.org wrote:
On 20-10-21, 18:10, Andy Shevchenko wrote:
If there is a possibility to have 32-bit to 64-bit or vice versa communication you have a problem.
This should work as well.
The structure will get aligned to the size of largest element and each element will be aligned to itself. I don't see how this will break even in case of 32/64 bit communication.
I admit I haven't looked into the specification, but in the past we had had quite an issue exactly in GPIO on kernel side because of this kind of design mistake. The problem here if in the future one wants to supply more than one item at a time, it will be not possible with this interface. Yes, I understand that in current design it's rather missed scalability, but hey, I believe in the future we may need performance-wise calls.
In my experience, adding __packed to structures causes more problems than it solves, please don't do that.
The rules for the virtio structures should be roughly the same that I documented in Documentation/driver-api/ioctl.rst, and the layout that Viresh has picked does not suffer from any of the common issues that are listed there.
Arnd