Re: [Xen-devel] [PATCH v3 03/38] arm/p2m: Introduce p2m_(switch|restore)_vttbr_and_(g|s)et_flags

2016-09-02 Thread Sergej Proskurin
Hi Julien,

On 09/02/2016 11:57 AM, Julien Grall wrote:
> 
> 
> On 02/09/16 09:40, Sergej Proskurin wrote:
>> Hi Julien,
> 
> Hello Sergej,
> 
>> On 09/01/2016 05:51 PM, Julien Grall wrote:
>>> Hello Sergej,
>>>
>>> On 16/08/16 23:16, Sergej Proskurin wrote:
 This commit introduces macros for switching and restoring the vttbr
 considering the currently set irq flags. We define these macros, as the
 following commits will use the associated functionality multiple times
 throughout the file ./xen/arch/arm/p2m.c.

 Signed-off-by: Sergej Proskurin 
 ---
 Cc: Stefano Stabellini 
 Cc: Julien Grall 
 ---
  xen/arch/arm/p2m.c | 37 +++--
  1 file changed, 23 insertions(+), 14 deletions(-)

 diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
 index 08114d8..02e9ee7 100644
 --- a/xen/arch/arm/p2m.c
 +++ b/xen/arch/arm/p2m.c
 @@ -27,6 +27,26 @@ static unsigned int __read_mostly p2m_root_level;

  #define P2M_ROOT_PAGES(1<>>
>>> It makes more sense to save the content of VTTBR_EL2 in the macro.
>>>
>>
>> I assume you mean the VTTBR_EL2 within the macro parameter ovttbr. I
>> will move the definition of the ovttbr variable into the macro and

s/definition/initialization/

>> return its value at the end so that it can be subsequently provided with
>> the "p2m_restore_vttbr_and_set_flags" macro. Thank you.
> 
> I meant
> 
> #define p2m_switch_vttbr_and_get_flags(ovttbr, nvttbr, flags) \
> ({\
>   ovttbr = READ_SYSREG(VTTBR_EL2);\
>   if ( ovttbr != nvttbr ) \
>   {   \
>   local_irq_save(flags);  \
>   WRITE_SYSREG64(nvttbr, VTTBR_EL2);  \
>   isb();  \
>   }
> })
> 

That is what I understood, thank you :)

Cheers,
~Sergej

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v3 03/38] arm/p2m: Introduce p2m_(switch|restore)_vttbr_and_(g|s)et_flags

2016-09-02 Thread Julien Grall


On 02/09/16 09:40, Sergej Proskurin wrote:
> Hi Julien,

Hello Sergej,

> On 09/01/2016 05:51 PM, Julien Grall wrote:
>> Hello Sergej,
>>
>> On 16/08/16 23:16, Sergej Proskurin wrote:
>>> This commit introduces macros for switching and restoring the vttbr
>>> considering the currently set irq flags. We define these macros, as the
>>> following commits will use the associated functionality multiple times
>>> throughout the file ./xen/arch/arm/p2m.c.
>>>
>>> Signed-off-by: Sergej Proskurin 
>>> ---
>>> Cc: Stefano Stabellini 
>>> Cc: Julien Grall 
>>> ---
>>>  xen/arch/arm/p2m.c | 37 +++--
>>>  1 file changed, 23 insertions(+), 14 deletions(-)
>>>
>>> diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
>>> index 08114d8..02e9ee7 100644
>>> --- a/xen/arch/arm/p2m.c
>>> +++ b/xen/arch/arm/p2m.c
>>> @@ -27,6 +27,26 @@ static unsigned int __read_mostly p2m_root_level;
>>>
>>>  #define P2M_ROOT_PAGES(1<>>
>>> +#define p2m_switch_vttbr_and_get_flags(ovttbr, nvttbr, flags)   \
>>> +({  \
>>
>> It makes more sense to save the content of VTTBR_EL2 in the macro.
>>
> 
> I assume you mean the VTTBR_EL2 within the macro parameter ovttbr. I
> will move the definition of the ovttbr variable into the macro and
> return its value at the end so that it can be subsequently provided with
> the "p2m_restore_vttbr_and_set_flags" macro. Thank you.

I meant

#define p2m_switch_vttbr_and_get_flags(ovttbr, nvttbr, flags)   \
({  \
ovttbr = READ_SYSREG(VTTBR_EL2);\
if ( ovttbr != nvttbr ) \
{   \
local_irq_save(flags);  \
WRITE_SYSREG64(nvttbr, VTTBR_EL2);  \
isb();  \
}
})

Regards,

-- 
Julien Grall

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v3 03/38] arm/p2m: Introduce p2m_(switch|restore)_vttbr_and_(g|s)et_flags

2016-09-02 Thread Sergej Proskurin
Hi Julien,

On 09/01/2016 05:51 PM, Julien Grall wrote:
> Hello Sergej,
> 
> On 16/08/16 23:16, Sergej Proskurin wrote:
>> This commit introduces macros for switching and restoring the vttbr
>> considering the currently set irq flags. We define these macros, as the
>> following commits will use the associated functionality multiple times
>> throughout the file ./xen/arch/arm/p2m.c.
>>
>> Signed-off-by: Sergej Proskurin 
>> ---
>> Cc: Stefano Stabellini 
>> Cc: Julien Grall 
>> ---
>>  xen/arch/arm/p2m.c | 37 +++--
>>  1 file changed, 23 insertions(+), 14 deletions(-)
>>
>> diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
>> index 08114d8..02e9ee7 100644
>> --- a/xen/arch/arm/p2m.c
>> +++ b/xen/arch/arm/p2m.c
>> @@ -27,6 +27,26 @@ static unsigned int __read_mostly p2m_root_level;
>>
>>  #define P2M_ROOT_PAGES(1<>
>> +#define p2m_switch_vttbr_and_get_flags(ovttbr, nvttbr, flags)   \
>> +({  \
> 
> It makes more sense to save the content of VTTBR_EL2 in the macro.
> 

I assume you mean the VTTBR_EL2 within the macro parameter ovttbr. I
will move the definition of the ovttbr variable into the macro and
return its value at the end so that it can be subsequently provided with
the "p2m_restore_vttbr_and_set_flags" macro. Thank you.

>> +if ( ovttbr != nvttbr ) \
>> +{   \
>> +local_irq_save(flags);  \
>> +WRITE_SYSREG64(nvttbr, VTTBR_EL2);  \
>> +isb();  \
>> +}   \
>> +})
>> +
>> +#define p2m_restore_vttbr_and_set_flags(ovttbr, flags)  \
>> +({  \
>> +if ( ovttbr != READ_SYSREG64(VTTBR_EL2) )   \
>> +{   \
>> +WRITE_SYSREG64(ovttbr, VTTBR_EL2);  \
>> +isb();  \
>> +local_irq_restore(flags);   \
>> +}   \
>> +})
>> +
>>  unsigned int __read_mostly p2m_ipa_bits;
>>
>>  /* Helpers to lookup the properties of each level */
>> @@ -173,28 +193,17 @@ void p2m_restore_state(struct vcpu *n)
>>  static void p2m_flush_tlb(struct p2m_domain *p2m)
>>  {
>>  unsigned long flags = 0;
>> -uint64_t ovttbr;
>> +uint64_t ovttbr = READ_SYSREG64(VTTBR_EL2);
>>
>>  /*
>>   * ARM only provides an instruction to flush TLBs for the current
>>   * VMID. So switch to the VTTBR of a given P2M if different.
>>   */
>> -ovttbr = READ_SYSREG64(VTTBR_EL2);
>> -if ( ovttbr != p2m->vttbr )
>> -{
>> -local_irq_save(flags);
>> -WRITE_SYSREG64(p2m->vttbr, VTTBR_EL2);
>> -isb();
>> -}
>> +p2m_switch_vttbr_and_get_flags(ovttbr, p2m->vttbr, flags);
>>
>>  flush_tlb();
>>
>> -if ( ovttbr != READ_SYSREG64(VTTBR_EL2) )
>> -{
>> -WRITE_SYSREG64(ovttbr, VTTBR_EL2);
>> -isb();
>> -local_irq_restore(flags);
>> -}
>> +p2m_restore_vttbr_and_set_flags(ovttbr, flags);
>>  }
>>
>>  /*
>>
> 
> Regards,
> 


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v3 03/38] arm/p2m: Introduce p2m_(switch|restore)_vttbr_and_(g|s)et_flags

2016-09-01 Thread Julien Grall

Hello Sergej,

On 16/08/16 23:16, Sergej Proskurin wrote:

This commit introduces macros for switching and restoring the vttbr
considering the currently set irq flags. We define these macros, as the
following commits will use the associated functionality multiple times
throughout the file ./xen/arch/arm/p2m.c.

Signed-off-by: Sergej Proskurin 
---
Cc: Stefano Stabellini 
Cc: Julien Grall 
---
 xen/arch/arm/p2m.c | 37 +++--
 1 file changed, 23 insertions(+), 14 deletions(-)

diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index 08114d8..02e9ee7 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -27,6 +27,26 @@ static unsigned int __read_mostly p2m_root_level;

 #define P2M_ROOT_PAGES(1<vttbr )
-{
-local_irq_save(flags);
-WRITE_SYSREG64(p2m->vttbr, VTTBR_EL2);
-isb();
-}
+p2m_switch_vttbr_and_get_flags(ovttbr, p2m->vttbr, flags);

 flush_tlb();

-if ( ovttbr != READ_SYSREG64(VTTBR_EL2) )
-{
-WRITE_SYSREG64(ovttbr, VTTBR_EL2);
-isb();
-local_irq_restore(flags);
-}
+p2m_restore_vttbr_and_set_flags(ovttbr, flags);
 }

 /*



Regards,

--
Julien Grall

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v3 03/38] arm/p2m: Introduce p2m_(switch|restore)_vttbr_and_(g|s)et_flags

2016-08-16 Thread Sergej Proskurin
This commit introduces macros for switching and restoring the vttbr
considering the currently set irq flags. We define these macros, as the
following commits will use the associated functionality multiple times
throughout the file ./xen/arch/arm/p2m.c.

Signed-off-by: Sergej Proskurin 
---
Cc: Stefano Stabellini 
Cc: Julien Grall 
---
 xen/arch/arm/p2m.c | 37 +++--
 1 file changed, 23 insertions(+), 14 deletions(-)

diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index 08114d8..02e9ee7 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -27,6 +27,26 @@ static unsigned int __read_mostly p2m_root_level;
 
 #define P2M_ROOT_PAGES(1<vttbr )
-{
-local_irq_save(flags);
-WRITE_SYSREG64(p2m->vttbr, VTTBR_EL2);
-isb();
-}
+p2m_switch_vttbr_and_get_flags(ovttbr, p2m->vttbr, flags);
 
 flush_tlb();
 
-if ( ovttbr != READ_SYSREG64(VTTBR_EL2) )
-{
-WRITE_SYSREG64(ovttbr, VTTBR_EL2);
-isb();
-local_irq_restore(flags);
-}
+p2m_restore_vttbr_and_set_flags(ovttbr, flags);
 }
 
 /*
-- 
2.9.0


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel