[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v02 1/7] arm: introduce remoteprocessor iommu module



Hi Stefano,

Could you lease clarify:

>>> +static int mmu_mmio_write(struct vcpu *v, mmio_info_t *info)
>>> +{
>>> +    struct mmu_info *mmu = NULL;
>>> +    unsigned long flags;
>>> +    register_t *r;
>>> +    u32 new_addr, val;
>>> +
>>> +    r = select_user_reg(guest_cpu_user_regs(), info->dabt.reg);
>>> +
>>> +    ASSERT(r);
>>> +
>>> +    /* dom0 should not access remoteproc MMU */
>>> +    if ( 0 == current->domain->domain_id )
>>> +        return 1;
>>
>> This is too specific to one particular configuration.
>> Would it be possible to generalize this somehow? At the very least you
>> could introduce an XSM label to access the pagetables, so that you can
>> dynamically configure the domains the can write to them.
>>
>
> I need to think about this. Sounds reasonable.
>

I tried to compile Xen with XSM support and got an error with
including msi.h file:

arm-linux-gnueabi-gcc -O1 -fno-omit-frame-pointer -marm -g
-fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes
-Wdeclaration-after-statement -Wno-unused-but-set-variable
-I/home/x0174653/xen/dra7/core_dra7/hypervisor/xen/include -nopie
-fno-stack-protector -fno-exceptions -Wnested-externs -msoft-float
-mcpu=cortex-a15 -DGCC_HAS_VISIBILITY_ATTRIBUTE -fno-builtin
-fno-common -Werror -Wredundant-decls -Wno-pointer-arith -pipe -g
-D__XEN__ -include
/home/x0174653/xen/dra7/core_dra7/hypervisor/xen/include/xen/config.h
-nostdinc -fno-optimize-sibling-calls -DXSM_ENABLE -DFLASK_ENABLE
-DXSM_MAGIC=0xf97cff8c -DFLASK_DEVELOP -DFLASK_BOOTPARAM
-DFLASK_AVC_STATS -DVERBOSE -DHAS_DEVICE_TREE -fno-omit-frame-pointer
-DCONFIG_FRAME_POINTER -MMD -MF .hooks.o.d -I./include -c hooks.c -o
hooks.o
hooks.c:22:21: fatal error: asm/msi.h: No such file or directory

I see that msi.h is available only for x86 platforms. So, the question
is - is XSM supported on ARMs ?

I used this link to started working with XSM
http://wiki.xen.org/wiki/Xen_Security_Modules_:_XSM-FLASK

>>
>>> +    /* find corresponding MMU */
>>> +    mmu = mmu_lookup(info->gpa);
>>> +    if ( !mmu )
>>> +    {
>>> +        pr_mmu("can't get mmu for addr 0x%08x", (u32)info->gpa);
>>> +        return -EINVAL;
>>> +    }
>>> +
>>> +    ASSERT(v->domain == current->domain);
>>
>> You can remove this assert.
>>
>
> OK.
>
>>
>>> +    spin_lock_irqsave(&mmu->lock, flags);
>>> +
>>> +    /* get new address of translated pagetable */
>>> +    new_addr = mmu_trap_translate_pagetable(mmu, info);
>>> +    if ( MMU_INVALID_ADDRESS != new_addr )
>>> +        val = new_addr;
>>> +    else
>>> +        val = *r;
>>> +
>>> +    writel(val, mmu->mem_map + ((u32)(info->gpa) - mmu->mem_start));
>>> +    spin_unlock_irqrestore(&mmu->lock, flags);
>>> +
>>> +    return 1;
>>> +}
>>> +
>>> +static int mmu_init(struct mmu_info *mmu, u32 data)
>>> +{
>>> +    ASSERT(mmu);
>>> +    ASSERT(!mmu->mem_map);
>>> +
>>> +    INIT_LIST_HEAD(&mmu->pagetables_list);
>>> +
>>> +    /* map MMU memory */
>>> +    mmu->mem_map = ioremap_nocache(mmu->mem_start, mmu->mem_size);
>>> +     if ( !mmu->mem_map )
>>> +    {
>>> +        pr_mmu("failed to map memory");
>>> +        return -EINVAL;
>>> +    }
>>> +
>>> +    pr_mmu("memory map = 0x%pS", _p(mmu->mem_map));
>>> +
>>> +    spin_lock_init(&mmu->lock);
>>> +
>>> +    return 0;
>>> +}
>>> +
>>> +static int mmu_init_all(void)
>>> +{
>>> +    int res;
>>> +
>>> +    res = mmu_for_each(mmu_init, 0);
>>> +    if ( res )
>>> +    {
>>> +        printk("%s error during init %d\n", __func__, res);
>>> +        return res;
>>> +    }
>>> +
>>> +    return 0;
>>> +}
>>> +
>>> +const struct mmio_handler remoteproc_mmio_handler = {
>>> +    .check_handler = mmu_mmio_check,
>>> +    .read_handler  = mmu_mmio_read,
>>> +    .write_handler = mmu_mmio_write,
>>> +};
>>> +
>>> +__initcall(mmu_init_all);
>>> +
>>> +/*
>>> + * Local variables:
>>> + * mode: C
>>> + * c-file-style: "BSD"
>>> + * c-basic-offset: 4
>>> + * indent-tabs-mode: nil
>>> + * End:
>>> + */
>>> diff --git a/xen/include/xen/remoteproc_iommu.h 
>>> b/xen/include/xen/remoteproc_iommu.h
>>> new file mode 100644
>>> index 0000000..22e2951
>>> --- /dev/null
>>> +++ b/xen/include/xen/remoteproc_iommu.h
>>> @@ -0,0 +1,79 @@
>>> +/*
>>> + * xen/include/xen/remoteproc_iommu.h
>>> + *
>>> + * Andrii Tseglytskyi <andrii.tseglytskyi@xxxxxxxxxxxxxxx>
>>> + * Copyright (c) 2014 GlobalLogic
>>> + *
>>> + * This program is free software; you can redistribute it and/or modify
>>> + * it under the terms of the GNU General Public License as published by
>>> + * the Free Software Foundation; either version 2 of the License, or
>>> + * (at your option) any later version.
>>> + *
>>> + * This program is distributed in the hope that it will be useful,
>>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>>> + * GNU General Public License for more details.
>>> + */
>>> +
>>> +#ifndef _REMOTEPROC_IOMMU_H_
>>> +#define _REMOTEPROC_IOMMU_H_
>>> +
>>> +#include <asm/types.h>
>>> +
>>> +#define MMU_SECTION_SIZE(shift)     (1UL << (shift))
>>> +#define MMU_SECTION_MASK(shift)     (~(MMU_SECTION_SIZE(shift) - 1))
>>> +
>>> +/* 4096 first level descriptors for "supersection" and "section" */
>>> +#define MMU_PTRS_PER_PGD(mmu)       (1UL << (32 - 
>>> (mmu->pg_data->pgd_shift)))
>>> +#define MMU_PGD_TABLE_SIZE(mmu)     (MMU_PTRS_PER_PGD(mmu) * sizeof(u32))
>>> +
>>> +/* 256 second level descriptors for "small" and "large" pages */
>>> +#define MMU_PTRS_PER_PTE(mmu)       (1UL << ((mmu->pg_data->pgd_shift) - 
>>> (mmu->pg_data->pte_shift)))
>>> +#define MMU_PTE_TABLE_SIZE(mmu)     (MMU_PTRS_PER_PTE(mmu) * sizeof(u32))
>>> +
>>> +/* 16 sections in supersection */
>>> +#define MMU_SECTION_PER_SUPER(mmu)  (1UL << ((mmu->pg_data->super_shift) - 
>>> (mmu->pg_data->section_shift)))
>>> +
>>> +#define MMU_INVALID_ADDRESS ((u32)(-1))
>>> +
>>> +#define pr_mmu(fmt, ...) \
>>> +     printk("%s: %s: "fmt"\n", __func__, ((mmu) ? (mmu)->name : ""), 
>>> ##__VA_ARGS__)
>>> +
>>> +struct pagetable_data {
>>> +     /* 1st level translation */
>>> +     u32 pgd_shift;
>>> +     u32 pte_shift;
>>> +     u32 super_shift;
>>> +     u32 section_shift;
>>> +     /* 2nd level translation */
>>> +     u32 pte_large_shift;
>>> +};
>>> +
>>> +struct mmu_pagetable {
>>> +     u32                                     *hyp_pagetable;
>>> +     u32                                     *kern_pagetable;
>>> +     u32                                     paddr;
>>> +     u32                                     maddr;
>>> +     struct list_head        link_node;
>>> +     u32                                     page_counter;
>>> +};
>>> +
>>> +struct mmu_info {
>>> +     const char                              *name;
>>> +     const struct pagetable_data *pg_data;
>>> +     /* register where phys pointer to pagetable is stored */
>>> +     u32                                     *trap_offsets;
>>> +     paddr_t                         mem_start;
>>> +     u32                                     mem_size;
>>> +     spinlock_t                      lock;
>>> +     struct list_head        pagetables_list;
>>> +     u32                                     num_traps;
>>> +     void __iomem            *mem_map;
>>> +     u32     (*translate_pfunc)(struct mmu_info *, struct mmu_pagetable *);
>>> +     void (*print_pagetable_pfunc)(struct mmu_info *);
>>> +};
>>> +
>>> +u32 mmu_translate_second_level(struct mmu_info *mmu, struct mmu_pagetable 
>>> *pgt,
>>> +                               u32 maddr, u32 hyp_addr);
>>> +
>>> +#endif /* _REMOTEPROC_IOMMU_H_ */
>>> --
>>> 1.7.9.5
>>>
>>>
>>> _______________________________________________
>>> Xen-devel mailing list
>>> Xen-devel@xxxxxxxxxxxxx
>>> http://lists.xen.org/xen-devel
>>>
>
>
>
> --
>
> Andrii Tseglytskyi | Embedded Dev
> GlobalLogic
> www.globallogic.com



-- 

Andrii Tseglytskyi | Embedded Dev
GlobalLogic
www.globallogic.com

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.