diff mbox

[v2,13/25] arm/altp2m: Make p2m_restore_state ready for altp2m.

Message ID 20160801171028.11615-14-proskurin@sec.in.tum.de (mailing list archive)
State New, archived
Headers show

Commit Message

Sergej Proskurin Aug. 1, 2016, 5:10 p.m. UTC
This commit adapts the function "p2m_restore_state" in a way that the
currently active altp2m table is considered during state restoration.

Signed-off-by: Sergej Proskurin <proskurin@sec.in.tum.de>
---
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Julien Grall <julien.grall@arm.com>
---
 xen/arch/arm/p2m.c           | 4 +++-
 xen/include/asm-arm/altp2m.h | 3 +++
 2 files changed, 6 insertions(+), 1 deletion(-)

Comments

Julien Grall Aug. 4, 2016, 11:55 a.m. UTC | #1
Hello,

On 01/08/16 18:10, Sergej Proskurin wrote:
> This commit adapts the function "p2m_restore_state" in a way that the
> currently active altp2m table is considered during state restoration.
>
> Signed-off-by: Sergej Proskurin <proskurin@sec.in.tum.de>
> ---
> Cc: Stefano Stabellini <sstabellini@kernel.org>
> Cc: Julien Grall <julien.grall@arm.com>
> ---
>  xen/arch/arm/p2m.c           | 4 +++-
>  xen/include/asm-arm/altp2m.h | 3 +++
>  2 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
> index 8afea11..bcad51f 100644
> --- a/xen/arch/arm/p2m.c
> +++ b/xen/arch/arm/p2m.c
> @@ -115,7 +115,9 @@ void p2m_save_state(struct vcpu *p)
>  void p2m_restore_state(struct vcpu *n)
>  {
>      register_t hcr;
> -    struct p2m_domain *p2m = &n->domain->arch.p2m;
> +    struct domain *d = n->domain;
> +    struct p2m_domain *p2m = unlikely(altp2m_active(d)) ?
> +                             altp2m_get_altp2m(n) : p2m_get_hostp2m(d);

This seems to be a common idiom in multiple place. I would like to see a 
helper for this.

However, I think this could be avoided if you store a pointer to the p2m 
directly in arch_vcpu.

>
>      if ( is_idle_vcpu(n) )
>          return;
> diff --git a/xen/include/asm-arm/altp2m.h b/xen/include/asm-arm/altp2m.h
> index 790bb33..a6496b7 100644
> --- a/xen/include/asm-arm/altp2m.h
> +++ b/xen/include/asm-arm/altp2m.h
> @@ -49,6 +49,9 @@ void altp2m_teardown(struct domain *d);
>  void altp2m_vcpu_initialise(struct vcpu *v);
>  void altp2m_vcpu_destroy(struct vcpu *v);
>
> +/* Get current alternate p2m table. */
> +struct p2m_domain *altp2m_get_altp2m(struct vcpu *v);
> +

This should be added in the patch where the function was added (i.e 
patch #8).

>  /* Switch alternate p2m for entire domain */
>  int altp2m_switch_domain_altp2m_by_id(struct domain *d,
>                                        unsigned int idx);
>

Regards,
Sergej Proskurin Aug. 6, 2016, 10:20 a.m. UTC | #2
Hi Julien,


On 08/04/2016 01:55 PM, Julien Grall wrote:
> Hello,
>
> On 01/08/16 18:10, Sergej Proskurin wrote:
>> This commit adapts the function "p2m_restore_state" in a way that the
>> currently active altp2m table is considered during state restoration.
>>
>> Signed-off-by: Sergej Proskurin <proskurin@sec.in.tum.de>
>> ---
>> Cc: Stefano Stabellini <sstabellini@kernel.org>
>> Cc: Julien Grall <julien.grall@arm.com>
>> ---
>>  xen/arch/arm/p2m.c           | 4 +++-
>>  xen/include/asm-arm/altp2m.h | 3 +++
>>  2 files changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
>> index 8afea11..bcad51f 100644
>> --- a/xen/arch/arm/p2m.c
>> +++ b/xen/arch/arm/p2m.c
>> @@ -115,7 +115,9 @@ void p2m_save_state(struct vcpu *p)
>>  void p2m_restore_state(struct vcpu *n)
>>  {
>>      register_t hcr;
>> -    struct p2m_domain *p2m = &n->domain->arch.p2m;
>> +    struct domain *d = n->domain;
>> +    struct p2m_domain *p2m = unlikely(altp2m_active(d)) ?
>> +                             altp2m_get_altp2m(n) : p2m_get_hostp2m(d);
>
> This seems to be a common idiom in multiple place. I would like to see
> a helper for this.

Ok.

>
> However, I think this could be avoided if you store a pointer to the
> p2m directly in arch_vcpu.
>

This answers my question in the previous patch (patch #12). It would
definitely make thinks easier in some cases. I will check if we can do
it without too much troubles.

>>
>>      if ( is_idle_vcpu(n) )
>>          return;
>> diff --git a/xen/include/asm-arm/altp2m.h b/xen/include/asm-arm/altp2m.h
>> index 790bb33..a6496b7 100644
>> --- a/xen/include/asm-arm/altp2m.h
>> +++ b/xen/include/asm-arm/altp2m.h
>> @@ -49,6 +49,9 @@ void altp2m_teardown(struct domain *d);
>>  void altp2m_vcpu_initialise(struct vcpu *v);
>>  void altp2m_vcpu_destroy(struct vcpu *v);
>>
>> +/* Get current alternate p2m table. */
>> +struct p2m_domain *altp2m_get_altp2m(struct vcpu *v);
>> +
>
> This should be added in the patch where the function was added (i.e
> patch #8).
>

Ok.

>>  /* Switch alternate p2m for entire domain */
>>  int altp2m_switch_domain_altp2m_by_id(struct domain *d,
>>                                        unsigned int idx);
>>
>

Best regards,
~Sergej
diff mbox

Patch

diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index 8afea11..bcad51f 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -115,7 +115,9 @@  void p2m_save_state(struct vcpu *p)
 void p2m_restore_state(struct vcpu *n)
 {
     register_t hcr;
-    struct p2m_domain *p2m = &n->domain->arch.p2m;
+    struct domain *d = n->domain;
+    struct p2m_domain *p2m = unlikely(altp2m_active(d)) ?
+                             altp2m_get_altp2m(n) : p2m_get_hostp2m(d);
 
     if ( is_idle_vcpu(n) )
         return;
diff --git a/xen/include/asm-arm/altp2m.h b/xen/include/asm-arm/altp2m.h
index 790bb33..a6496b7 100644
--- a/xen/include/asm-arm/altp2m.h
+++ b/xen/include/asm-arm/altp2m.h
@@ -49,6 +49,9 @@  void altp2m_teardown(struct domain *d);
 void altp2m_vcpu_initialise(struct vcpu *v);
 void altp2m_vcpu_destroy(struct vcpu *v);
 
+/* Get current alternate p2m table. */
+struct p2m_domain *altp2m_get_altp2m(struct vcpu *v);
+
 /* Switch alternate p2m for entire domain */
 int altp2m_switch_domain_altp2m_by_id(struct domain *d,
                                       unsigned int idx);