Re: [PATCH v6 1/9] xen/arm: introduce static shared memory

2022-09-02 Thread Julien Grall

Hi Penny,

On 02/09/2022 04:26, Penny Zheng wrote:

Do you think I shall further point out that right now, this part
feature is not implemented in codes?


I have made a couple of suggestion for the code. But I think the binding
would look a bit odd without the host physical address. We would now have:

< [size] [guest address]>

I think it would be more natural if we had

<[guest address] [size]>

And

<[guest address] [size] [host physical address]>



Ok, about the binding order change, do you prefer it in v7 or 4.17-post,
since it may also need a few code tweak.


The binding will become stable as soon as we release 4.17. So this would 
need to be fixed before releasing.


Cheers,

--
Julien Grall



RE: [PATCH v6 1/9] xen/arm: introduce static shared memory

2022-09-01 Thread Penny Zheng
Hi Julien

> -Original Message-
> From: Julien Grall 
> Sent: Thursday, September 1, 2022 11:40 PM
> To: Penny Zheng ; xen-devel@lists.xenproject.org
> Cc: Stefano Stabellini ; Bertrand Marquis
> ; Volodymyr Babchuk
> 
> Subject: Re: [PATCH v6 1/9] xen/arm: introduce static shared memory
> 
> Hi Penny,
> 
> On 29/08/2022 07:57, Penny Zheng wrote:
> >> -Original Message-
> >> From: Julien Grall 
> >> Sent: Friday, August 26, 2022 9:17 PM
> >> To: Penny Zheng ; xen-
> de...@lists.xenproject.org
> >> Cc: Stefano Stabellini ; Bertrand Marquis
> >> ; Volodymyr Babchuk
> >> 
> >> Subject: Re: [PATCH v6 1/9] xen/arm: introduce static shared memory
> >>
> >> Hi Penny,
> >>
> >
> > Hi Julien
> >
> >> On 21/07/2022 14:21, Penny Zheng wrote:
> >>> From: Penny Zheng 
> >>>
> >>> This patch series introduces a new feature: setting up static shared
> >>> memory on a dom0less system, through device tree configuration.
> >>>
> >>> This commit parses shared memory node at boot-time, and reserve it
> >>> in bootinfo.reserved_mem to avoid other use.
> >>>
> >>> This commits proposes a new Kconfig CONFIG_STATIC_SHM to wrap
> >>> static-shm-related codes, and this option depends on static memory(
> >>> CONFIG_STATIC_MEMORY). That's because that later we want to reuse a
> >>> few helpers, guarded with CONFIG_STATIC_MEMORY, like
> >>> acquire_staticmem_pages, etc, on static shared memory.
> >>>
> >>> Signed-off-by: Penny Zheng 
> >>> ---
> >>> v6 change:
> >>> - when host physical address is ommited, output the error message
> >>> since xen doesn't support it at the moment
> >>> - add the following check: 1) The shm ID matches and the region
> >>> exactly match
> >>> 2) The shm ID doesn't match and the region doesn't overlap
> >>> - change it to "unsigned int" to be aligned with nr_banks
> >>> - check the len of the property to confirm is it big enough to
> >>> contain "paddr", "size", and "gaddr"
> >>> - shm_id defined before nr_shm_domain, so we could re-use the
> >>> existing hole and avoid increasing the size of the structure.
> >>> - change "nr_shm_domain" to "nr_shm_borrowers", to not increment if
> >>> the role is owner in parsing code
> >>> - make "xen,shm_id" property as arbitrary string, with a strict
> >>> limit on the number of characters, MAX_SHM_ID_LENGTH
> >>> ---
> >>> v5 change:
> >>> - no change
> >>> ---
> >>> v4 change:
> >>> - nit fix on doc
> >>> ---
> >>> v3 change:
> >>> - make nr_shm_domain unsigned int
> >>> ---
> >>> v2 change:
> >>> - document refinement
> >>> - remove bitmap and use the iteration to check
> >>> - add a new field nr_shm_domain to keep the number of shared domain
> >>> ---
> >>>docs/misc/arm/device-tree/booting.txt | 124 
> >>>xen/arch/arm/Kconfig  |   6 +
> >>>xen/arch/arm/bootfdt.c| 157 ++
> >>>xen/arch/arm/include/asm/setup.h  |   9 ++
> >>>4 files changed, 296 insertions(+)
> >>>
> >>> diff --git a/docs/misc/arm/device-tree/booting.txt
> >>> b/docs/misc/arm/device-tree/booting.txt
> >>> index 98253414b8..8013fb98fe 100644
> >>> --- a/docs/misc/arm/device-tree/booting.txt
> >>> +++ b/docs/misc/arm/device-tree/booting.txt
> >>> @@ -378,3 +378,127 @@ device-tree:
> >>>
> >>>This will reserve a 512MB region starting at the host physical address
> >>>0x3000 to be exclusively used by DomU1.
> >>> +
> >>> +Static Shared Memory
> >>> +
> >>> +
> >>> +The static shared memory device tree nodes allow users to
> >>> +statically set up shared memory on dom0less system, enabling
> >>> +domains to do shm-based communication.
> >>> +
> >>> +- compatible
> >>> +
> >>> +"xen,domain-shared-memory-v1"
> >>> +
> >>> +- xen,shm-id
> >>> +
> >>> +An arbitrary string that represents the unique ident

Re: [PATCH v6 1/9] xen/arm: introduce static shared memory

2022-09-01 Thread Bertrand Marquis
Hi,

> On 1 Sep 2022, at 16:40, Julien Grall  wrote:
> 
> Hi Penny,
> 
> On 29/08/2022 07:57, Penny Zheng wrote:
>>> -Original Message-
>>> From: Julien Grall 
>>> Sent: Friday, August 26, 2022 9:17 PM
>>> To: Penny Zheng ; xen-devel@lists.xenproject.org
>>> Cc: Stefano Stabellini ; Bertrand Marquis
>>> ; Volodymyr Babchuk
>>> 
>>> Subject: Re: [PATCH v6 1/9] xen/arm: introduce static shared memory
>>> 
>>> Hi Penny,
>>> 
>> Hi Julien
>>  
>>> On 21/07/2022 14:21, Penny Zheng wrote:
>>>> From: Penny Zheng 
>>>> 
>>>> This patch series introduces a new feature: setting up static shared
>>>> memory on a dom0less system, through device tree configuration.
>>>> 
>>>> This commit parses shared memory node at boot-time, and reserve it in
>>>> bootinfo.reserved_mem to avoid other use.
>>>> 
>>>> This commits proposes a new Kconfig CONFIG_STATIC_SHM to wrap
>>>> static-shm-related codes, and this option depends on static memory(
>>>> CONFIG_STATIC_MEMORY). That's because that later we want to reuse a
>>>> few helpers, guarded with CONFIG_STATIC_MEMORY, like
>>>> acquire_staticmem_pages, etc, on static shared memory.
>>>> 
>>>> Signed-off-by: Penny Zheng 
>>>> ---
>>>> v6 change:
>>>> - when host physical address is ommited, output the error message
>>>> since xen doesn't support it at the moment
>>>> - add the following check: 1) The shm ID matches and the region
>>>> exactly match
>>>> 2) The shm ID doesn't match and the region doesn't overlap
>>>> - change it to "unsigned int" to be aligned with nr_banks
>>>> - check the len of the property to confirm is it big enough to contain
>>>> "paddr", "size", and "gaddr"
>>>> - shm_id defined before nr_shm_domain, so we could re-use the existing
>>>> hole and avoid increasing the size of the structure.
>>>> - change "nr_shm_domain" to "nr_shm_borrowers", to not increment if
>>>> the role is owner in parsing code
>>>> - make "xen,shm_id" property as arbitrary string, with a strict limit
>>>> on the number of characters, MAX_SHM_ID_LENGTH
>>>> ---
>>>> v5 change:
>>>> - no change
>>>> ---
>>>> v4 change:
>>>> - nit fix on doc
>>>> ---
>>>> v3 change:
>>>> - make nr_shm_domain unsigned int
>>>> ---
>>>> v2 change:
>>>> - document refinement
>>>> - remove bitmap and use the iteration to check
>>>> - add a new field nr_shm_domain to keep the number of shared domain
>>>> ---
>>>>   docs/misc/arm/device-tree/booting.txt | 124 
>>>>   xen/arch/arm/Kconfig  |   6 +
>>>>   xen/arch/arm/bootfdt.c| 157 ++
>>>>   xen/arch/arm/include/asm/setup.h  |   9 ++
>>>>   4 files changed, 296 insertions(+)
>>>> 
>>>> diff --git a/docs/misc/arm/device-tree/booting.txt
>>>> b/docs/misc/arm/device-tree/booting.txt
>>>> index 98253414b8..8013fb98fe 100644
>>>> --- a/docs/misc/arm/device-tree/booting.txt
>>>> +++ b/docs/misc/arm/device-tree/booting.txt
>>>> @@ -378,3 +378,127 @@ device-tree:
>>>> 
>>>>   This will reserve a 512MB region starting at the host physical address
>>>>   0x3000 to be exclusively used by DomU1.
>>>> +
>>>> +Static Shared Memory
>>>> +
>>>> +
>>>> +The static shared memory device tree nodes allow users to statically
>>>> +set up shared memory on dom0less system, enabling domains to do
>>>> +shm-based communication.
>>>> +
>>>> +- compatible
>>>> +
>>>> +"xen,domain-shared-memory-v1"
>>>> +
>>>> +- xen,shm-id
>>>> +
>>>> +An arbitrary string that represents the unique identifier of the 
>>>> shared
>>>> +memory region, with a strict limit on the number of characters(\0
>>> included),
>>>> +`MAX_SHM_ID_LENGTH(16)`. e.g. "xen,shm-id = "my-shared-mem-1"".
>>>> +
>>>> +- xen,shared-mem
>>>> +
>>>> +An array takes a physical addr

Re: [PATCH v6 1/9] xen/arm: introduce static shared memory

2022-09-01 Thread Julien Grall

Hi Penny,

On 29/08/2022 07:57, Penny Zheng wrote:

-Original Message-
From: Julien Grall 
Sent: Friday, August 26, 2022 9:17 PM
To: Penny Zheng ; xen-devel@lists.xenproject.org
Cc: Stefano Stabellini ; Bertrand Marquis
; Volodymyr Babchuk

Subject: Re: [PATCH v6 1/9] xen/arm: introduce static shared memory

Hi Penny,



Hi Julien
  

On 21/07/2022 14:21, Penny Zheng wrote:

From: Penny Zheng 

This patch series introduces a new feature: setting up static shared
memory on a dom0less system, through device tree configuration.

This commit parses shared memory node at boot-time, and reserve it in
bootinfo.reserved_mem to avoid other use.

This commits proposes a new Kconfig CONFIG_STATIC_SHM to wrap
static-shm-related codes, and this option depends on static memory(
CONFIG_STATIC_MEMORY). That's because that later we want to reuse a
few helpers, guarded with CONFIG_STATIC_MEMORY, like
acquire_staticmem_pages, etc, on static shared memory.

Signed-off-by: Penny Zheng 
---
v6 change:
- when host physical address is ommited, output the error message
since xen doesn't support it at the moment
- add the following check: 1) The shm ID matches and the region
exactly match
2) The shm ID doesn't match and the region doesn't overlap
- change it to "unsigned int" to be aligned with nr_banks
- check the len of the property to confirm is it big enough to contain
"paddr", "size", and "gaddr"
- shm_id defined before nr_shm_domain, so we could re-use the existing
hole and avoid increasing the size of the structure.
- change "nr_shm_domain" to "nr_shm_borrowers", to not increment if
the role is owner in parsing code
- make "xen,shm_id" property as arbitrary string, with a strict limit
on the number of characters, MAX_SHM_ID_LENGTH
---
v5 change:
- no change
---
v4 change:
- nit fix on doc
---
v3 change:
- make nr_shm_domain unsigned int
---
v2 change:
- document refinement
- remove bitmap and use the iteration to check
- add a new field nr_shm_domain to keep the number of shared domain
---
   docs/misc/arm/device-tree/booting.txt | 124 
   xen/arch/arm/Kconfig  |   6 +
   xen/arch/arm/bootfdt.c| 157 ++
   xen/arch/arm/include/asm/setup.h  |   9 ++
   4 files changed, 296 insertions(+)

diff --git a/docs/misc/arm/device-tree/booting.txt
b/docs/misc/arm/device-tree/booting.txt
index 98253414b8..8013fb98fe 100644
--- a/docs/misc/arm/device-tree/booting.txt
+++ b/docs/misc/arm/device-tree/booting.txt
@@ -378,3 +378,127 @@ device-tree:

   This will reserve a 512MB region starting at the host physical address
   0x3000 to be exclusively used by DomU1.
+
+Static Shared Memory
+
+
+The static shared memory device tree nodes allow users to statically
+set up shared memory on dom0less system, enabling domains to do
+shm-based communication.
+
+- compatible
+
+"xen,domain-shared-memory-v1"
+
+- xen,shm-id
+
+An arbitrary string that represents the unique identifier of the shared
+memory region, with a strict limit on the number of characters(\0

included),

+`MAX_SHM_ID_LENGTH(16)`. e.g. "xen,shm-id = "my-shared-mem-1"".
+
+- xen,shared-mem
+
+An array takes a physical address, which is the base address of the
+shared memory region in host physical address space, a size, and a

guest

+physical address, as the target address of the mapping.
+e.g. xen,shared-mem = < [host physical address] [size] [guest
+ address] >


Your implementation below is checking for overlap and also have some
restriction. Can they be documented in the binding?


+
+The number of cells for the host address (and size) is the same as the
+guest pseudo-physical address and they are inherited from the parent

node.

In v5, we discussed to have the host address optional. However, the binding
has not been updated to reflect that. Note that I am not asking to implement,
but instead request that the binding can be used for such setup.



How about:
"
Host physical address could be omitted by users, and let Xen decide where it 
locates.
"


I am fine with that.


Do you think I shall further point out that right now, this part feature is not 
implemented
in codes?


I have made a couple of suggestion for the code. But I think the binding 
would look a bit odd without the host physical address. We would now have:


< [size] [guest address]>

I think it would be more natural if we had

<[guest address] [size]>

And

<[guest address] [size] [host physical address]>




a/xen/arch/arm/include/asm/setup.h

b/xen/arch/arm/include/asm/setup.h

index 2bb01ecfa8..39d4e93b8b 100644
--- a/xen/arch/arm/include/asm/setup.h
+++ b/xen/arch/arm/include/asm/setup.h
@@ -23,10 +23,19 @@ typedef enum {
   }  bootmodule_kind;


+#ifdef CONFIG_STATIC_SHM
+/* Indicates the maximum number of characters(\0 in

RE: [PATCH v6 1/9] xen/arm: introduce static shared memory

2022-08-29 Thread Stefano Stabellini
On Mon, 29 Aug 2022, Penny Zheng wrote:
> > -Original Message-
> > From: Julien Grall 
> > Sent: Friday, August 26, 2022 9:17 PM
> > To: Penny Zheng ; xen-devel@lists.xenproject.org
> > Cc: Stefano Stabellini ; Bertrand Marquis
> > ; Volodymyr Babchuk
> > 
> > Subject: Re: [PATCH v6 1/9] xen/arm: introduce static shared memory
> > 
> > Hi Penny,
> >
> 
> Hi Julien
>  
> > On 21/07/2022 14:21, Penny Zheng wrote:
> > > From: Penny Zheng 
> > >
> > > This patch series introduces a new feature: setting up static shared
> > > memory on a dom0less system, through device tree configuration.
> > >
> > > This commit parses shared memory node at boot-time, and reserve it in
> > > bootinfo.reserved_mem to avoid other use.
> > >
> > > This commits proposes a new Kconfig CONFIG_STATIC_SHM to wrap
> > > static-shm-related codes, and this option depends on static memory(
> > > CONFIG_STATIC_MEMORY). That's because that later we want to reuse a
> > > few helpers, guarded with CONFIG_STATIC_MEMORY, like
> > > acquire_staticmem_pages, etc, on static shared memory.
> > >
> > > Signed-off-by: Penny Zheng 
> > > ---
> > > v6 change:
> > > - when host physical address is ommited, output the error message
> > > since xen doesn't support it at the moment
> > > - add the following check: 1) The shm ID matches and the region
> > > exactly match
> > > 2) The shm ID doesn't match and the region doesn't overlap
> > > - change it to "unsigned int" to be aligned with nr_banks
> > > - check the len of the property to confirm is it big enough to contain
> > > "paddr", "size", and "gaddr"
> > > - shm_id defined before nr_shm_domain, so we could re-use the existing
> > > hole and avoid increasing the size of the structure.
> > > - change "nr_shm_domain" to "nr_shm_borrowers", to not increment if
> > > the role is owner in parsing code
> > > - make "xen,shm_id" property as arbitrary string, with a strict limit
> > > on the number of characters, MAX_SHM_ID_LENGTH
> > > ---
> > > v5 change:
> > > - no change
> > > ---
> > > v4 change:
> > > - nit fix on doc
> > > ---
> > > v3 change:
> > > - make nr_shm_domain unsigned int
> > > ---
> > > v2 change:
> > > - document refinement
> > > - remove bitmap and use the iteration to check
> > > - add a new field nr_shm_domain to keep the number of shared domain
> > > ---
> > >   docs/misc/arm/device-tree/booting.txt | 124 
> > >   xen/arch/arm/Kconfig  |   6 +
> > >   xen/arch/arm/bootfdt.c| 157 ++
> > >   xen/arch/arm/include/asm/setup.h  |   9 ++
> > >   4 files changed, 296 insertions(+)
> > >
> > > diff --git a/docs/misc/arm/device-tree/booting.txt
> > > b/docs/misc/arm/device-tree/booting.txt
> > > index 98253414b8..8013fb98fe 100644
> > > --- a/docs/misc/arm/device-tree/booting.txt
> > > +++ b/docs/misc/arm/device-tree/booting.txt
> > > @@ -378,3 +378,127 @@ device-tree:
> > >
> > >   This will reserve a 512MB region starting at the host physical address
> > >   0x3000 to be exclusively used by DomU1.
> > > +
> > > +Static Shared Memory
> > > +
> > > +
> > > +The static shared memory device tree nodes allow users to statically
> > > +set up shared memory on dom0less system, enabling domains to do
> > > +shm-based communication.
> > > +
> > > +- compatible
> > > +
> > > +"xen,domain-shared-memory-v1"
> > > +
> > > +- xen,shm-id
> > > +
> > > +An arbitrary string that represents the unique identifier of the 
> > > shared
> > > +memory region, with a strict limit on the number of characters(\0
> > included),
> > > +`MAX_SHM_ID_LENGTH(16)`. e.g. "xen,shm-id = "my-shared-mem-1"".
> > > +
> > > +- xen,shared-mem
> > > +
> > > +An array takes a physical address, which is the base address of the
> > > +shared memory region in host physical address space, a size, and a
> > guest
> > > +physical address, as the target address of the mapping.
> > > +e.g. xen,shared-mem = < [host physical address] [size] [guest

RE: [PATCH v6 1/9] xen/arm: introduce static shared memory

2022-08-29 Thread Penny Zheng
> -Original Message-
> From: Julien Grall 
> Sent: Friday, August 26, 2022 9:17 PM
> To: Penny Zheng ; xen-devel@lists.xenproject.org
> Cc: Stefano Stabellini ; Bertrand Marquis
> ; Volodymyr Babchuk
> 
> Subject: Re: [PATCH v6 1/9] xen/arm: introduce static shared memory
> 
> Hi Penny,
>

Hi Julien
 
> On 21/07/2022 14:21, Penny Zheng wrote:
> > From: Penny Zheng 
> >
> > This patch series introduces a new feature: setting up static shared
> > memory on a dom0less system, through device tree configuration.
> >
> > This commit parses shared memory node at boot-time, and reserve it in
> > bootinfo.reserved_mem to avoid other use.
> >
> > This commits proposes a new Kconfig CONFIG_STATIC_SHM to wrap
> > static-shm-related codes, and this option depends on static memory(
> > CONFIG_STATIC_MEMORY). That's because that later we want to reuse a
> > few helpers, guarded with CONFIG_STATIC_MEMORY, like
> > acquire_staticmem_pages, etc, on static shared memory.
> >
> > Signed-off-by: Penny Zheng 
> > ---
> > v6 change:
> > - when host physical address is ommited, output the error message
> > since xen doesn't support it at the moment
> > - add the following check: 1) The shm ID matches and the region
> > exactly match
> > 2) The shm ID doesn't match and the region doesn't overlap
> > - change it to "unsigned int" to be aligned with nr_banks
> > - check the len of the property to confirm is it big enough to contain
> > "paddr", "size", and "gaddr"
> > - shm_id defined before nr_shm_domain, so we could re-use the existing
> > hole and avoid increasing the size of the structure.
> > - change "nr_shm_domain" to "nr_shm_borrowers", to not increment if
> > the role is owner in parsing code
> > - make "xen,shm_id" property as arbitrary string, with a strict limit
> > on the number of characters, MAX_SHM_ID_LENGTH
> > ---
> > v5 change:
> > - no change
> > ---
> > v4 change:
> > - nit fix on doc
> > ---
> > v3 change:
> > - make nr_shm_domain unsigned int
> > ---
> > v2 change:
> > - document refinement
> > - remove bitmap and use the iteration to check
> > - add a new field nr_shm_domain to keep the number of shared domain
> > ---
> >   docs/misc/arm/device-tree/booting.txt | 124 
> >   xen/arch/arm/Kconfig  |   6 +
> >   xen/arch/arm/bootfdt.c| 157 ++
> >   xen/arch/arm/include/asm/setup.h  |   9 ++
> >   4 files changed, 296 insertions(+)
> >
> > diff --git a/docs/misc/arm/device-tree/booting.txt
> > b/docs/misc/arm/device-tree/booting.txt
> > index 98253414b8..8013fb98fe 100644
> > --- a/docs/misc/arm/device-tree/booting.txt
> > +++ b/docs/misc/arm/device-tree/booting.txt
> > @@ -378,3 +378,127 @@ device-tree:
> >
> >   This will reserve a 512MB region starting at the host physical address
> >   0x3000 to be exclusively used by DomU1.
> > +
> > +Static Shared Memory
> > +
> > +
> > +The static shared memory device tree nodes allow users to statically
> > +set up shared memory on dom0less system, enabling domains to do
> > +shm-based communication.
> > +
> > +- compatible
> > +
> > +"xen,domain-shared-memory-v1"
> > +
> > +- xen,shm-id
> > +
> > +An arbitrary string that represents the unique identifier of the shared
> > +memory region, with a strict limit on the number of characters(\0
> included),
> > +`MAX_SHM_ID_LENGTH(16)`. e.g. "xen,shm-id = "my-shared-mem-1"".
> > +
> > +- xen,shared-mem
> > +
> > +An array takes a physical address, which is the base address of the
> > +shared memory region in host physical address space, a size, and a
> guest
> > +physical address, as the target address of the mapping.
> > +e.g. xen,shared-mem = < [host physical address] [size] [guest
> > + address] >
> 
> Your implementation below is checking for overlap and also have some
> restriction. Can they be documented in the binding?
> 
> > +
> > +The number of cells for the host address (and size) is the same as the
> > +guest pseudo-physical address and they are inherited from the parent
> node.
> 
> In v5, we discussed to have the host address optional. However, the binding
> has not been updated to reflect that. Note that I am not asking to implement,
> but instead request th

Re: [PATCH v6 1/9] xen/arm: introduce static shared memory

2022-08-26 Thread Julien Grall

Hi Penny,

On 21/07/2022 14:21, Penny Zheng wrote:

From: Penny Zheng 

This patch series introduces a new feature: setting up static
shared memory on a dom0less system, through device tree configuration.

This commit parses shared memory node at boot-time, and reserve it in
bootinfo.reserved_mem to avoid other use.

This commits proposes a new Kconfig CONFIG_STATIC_SHM to wrap
static-shm-related codes, and this option depends on static memory(
CONFIG_STATIC_MEMORY). That's because that later we want to reuse a few
helpers, guarded with CONFIG_STATIC_MEMORY, like acquire_staticmem_pages, etc,
on static shared memory.

Signed-off-by: Penny Zheng 
---
v6 change:
- when host physical address is ommited, output the error message since
xen doesn't support it at the moment
- add the following check: 1) The shm ID matches and the region exactly match
2) The shm ID doesn't match and the region doesn't overlap
- change it to "unsigned int" to be aligned with nr_banks
- check the len of the property to confirm is it big enough to
contain "paddr", "size", and "gaddr"
- shm_id defined before nr_shm_domain, so we could re-use the existing hole and
avoid increasing the size of the structure.
- change "nr_shm_domain" to "nr_shm_borrowers", to not increment if the role
is owner in parsing code
- make "xen,shm_id" property as arbitrary string, with a strict limit on
the number of characters, MAX_SHM_ID_LENGTH
---
v5 change:
- no change
---
v4 change:
- nit fix on doc
---
v3 change:
- make nr_shm_domain unsigned int
---
v2 change:
- document refinement
- remove bitmap and use the iteration to check
- add a new field nr_shm_domain to keep the number of shared domain
---
  docs/misc/arm/device-tree/booting.txt | 124 
  xen/arch/arm/Kconfig  |   6 +
  xen/arch/arm/bootfdt.c| 157 ++
  xen/arch/arm/include/asm/setup.h  |   9 ++
  4 files changed, 296 insertions(+)

diff --git a/docs/misc/arm/device-tree/booting.txt 
b/docs/misc/arm/device-tree/booting.txt
index 98253414b8..8013fb98fe 100644
--- a/docs/misc/arm/device-tree/booting.txt
+++ b/docs/misc/arm/device-tree/booting.txt
@@ -378,3 +378,127 @@ device-tree:
  
  This will reserve a 512MB region starting at the host physical address

  0x3000 to be exclusively used by DomU1.
+
+Static Shared Memory
+
+
+The static shared memory device tree nodes allow users to statically set up
+shared memory on dom0less system, enabling domains to do shm-based
+communication.
+
+- compatible
+
+"xen,domain-shared-memory-v1"
+
+- xen,shm-id
+
+An arbitrary string that represents the unique identifier of the shared
+memory region, with a strict limit on the number of characters(\0 
included),
+`MAX_SHM_ID_LENGTH(16)`. e.g. "xen,shm-id = "my-shared-mem-1"".
+
+- xen,shared-mem
+
+An array takes a physical address, which is the base address of the
+shared memory region in host physical address space, a size, and a guest
+physical address, as the target address of the mapping.
+e.g. xen,shared-mem = < [host physical address] [size] [guest address] >


Your implementation below is checking for overlap and also have some 
restriction. Can they be documented in the binding?



+
+The number of cells for the host address (and size) is the same as the
+guest pseudo-physical address and they are inherited from the parent node.


In v5, we discussed to have the host address optional. However, the 
binding has not been updated to reflect that. Note that I am not asking 
to implement, but instead request that the binding can be used for such 
setup.



+
+
+- role (Optional)
+
+A string property specifying the ownership of a shared memory region,
+the value must be one of the following: "owner", or "borrower"
+A shared memory region could be explicitly backed by one domain, which is
+called "owner domain", and all the other domains who are also sharing
+this region are called "borrower domain".
+If not specified, the default value is "borrower" and owner is
+DOMID_IO, a system domain.
+
+As an example:
+
+chosen {
+#address-cells = <0x1>;
+#size-cells = <0x1>;
+xen,xen-bootargs = "console=dtuart dtuart=serial0 bootscrub=0";
+
+..
+
+/* this is for Dom0 */
+dom0-shared-mem@1000 {
+compatible = "xen,domain-shared-memory-v1";
+role = "owner";
+xen,shm-id = "my-shared-mem-0";
+xen,shared-mem = <0x1000 0x1000 0x1000>;
+}
+
+domU1 {
+compatible = "xen,domain";
+#address-cells = <0x1>;
+#size-cells = <0x1>;
+memory = <0 131072>;
+cpus = <2>;
+vpl011;
+
+/*
+ * shared memory region identified as 0x0(xen,shm-id = <0x0>)
+ * is shared between Dom0 and DomU1.
+ */
+domU1-shared-mem@1000 {
+compatible = "xen,domain-shared-memory-v1";
+role = 

[PATCH v6 1/9] xen/arm: introduce static shared memory

2022-07-21 Thread Penny Zheng
From: Penny Zheng 

This patch series introduces a new feature: setting up static
shared memory on a dom0less system, through device tree configuration.

This commit parses shared memory node at boot-time, and reserve it in
bootinfo.reserved_mem to avoid other use.

This commits proposes a new Kconfig CONFIG_STATIC_SHM to wrap
static-shm-related codes, and this option depends on static memory(
CONFIG_STATIC_MEMORY). That's because that later we want to reuse a few
helpers, guarded with CONFIG_STATIC_MEMORY, like acquire_staticmem_pages, etc,
on static shared memory.

Signed-off-by: Penny Zheng 
---
v6 change:
- when host physical address is ommited, output the error message since
xen doesn't support it at the moment
- add the following check: 1) The shm ID matches and the region exactly match
2) The shm ID doesn't match and the region doesn't overlap
- change it to "unsigned int" to be aligned with nr_banks
- check the len of the property to confirm is it big enough to
contain "paddr", "size", and "gaddr"
- shm_id defined before nr_shm_domain, so we could re-use the existing hole and
avoid increasing the size of the structure.
- change "nr_shm_domain" to "nr_shm_borrowers", to not increment if the role
is owner in parsing code
- make "xen,shm_id" property as arbitrary string, with a strict limit on
the number of characters, MAX_SHM_ID_LENGTH
---
v5 change:
- no change
---
v4 change:
- nit fix on doc
---
v3 change:
- make nr_shm_domain unsigned int
---
v2 change:
- document refinement
- remove bitmap and use the iteration to check
- add a new field nr_shm_domain to keep the number of shared domain
---
 docs/misc/arm/device-tree/booting.txt | 124 
 xen/arch/arm/Kconfig  |   6 +
 xen/arch/arm/bootfdt.c| 157 ++
 xen/arch/arm/include/asm/setup.h  |   9 ++
 4 files changed, 296 insertions(+)

diff --git a/docs/misc/arm/device-tree/booting.txt 
b/docs/misc/arm/device-tree/booting.txt
index 98253414b8..8013fb98fe 100644
--- a/docs/misc/arm/device-tree/booting.txt
+++ b/docs/misc/arm/device-tree/booting.txt
@@ -378,3 +378,127 @@ device-tree:
 
 This will reserve a 512MB region starting at the host physical address
 0x3000 to be exclusively used by DomU1.
+
+Static Shared Memory
+
+
+The static shared memory device tree nodes allow users to statically set up
+shared memory on dom0less system, enabling domains to do shm-based
+communication.
+
+- compatible
+
+"xen,domain-shared-memory-v1"
+
+- xen,shm-id
+
+An arbitrary string that represents the unique identifier of the shared
+memory region, with a strict limit on the number of characters(\0 
included),
+`MAX_SHM_ID_LENGTH(16)`. e.g. "xen,shm-id = "my-shared-mem-1"".
+
+- xen,shared-mem
+
+An array takes a physical address, which is the base address of the
+shared memory region in host physical address space, a size, and a guest
+physical address, as the target address of the mapping.
+e.g. xen,shared-mem = < [host physical address] [size] [guest address] >
+
+The number of cells for the host address (and size) is the same as the
+guest pseudo-physical address and they are inherited from the parent node.
+
+
+- role (Optional)
+
+A string property specifying the ownership of a shared memory region,
+the value must be one of the following: "owner", or "borrower"
+A shared memory region could be explicitly backed by one domain, which is
+called "owner domain", and all the other domains who are also sharing
+this region are called "borrower domain".
+If not specified, the default value is "borrower" and owner is
+DOMID_IO, a system domain.
+
+As an example:
+
+chosen {
+#address-cells = <0x1>;
+#size-cells = <0x1>;
+xen,xen-bootargs = "console=dtuart dtuart=serial0 bootscrub=0";
+
+..
+
+/* this is for Dom0 */
+dom0-shared-mem@1000 {
+compatible = "xen,domain-shared-memory-v1";
+role = "owner";
+xen,shm-id = "my-shared-mem-0";
+xen,shared-mem = <0x1000 0x1000 0x1000>;
+}
+
+domU1 {
+compatible = "xen,domain";
+#address-cells = <0x1>;
+#size-cells = <0x1>;
+memory = <0 131072>;
+cpus = <2>;
+vpl011;
+
+/*
+ * shared memory region identified as 0x0(xen,shm-id = <0x0>)
+ * is shared between Dom0 and DomU1.
+ */
+domU1-shared-mem@1000 {
+compatible = "xen,domain-shared-memory-v1";
+role = "borrower";
+xen,shm-id = "my-shared-mem-0";
+xen,shared-mem = <0x1000 0x1000 0x5000>;
+}
+
+/*
+ * shared memory region identified as 0x1(xen,shm-id = <0x1>)
+ * is shared between DomU1 and DomU2.
+ */
+domU1-shared-mem@5000 {
+compatible = "xen,domain-shared-memory-v1";
+xen,shm-id = "my-shared-mem-1";
+