xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@linaro.org>
To: Andrii Tseglytskyi <andrii.tseglytskyi@globallogic.com>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
	Tim Deegan <tim@xen.org>, Ian Campbell <Ian.Campbell@citrix.com>,
	xen-devel@lists.xen.org
Subject: Re: [PATCH v02 1/7] arm: introduce remoteprocessor iommu module
Date: Tue, 22 Jul 2014 17:29:01 +0100	[thread overview]
Message-ID: <53CE914D.70209@linaro.org> (raw)
In-Reply-To: <CAH_mUMPVxg0HT3nPgRDf60EgQF+1frdbKFv-bEZti=98NCgacg@mail.gmail.com>

On 07/22/2014 04:20 PM, Andrii Tseglytskyi wrote:
> Hi Julien,

Hi Andrii,

>>
>>> +    }                                                   \
>>> +    __res;                                              \
>>> +})
>>> +
>>> +static int mmu_check_mem_range(struct mmu_info *mmu, paddr_t addr)
>>> +{
>>> +    if ( (addr >= mmu->mem_start) && (addr < (mmu->mem_start +
>>> mmu->mem_size)) )
>>> +        return 1;
>>> +
>>> +    return 0;
>>> +}
>>> +
>>> +static inline struct mmu_info *mmu_lookup(u32 addr)
>>> +{
>>> +    u32 i;
>>> +
>>> +    /* enumerate all registered MMU's and check is address in range */
>>> +    for ( i = 0; i < ARRAY_SIZE(mmu_list); i++ )
>>> +    {
>>> +        if ( mmu_check_mem_range(mmu_list[i], addr) )
>>> +            return mmu_list[i];
>>> +    }
>>> +
>>> +    return NULL;
>>> +}
>>> +
>>> +static int mmu_mmio_check(struct vcpu *v, paddr_t addr)
>>> +{
>>> +    return mmu_for_each(mmu_check_mem_range, addr);
>>> +}
>>
>>
>> This solution leads any guest to access to the MMU and therefore program it.
>> If you plan to use for passthrough, you have to find a way to say that a
>> specific domain is able to use the MMU, maybe an hypercall. Otherwise this
>> is a security issue.
>>
>> IIRC I have already raised this concern on V1 :). It would be nice if you
>> resolve it ASAP, because I suspect it will need some rework in the way you
>> handle MMNU.
>>
> 
> Agree. I need to think how to solve this. I don't think that the
> hypercall is what is needed here.

IHMO, only the toolstack is able to know which domain will use the
remote processor or not. Adding a new DOMCTL looks like the best solution.

>> ioremap_* should only be used to map device memory. For the guest memory you
>> have to use copy_from_guest helper.
>>
> 
> OK. Just a small question - if I use copy_from_guest(), can I copy
> from physical pointer ?  Here I have an address, which points to exact
> physical memory.

copy_from_guest only cope with virtual guest address. You have to use
directly p2m_lookup and map_domain_page.

There is a ongoing discussion about it. See:
http://lists.xen.org/archives/html/xen-devel/2014-07/msg02096.html

>>
>>> +    /* dom0 should not access remoteproc MMU */
>>> +    if ( 0 == current->domain->domain_id )
>>> +        return 1;
>>
>>
>> Why this restriction?
>>
> 
> We agreed that remoteproc will be handled by domU, which doesn't has 1
> to 1 memory mapping.
> If remoteproc belongs to dom0, translation is not needed - it MMU will
> be configured with machine pointers.

In this case, the io ops are not registered for DOM0. So we should never
reach this case.

>>
>> So, the iohandler is usually call on the current VCPU, there is no need to
>> worry about it. Futhermore, I would pass the vcpu/domain in argument of the
>> next function.
>>
> 
> Can be. In first revision of these patches domain passed as a
> parameter. But that leaded to one more additional parameter in all
> functions below this call. I found that I can reduce arg list if I use
> current-> domain pointer.

Ok.

>>> +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;
>>> +    }
>>
>>
>> Hmmm... do_initcalls doesn't check the return value. How your code behave we
>> one of the MMU has not been initialized?
>>
>> I think do_initcalls & co should check the return, but as it's the common
>> code I don't know how x86 respect this convention to return 0 if succeded.
>> Ian, Stefano, any thoughs?
>>
> 
> I would like to make this specific to ARM only if possible.

It looks like Ian and Stefano doesn't answer to this question. If we
can't check the return of the init call in do_initcalls, I would replace
by a panic.

Regards,

-- 
Julien Grall

  reply	other threads:[~2014-07-22 16:29 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-26 11:06 [PATCH v02 0/7] arm: introduce remoteprocessor iommu module Andrii Tseglytskyi
2014-06-26 11:07 ` [PATCH v02 1/7] " Andrii Tseglytskyi
2014-06-29 18:00   ` Julien Grall
2014-07-22 15:20     ` Andrii Tseglytskyi
2014-07-22 16:29       ` Julien Grall [this message]
2014-07-31 11:59       ` Andrii Tseglytskyi
2014-07-31 12:11         ` Julien Grall
2014-07-31 12:49           ` Andrii Tseglytskyi
2014-07-04 13:59   ` Stefano Stabellini
2014-07-16 15:19     ` Ian Campbell
2014-07-22 12:42       ` Stefano Stabellini
2014-07-22 13:29         ` Julien Grall
2014-07-22 16:31           ` Andrii Tseglytskyi
2014-07-22 17:22         ` Andrii Tseglytskyi
2014-07-23 10:32           ` Stefano Stabellini
2014-07-23 10:54             ` Andrii Tseglytskyi
2014-07-22 15:40       ` Andrii Tseglytskyi
2014-07-22 15:32     ` Andrii Tseglytskyi
2014-08-01 10:06       ` Andrii Tseglytskyi
2014-08-01 10:32         ` Julien Grall
2014-08-01 10:34           ` Andrii Tseglytskyi
2014-08-01 10:37             ` Julien Grall
2014-08-01 10:43               ` Andrii Tseglytskyi
2014-08-20 19:40     ` Andrii Tseglytskyi
2014-08-21 15:30       ` Andrii Tseglytskyi
2014-08-21 23:41         ` Stefano Stabellini
2014-08-21 23:43       ` Stefano Stabellini
2014-07-16 15:29   ` Ian Campbell
2014-07-16 15:34     ` Ian Campbell
2014-07-22 16:24       ` Andrii Tseglytskyi
2014-07-22 16:14     ` Andrii Tseglytskyi
2014-06-26 11:07 ` [PATCH v02 2/7] arm: omap: introduce iommu translation for IPU remoteproc Andrii Tseglytskyi
2014-07-04 14:01   ` Stefano Stabellini
2014-07-22 16:56     ` Andrii Tseglytskyi
2014-07-04 14:30   ` Julien Grall
2014-07-22 16:58     ` Andrii Tseglytskyi
2014-07-16 15:36   ` Ian Campbell
2014-07-22 17:16     ` Andrii Tseglytskyi
2014-06-26 11:07 ` [PATCH v02 3/7] arm: omap: introduce iommu translation for GPU remoteproc Andrii Tseglytskyi
2014-06-26 11:07 ` [PATCH v02 4/7] arm: omap: introduce print pagetable function for IPU remoteproc Andrii Tseglytskyi
2014-07-16 15:38   ` Ian Campbell
2014-07-22 16:55     ` Andrii Tseglytskyi
2014-06-26 11:07 ` [PATCH v02 5/7] arm: omap: introduce print pagetable function for GPU remoteproc Andrii Tseglytskyi
2014-06-26 11:07 ` [PATCH v02 6/7] arm: introduce do_translate_pagetable hypercall Andrii Tseglytskyi
2014-07-04 14:05   ` Stefano Stabellini
2014-07-16 15:42     ` Ian Campbell
2014-07-22 16:47       ` Andrii Tseglytskyi
2014-07-22 16:37     ` Andrii Tseglytskyi
2014-07-04 14:35   ` Julien Grall
2014-07-16 15:43     ` Ian Campbell
2014-07-22 16:50       ` Andrii Tseglytskyi
2014-07-22 16:39     ` Andrii Tseglytskyi
2014-07-22 16:44       ` Julien Grall
2014-07-22 16:48         ` Andrii Tseglytskyi
2014-06-26 11:07 ` [PATCH v02 7/7] arm: add trap for remoteproc mmio accesses Andrii Tseglytskyi
2014-06-26 16:52   ` Julien Grall
2014-06-27  8:36     ` Andrii Tseglytskyi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53CE914D.70209@linaro.org \
    --to=julien.grall@linaro.org \
    --cc=Ian.Campbell@citrix.com \
    --cc=andrii.tseglytskyi@globallogic.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).