diff mbox

[Xen-devel,RFC,29/35] arm : acpi enable PSCI and hvc in acpi FADT table

Message ID 1423058539-26403-30-git-send-email-parth.dixit@linaro.org
State New
Headers show

Commit Message

Parth Dixit Feb. 4, 2015, 2:02 p.m. UTC
From: Parth Dixit <parth.dixit@linaro.org>

Enable PSCI and hvc flags in FADT table so that dom0 uses PSCI to
boot vcpu's

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
---
 xen/arch/arm/arm64/acpi/arm-core.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Julien Grall Feb. 5, 2015, 4:33 a.m. UTC | #1
Hi Parth,

On 04/02/2015 14:02, parth.dixit@linaro.org wrote:
> From: Parth Dixit <parth.dixit@linaro.org>
>
> Enable PSCI and hvc flags in FADT table so that dom0 uses PSCI to
> boot vcpu's

VCPUs

>
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> ---
>   xen/arch/arm/arm64/acpi/arm-core.c | 16 ++++++++++++++++
>   1 file changed, 16 insertions(+)
>
> diff --git a/xen/arch/arm/arm64/acpi/arm-core.c b/xen/arch/arm/arm64/acpi/arm-core.c
> index 6707e4c..9a26202 100644
> --- a/xen/arch/arm/arm64/acpi/arm-core.c
> +++ b/xen/arch/arm/arm64/acpi/arm-core.c
> @@ -28,6 +28,7 @@
>   #include <xen/errno.h>
>   #include <xen/stdbool.h>
>   #include <xen/cpumask.h>
> +#include <acpi/actables.h>
>
>   #include <asm/cputype.h>
>   #include <asm/acpi.h>
> @@ -242,6 +243,19 @@ static int __init acpi_parse_fadt(struct acpi_table_header *table)
>          return 0;
>   }
>
> +static void set_psci_fadt(void)
> +{
> +    struct acpi_table_fadt *fadt=NULL;
> +    struct acpi_table_header *table=NULL;
> +    u8 checksum;
> +
> +    acpi_get_table(ACPI_SIG_FADT, 0, &table);
> +    fadt = (struct acpi_table_fadt *)table;
> +    fadt->arm_boot_flags |= ( ACPI_FADT_PSCI_COMPLIANT | ACPI_FADT_PSCI_USE_HVC );
> +    checksum = acpi_tb_checksum(ACPI_CAST_PTR(u8, fadt), fadt->header.length);
> +    fadt->header.checksum = (u8)( fadt->header.checksum-checksum );
> +}
> +
>   int acpi_map_tables(struct domain *d)
>   {
>       int i,res;
> @@ -263,6 +277,8 @@ int acpi_map_tables(struct domain *d)
>            return res;
>       }
>
> +    set_psci_fadt();
> +

With this change, the name of the function (acpi_map_tables) doesn't 
seem correct.

>       for( i = 0; i < acpi_gbl_root_table_list.count; i++ )
>       {
>           addr = acpi_gbl_root_table_list.tables[i].address;
>

Regards,
Julien Grall Feb. 6, 2015, 12:47 a.m. UTC | #2
Hi Parth,

On 06/02/2015 01:12, Stefano Stabellini wrote:
> On Wed, 4 Feb 2015, parth.dixit@linaro.org wrote:
>> From: Parth Dixit <parth.dixit@linaro.org>
>>
>> Enable PSCI and hvc flags in FADT table so that dom0 uses PSCI to
>> boot vcpu's
>>
>> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
>> ---
>>   xen/arch/arm/arm64/acpi/arm-core.c | 16 ++++++++++++++++
>>   1 file changed, 16 insertions(+)
>>
>> diff --git a/xen/arch/arm/arm64/acpi/arm-core.c b/xen/arch/arm/arm64/acpi/arm-core.c
>> index 6707e4c..9a26202 100644
>> --- a/xen/arch/arm/arm64/acpi/arm-core.c
>> +++ b/xen/arch/arm/arm64/acpi/arm-core.c
>> @@ -28,6 +28,7 @@
>>   #include <xen/errno.h>
>>   #include <xen/stdbool.h>
>>   #include <xen/cpumask.h>
>> +#include <acpi/actables.h>
>>
>>   #include <asm/cputype.h>
>>   #include <asm/acpi.h>
>> @@ -242,6 +243,19 @@ static int __init acpi_parse_fadt(struct acpi_table_header *table)
>>          return 0;
>>   }
>>
>> +static void set_psci_fadt(void)
>> +{
>> +    struct acpi_table_fadt *fadt=NULL;
>> +    struct acpi_table_header *table=NULL;
>> +    u8 checksum;
>> +
>> +    acpi_get_table(ACPI_SIG_FADT, 0, &table);
>> +    fadt = (struct acpi_table_fadt *)table;
>> +    fadt->arm_boot_flags |= ( ACPI_FADT_PSCI_COMPLIANT | ACPI_FADT_PSCI_USE_HVC );
>
> Are we actually allowed to modify the real acpi table passed by the firmware?
> Could it be read-only?
>
> If we can change it,  do we need a dsb() before the acpi_tb_checksum?

IIRC, the ACPI memory region is mapped cached and preparing the ACPI 
blob is only done in one processor. So the dsb() is not necessary here.

But ... that made me think that we should clear the cache after changes 
in the table. We can't assume that the guest will map with cache 
attribute the ACPI tables.

Regards,
diff mbox

Patch

diff --git a/xen/arch/arm/arm64/acpi/arm-core.c b/xen/arch/arm/arm64/acpi/arm-core.c
index 6707e4c..9a26202 100644
--- a/xen/arch/arm/arm64/acpi/arm-core.c
+++ b/xen/arch/arm/arm64/acpi/arm-core.c
@@ -28,6 +28,7 @@ 
 #include <xen/errno.h>
 #include <xen/stdbool.h>
 #include <xen/cpumask.h>
+#include <acpi/actables.h>
 
 #include <asm/cputype.h>
 #include <asm/acpi.h>
@@ -242,6 +243,19 @@  static int __init acpi_parse_fadt(struct acpi_table_header *table)
        return 0;
 }
 
+static void set_psci_fadt(void)
+{
+    struct acpi_table_fadt *fadt=NULL;
+    struct acpi_table_header *table=NULL;
+    u8 checksum;
+
+    acpi_get_table(ACPI_SIG_FADT, 0, &table);
+    fadt = (struct acpi_table_fadt *)table;
+    fadt->arm_boot_flags |= ( ACPI_FADT_PSCI_COMPLIANT | ACPI_FADT_PSCI_USE_HVC );
+    checksum = acpi_tb_checksum(ACPI_CAST_PTR(u8, fadt), fadt->header.length);
+    fadt->header.checksum = (u8)( fadt->header.checksum-checksum );
+}
+
 int acpi_map_tables(struct domain *d)
 {
     int i,res;
@@ -263,6 +277,8 @@  int acpi_map_tables(struct domain *d)
          return res;
     }
 
+    set_psci_fadt();
+
     for( i = 0; i < acpi_gbl_root_table_list.count; i++ )
     {
         addr = acpi_gbl_root_table_list.tables[i].address;