x86/mm: also allow L2 (un)validation to be fully preemptible
authorJan Beulich <jbeulich@suse.com>
Tue, 5 Mar 2019 12:51:18 +0000 (13:51 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 5 Mar 2019 12:51:18 +0000 (13:51 +0100)
commit176ebf9c8bc2828f6637eb61cc1cf166e302c699
treee98a2e38eb0d81521e971e4fbf12684f0293672f
parentfe21b78ef99a1b505cfb6d3789ede9591609dd70
x86/mm: also allow L2 (un)validation to be fully preemptible

Commit c612481d1c ("x86/mm: Plumbing to allow any PTE update to fail
with -ERESTART") added assertions next to the {alloc,free}_l2_table()
invocations to document (and validate in debug builds) that L2
(un)validations are always preemptible.

The assertion in free_page_type() was now observed to trigger when
recursive L2 page tables get cleaned up.

In particular put_page_from_l2e()'s assumption that _put_page_type()
would always succeed is now wrong, resulting in a partially un-validated
page left in a domain, which has no other means of getting cleaned up
later on. If not causing any problems earlier, this would ultimately
trigger the check for ->u.inuse.type_info having a zero count when
freeing the page during cleanup after the domain has died.

As a result it should be considered a mistake to not have extended
preemption fully to L2 when it was added to L3/L4 table handling, which
this change aims to correct.

The validation side additions are done just for symmetry.

This is part of XSA-290.

Reported-by: Manuel Bouyer <bouyer@antioche.eu.org>
Tested-by: Manuel Bouyer <bouyer@antioche.eu.org>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/mm.c