]> xenbits.xensource.com Git - xen.git/commit
x86/p2m: fix PoD accounting in guest_physmap_add_entry()
authorJan Beulich <jbeulich@suse.com>
Wed, 25 Aug 2021 13:45:21 +0000 (15:45 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 25 Aug 2021 13:45:21 +0000 (15:45 +0200)
commit2f4cfe5a234b4f788aad93e08b9994c87d09343e
tree790c3e6a43eee98858311787e11ebc2a38ab6c2b
parent0475382080896460f10a12c72a20369bda1f6728
x86/p2m: fix PoD accounting in guest_physmap_add_entry()

The initial observation was that the mfn_valid() check comes too late:
Neither mfn_add() nor mfn_to_page() (let alone de-referencing the
result of the latter) are valid for MFNs failing this check. Move it up
and - noticing that there's no caller doing so - also add an assertion
that this should never produce "false" here.

In turn this would have meant that the "else" to that if() could now go
away, which didn't seem right at all. And indeed, considering callers
like memory_exchange() or various grant table functions, the PoD
accounting should have been outside of that if() from the very
beginning.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
master commit: aea270e3f7c0db696c88a0e94b1ece7abd339c84
master date: 2020-02-21 17:14:38 +0100
xen/arch/x86/mm/p2m.c