ANDROID: 16K: Fix padding calculation during VMA split

During a VMA split, the original VMA's bounds (vm_start and vm_end) are
updated before its padding flags are adjusted. This creates a transient
state where the VMA's page count (vma_pages(vma)) is smaller than the
number of padding pages stored in its flags.

As a result, the consistency check in vma_pad_pages() incorrectly
fails, returns 0, and triggers a WARN_ON because it sees the padding
exceeding the now-shortened VMA size.

Fix this by introducing an internal __vma_pad_pages() helper that
accepts the new VMA as an optional argument. When called during a
split, it sums the pages of both VMA halves to reconstruct the
original size for the padding check.

Additionally, update the internal page count variables to use unsigned
long to maintain consistency with the return type of vma_pages().

Bug: 505115555
Bug: 507355203
Reported-by: Hsin-Te Yuan <yuanhsinte@google.com>
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
Cherrypick-From: https://android-review.googlesource.com/q/commit:196114e65d45833c38df99c402e4f535c65438b7
Merged-In: I6329ffa4118a4e0eea0a171317b85f7afd810b02
Change-Id: I6329ffa4118a4e0eea0a171317b85f7afd810b02
1 file changed