All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Grall <julien@xen.org>
To: Oleksii Moisieiev <Oleksii_Moisieiev@epam.com>
Cc: Oleksandr <olekstysh@gmail.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>,
	Bertrand Marquis <bertrand.marquis@arm.com>
Subject: Re: [RFC v1 3/5] xen/arm: introduce SCMI-SMC mediator driver
Date: Thu, 6 Jan 2022 14:02:10 +0000	[thread overview]
Message-ID: <55954632-e2c7-5455-6538-29c7990c8f62@xen.org> (raw)
In-Reply-To: <20220106135328.GA1413532@EPUAKYIW015D>



On 06/01/2022 13:53, Oleksii Moisieiev wrote:
> Hi Julien,

Hi,

> 
> On Mon, Jan 03, 2022 at 01:14:17PM +0000, Julien Grall wrote:
>> Hi,
>>
>> On 24/12/2021 17:02, Oleksii Moisieiev wrote:
>>> On Fri, Dec 24, 2021 at 03:42:42PM +0100, Julien Grall wrote:
>>>> On 20/12/2021 16:41, Oleksii Moisieiev wrote:
>>>>>>      2) What are the expected memory attribute for the regions?
>>>>>
>>>>> xen uses iommu_permit_access to pass agent page to the guest. So guest can access the page directly.
>>>>
>>>> I think you misunderstood my comment. Memory can be mapped with various type
>>>> (e.g. Device, Memory) and attribute (cacheable, non-cacheable...). What will
>>>> the firmware expect? What will the guest OS usually?
>>>>
>>>> The reason I am asking is the attributes have to matched to avoid any
>>>> coherency issues. At the moment, if you use XEN_DOMCTL_memory_mapping, Xen
>>>> will configure the stage-2 to use Device nGnRnE. As the result, the result
>>>> memory access will be Device nGnRnE which is very strict.
>>>>
>>>
>>> Let me share with you the configuration example:
>>> scmi expects memory to be configured in the device-tree:
>>>
>>> cpu_scp_shm: scp-shmem@0xXXXXXXX {
>>> 	compatible = "arm,scmi-shmem";
>>> 	reg = <0x0 0xXXXXXX 0x0 0x1000>;
>>> };
>>>
>>> where XXXXXX address I allocate in alloc_magic_pages function.
>>
>> The goal of alloc_magic_pages() is to allocate RAM. However, what you want
>> is a guest physical address and then map a part of the shared page.
> 
> Do you mean that I can't use alloc_magic_pages to allocate shared
> memory region for SCMI?
Correct. alloc_magic_pages() will allocate a RAM page and then assign to 
the guest. From your description, this is not what you want because you 
will call XEN_DOMCTL_memory_mapping (and therefore replace the mapping).

> 
>>
>> I can see two options here:
>>    1) Hardcode the SCMI region in the memory map
>>    2) Create a new region in the memory map that can be used for reserving
>> memory for mapping.
> 
> Could you please explain what do you mean under the "new region in the
> memory map"?

I mean reserving some guest physical address that could be used for map 
host physical address (e.g. SCMI region, GIC CPU interface...).

So rather than hardcoding the address, we have something more flexible.

> 
>>
>> We still have plenty of space in the guest memory map. So the former is
>> probably going to be fine for now.
>>
>>> Then I get paddr of the scmi channel for this domain and use
>>> XEN_DOMCTL_memory_mapping to map scmi channel address to gfn.
>>>   > Hope I wass able to answer your question.
>>
>> What you provided me is how the guest OS will locate the shared memory. This
>> still doesn't tell me which memory attribute will be used to map the page in
>> Stage-1 (guest page-tables).
>>
>> To find that out, you want to look at the driver and how the mapping is
>> done. The Linux driver (drivers/firmware/arm_scmi) is using devm_ioremap()
>> (see smc_chan_setup()).
>>
>> Under the hood, the function devm_ioremap() is using PROT_DEVICE_nGnRE
>> (arm64) which is one of the most restrictive memory attribute.
>>
>> This means the firmware should be able to deal with the most restrictive
>> attribute and therefore using XEN_DOMCTL_memory_mapping to map the shared
>> page in stage-2 should be fine.
>>
> 
> I'm using vmap call to map channel memory (see smc_create_channel()).
> vmap call sets PAGE_HYPERVISOR flag which sets MT_NORMAL (0x7) flag.

You want to use ioremap().

> Considering that protocol is synchronous and only one agent per channel is
> expected - this works fine for now.
> But I agree that the same memory attributes should be used in xen and
> kernel. I fill fix that in v2.

I am a bit confused. Are you mapping the full shared memory area in Xen? 
If yes, why do you need to map the memory that is going to be shared 
with a domain?

Cheers,

-- 
Julien Grall


  reply	other threads:[~2022-01-06 14:02 UTC|newest]

Thread overview: 95+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-14  9:34 [RFC v1 0/5] Introduce SCI-mediator feature Oleksii Moisieiev
2021-12-14  9:34 ` [RFC v1 1/5] xen/arm: add support for Renesas R-Car Gen3 platform Oleksii Moisieiev
2021-12-15  6:38   ` Oleksandr Andrushchenko
2021-12-15 20:08     ` Oleksii Moisieiev
2021-12-15  9:39   ` Julien Grall
2021-12-17 10:48     ` Oleksii Moisieiev
2021-12-15  9:57   ` Oleksandr Tyshchenko
2021-12-17 10:52     ` Oleksii Moisieiev
2021-12-14  9:34 ` [RFC v1 2/5] xen/arm: add generic SCI mediator framework Oleksii Moisieiev
2021-12-17  2:45   ` Stefano Stabellini
2021-12-17 12:50     ` Oleksii Moisieiev
2021-12-14  9:34 ` [RFC v1 3/5] xen/arm: introduce SCMI-SMC mediator driver Oleksii Moisieiev
2021-12-17 11:35   ` Oleksandr
2021-12-17 13:23     ` Oleksii Moisieiev
2021-12-17 13:37       ` Julien Grall
2021-12-17 13:58         ` Oleksii Moisieiev
2021-12-17 16:38           ` Julien Grall
2021-12-20 15:41             ` Oleksii Moisieiev
2021-12-24 14:42               ` Julien Grall
2021-12-24 17:02                 ` Oleksii Moisieiev
2022-01-03 13:14                   ` Julien Grall
2022-01-06 13:53                     ` Oleksii Moisieiev
2022-01-06 14:02                       ` Julien Grall [this message]
2022-01-06 15:43                         ` Oleksii Moisieiev
2022-01-06 16:04                           ` Julien Grall
2022-01-06 16:28                             ` Oleksii Moisieiev
2022-01-19 10:37                             ` Oleksii Moisieiev
2022-01-20  2:10                               ` Stefano Stabellini
2022-01-20 10:25                                 ` Oleksii Moisieiev
2021-12-18  2:14   ` Stefano Stabellini
2021-12-20 18:12     ` Oleksii Moisieiev
2021-12-21  0:52       ` Stefano Stabellini
2021-12-21 20:03         ` Oleksii Moisieiev
2021-12-21 21:22           ` Stefano Stabellini
2021-12-22 11:04             ` Oleksii Moisieiev
2021-12-23  2:23               ` Stefano Stabellini
2021-12-23 18:45                 ` Volodymyr Babchuk
2021-12-23 19:06                 ` Oleksii Moisieiev
2021-12-24  0:16                   ` Stefano Stabellini
2021-12-24 13:29                     ` Julien Grall
2021-12-24 13:59                       ` Oleksii Moisieiev
2021-12-24 14:28                         ` Julien Grall
2021-12-24 16:49                           ` Oleksii Moisieiev
2022-01-03 14:23                             ` Julien Grall
2022-01-06 15:19                               ` Oleksii Moisieiev
2021-12-24 14:07                     ` Oleksii Moisieiev
2022-01-19 12:04                 ` Oleksii Moisieiev
2022-01-20  1:28                   ` Stefano Stabellini
2022-01-20 10:21                     ` Oleksii Moisieiev
2022-01-20 22:29                       ` Stefano Stabellini
2022-01-21 15:07                         ` Oleksii Moisieiev
2022-01-21 20:49                           ` Stefano Stabellini
2022-01-24 18:22                             ` Oleksii Moisieiev
2022-01-24 19:06                               ` Stefano Stabellini
2022-01-24 19:26                                 ` Julien Grall
2022-01-24 22:14                                   ` Stefano Stabellini
2022-01-25 14:35                                     ` Oleksii Moisieiev
2022-01-25 21:19                                       ` Stefano Stabellini
2022-01-27 18:11                                         ` Oleksii Moisieiev
2022-01-27 21:18                                           ` Stefano Stabellini
2021-12-14  9:34 ` [RFC v1 4/5] tools/arm: add "scmi_smc" option to xl.cfg Oleksii Moisieiev
2021-12-15 21:51   ` Oleksandr
2021-12-17 11:00     ` Oleksii Moisieiev
2021-12-21  0:54   ` Stefano Stabellini
2021-12-22 10:24     ` Oleksii Moisieiev
2021-12-23  2:23       ` Stefano Stabellini
2021-12-23 19:13         ` Oleksii Moisieiev
2021-12-21 13:27   ` Anthony PERARD
2021-12-22 12:20     ` Oleksii Moisieiev
2021-12-14  9:34 ` [RFC v1 5/5] xen/arm: add SCI mediator support for DomUs Oleksii Moisieiev
2021-12-14  9:41   ` Jan Beulich
2021-12-16 17:36     ` Oleksii Moisieiev
2021-12-17  7:12       ` Jan Beulich
2021-12-17  7:16         ` Jan Beulich
2021-12-17 13:40           ` Oleksii Moisieiev
2021-12-16  0:04   ` Oleksandr
2021-12-17 12:15     ` Oleksii Moisieiev
2021-12-21 14:45       ` Anthony PERARD
2021-12-21 21:39         ` Stefano Stabellini
2021-12-22  9:24           ` Julien Grall
2021-12-22 11:17             ` Volodymyr Babchuk
2021-12-22 11:30               ` Julien Grall
2021-12-22 12:34                 ` Volodymyr Babchuk
2021-12-22 13:49                   ` Julien Grall
2021-12-23  2:23                     ` Stefano Stabellini
2021-12-23 19:06                       ` Stefano Stabellini
2021-12-24 13:30                         ` Julien Grall
2022-01-19  9:40                           ` Oleksii Moisieiev
2022-01-20  1:53                             ` Stefano Stabellini
2022-01-20 10:27                               ` Oleksii Moisieiev
2021-12-23 19:11                       ` Oleksii Moisieiev
2021-12-21  1:37   ` Stefano Stabellini
2021-12-22 13:41     ` Oleksii Moisieiev
2021-12-16  0:33 ` [RFC v1 0/5] Introduce SCI-mediator feature Oleksandr
2021-12-17 12:24   ` Oleksii Moisieiev

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=55954632-e2c7-5455-6538-29c7990c8f62@xen.org \
    --to=julien@xen.org \
    --cc=Oleksii_Moisieiev@epam.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=bertrand.marquis@arm.com \
    --cc=olekstysh@gmail.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.