Re: [Xen-devel] [PATCH 07/34] x86: only call memory_type_changed for HVM guests

2018-08-22 Thread Wei Liu
On Mon, Aug 20, 2018 at 05:57:25AM -0600, Jan Beulich wrote:
> >>> On 17.08.18 at 17:12,  wrote:
> > --- a/xen/arch/x86/domctl.c
> > +++ b/xen/arch/x86/domctl.c
> > @@ -416,7 +416,7 @@ long arch_do_domctl(
> >  ret = ioports_permit_access(d, fp, fp + np - 1);
> >  else
> >  ret = ioports_deny_access(d, fp, fp + np - 1);
> > -if ( !ret )
> > +if ( !ret && is_hvm_domain(d) )
> >  memory_type_changed(d);
> 
> I think whether to add is_hvm_...() conditionals or whether to introduce
> stubs should be selected based on resulting code churn: In the case
> here this would seem to suggest a static inline stub is on order. Or
> perhaps more generically - if a function already sits solely on is_hvm_...()
> guarded code paths, don't introduce a stub, but otherwise probably
> introducing a stub is preferable over scattering around new is_hvm_...()
> guards.

If there had been dozens of calls to memory_type_changed I would have
added a stub instead. I will switch to using stubs in the next version.

If a function already sits under is_hvm_* no stub will be needed in the
first place, assuming DCE works properly.

Wei.

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH 07/34] x86: only call memory_type_changed for HVM guests

2018-08-20 Thread Jan Beulich
>>> On 17.08.18 at 17:12,  wrote:
> --- a/xen/arch/x86/domctl.c
> +++ b/xen/arch/x86/domctl.c
> @@ -416,7 +416,7 @@ long arch_do_domctl(
>  ret = ioports_permit_access(d, fp, fp + np - 1);
>  else
>  ret = ioports_deny_access(d, fp, fp + np - 1);
> -if ( !ret )
> +if ( !ret && is_hvm_domain(d) )
>  memory_type_changed(d);

I think whether to add is_hvm_...() conditionals or whether to introduce
stubs should be selected based on resulting code churn: In the case
here this would seem to suggest a static inline stub is on order. Or
perhaps more generically - if a function already sits solely on is_hvm_...()
guarded code paths, don't introduce a stub, but otherwise probably
introducing a stub is preferable over scattering around new is_hvm_...()
guards.

> @@ -1037,7 +1037,8 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) 
> u_domctl)
> ret, d->domain_id, mfn, mfn_end);
>  }
>  /* Do this unconditionally to cover errors on above failure paths. */
> -memory_type_changed(d);
> + if ( is_hvm_domain(d) )

Hard tab (not that it matters much with the above).

Jan



___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

[Xen-devel] [PATCH 07/34] x86: only call memory_type_changed for HVM guests

2018-08-17 Thread Wei Liu
Jan indicated that for PV guests the memory type is not changed, for
HVM guests memory_type_changed is needed for EPT's effective memory
type calculation. Call memory_type_changed for HVM guests only.

Signed-off-by: Wei Liu 
---
 xen/arch/x86/domctl.c   | 4 ++--
 xen/common/domctl.c | 5 +++--
 xen/drivers/passthrough/iommu.c | 3 ++-
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
index 1002659..a8325f5 100644
--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -416,7 +416,7 @@ long arch_do_domctl(
 ret = ioports_permit_access(d, fp, fp + np - 1);
 else
 ret = ioports_deny_access(d, fp, fp + np - 1);
-if ( !ret )
+if ( !ret && is_hvm_domain(d) )
 memory_type_changed(d);
 break;
 }
@@ -824,7 +824,7 @@ long arch_do_domctl(
"ioport_map: error %ld denying dom%d access to 
[%x,%x]\n",
ret, d->domain_id, fmp, fmp + np - 1);
 }
-if ( !ret )
+if ( !ret && is_hvm_domain(d) )
 memory_type_changed(d);
 break;
 }
diff --git a/xen/common/domctl.c b/xen/common/domctl.c
index 0ef554a..ae99fed 100644
--- a/xen/common/domctl.c
+++ b/xen/common/domctl.c
@@ -977,7 +977,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) 
u_domctl)
 ret = iomem_permit_access(d, mfn, mfn + nr_mfns - 1);
 else
 ret = iomem_deny_access(d, mfn, mfn + nr_mfns - 1);
-if ( !ret )
+if ( !ret && is_hvm_domain(d) )
 memory_type_changed(d);
 break;
 }
@@ -1037,7 +1037,8 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) 
u_domctl)
ret, d->domain_id, mfn, mfn_end);
 }
 /* Do this unconditionally to cover errors on above failure paths. */
-memory_type_changed(d);
+   if ( is_hvm_domain(d) )
+memory_type_changed(d);
 break;
 }
 
diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c
index 70d218f..cf5aa20 100644
--- a/xen/drivers/passthrough/iommu.c
+++ b/xen/drivers/passthrough/iommu.c
@@ -240,7 +240,8 @@ int iommu_construct(struct domain *d)
  * memory_type_changed lose effect if memory type changes.
  * Call memory_type_changed here to amend this.
  */
-memory_type_changed(d);
+if ( is_hvm_domain(d) )
+memory_type_changed(d);
 
 return 0;
 }
-- 
git-series 0.9.1

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel