From: "Jan Beulich" Subject: [PATCH] x86/HVM: don't use confusing/non-suitable XSM checks Date: Fri, 16 May 2014 10:25:37 +0100 Message-ID: <5375F5B10200007800012F1D@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part16243D81.1__=" Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WlEOb-0007Jh-Gd for xen-devel@lists.xenproject.org; Fri, 16 May 2014 09:25:41 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Andres Lagar-Cavilla , dgdegra@tycho.nsa.gov, Keir Fraser , Tim Deegan List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part16243D81.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline XSM_TARGET checks following rcu_lock_{,live_}remote_domain_by_id() are rather pointless and potentially confusing. Use XSM_DM_PRIV there instead. Note that setting flask_ops.hvm_control to flask_hvm_param() (instead of introducing flask_hvm_control() is intentional - that function is already separating the contol and non-control sub-operations. Signed-off-by: Jan Beulich --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -4748,7 +4748,7 @@ long do_hvm_op(unsigned long op, XEN_GUE if ( a.nr > GB(1) >> PAGE_SHIFT ) goto param_fail2; =20 - rc =3D xsm_hvm_param(XSM_TARGET, d, op); + rc =3D xsm_hvm_control(XSM_DM_PRIV, d, op); if ( rc ) goto param_fail2; =20 @@ -4786,7 +4786,7 @@ long do_hvm_op(unsigned long op, XEN_GUE if ( !is_hvm_domain(d) ) goto param_fail3; =20 - rc =3D xsm_hvm_param(XSM_TARGET, d, op); + rc =3D xsm_hvm_control(XSM_DM_PRIV, d, op); if ( rc ) goto param_fail3; =20 @@ -4896,7 +4896,7 @@ long do_hvm_op(unsigned long op, XEN_GUE if ( !is_hvm_domain(d) ) goto param_fail4; =20 - rc =3D xsm_hvm_param(XSM_TARGET, d, op); + rc =3D xsm_hvm_control(XSM_DM_PRIV, d, op); if ( rc ) goto param_fail4; =20 @@ -5026,7 +5026,7 @@ long do_hvm_op(unsigned long op, XEN_GUE if ( !is_hvm_domain(d) ) goto param_fail8; =20 - rc =3D xsm_hvm_param(XSM_TARGET, d, op); + rc =3D xsm_hvm_control(XSM_DM_PRIV, d, op); if ( rc ) goto param_fail8; =20 --- a/xen/arch/x86/mm/mem_access.c +++ b/xen/arch/x86/mm/mem_access.c @@ -47,7 +47,7 @@ int mem_access_memop(unsigned long cmd, if ( !is_hvm_domain(d) ) goto out; =20 - rc =3D xsm_mem_event_op(XSM_TARGET, d, XENMEM_access_op); + rc =3D xsm_mem_event_op(XSM_DM_PRIV, d, XENMEM_access_op); if ( rc ) goto out; =20 --- a/xen/arch/x86/mm/mem_event.c +++ b/xen/arch/x86/mm/mem_event.c @@ -449,7 +449,7 @@ int do_mem_event_op(int op, uint32_t dom if ( ret ) return ret; =20 - ret =3D xsm_mem_event_op(XSM_TARGET, d, op); + ret =3D xsm_mem_event_op(XSM_DM_PRIV, d, op); if ( ret ) goto out; =20 --- a/xen/arch/x86/mm/mem_sharing.c +++ b/xen/arch/x86/mm/mem_sharing.c @@ -1358,7 +1358,7 @@ int mem_sharing_memop(struct domain *d,=20 if ( rc ) return rc; =20 - rc =3D xsm_mem_sharing_op(XSM_TARGET, d, cd, mec->op); + rc =3D xsm_mem_sharing_op(XSM_DM_PRIV, d, cd, mec->op); if ( rc ) { rcu_unlock_domain(cd); @@ -1422,7 +1422,7 @@ int mem_sharing_memop(struct domain *d,=20 if ( rc ) return rc; =20 - rc =3D xsm_mem_sharing_op(XSM_TARGET, d, cd, mec->op); + rc =3D xsm_mem_sharing_op(XSM_DM_PRIV, d, cd, mec->op); if ( rc ) { rcu_unlock_domain(cd); --- a/xen/include/xsm/dummy.h +++ b/xen/include/xsm/dummy.h @@ -495,6 +495,12 @@ static XSM_INLINE int xsm_hvm_param(XSM_ return xsm_default_action(action, current->domain, d); } =20 +static XSM_INLINE int xsm_hvm_control(XSM_DEFAULT_ARG struct domain *d, = unsigned long op) +{ + XSM_ASSERT_ACTION(XSM_DM_PRIV); + return xsm_default_action(action, current->domain, d); +} + static XSM_INLINE int xsm_hvm_param_nested(XSM_DEFAULT_ARG struct domain = *d) { XSM_ASSERT_ACTION(XSM_PRIV); @@ -546,13 +552,13 @@ static XSM_INLINE int xsm_mem_event_cont =20 static XSM_INLINE int xsm_mem_event_op(XSM_DEFAULT_ARG struct domain *d, = int op) { - XSM_ASSERT_ACTION(XSM_TARGET); + XSM_ASSERT_ACTION(XSM_DM_PRIV); return xsm_default_action(action, current->domain, d); } =20 static XSM_INLINE int xsm_mem_sharing_op(XSM_DEFAULT_ARG struct domain = *d, struct domain *cd, int op) { - XSM_ASSERT_ACTION(XSM_TARGET); + XSM_ASSERT_ACTION(XSM_DM_PRIV); return xsm_default_action(action, current->domain, cd); } =20 --- a/xen/include/xsm/xsm.h +++ b/xen/include/xsm/xsm.h @@ -137,6 +137,7 @@ struct xsm_operations { #endif =20 int (*hvm_param) (struct domain *d, unsigned long op); + int (*hvm_control) (struct domain *d, unsigned long op); int (*hvm_param_nested) (struct domain *d); =20 #ifdef CONFIG_X86 @@ -522,6 +523,11 @@ static inline int xsm_hvm_param (xsm_def return xsm_ops->hvm_param(d, op); } =20 +static inline int xsm_hvm_control(xsm_default_t def, struct domain *d, = unsigned long op) +{ + return xsm_ops->hvm_control(d, op); +} + static inline int xsm_hvm_param_nested (xsm_default_t def, struct domain = *d) { return xsm_ops->hvm_param_nested(d); --- a/xen/xsm/dummy.c +++ b/xen/xsm/dummy.c @@ -105,6 +105,7 @@ void xsm_fixup_ops (struct xsm_operation set_to_dummy_if_null(ops, tmem_op); set_to_dummy_if_null(ops, tmem_control); set_to_dummy_if_null(ops, hvm_param); + set_to_dummy_if_null(ops, hvm_control); set_to_dummy_if_null(ops, hvm_param_nested); =20 set_to_dummy_if_null(ops, do_xsm_op); --- a/xen/xsm/flask/hooks.c +++ b/xen/xsm/flask/hooks.c @@ -1543,6 +1543,7 @@ static struct xsm_operations flask_ops =3D .tmem_op =3D flask_tmem_op, .tmem_control =3D flask_tmem_control, .hvm_param =3D flask_hvm_param, + .hvm_control =3D flask_hvm_param, .hvm_param_nested =3D flask_hvm_param_nested, =20 .do_xsm_op =3D do_flask_op, --=__Part16243D81.1__= Content-Type: text/plain; name="x86-HVM-consistent-XSM-checks.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-HVM-consistent-XSM-checks.patch" x86/HVM: don't use confusing/non-suitable XSM checks=0A=0AXSM_TARGET = checks following rcu_lock_{,live_}remote_domain_by_id() are=0Arather = pointless and potentially confusing. Use XSM_DM_PRIV there=0Ainstead.=0A=0A= Note that setting flask_ops.hvm_control to flask_hvm_param() (instead=0Aof = introducing flask_hvm_control() is intentional - that function is=0Aalready= separating the contol and non-control sub-operations.=0A=0ASigned-off-by: = Jan Beulich =0A=0A--- a/xen/arch/x86/hvm/hvm.c=0A+++ = b/xen/arch/x86/hvm/hvm.c=0A@@ -4748,7 +4748,7 @@ long do_hvm_op(unsigned = long op, XEN_GUE=0A if ( a.nr > GB(1) >> PAGE_SHIFT )=0A = goto param_fail2;=0A =0A- rc =3D xsm_hvm_param(XSM_TARGET, d, = op);=0A+ rc =3D xsm_hvm_control(XSM_DM_PRIV, d, op);=0A if = ( rc )=0A goto param_fail2;=0A =0A@@ -4786,7 +4786,7 @@ long = do_hvm_op(unsigned long op, XEN_GUE=0A if ( !is_hvm_domain(d) )=0A = goto param_fail3;=0A =0A- rc =3D xsm_hvm_param(XSM_TARGE= T, d, op);=0A+ rc =3D xsm_hvm_control(XSM_DM_PRIV, d, op);=0A = if ( rc )=0A goto param_fail3;=0A =0A@@ -4896,7 +4896,7 @@ = long do_hvm_op(unsigned long op, XEN_GUE=0A if ( !is_hvm_domain(d) = )=0A goto param_fail4;=0A =0A- rc =3D xsm_hvm_param(XSM_= TARGET, d, op);=0A+ rc =3D xsm_hvm_control(XSM_DM_PRIV, d, op);=0A = if ( rc )=0A goto param_fail4;=0A =0A@@ -5026,7 +5026,7 = @@ long do_hvm_op(unsigned long op, XEN_GUE=0A if ( !is_hvm_domain(= d) )=0A goto param_fail8;=0A =0A- rc =3D xsm_hvm_param(X= SM_TARGET, d, op);=0A+ rc =3D xsm_hvm_control(XSM_DM_PRIV, d, = op);=0A if ( rc )=0A goto param_fail8;=0A =0A--- = a/xen/arch/x86/mm/mem_access.c=0A+++ b/xen/arch/x86/mm/mem_access.c=0A@@ = -47,7 +47,7 @@ int mem_access_memop(unsigned long cmd,=0A if ( = !is_hvm_domain(d) )=0A goto out;=0A =0A- rc =3D xsm_mem_event_op= (XSM_TARGET, d, XENMEM_access_op);=0A+ rc =3D xsm_mem_event_op(XSM_DM_PR= IV, d, XENMEM_access_op);=0A if ( rc )=0A goto out;=0A =0A--- = a/xen/arch/x86/mm/mem_event.c=0A+++ b/xen/arch/x86/mm/mem_event.c=0A@@ = -449,7 +449,7 @@ int do_mem_event_op(int op, uint32_t dom=0A if ( ret = )=0A return ret;=0A =0A- ret =3D xsm_mem_event_op(XSM_TARGET, = d, op);=0A+ ret =3D xsm_mem_event_op(XSM_DM_PRIV, d, op);=0A if ( = ret )=0A goto out;=0A =0A--- a/xen/arch/x86/mm/mem_sharing.c=0A+++ = b/xen/arch/x86/mm/mem_sharing.c=0A@@ -1358,7 +1358,7 @@ int mem_sharing_mem= op(struct domain *d, =0A if ( rc )=0A return = rc;=0A =0A- rc =3D xsm_mem_sharing_op(XSM_TARGET, d, cd, = mec->op);=0A+ rc =3D xsm_mem_sharing_op(XSM_DM_PRIV, d, cd, = mec->op);=0A if ( rc )=0A {=0A = rcu_unlock_domain(cd);=0A@@ -1422,7 +1422,7 @@ int mem_sharing_memop(struct= domain *d, =0A if ( rc )=0A return rc;=0A = =0A- rc =3D xsm_mem_sharing_op(XSM_TARGET, d, cd, mec->op);=0A+ = rc =3D xsm_mem_sharing_op(XSM_DM_PRIV, d, cd, mec->op);=0A = if ( rc )=0A {=0A rcu_unlock_domain(cd);= =0A--- a/xen/include/xsm/dummy.h=0A+++ b/xen/include/xsm/dummy.h=0A@@ = -495,6 +495,12 @@ static XSM_INLINE int xsm_hvm_param(XSM_=0A return = xsm_default_action(action, current->domain, d);=0A }=0A =0A+static = XSM_INLINE int xsm_hvm_control(XSM_DEFAULT_ARG struct domain *d, unsigned = long op)=0A+{=0A+ XSM_ASSERT_ACTION(XSM_DM_PRIV);=0A+ return = xsm_default_action(action, current->domain, d);=0A+}=0A+=0A static = XSM_INLINE int xsm_hvm_param_nested(XSM_DEFAULT_ARG struct domain *d)=0A = {=0A XSM_ASSERT_ACTION(XSM_PRIV);=0A@@ -546,13 +552,13 @@ static = XSM_INLINE int xsm_mem_event_cont=0A =0A static XSM_INLINE int xsm_mem_even= t_op(XSM_DEFAULT_ARG struct domain *d, int op)=0A {=0A- XSM_ASSERT_ACTIO= N(XSM_TARGET);=0A+ XSM_ASSERT_ACTION(XSM_DM_PRIV);=0A return = xsm_default_action(action, current->domain, d);=0A }=0A =0A static = XSM_INLINE int xsm_mem_sharing_op(XSM_DEFAULT_ARG struct domain *d, struct = domain *cd, int op)=0A {=0A- XSM_ASSERT_ACTION(XSM_TARGET);=0A+ = XSM_ASSERT_ACTION(XSM_DM_PRIV);=0A return xsm_default_action(action, = current->domain, cd);=0A }=0A =0A--- a/xen/include/xsm/xsm.h=0A+++ = b/xen/include/xsm/xsm.h=0A@@ -137,6 +137,7 @@ struct xsm_operations {=0A = #endif=0A =0A int (*hvm_param) (struct domain *d, unsigned long = op);=0A+ int (*hvm_control) (struct domain *d, unsigned long op);=0A = int (*hvm_param_nested) (struct domain *d);=0A =0A #ifdef CONFIG_X86=0A@@ = -522,6 +523,11 @@ static inline int xsm_hvm_param (xsm_def=0A return = xsm_ops->hvm_param(d, op);=0A }=0A =0A+static inline int xsm_hvm_control(xs= m_default_t def, struct domain *d, unsigned long op)=0A+{=0A+ return = xsm_ops->hvm_control(d, op);=0A+}=0A+=0A static inline int xsm_hvm_param_ne= sted (xsm_default_t def, struct domain *d)=0A {=0A return xsm_ops->hvm_= param_nested(d);=0A--- a/xen/xsm/dummy.c=0A+++ b/xen/xsm/dummy.c=0A@@ = -105,6 +105,7 @@ void xsm_fixup_ops (struct xsm_operation=0A set_to_dum= my_if_null(ops, tmem_op);=0A set_to_dummy_if_null(ops, tmem_control);= =0A set_to_dummy_if_null(ops, hvm_param);=0A+ set_to_dummy_if_null(o= ps, hvm_control);=0A set_to_dummy_if_null(ops, hvm_param_nested);=0A = =0A set_to_dummy_if_null(ops, do_xsm_op);=0A--- a/xen/xsm/flask/hooks.c= =0A+++ b/xen/xsm/flask/hooks.c=0A@@ -1543,6 +1543,7 @@ static struct = xsm_operations flask_ops =3D=0A .tmem_op =3D flask_tmem_op,=0A = .tmem_control =3D flask_tmem_control,=0A .hvm_param =3D flask_hvm_param= ,=0A+ .hvm_control =3D flask_hvm_param,=0A .hvm_param_nested =3D = flask_hvm_param_nested,=0A =0A .do_xsm_op =3D do_flask_op,=0A --=__Part16243D81.1__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__Part16243D81.1__=--