xen arm: add XSM hooks to arch_memory_op
PATCH 1/1 xen arm: add XSM hooks to arch_memory_op
Treat XENMEM_add_to_physmap_range the same as XENMEM_add_to_physmap.
---
v4:
- Just fix FLASK_ENABLED=n here, leave build issues with FLASK_ENABLE=y till the next patch
v3:
- ppropage errors from xsm_*_*_physmap.
- refactor MSI support into arch specific functions
v2:
- move the hooks in hooks.c and dummy.c too.
- make XSM actually build on arm.
--- xen/arch/arm/mm.c | 15 +++++++++++++++ xen/include/xsm/dummy.h | 24 ++++++++++++------------ xen/include/xsm/xsm.h | 12 ++++++------ xen/xsm/dummy.c | 5 +++-- xen/xsm/flask/hooks.c | 25 +++++++++++++------------ 5 files changed, 49 insertions(+), 32 deletions(-)
xen/arch/arm/mm.c +15 -0
@@ -35,6 +35,7 @@#include <asm/current.h> #include <public/memory.h> #include <xen/sched.h> +#include <xsm/xsm.h> struct domain *dom_xen, *dom_io, *dom_cow;
@@ -655,6 +656,13 @@ long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg)if ( rc !=0 )return rc; + rc =xsm_add_to_physmap (XSM_TARGET , current->domain, d); +if ( rc ) + { +rcu_unlock_domain (d); +return rc; + } + rc =xenmem_add_to_physmap_one (d, xatp.space,DOMID_INVALID , xatp.idx, xatp.gpfn);
@@ -675,6 +683,13 @@ long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg)if ( rc !=0 )return rc; + rc =xsm_add_to_physmap (XSM_TARGET , current->domain, d); +if ( rc ) + { +rcu_unlock_domain (d); +return rc; + } + rc =xenmem_add_to_physmap_range (d, &xatpr);rcu_unlock_domain (d);
xen/include/xsm/dummy.h +12 -12
@@ -443,6 +443,18 @@ static XSM_INLINE int xsm_pci_config_permission(XSM_DEFAULT_ARG struct domain *dreturn xsm_default_action (action, current->domain, d); } +static XSM_INLINE int xsm_add_to_physmap(XSM_DEFAULT_ARG struct domain *d1, struct domain *d2) +{ +XSM_ASSERT_ACTION (XSM_TARGET ); +return xsm_default_action (action, d1, d2); +} + +static XSM_INLINE int xsm_remove_from_physmap(XSM_DEFAULT_ARG struct domain *d1, struct domain *d2) +{ +XSM_ASSERT_ACTION (XSM_TARGET ); +return xsm_default_action (action, d1, d2); +} +#ifdef CONFIG_X86 static XSM_INLINE int xsm_shadow_control(XSM_DEFAULT_ARG struct domain *d, uint32_t op) {
@@ -544,18 +556,6 @@ static XSM_INLINE int xsm_update_va_mapping(XSM_DEFAULT_ARG struct domain *d, streturn xsm_default_action (action, d, f); } -static XSM_INLINE int xsm_add_to_physmap(XSM_DEFAULT_ARG struct domain *d1, struct domain *d2) -{ -XSM_ASSERT_ACTION (XSM_TARGET ); -return xsm_default_action (action, d1, d2); -} - -static XSM_INLINE int xsm_remove_from_physmap(XSM_DEFAULT_ARG struct domain *d1, struct domain *d2) -{ -XSM_ASSERT_ACTION (XSM_TARGET ); -return xsm_default_action (action, d1, d2); -} - static XSM_INLINE int xsm_bind_pt_irq(XSM_DEFAULT_ARG struct domain *d, struct xen_domctl_bind_pt_irq *bind) {XSM_ASSERT_ACTION (XSM_HOOK );
xen/include/xsm/xsm.h +6 -6
@@ -90,6 +90,7 @@ struct xsm_operations {int (*memory_adjust_reservation) (struct domain *d1,struct domain *d2);int (*memory_stat_reservation) (struct domain *d1,struct domain *d2);int (*memory_pin_page) (struct domain *d1,struct domain *d2,struct page_info *page); +int (*add_to_physmap) (struct domain *d1,struct domain *d2);int (*remove_from_physmap) (struct domain *d1,struct domain *d2);int (*console_io) (struct domain *d,int cmd);
@@ -149,7 +150,6 @@ struct xsm_operations { struct domain *f, uint32_t flags);int (*mmuext_op) (struct domain *d,struct domain *f);int (*update_va_mapping) (struct domain *d,struct domain *f,l1_pgentry_t pte); -int (*add_to_physmap) (struct domain *d1,struct domain *d2);int (*bind_pt_irq) (struct domain *d,struct xen_domctl_bind_pt_irq *bind);int (*unbind_pt_irq) (struct domain *d,struct xen_domctl_bind_pt_irq *bind);int (*ioport_permission) (struct domain *d,uint32_t s,uint32_t e,uint8_t allow);
@@ -335,6 +335,11 @@ static inline int xsm_memory_pin_page(xsm_default_t def, struct domain *d1, strureturn xsm_ops->memory_pin_page (d1, d2, page); } +static inline int xsm_add_to_physmap (xsm_default_t def,struct domain *d1,struct domain *d2) +{ +return xsm_ops->add_to_physmap (d1, d2); +} +static inline int xsm_remove_from_physmap (xsm_default_t def,struct domain *d1,struct domain *d2) {return xsm_ops->remove_from_physmap (d1, d2);
@@ -558,11 +563,6 @@ static inline int xsm_update_va_mapping(xsm_default_t def, struct domain *d, strreturn xsm_ops->update_va_mapping (d, f, pte); } -static inline int xsm_add_to_physmap (xsm_default_t def,struct domain *d1,struct domain *d2) -{ -return xsm_ops->add_to_physmap (d1, d2); -} -static inline int xsm_bind_pt_irq (xsm_default_t def,struct domain *d,struct xen_domctl_bind_pt_irq *bind) {
xen/xsm/dummy.c +3 -2
@@ -101,6 +101,9 @@ void xsm_fixup_ops (struct xsm_operations *ops)set_to_dummy_if_null (ops, do_xsm_op); +set_to_dummy_if_null (ops, add_to_physmap); +set_to_dummy_if_null (ops, remove_from_physmap); +#ifdef CONFIG_X86 set_to_dummy_if_null (ops, shadow_control);set_to_dummy_if_null (ops, hvm_param);
@@ -118,8 +121,6 @@ void xsm_fixup_ops (struct xsm_operations *ops)set_to_dummy_if_null (ops, mmu_update);set_to_dummy_if_null (ops, mmuext_op);set_to_dummy_if_null (ops, update_va_mapping); -set_to_dummy_if_null (ops, add_to_physmap); -set_to_dummy_if_null (ops, remove_from_physmap);set_to_dummy_if_null (ops, bind_pt_irq);set_to_dummy_if_null (ops, unbind_pt_irq);set_to_dummy_if_null (ops, ioport_permission);
xen/xsm/flask/hooks.c +13 -12
@@ -1055,6 +1055,16 @@ static inline int flask_tmem_control(void)return domain_has_xen (current->domain,XEN__TMEM_CONTROL ); } +static int flask_add_to_physmap (struct domain *d1,struct domain *d2) +{ +return domain_has_perm (d1, d2,SECCLASS_MMU ,MMU__PHYSMAP ); +} + +static int flask_remove_from_physmap (struct domain *d1,struct domain *d2) +{ +return domain_has_perm (d1, d2,SECCLASS_MMU ,MMU__PHYSMAP ); +} +#ifdef CONFIG_X86 static int flask_shadow_control (struct domain *d,uint32_t op) {
@@ -1325,16 +1335,6 @@ static int flask_update_va_mapping(struct domain *d, struct domain *f,return domain_has_perm (d, f,SECCLASS_MMU , map_perms); } -static int flask_add_to_physmap (struct domain *d1,struct domain *d2) -{ -return domain_has_perm (d1, d2,SECCLASS_MMU ,MMU__PHYSMAP ); -} - -static int flask_remove_from_physmap (struct domain *d1,struct domain *d2) -{ -return domain_has_perm (d1, d2,SECCLASS_MMU ,MMU__PHYSMAP ); -} -static int flask_get_device_group (uint32_t machine_bdf) {u32 rsid;
@@ -1501,6 +1501,9 @@ static struct xsm_operations flask_ops = { .do_xsm_op = do_flask_op, + .add_to_physmap = flask_add_to_physmap, + .remove_from_physmap = flask_remove_from_physmap, + #ifdef CONFIG_X86 .shadow_control = flask_shadow_control, .hvm_param = flask_hvm_param,
@@ -1518,8 +1521,6 @@ static struct xsm_operations flask_ops = { .mmu_update = flask_mmu_update, .mmuext_op = flask_mmuext_op, .update_va_mapping = flask_update_va_mapping, - .add_to_physmap = flask_add_to_physmap, - .remove_from_physmap = flask_remove_from_physmap, .get_device_group = flask_get_device_group, .test_assign_device = flask_test_assign_device, .assign_device = flask_assign_device,
Signature · 1 line
1.7.9.1
Quoted 1 line · Ian Campbell
Treat
XENMEM_add_to_physmap_rangethe same asXENMEM_add_to_physmap.
Does this patch look OK? Since it fixes a build failure on ARM I'd like to get it in ASAP.
Quoted 228 lines
Reported-by Lars Rasmusson <[email protected]>Signed-off-by Ian Campbell <[email protected]>Cc Daniel De Graaf <[email protected]>---
v4:
- Just fix FLASK_ENABLED=n here, leave build issues with FLASK_ENABLE=y till the next patch
v3:
- ppropage errors from xsm_*_*_physmap.
- refactor MSI support into arch specific functions
v2:
- move the hooks inhooks.canddummy.ctoo.
- make XSM actually build on arm.--- xen/arch/arm/mm.c | 15 +++++++++++++++ xen/include/xsm/dummy.h | 24 ++++++++++++------------ xen/include/xsm/xsm.h | 12 ++++++------ xen/xsm/dummy.c | 5 +++-- xen/xsm/flask/hooks.c | 25 +++++++++++++------------ 5 files changed, 49 insertions(+), 32 deletions(-)xen/arch/arm/mm.c +15
-0@@ -35,6 +35,7 @@#include <asm/current.h> #include <public/memory.h> #include <xen/sched.h> +#include <xsm/xsm.h> struct domain *dom_xen, *dom_io, *dom_cow;@@ -655,6 +656,13 @@ long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg)if ( rc !=0 )return rc; + rc =xsm_add_to_physmap (XSM_TARGET , current->domain, d); +if ( rc ) + { +rcu_unlock_domain (d); +return rc; + } + rc =xenmem_add_to_physmap_one (d, xatp.space,DOMID_INVALID , xatp.idx, xatp.gpfn);@@ -675,6 +683,13 @@ long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg)if ( rc !=0 )return rc; + rc =xsm_add_to_physmap (XSM_TARGET , current->domain, d); +if ( rc ) + { +rcu_unlock_domain (d); +return rc; + } + rc =xenmem_add_to_physmap_range (d, &xatpr);rcu_unlock_domain (d);xen/include/xsm/dummy.h +12
-12@@ -443,6 +443,18 @@ static XSM_INLINE int xsm_pci_config_permission(XSM_DEFAULT_ARG struct domain *dreturn xsm_default_action (action, current->domain, d); } +static XSM_INLINE int xsm_add_to_physmap(XSM_DEFAULT_ARG struct domain *d1, struct domain *d2) +{ +XSM_ASSERT_ACTION (XSM_TARGET ); +return xsm_default_action (action, d1, d2); +} + +static XSM_INLINE int xsm_remove_from_physmap(XSM_DEFAULT_ARG struct domain *d1, struct domain *d2) +{ +XSM_ASSERT_ACTION (XSM_TARGET ); +return xsm_default_action (action, d1, d2); +} +#ifdef CONFIG_X86 static XSM_INLINE int xsm_shadow_control(XSM_DEFAULT_ARG struct domain *d, uint32_t op) {@@ -544,18 +556,6 @@ static XSM_INLINE int xsm_update_va_mapping(XSM_DEFAULT_ARG struct domain *d, streturn xsm_default_action (action, d, f); } -static XSM_INLINE int xsm_add_to_physmap(XSM_DEFAULT_ARG struct domain *d1, struct domain *d2) -{ -XSM_ASSERT_ACTION (XSM_TARGET ); -return xsm_default_action (action, d1, d2); -} - -static XSM_INLINE int xsm_remove_from_physmap(XSM_DEFAULT_ARG struct domain *d1, struct domain *d2) -{ -XSM_ASSERT_ACTION (XSM_TARGET ); -return xsm_default_action (action, d1, d2); -} - static XSM_INLINE int xsm_bind_pt_irq(XSM_DEFAULT_ARG struct domain *d, struct xen_domctl_bind_pt_irq *bind) {XSM_ASSERT_ACTION (XSM_HOOK );xen/include/xsm/xsm.h +6
-6@@ -90,6 +90,7 @@ struct xsm_operations {int (*memory_adjust_reservation) (struct domain *d1,struct domain *d2);int (*memory_stat_reservation) (struct domain *d1,struct domain *d2);int (*memory_pin_page) (struct domain *d1,struct domain *d2,struct page_info *page); +int (*add_to_physmap) (struct domain *d1,struct domain *d2);int (*remove_from_physmap) (struct domain *d1,struct domain *d2);int (*console_io) (struct domain *d,int cmd);@@ -149,7 +150,6 @@ struct xsm_operations { struct domain *f, uint32_t flags);int (*mmuext_op) (struct domain *d,struct domain *f);int (*update_va_mapping) (struct domain *d,struct domain *f,l1_pgentry_t pte); -int (*add_to_physmap) (struct domain *d1,struct domain *d2);int (*bind_pt_irq) (struct domain *d,struct xen_domctl_bind_pt_irq *bind);int (*unbind_pt_irq) (struct domain *d,struct xen_domctl_bind_pt_irq *bind);int (*ioport_permission) (struct domain *d,uint32_t s,uint32_t e,uint8_t allow);@@ -335,6 +335,11 @@ static inline int xsm_memory_pin_page(xsm_default_t def, struct domain *d1, strureturn xsm_ops->memory_pin_page (d1, d2, page); } +static inline int xsm_add_to_physmap (xsm_default_t def,struct domain *d1,struct domain *d2) +{ +return xsm_ops->add_to_physmap (d1, d2); +} +static inline int xsm_remove_from_physmap (xsm_default_t def,struct domain *d1,struct domain *d2) {return xsm_ops->remove_from_physmap (d1, d2);@@ -558,11 +563,6 @@ static inline int xsm_update_va_mapping(xsm_default_t def, struct domain *d, strreturn xsm_ops->update_va_mapping (d, f, pte); } -static inline int xsm_add_to_physmap (xsm_default_t def,struct domain *d1,struct domain *d2) -{ -return xsm_ops->add_to_physmap (d1, d2); -} -static inline int xsm_bind_pt_irq (xsm_default_t def,struct domain *d,struct xen_domctl_bind_pt_irq *bind) {xen/xsm/dummy.c +3
-2@@ -101,6 +101,9 @@ void xsm_fixup_ops (struct xsm_operations *ops)set_to_dummy_if_null (ops, do_xsm_op); +set_to_dummy_if_null (ops, add_to_physmap); +set_to_dummy_if_null (ops, remove_from_physmap); +#ifdef CONFIG_X86 set_to_dummy_if_null (ops, shadow_control);set_to_dummy_if_null (ops, hvm_param);@@ -118,8 +121,6 @@ void xsm_fixup_ops (struct xsm_operations *ops)set_to_dummy_if_null (ops, mmu_update);set_to_dummy_if_null (ops, mmuext_op);set_to_dummy_if_null (ops, update_va_mapping); -set_to_dummy_if_null (ops, add_to_physmap); -set_to_dummy_if_null (ops, remove_from_physmap);set_to_dummy_if_null (ops, bind_pt_irq);set_to_dummy_if_null (ops, unbind_pt_irq);set_to_dummy_if_null (ops, ioport_permission);xen/xsm/flask/hooks.c +13
-12@@ -1055,6 +1055,16 @@ static inline int flask_tmem_control(void)return domain_has_xen (current->domain,XEN__TMEM_CONTROL ); } +static int flask_add_to_physmap (struct domain *d1,struct domain *d2) +{ +return domain_has_perm (d1, d2,SECCLASS_MMU ,MMU__PHYSMAP ); +} + +static int flask_remove_from_physmap (struct domain *d1,struct domain *d2) +{ +return domain_has_perm (d1, d2,SECCLASS_MMU ,MMU__PHYSMAP ); +} +#ifdef CONFIG_X86 static int flask_shadow_control (struct domain *d,uint32_t op) {@@ -1325,16 +1335,6 @@ static int flask_update_va_mapping(struct domain *d, struct domain *f,return domain_has_perm (d, f,SECCLASS_MMU , map_perms); } -static int flask_add_to_physmap (struct domain *d1,struct domain *d2) -{ -return domain_has_perm (d1, d2,SECCLASS_MMU ,MMU__PHYSMAP ); -} - -static int flask_remove_from_physmap (struct domain *d1,struct domain *d2) -{ -return domain_has_perm (d1, d2,SECCLASS_MMU ,MMU__PHYSMAP ); -} -static int flask_get_device_group (uint32_t machine_bdf) {u32 rsid;@@ -1501,6 +1501,9 @@ static struct xsm_operations flask_ops = { .do_xsm_op = do_flask_op, + .add_to_physmap = flask_add_to_physmap, + .remove_from_physmap = flask_remove_from_physmap, + #ifdef CONFIG_X86 .shadow_control = flask_shadow_control, .hvm_param = flask_hvm_param,@@ -1518,8 +1521,6 @@ static struct xsm_operations flask_ops = { .mmu_update = flask_mmu_update, .mmuext_op = flask_mmuext_op, .update_va_mapping = flask_update_va_mapping, - .add_to_physmap = flask_add_to_physmap, - .remove_from_physmap = flask_remove_from_physmap, .get_device_group = flask_get_device_group, .test_assign_device = flask_test_assign_device, .assign_device = flask_assign_device,
Quoted 5 lines · Ian Campbell
Quoted 1 line · Ian Campbell
Treat
XENMEM_add_to_physmap_rangethe same asXENMEM_add_to_physmap.Does this patch look OK? Since it fixes a build failure on ARM I'd like to get it in ASAP.
It looks OK to me.
Quoted 231 lines
Quoted 228 lines
Reported-by Lars Rasmusson <[email protected]>Signed-off-by Ian Campbell <[email protected]>Cc Daniel De Graaf <[email protected]>---
v4:
- Just fix FLASK_ENABLED=n here, leave build issues with FLASK_ENABLE=y till the next patch
v3:
- ppropage errors from xsm_*_*_physmap.
- refactor MSI support into arch specific functions
v2:
- move the hooks inhooks.canddummy.ctoo.
- make XSM actually build on arm.--- xen/arch/arm/mm.c | 15 +++++++++++++++ xen/include/xsm/dummy.h | 24 ++++++++++++------------ xen/include/xsm/xsm.h | 12 ++++++------ xen/xsm/dummy.c | 5 +++-- xen/xsm/flask/hooks.c | 25 +++++++++++++------------ 5 files changed, 49 insertions(+), 32 deletions(-)xen/arch/arm/mm.c +15
-0@@ -35,6 +35,7 @@#include <asm/current.h> #include <public/memory.h> #include <xen/sched.h> +#include <xsm/xsm.h> struct domain *dom_xen, *dom_io, *dom_cow;@@ -655,6 +656,13 @@ long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg)if ( rc !=0 )return rc; + rc =xsm_add_to_physmap (XSM_TARGET , current->domain, d); +if ( rc ) + { +rcu_unlock_domain (d); +return rc; + } + rc =xenmem_add_to_physmap_one (d, xatp.space,DOMID_INVALID , xatp.idx, xatp.gpfn);@@ -675,6 +683,13 @@ long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg)if ( rc !=0 )return rc; + rc =xsm_add_to_physmap (XSM_TARGET , current->domain, d); +if ( rc ) + { +rcu_unlock_domain (d); +return rc; + } + rc =xenmem_add_to_physmap_range (d, &xatpr);rcu_unlock_domain (d);xen/include/xsm/dummy.h +12
-12@@ -443,6 +443,18 @@ static XSM_INLINE int xsm_pci_config_permission(XSM_DEFAULT_ARG struct domain *dreturn xsm_default_action (action, current->domain, d); } +static XSM_INLINE int xsm_add_to_physmap(XSM_DEFAULT_ARG struct domain *d1, struct domain *d2) +{ +XSM_ASSERT_ACTION (XSM_TARGET ); +return xsm_default_action (action, d1, d2); +} + +static XSM_INLINE int xsm_remove_from_physmap(XSM_DEFAULT_ARG struct domain *d1, struct domain *d2) +{ +XSM_ASSERT_ACTION (XSM_TARGET ); +return xsm_default_action (action, d1, d2); +} +#ifdef CONFIG_X86 static XSM_INLINE int xsm_shadow_control(XSM_DEFAULT_ARG struct domain *d, uint32_t op) {@@ -544,18 +556,6 @@ static XSM_INLINE int xsm_update_va_mapping(XSM_DEFAULT_ARG struct domain *d, streturn xsm_default_action (action, d, f); } -static XSM_INLINE int xsm_add_to_physmap(XSM_DEFAULT_ARG struct domain *d1, struct domain *d2) -{ -XSM_ASSERT_ACTION (XSM_TARGET ); -return xsm_default_action (action, d1, d2); -} - -static XSM_INLINE int xsm_remove_from_physmap(XSM_DEFAULT_ARG struct domain *d1, struct domain *d2) -{ -XSM_ASSERT_ACTION (XSM_TARGET ); -return xsm_default_action (action, d1, d2); -} - static XSM_INLINE int xsm_bind_pt_irq(XSM_DEFAULT_ARG struct domain *d, struct xen_domctl_bind_pt_irq *bind) {XSM_ASSERT_ACTION (XSM_HOOK );xen/include/xsm/xsm.h +6
-6@@ -90,6 +90,7 @@ struct xsm_operations {int (*memory_adjust_reservation) (struct domain *d1,struct domain *d2);int (*memory_stat_reservation) (struct domain *d1,struct domain *d2);int (*memory_pin_page) (struct domain *d1,struct domain *d2,struct page_info *page); +int (*add_to_physmap) (struct domain *d1,struct domain *d2);int (*remove_from_physmap) (struct domain *d1,struct domain *d2);int (*console_io) (struct domain *d,int cmd);@@ -149,7 +150,6 @@ struct xsm_operations { struct domain *f, uint32_t flags);int (*mmuext_op) (struct domain *d,struct domain *f);int (*update_va_mapping) (struct domain *d,struct domain *f,l1_pgentry_t pte); -int (*add_to_physmap) (struct domain *d1,struct domain *d2);int (*bind_pt_irq) (struct domain *d,struct xen_domctl_bind_pt_irq *bind);int (*unbind_pt_irq) (struct domain *d,struct xen_domctl_bind_pt_irq *bind);int (*ioport_permission) (struct domain *d,uint32_t s,uint32_t e,uint8_t allow);@@ -335,6 +335,11 @@ static inline int xsm_memory_pin_page(xsm_default_t def, struct domain *d1, strureturn xsm_ops->memory_pin_page (d1, d2, page); } +static inline int xsm_add_to_physmap (xsm_default_t def,struct domain *d1,struct domain *d2) +{ +return xsm_ops->add_to_physmap (d1, d2); +} +static inline int xsm_remove_from_physmap (xsm_default_t def,struct domain *d1,struct domain *d2) {return xsm_ops->remove_from_physmap (d1, d2);@@ -558,11 +563,6 @@ static inline int xsm_update_va_mapping(xsm_default_t def, struct domain *d, strreturn xsm_ops->update_va_mapping (d, f, pte); } -static inline int xsm_add_to_physmap (xsm_default_t def,struct domain *d1,struct domain *d2) -{ -return xsm_ops->add_to_physmap (d1, d2); -} -static inline int xsm_bind_pt_irq (xsm_default_t def,struct domain *d,struct xen_domctl_bind_pt_irq *bind) {xen/xsm/dummy.c +3
-2@@ -101,6 +101,9 @@ void xsm_fixup_ops (struct xsm_operations *ops)set_to_dummy_if_null (ops, do_xsm_op); +set_to_dummy_if_null (ops, add_to_physmap); +set_to_dummy_if_null (ops, remove_from_physmap); +#ifdef CONFIG_X86 set_to_dummy_if_null (ops, shadow_control);set_to_dummy_if_null (ops, hvm_param);@@ -118,8 +121,6 @@ void xsm_fixup_ops (struct xsm_operations *ops)set_to_dummy_if_null (ops, mmu_update);set_to_dummy_if_null (ops, mmuext_op);set_to_dummy_if_null (ops, update_va_mapping); -set_to_dummy_if_null (ops, add_to_physmap); -set_to_dummy_if_null (ops, remove_from_physmap);set_to_dummy_if_null (ops, bind_pt_irq);set_to_dummy_if_null (ops, unbind_pt_irq);set_to_dummy_if_null (ops, ioport_permission);xen/xsm/flask/hooks.c +13
-12@@ -1055,6 +1055,16 @@ static inline int flask_tmem_control(void)return domain_has_xen (current->domain,XEN__TMEM_CONTROL ); } +static int flask_add_to_physmap (struct domain *d1,struct domain *d2) +{ +return domain_has_perm (d1, d2,SECCLASS_MMU ,MMU__PHYSMAP ); +} + +static int flask_remove_from_physmap (struct domain *d1,struct domain *d2) +{ +return domain_has_perm (d1, d2,SECCLASS_MMU ,MMU__PHYSMAP ); +} +#ifdef CONFIG_X86 static int flask_shadow_control (struct domain *d,uint32_t op) {@@ -1325,16 +1335,6 @@ static int flask_update_va_mapping(struct domain *d, struct domain *f,return domain_has_perm (d, f,SECCLASS_MMU , map_perms); } -static int flask_add_to_physmap (struct domain *d1,struct domain *d2) -{ -return domain_has_perm (d1, d2,SECCLASS_MMU ,MMU__PHYSMAP ); -} - -static int flask_remove_from_physmap (struct domain *d1,struct domain *d2) -{ -return domain_has_perm (d1, d2,SECCLASS_MMU ,MMU__PHYSMAP ); -} -static int flask_get_device_group (uint32_t machine_bdf) {u32 rsid;@@ -1501,6 +1501,9 @@ static struct xsm_operations flask_ops = { .do_xsm_op = do_flask_op, + .add_to_physmap = flask_add_to_physmap, + .remove_from_physmap = flask_remove_from_physmap, + #ifdef CONFIG_X86 .shadow_control = flask_shadow_control, .hvm_param = flask_hvm_param,@@ -1518,8 +1521,6 @@ static struct xsm_operations flask_ops = { .mmu_update = flask_mmu_update, .mmuext_op = flask_mmuext_op, .update_va_mapping = flask_update_va_mapping, - .add_to_physmap = flask_add_to_physmap, - .remove_from_physmap = flask_remove_from_physmap, .get_device_group = flask_get_device_group, .test_assign_device = flask_test_assign_device, .assign_device = flask_assign_device,
Quoted 8 lines · Stefano Stabellini
Quoted 5 lines · Ian Campbell
Quoted 1 line · Ian Campbell
Treat
XENMEM_add_to_physmap_rangethe same asXENMEM_add_to_physmap.Does this patch look OK? Since it fixes a build failure on ARM I'd like to get it in ASAP.
It looks OK to me.
Thanks
Keir/Daniel, any objections to this? Keir acked the earlier fix from Lars but this one is substantially different enough for me not to want to carry it over.
This is an ARM build fix arising from the recent XSM changes.
Ian.
Quoted 232 lines
Quoted 232 lines
Quoted 229 lines
Reported-by Lars Rasmusson <[email protected]>Signed-off-by Ian Campbell <[email protected]>Cc Daniel De Graaf <[email protected]>---
v4:
- Just fix FLASK_ENABLED=n here, leave build issues with FLASK_ENABLE=y till the next patch
v3:
- ppropage errors from xsm_*_*_physmap.
- refactor MSI support into arch specific functions
v2:
- move the hooks inhooks.canddummy.ctoo.
- make XSM actually build on arm.--- xen/arch/arm/mm.c | 15 +++++++++++++++ xen/include/xsm/dummy.h | 24 ++++++++++++------------ xen/include/xsm/xsm.h | 12 ++++++------ xen/xsm/dummy.c | 5 +++-- xen/xsm/flask/hooks.c | 25 +++++++++++++------------ 5 files changed, 49 insertions(+), 32 deletions(-)xen/arch/arm/mm.c +15
-0@@ -35,6 +35,7 @@#include <asm/current.h> #include <public/memory.h> #include <xen/sched.h> +#include <xsm/xsm.h> struct domain *dom_xen, *dom_io, *dom_cow;@@ -655,6 +656,13 @@ long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg)if ( rc !=0 )return rc; + rc =xsm_add_to_physmap (XSM_TARGET , current->domain, d); +if ( rc ) + { +rcu_unlock_domain (d); +return rc; + } + rc =xenmem_add_to_physmap_one (d, xatp.space,DOMID_INVALID , xatp.idx, xatp.gpfn);@@ -675,6 +683,13 @@ long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg)if ( rc !=0 )return rc; + rc =xsm_add_to_physmap (XSM_TARGET , current->domain, d); +if ( rc ) + { +rcu_unlock_domain (d); +return rc; + } + rc =xenmem_add_to_physmap_range (d, &xatpr);rcu_unlock_domain (d);xen/include/xsm/dummy.h +12
-12@@ -443,6 +443,18 @@ static XSM_INLINE int xsm_pci_config_permission(XSM_DEFAULT_ARG struct domain *dreturn xsm_default_action (action, current->domain, d); } +static XSM_INLINE int xsm_add_to_physmap(XSM_DEFAULT_ARG struct domain *d1, struct domain *d2) +{ +XSM_ASSERT_ACTION (XSM_TARGET ); +return xsm_default_action (action, d1, d2); +} + +static XSM_INLINE int xsm_remove_from_physmap(XSM_DEFAULT_ARG struct domain *d1, struct domain *d2) +{ +XSM_ASSERT_ACTION (XSM_TARGET ); +return xsm_default_action (action, d1, d2); +} +#ifdef CONFIG_X86 static XSM_INLINE int xsm_shadow_control(XSM_DEFAULT_ARG struct domain *d, uint32_t op) {@@ -544,18 +556,6 @@ static XSM_INLINE int xsm_update_va_mapping(XSM_DEFAULT_ARG struct domain *d, streturn xsm_default_action (action, d, f); } -static XSM_INLINE int xsm_add_to_physmap(XSM_DEFAULT_ARG struct domain *d1, struct domain *d2) -{ -XSM_ASSERT_ACTION (XSM_TARGET ); -return xsm_default_action (action, d1, d2); -} - -static XSM_INLINE int xsm_remove_from_physmap(XSM_DEFAULT_ARG struct domain *d1, struct domain *d2) -{ -XSM_ASSERT_ACTION (XSM_TARGET ); -return xsm_default_action (action, d1, d2); -} - static XSM_INLINE int xsm_bind_pt_irq(XSM_DEFAULT_ARG struct domain *d, struct xen_domctl_bind_pt_irq *bind) {XSM_ASSERT_ACTION (XSM_HOOK );xen/include/xsm/xsm.h +6
-6@@ -90,6 +90,7 @@ struct xsm_operations {int (*memory_adjust_reservation) (struct domain *d1,struct domain *d2);int (*memory_stat_reservation) (struct domain *d1,struct domain *d2);int (*memory_pin_page) (struct domain *d1,struct domain *d2,struct page_info *page); +int (*add_to_physmap) (struct domain *d1,struct domain *d2);int (*remove_from_physmap) (struct domain *d1,struct domain *d2);int (*console_io) (struct domain *d,int cmd);@@ -149,7 +150,6 @@ struct xsm_operations { struct domain *f, uint32_t flags);int (*mmuext_op) (struct domain *d,struct domain *f);int (*update_va_mapping) (struct domain *d,struct domain *f,l1_pgentry_t pte); -int (*add_to_physmap) (struct domain *d1,struct domain *d2);int (*bind_pt_irq) (struct domain *d,struct xen_domctl_bind_pt_irq *bind);int (*unbind_pt_irq) (struct domain *d,struct xen_domctl_bind_pt_irq *bind);int (*ioport_permission) (struct domain *d,uint32_t s,uint32_t e,uint8_t allow);@@ -335,6 +335,11 @@ static inline int xsm_memory_pin_page(xsm_default_t def, struct domain *d1, strureturn xsm_ops->memory_pin_page (d1, d2, page); } +static inline int xsm_add_to_physmap (xsm_default_t def,struct domain *d1,struct domain *d2) +{ +return xsm_ops->add_to_physmap (d1, d2); +} +static inline int xsm_remove_from_physmap (xsm_default_t def,struct domain *d1,struct domain *d2) {return xsm_ops->remove_from_physmap (d1, d2);@@ -558,11 +563,6 @@ static inline int xsm_update_va_mapping(xsm_default_t def, struct domain *d, strreturn xsm_ops->update_va_mapping (d, f, pte); } -static inline int xsm_add_to_physmap (xsm_default_t def,struct domain *d1,struct domain *d2) -{ -return xsm_ops->add_to_physmap (d1, d2); -} -static inline int xsm_bind_pt_irq (xsm_default_t def,struct domain *d,struct xen_domctl_bind_pt_irq *bind) {xen/xsm/dummy.c +3
-2@@ -101,6 +101,9 @@ void xsm_fixup_ops (struct xsm_operations *ops)set_to_dummy_if_null (ops, do_xsm_op); +set_to_dummy_if_null (ops, add_to_physmap); +set_to_dummy_if_null (ops, remove_from_physmap); +#ifdef CONFIG_X86 set_to_dummy_if_null (ops, shadow_control);set_to_dummy_if_null (ops, hvm_param);@@ -118,8 +121,6 @@ void xsm_fixup_ops (struct xsm_operations *ops)set_to_dummy_if_null (ops, mmu_update);set_to_dummy_if_null (ops, mmuext_op);set_to_dummy_if_null (ops, update_va_mapping); -set_to_dummy_if_null (ops, add_to_physmap); -set_to_dummy_if_null (ops, remove_from_physmap);set_to_dummy_if_null (ops, bind_pt_irq);set_to_dummy_if_null (ops, unbind_pt_irq);set_to_dummy_if_null (ops, ioport_permission);xen/xsm/flask/hooks.c +13
-12@@ -1055,6 +1055,16 @@ static inline int flask_tmem_control(void)return domain_has_xen (current->domain,XEN__TMEM_CONTROL ); } +static int flask_add_to_physmap (struct domain *d1,struct domain *d2) +{ +return domain_has_perm (d1, d2,SECCLASS_MMU ,MMU__PHYSMAP ); +} + +static int flask_remove_from_physmap (struct domain *d1,struct domain *d2) +{ +return domain_has_perm (d1, d2,SECCLASS_MMU ,MMU__PHYSMAP ); +} +#ifdef CONFIG_X86 static int flask_shadow_control (struct domain *d,uint32_t op) {@@ -1325,16 +1335,6 @@ static int flask_update_va_mapping(struct domain *d, struct domain *f,return domain_has_perm (d, f,SECCLASS_MMU , map_perms); } -static int flask_add_to_physmap (struct domain *d1,struct domain *d2) -{ -return domain_has_perm (d1, d2,SECCLASS_MMU ,MMU__PHYSMAP ); -} - -static int flask_remove_from_physmap (struct domain *d1,struct domain *d2) -{ -return domain_has_perm (d1, d2,SECCLASS_MMU ,MMU__PHYSMAP ); -} -static int flask_get_device_group (uint32_t machine_bdf) {u32 rsid;@@ -1501,6 +1501,9 @@ static struct xsm_operations flask_ops = { .do_xsm_op = do_flask_op, + .add_to_physmap = flask_add_to_physmap, + .remove_from_physmap = flask_remove_from_physmap, + #ifdef CONFIG_X86 .shadow_control = flask_shadow_control, .hvm_param = flask_hvm_param,@@ -1518,8 +1521,6 @@ static struct xsm_operations flask_ops = { .mmu_update = flask_mmu_update, .mmuext_op = flask_mmuext_op, .update_va_mapping = flask_update_va_mapping, - .add_to_physmap = flask_add_to_physmap, - .remove_from_physmap = flask_remove_from_physmap, .get_device_group = flask_get_device_group, .test_assign_device = flask_test_assign_device, .assign_device = flask_assign_device,
Quoted 8 lines · Ian Campbell
Quoted 7 lines · Stefano Stabellini
Quoted 5 lines · Ian Campbell
Quoted 1 line · Ian Campbell
Treat
XENMEM_add_to_physmap_rangethe same asXENMEM_add_to_physmap.Does this patch look OK? Since it fixes a build failure on ARM I'd like to get it in ASAP.
Quoted 7 lines
Quoted 1 line
It looks OK to me.
Thanks
Keir/Daniel, any objections to this? Keir acked the earlier fix from Lars but this one is substantially different enough for me not to want to carry it over.
Fine by me, you can keep my Ack.
Quoted 261 lines
This is an ARM build fix arising from the recent XSM changes.
Ian.
Quoted 255 lines
Quoted 255 lines
Quoted 252 lines
Reported-by Lars Rasmusson <[email protected]>Signed-off-by Ian Campbell <[email protected]>Cc Daniel De Graaf <[email protected]>---
v4:
- Just fix FLASK_ENABLED=n here, leave build issues with FLASK_ENABLE=y till the next patch
v3:
- ppropage errors from xsm_*_*_physmap.
- refactor MSI support into arch specific functions
v2:
- move the hooks inhooks.canddummy.ctoo.
- make XSM actually build on arm.--- xen/arch/arm/mm.c | 15 +++++++++++++++ xen/include/xsm/dummy.h | 24 ++++++++++++------------ xen/include/xsm/xsm.h | 12 ++++++------ xen/xsm/dummy.c | 5 +++-- xen/xsm/flask/hooks.c | 25 +++++++++++++------------ 5 files changed, 49 insertions(+), 32 deletions(-)xen/arch/arm/mm.c +15
-0@@ -35,6 +35,7 @@#include <asm/current.h> #include <public/memory.h> #include <xen/sched.h> +#include <xsm/xsm.h> struct domain *dom_xen, *dom_io, *dom_cow;@@ -655,6 +656,13 @@ long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg)if ( rc !=0 )return rc; + rc =xsm_add_to_physmap (XSM_TARGET , current->domain, d); +if ( rc ) + { +rcu_unlock_domain (d); +return rc; + } + rc =xenmem_add_to_physmap_one (d, xatp.space,DOMID_INVALID , xatp.idx, xatp.gpfn);@@ -675,6 +683,13 @@ long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg)if ( rc !=0 )return rc; + rc =xsm_add_to_physmap (XSM_TARGET , current->domain, d); +if ( rc ) + { +rcu_unlock_domain (d); +return rc; + } + rc =xenmem_add_to_physmap_range (d, &xatpr);rcu_unlock_domain(d);xen/include/xsm/dummy.h +0
-0@@ -443,6 +443,18 @@ static XSM_INLINE intxsm_pci_config_permission(XSM_DEFAULT_ARG struct domain *d
return xsm_default_action(action, current->domain, d);}
+static
XSM_INLINEintxsm_add_to_physmap(XSM_DEFAULT_ARG struct domain *d1, struct domain *d2)xen/include/xsm/dummy.h +6
-0+{ +XSM_ASSERT_ACTION (XSM_TARGET ); +return xsm_default_action (action, d1, d2); +} + +static XSM_INLINE int xsm_remove_from_physmap(XSM_DEFAULT_ARG structdomain *d1, struct domain *d2)
xen/include/xsm/dummy.h +5
-0+{ +XSM_ASSERT_ACTION (XSM_TARGET ); +return xsm_default_action (action, d1, d2); +} +#ifdef CONFIG_X86 static XSM_INLINE int xsm_shadow_control(XSM_DEFAULT_ARG struct domain *d,
uint32_top)
{xen/include/xsm/dummy.h +0
-0@@ -544,18 +556,6 @@ static XSM_INLINE intxsm_update_va_mapping(XSM_DEFAULT_ARG struct domain *d, st
return xsm_default_action(action, d, f);}
-static
XSM_INLINEintxsm_add_to_physmap(XSM_DEFAULT_ARG struct domain *d1, struct domain *d2)xen/include/xsm/dummy.h +0
-6-{ -XSM_ASSERT_ACTION (XSM_TARGET ); -return xsm_default_action (action, d1, d2); -} - -static XSM_INLINE int xsm_remove_from_physmap(XSM_DEFAULT_ARG structdomain *d1, struct domain *d2)
xen/include/xsm/dummy.h +0
-5-{ -XSM_ASSERT_ACTION (XSM_TARGET ); -return xsm_default_action (action, d1, d2); -} - static XSM_INLINE int xsm_bind_pt_irq(XSM_DEFAULT_ARG struct domain *d,struct
xen_domctl_bind_pt_irq*bind){ XSM_ASSERT_ACTION(XSM_HOOK);xen/include/xsm/xsm.h +1
-0@@ -90,6 +90,7 @@ struct xsm_operations {int (*memory_adjust_reservation) (struct domain *d1,struct domain *d2);int (*memory_stat_reservation) (struct domain *d1,struct domain *d2);int (*memory_pin_page) (struct domain *d1,struct domain *d2,struct page_info *page); +int (*add_to_physmap) (struct domain *d1,struct domain *d2);int (*remove_from_physmap) (struct domain *d1,struct domain *d2);int (*console_io) (struct domain *d, int cmd);xen/include/xsm/xsm.h +0
-1@@ -149,7 +150,6 @@ struct xsm_operations { struct domain *f, uint32_t flags);int (*mmuext_op) (struct domain *d,struct domain *f);int (*update_va_mapping) (struct domain *d,struct domain *f,l1_pgentry_t pte); -int (*add_to_physmap) (struct domain *d1,struct domain *d2);int (*bind_pt_irq) (struct domain *d,struct xen_domctl_bind_pt_irq *bind);int (
*unbind_pt_irq) (struct domain *d, structxen_domctl_bind_pt_irq
*bind);
int (*ioport_permission) (struct domain *d,uint32_ts,uint32_te,uint8_tallow);xen/include/xsm/xsm.h +0
-0@@ -335,6 +335,11 @@ static inline int xsm_memory_pin_page(xsm_default_tdef, struct domain *d1, stru
return xsm_ops->memory_pin_page(d1, d2, page);}
+static inline int
xsm_add_to_physmap(xsm_default_t def, struct domain *d1, struct domain *d2)xen/include/xsm/xsm.h +4
-0+{ +return xsm_ops->add_to_physmap (d1, d2); +} + static inline int xsm_remove_from_physmap(xsm_default_t def, struct domain*d1, struct domain *d2)
{ return xsm_ops->remove_from_physmap(d1, d2);xen/include/xsm/xsm.h +0
-0@@ -558,11 +563,6 @@ static inline int xsm_update_va_mapping(xsm_default_tdef, struct domain *d, str
return xsm_ops->update_va_mapping(d, f, pte);}
-static inline int
xsm_add_to_physmap(xsm_default_t def, struct domain *d1, struct domain *d2)xen/include/xsm/xsm.h +0
-4-{ -return xsm_ops->add_to_physmap (d1, d2); -} - static inline int xsm_bind_pt_irq(xsm_default_t def, struct domain *d, struct
xen_domctl_bind_pt_irq*bind)
{xen/xsm/dummy.c +3
-2@@ -101,6 +101,9 @@ void xsm_fixup_ops (struct xsm_operations *ops)set_to_dummy_if_null (ops, do_xsm_op); +set_to_dummy_if_null (ops, add_to_physmap); +set_to_dummy_if_null (ops, remove_from_physmap); +#ifdef CONFIG_X86 set_to_dummy_if_null (ops, shadow_control);set_to_dummy_if_null (ops, hvm_param);@@ -118,8 +121,6 @@ void xsm_fixup_ops (struct xsm_operations *ops)set_to_dummy_if_null (ops, mmu_update);set_to_dummy_if_null (ops, mmuext_op);set_to_dummy_if_null (ops, update_va_mapping); -set_to_dummy_if_null (ops, add_to_physmap); -set_to_dummy_if_null (ops, remove_from_physmap);set_to_dummy_if_null (ops, bind_pt_irq);set_to_dummy_if_null (ops, unbind_pt_irq);set_to_dummy_if_null (ops, ioport_permission);xen/xsm/flask/hooks.c +10
-10@@ -1055,6 +1055,16 @@ static inline int flask_tmem_control(void)return domain_has_xen (current->domain,XEN__TMEM_CONTROL ); } +static int flask_add_to_physmap (struct domain *d1,struct domain *d2) +{ +return domain_has_perm (d1, d2,SECCLASS_MMU ,MMU__PHYSMAP ); +} + +static int flask_remove_from_physmap (struct domain *d1,struct domain *d2) +{ +return domain_has_perm (d1, d2,SECCLASS_MMU ,MMU__PHYSMAP ); +} +#ifdef CONFIG_X86 static int flask_shadow_control (struct domain *d,uint32_t op) {@@ -1325,16 +1335,6 @@ static int flask_update_va_mapping(struct domain *d,struct domain *f, return domain_has_perm(d, f, SECCLASS_MMU, map_perms); } -static int flask_add_to_physmap (struct domain *d1,struct domain *d2) -{ -return domain_has_perm (d1, d2,SECCLASS_MMU ,MMU__PHYSMAP ); -} - -static int flask_remove_from_physmap (struct domain *d1,struct domain *d2) -{ -return domain_has_perm (d1, d2,SECCLASS_MMU ,MMU__PHYSMAP ); -} -static int flask_get_device_group (uint32_t machine_bdf) {u32 rsid;xen/xsm/flask/hooks.c +3
-2@@ -1501,6 +1501,9 @@ static struct xsm_operations flask_ops = { .do_xsm_op = do_flask_op, + .add_to_physmap = flask_add_to_physmap, + .remove_from_physmap = flask_remove_from_physmap, + #ifdef CONFIG_X86 .shadow_control = flask_shadow_control, .hvm_param = flask_hvm_param,@@ -1518,8 +1521,6 @@ static struct xsm_operations flask_ops = { .mmu_update = flask_mmu_update, .mmuext_op = flask_mmuext_op, .update_va_mapping = flask_update_va_mapping, - .add_to_physmap = flask_add_to_physmap, - .remove_from_physmap = flask_remove_from_physmap, .get_device_group = flask_get_device_group, .test_assign_device = flask_test_assign_device, .assign_device = flask_assign_device,
Ian Campbell
AppliedQuoted 12 lines · Keir Fraser
Quoted 10 lines · Ian Campbell
Quoted 8 lines · Stefano Stabellini
Quoted 5 lines · Ian Campbell
Quoted 1 line · Ian Campbell
Treat
XENMEM_add_to_physmap_rangethe same asXENMEM_add_to_physmap.Does this patch look OK? Since it fixes a build failure on ARM I'd like to get it in ASAP.
It looks OK to me.
Quoted 7 lines
Quoted 5 lines
Thanks
Keir/Daniel, any objections to this? Keir acked the earlier fix from Lars but this one is substantially different enough for me not to want to carry it over.
Fine by me, you can keep my Ack.
Thanks, applied.