[PATCH] x86/EPT: minor local variable adjustment in ept_set_entry()

Jan Beulich posted 1 patch 3 years, 7 months ago
Test gitlab-ci passed
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/c682ec9a-c339-a929-1c91-c20bf53d9722@suse.com
[PATCH] x86/EPT: minor local variable adjustment in ept_set_entry()
Posted by Jan Beulich 3 years, 7 months ago
Not having direct_mmio (used only once anyway) as a local variable gets
the epte_get_entry_emt() invocation here in better sync with the other
ones. While at it also reduce ipat's scope.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/arch/x86/mm/p2m-ept.c
+++ b/xen/arch/x86/mm/p2m-ept.c
@@ -677,8 +677,6 @@ ept_set_entry(struct p2m_domain *p2m, gf
     unsigned long fn_mask = !mfn_eq(mfn, INVALID_MFN) ? (gfn | mfn_x(mfn)) : gfn;
     int ret, rc = 0;
     bool_t entry_written = 0;
-    bool_t direct_mmio = (p2mt == p2m_mmio_direct);
-    uint8_t ipat = 0;
     bool_t need_modify_vtd_table = 1;
     bool_t vtd_pte_present = 0;
     unsigned int iommu_flags = p2m_get_iommu_flags(p2mt, mfn);
@@ -790,8 +788,10 @@ ept_set_entry(struct p2m_domain *p2m, gf
 
     if ( mfn_valid(mfn) || p2m_allows_invalid_mfn(p2mt) )
     {
+        uint8_t ipat = 0;
         int emt = epte_get_entry_emt(p2m->domain, gfn, mfn,
-                                     i * EPT_TABLE_ORDER, &ipat, direct_mmio);
+                                     i * EPT_TABLE_ORDER, &ipat,
+                                     p2mt == p2m_mmio_direct);
 
         if ( emt >= 0 )
             new_entry.emt = emt;

Re: [PATCH] x86/EPT: minor local variable adjustment in ept_set_entry()
Posted by Roger Pau Monné 3 years, 7 months ago
On Mon, Apr 12, 2021 at 01:33:50PM +0200, Jan Beulich wrote:
> Not having direct_mmio (used only once anyway) as a local variable gets
> the epte_get_entry_emt() invocation here in better sync with the other
> ones. While at it also reduce ipat's scope.
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>

Thanks, Roger.

RE: [PATCH] x86/EPT: minor local variable adjustment in ept_set_entry()
Posted by Tian, Kevin 3 years, 7 months ago
> From: Jan Beulich <jbeulich@suse.com>
> Sent: Monday, April 12, 2021 7:34 PM
> Not having direct_mmio (used only once anyway) as a local variable gets
> the epte_get_entry_emt() invocation here in better sync with the other
> ones. While at it also reduce ipat's scope.
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Kevin Tian <kevin.tian@intel.com>

> 
> --- a/xen/arch/x86/mm/p2m-ept.c
> +++ b/xen/arch/x86/mm/p2m-ept.c
> @@ -677,8 +677,6 @@ ept_set_entry(struct p2m_domain *p2m, gf
>      unsigned long fn_mask = !mfn_eq(mfn, INVALID_MFN) ? (gfn |
> mfn_x(mfn)) : gfn;
>      int ret, rc = 0;
>      bool_t entry_written = 0;
> -    bool_t direct_mmio = (p2mt == p2m_mmio_direct);
> -    uint8_t ipat = 0;
>      bool_t need_modify_vtd_table = 1;
>      bool_t vtd_pte_present = 0;
>      unsigned int iommu_flags = p2m_get_iommu_flags(p2mt, mfn);
> @@ -790,8 +788,10 @@ ept_set_entry(struct p2m_domain *p2m, gf
> 
>      if ( mfn_valid(mfn) || p2m_allows_invalid_mfn(p2mt) )
>      {
> +        uint8_t ipat = 0;
>          int emt = epte_get_entry_emt(p2m->domain, gfn, mfn,
> -                                     i * EPT_TABLE_ORDER, &ipat, direct_mmio);
> +                                     i * EPT_TABLE_ORDER, &ipat,
> +                                     p2mt == p2m_mmio_direct);
> 
>          if ( emt >= 0 )
>              new_entry.emt = emt;