tegra: ivc: fix two counter-handling issues
1) Add a function for re-synchronizing local w_pos and r_pos indices
with the shared w_count and r_count counters. The local r/w index
must always remain in sync with the r/w counters in shared memory.
However, when a client guest reboots and the server's channel is
still active, the client must recover its queue positions using only
the information available in shared memory. The easiest way to do
this is to take the read and write frame count and modulus it with
the frame count. However, because the frame counts overflow at 2^32,
this only works if the frame count is a power of 2, so this
is imposed as a frame count requirement on all services.
Once IVC reset is implemented, this requirement can be lifted,
because the channel will be resynchronized by the client re-reserving
the active channel.
2) Without a range check in the empty check, it's too easy to perform a
denial of service attack against a server by placing the read and
write counters very far apart. We therefore require that a queue not
be over-full in order to be called non-empty to prevent receive loops
from processing billions of non-existent messages. Instead, the
receive queue from the malicious client will appear to go silent.
Bug 1581562
Bug 1582085
Change-Id: Ia949a0cd1df7217e247d7012a18a16242d311d1d
Signed-off-by: Peter Newman <pnewman@nvidia.com>
Reviewed-on: http://git-master/r/654391
Tested-by: Dawid Ciezarkiewicz <dawidc@nvidia.com>
Reviewed-by: Vladislav Buzov <vbuzov@nvidia.com>
Reviewed-by: Nitin Sehgal <nsehgal@nvidia.com>
Tested-by: Nitin Sehgal <nsehgal@nvidia.com>
Reviewed-by: Bahadir Balban <bbalban@nvidia.com>
Tested-by: Bahadir Balban <bbalban@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Alexander Van Brunt <avanbrunt@nvidia.com>
Reviewed-on: http://git-master/r/1198208
Tested-by: Haley Teng <hteng@nvidia.com>
1 file changed