x86/mm: Remove unnecessary mfn_valid() call from get_page_from_l1e()

mfn_valid() is not a trivially simple, and contains an evaluate_nospec() for
speculative defence.  Avoid calling it redundantly, and just store the result
of the first call.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
This commit is contained in:
Andrew Cooper committed 2022-05-18 15:05:18 +01:00
1 parent 25c160a74f
commit c154abe99d
1 file changed
+5 -3
+5 -3
View File
@@ -887,7 +887,7 @@ get_page_from_l1e(
uint32_t l1f = l1e_get_flags(l1e);
struct vcpu *curr = current;
struct domain *real_pg_owner;
bool write;
bool write, valid;
if ( unlikely(!(l1f & _PAGE_PRESENT)) )
{
@@ -902,13 +902,15 @@ get_page_from_l1e(
return -EINVAL;
}
if ( !mfn_valid(_mfn(mfn)) ||
valid = mfn_valid(_mfn(mfn));
if ( !valid ||
(real_pg_owner = page_get_owner_and_reference(page)) == dom_io )
{
int flip = 0;
/* Only needed the reference to confirm dom_io ownership. */
if ( mfn_valid(_mfn(mfn)) )
if ( valid )
put_page(page);
/* DOMID_IO reverts to caller for privilege checks. */
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.