x86/EPT: correct special page checking in epte_get_entry_emt()

mfn_valid() granularity is (currently) 256Mb. Therefore the start of a
1Gb page passing the test doesn't necessarily mean all parts of such a
range would also pass. Yet using the result of mfn_to_page() on an MFN
which doesn't pass mfn_valid() checking is liable to result in a crash
(the invocation of mfn_to_page() alone is presumably "just" UB in such a
case).

Fixes: ca24b2ffdb ("x86/hvm: set 'ipat' in EPT for special pages")
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
master commit: 5540b94e81
master date: 2024-06-13 16:53:34 +0200
This commit is contained in:
Jan Beulich committed 2024-06-26 13:39:44 +02:00
1 parent ce0a0cb0a7
commit 6e647efaf2
1 file changed
+5 -1
+5 -1
View File
@@ -518,8 +518,12 @@ int epte_get_entry_emt(struct domain *d, gfn_t gfn, mfn_t mfn,
}
for ( special_pgs = i = 0; i < (1ul << order); i++ )
if ( is_special_page(mfn_to_page(mfn_add(mfn, i))) )
{
mfn_t cur = mfn_add(mfn, i);
if ( mfn_valid(cur) && is_special_page(mfn_to_page(cur)) )
special_pgs++;
}
if ( special_pgs )
{
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.