[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] x86/mm: Remove unnecessary mfn_valid() call from get_page_from_l1e()


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 26 May 2022 17:31:01 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=W82GIxvujUZKFBMLSIORS/H4mpxmXUxgQqKM7j010fM=; b=Wx/V4t8oOy9OqaN0QwdSQl2eRIOgFPtD6XvG+MOAtX4zQUXgcVNJeNjjwYZbK3PWD0Ms/IH2nSfiISqiit+wPzuFM2Atop6mBap4DrTNcev6hH2B4bjiv3YDCUBwrzMAA/2DepXkNIHFtk1prctzULfefac1+qWcsSfk+3dFNpafFvQjQ3zwyoGkx/07k8PcyrjjSyP6GGfZ12bF3Pn6R3rj98FFykyVoBAaSdwjIRMQhKEus4fW7U4ZaJDyQNLZE77Pvb51+ZvAJgHBTr8Hqzr0bx6qL5RytZZQil9q9uOdxVqxM0HTspVZoI4ouk8ZrVH/9j26at/vL0Lwh6x7ow==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fpY8oyAdsLJnBC8/4DDlxqtjrhoy2WxMGfIZIfIwezSn1n+URAUAE+v2WFJfqzH6fhTtf0TaAOUQ1i5b4JO1t3PpmVIIRuEbcd4IBNHoojXAtxjFE36+kTIAZBmtO6sVmciplQIm1DmUlvQdcMtvqBDIK1TpQ9HARn5M8eCsN+QykuGHjzncjmNKKwAVlJi1UeoINRYDgMoq8xMD3ej5fJdPtvv0YtycgKhzWFdraMgZ1OfAQSgo+avQg4Fsw4cjhZmkVH9sKVpdFKS+jn7+E/uXXKsuarXhnVZA0nPgtB0cXJgNZtcP9hUXYIrU6jqMnTvUmAwC/FIBky24ofrH7w==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 26 May 2022 15:31:10 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 27.04.2022 16:04, Andrew Cooper wrote:
> 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.

Since it took quite some time for this to actually be committed, I did
notice it among more recent commits, and I've grown a question: Isn't
the latching of the result in a local variable undermining the supposed
speculative defense? It's not as if I could point out a particular
gadget here, but it feels like the adjustment should have specifically
justified the speculative safety ... But I guess my understanding of
all of this might still be somewhat flaky?

Jan

> @@ -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. */




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.