Daniel De Graaf
2012-Jul-31 14:27 UTC
[PATCH 1/2] xsm/flask: remove get_page call from update_va_mapping hook
This fixes the issue fixed by changeset 25605:9950f2dc2ee6, in another function: GFN to MFN translation should not be done via a struct page when possibly handling frames without an associated struct page. Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov> --- xen/xsm/flask/hooks.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c index 23b84f3..f2e198e 100644 --- a/xen/xsm/flask/hooks.c +++ b/xen/xsm/flask/hooks.c @@ -1372,8 +1372,9 @@ static int flask_update_va_mapping(struct domain *d, struct domain *f, int rc = 0; u32 psid; u32 map_perms = MMU__MAP_READ; - struct page_info *page = NULL; struct domain_security_struct *dsec; + unsigned long fgfn, fmfn; + p2m_type_t p2mt; if ( !(l1e_get_flags(pte) & _PAGE_PRESENT) ) return 0; @@ -1382,11 +1383,11 @@ static int flask_update_va_mapping(struct domain *d, struct domain *f, map_perms |= MMU__MAP_WRITE; dsec = d->ssid; + fgfn = l1e_get_pfn(pte); + fmfn = mfn_x(get_gfn_query(f, fgfn, &p2mt)); + rc = get_mfn_sid(fmfn, &psid); + put_gfn(f, fgfn); - page = get_page_from_gfn(f, l1e_get_pfn(pte), NULL, P2M_ALLOC); - rc = get_mfn_sid(page ? page_to_mfn(page) : INVALID_MFN, &psid); - if ( page ) - put_page(page); if ( rc ) return rc; -- 1.7.11.2
A few XSM hooks have been defined without implementation in dummy.c; these will cause a null function pointer deference if called. Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov> --- xen/xsm/dummy.c | 30 ++++++++++++++++++++++++++++++ xen/xsm/flask/hooks.c | 6 ++++++ 2 files changed, 36 insertions(+) diff --git a/xen/xsm/dummy.c b/xen/xsm/dummy.c index 7027ee7..5d35342 100644 --- a/xen/xsm/dummy.c +++ b/xen/xsm/dummy.c @@ -295,6 +295,21 @@ static char *dummy_show_security_evtchn (struct domain *d, const struct evtchn * return NULL; } +static int dummy_get_pod_target(struct domain *d) +{ + return 0; +} + +static int dummy_set_pod_target(struct domain *d) +{ + return 0; +} + +static int dummy_get_device_group (uint32_t machine_bdf) +{ + return 0; +} + static int dummy_test_assign_device (uint32_t machine_bdf) { return 0; @@ -503,6 +518,11 @@ static int dummy_firmware_info (void) return 0; } +static int dummy_efi_call(void) +{ + return 0; +} + static int dummy_acpi_sleep (void) { return 0; @@ -565,6 +585,11 @@ static int dummy_bind_pt_irq (struct domain *d, struct xen_domctl_bind_pt_irq *b return 0; } +static int dummy_unbind_pt_irq (struct domain *d) +{ + return 0; +} + static int dummy_pin_mem_cacheattr (struct domain *d) { return 0; @@ -652,6 +677,8 @@ void xsm_fixup_ops (struct xsm_operations *ops) set_to_dummy_if_null(ops, alloc_security_evtchn); set_to_dummy_if_null(ops, free_security_evtchn); set_to_dummy_if_null(ops, show_security_evtchn); + set_to_dummy_if_null(ops, get_pod_target); + set_to_dummy_if_null(ops, set_pod_target); set_to_dummy_if_null(ops, memory_adjust_reservation); set_to_dummy_if_null(ops, memory_stat_reservation); @@ -670,6 +697,7 @@ void xsm_fixup_ops (struct xsm_operations *ops) set_to_dummy_if_null(ops, iomem_permission); set_to_dummy_if_null(ops, pci_config_permission); + set_to_dummy_if_null(ops, get_device_group); set_to_dummy_if_null(ops, test_assign_device); set_to_dummy_if_null(ops, assign_device); set_to_dummy_if_null(ops, deassign_device); @@ -711,6 +739,7 @@ void xsm_fixup_ops (struct xsm_operations *ops) set_to_dummy_if_null(ops, physinfo); set_to_dummy_if_null(ops, platform_quirk); set_to_dummy_if_null(ops, firmware_info); + set_to_dummy_if_null(ops, efi_call); set_to_dummy_if_null(ops, acpi_sleep); set_to_dummy_if_null(ops, change_freq); set_to_dummy_if_null(ops, getidletime); @@ -723,6 +752,7 @@ void xsm_fixup_ops (struct xsm_operations *ops) set_to_dummy_if_null(ops, remove_from_physmap); set_to_dummy_if_null(ops, sendtrigger); set_to_dummy_if_null(ops, bind_pt_irq); + set_to_dummy_if_null(ops, unbind_pt_irq); set_to_dummy_if_null(ops, pin_mem_cacheattr); set_to_dummy_if_null(ops, ext_vcpucontext); set_to_dummy_if_null(ops, vcpuextstate); diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c index f2e198e..62771bf 100644 --- a/xen/xsm/flask/hooks.c +++ b/xen/xsm/flask/hooks.c @@ -1280,6 +1280,11 @@ static int flask_firmware_info(void) return domain_has_xen(current->domain, XEN__FIRMWARE); } +static int flask_efi_call(void) +{ + return domain_has_xen(current->domain, XEN__FIRMWARE); +} + static int flask_acpi_sleep(void) { return domain_has_xen(current->domain, XEN__SLEEP); @@ -1664,6 +1669,7 @@ static struct xsm_operations flask_ops = { .physinfo = flask_physinfo, .platform_quirk = flask_platform_quirk, .firmware_info = flask_firmware_info, + .efi_call = flask_efi_call, .acpi_sleep = flask_acpi_sleep, .change_freq = flask_change_freq, .getidletime = flask_getidletime, -- 1.7.11.2