xen/arm : emulation of arm's PSCI v0.2 standard
PATCH v2 1/1 xen/arm : emulation of arm's PSCI v0.2 standard
Arm based virtual machines dom0/guest will request power related functionality from xen through PSCI interface. This patch implements version 0.2 of PSCI standard specified by arm for 64bit and 32 bit arm machines.
- implemented WFI helper function for cpu_suspend
- modified arm_psci_fn_t to take three arguments
- implemented psci_cpu_on with additional error conditions
- removed switch-case in do_trap_psci function
- added PSCI v0.2 macros in psci.h from linux kernel
--- xen/arch/arm/domain.c | 13 ++++ xen/arch/arm/domain_build.c | 5 +- xen/arch/arm/traps.c | 34 ++++++-- xen/arch/arm/vpsci.c | 167 ++++++++++++++++++++++++++++++++++++++++ xen/include/asm-arm/event.h | 2 + xen/include/asm-arm/processor.h | 6 ++ xen/include/asm-arm/psci.h | 122 +++++++++++++++++++++++++++-- xen/include/public/arch-arm.h | 1 + 8 files changed, 339 insertions(+), 11 deletions(-)
xen/arch/arm/domain.c +13 -0
@@ -779,6 +779,19 @@ void vcpu_mark_events_pending(struct vcpu *v)vgic_vcpu_inject_irq (v, v->domain->arch.evtchn_irq,1 ); } +void vcpu_block_event (struct vcpu *v) +{ +vcpu_block (); +/* The ARM spec declares that even if local irqs are masked in +* the CPSR register, an irq should wake up a cpu from WFI anyway. +* For this reason we need to check for irqs that need delivery, +* ignoring the CPSR register, *after* calling SCHEDOP_block to +* avoid races with vgic_vcpu_inject_irq. +*/ +if (local_events_need_delivery_nomask () ) +vcpu_unblock (current); +} +/* * Local variables: * mode: C
xen/arch/arm/domain_build.c +4 -1
@@ -388,6 +388,9 @@ static int make_hypervisor_node(struct domain *d,static int make_psci_node (void *fdt,const struct dt_device_node *parent) {int res; +const char compat[] = +"arm,psci-0.2""\0" +"arm,psci" ;DPRINT ("Create PSCI node\n" );
@@ -396,7 +399,7 @@ static int make_psci_node(void *fdt, const struct dt_device_node *parent)if ( res )return res; - res =fdt_property_string (fdt,"compatible" ,"arm,psci" ); + res =fdt_property (fdt,"compatible" , compat,sizeof (compat));if ( res )return res;
xen/arch/arm/traps.c +29 -5
@@ -1030,7 +1030,7 @@ static arm_hypercall_t arm_hypercall_table[] = { HYPERCALL_ARM(vcpu_op, 3), }; -typedef int (*arm_psci_fn_t )(uint32_t ,register_t ); +typedef int (*arm_psci_fn_t )(register_t ,register_t ,register_t ); typedef struct { arm_psci_fn_t fn;
@@ -1046,6 +1046,17 @@ typedef struct {static arm_psci_t arm_psci_table[] = {PSCI (cpu_off,1 ),PSCI (cpu_on,2 ), + PSCI(0_2_version,0), + PSCI(0_2_cpu_suspend,3), + PSCI(0_2_cpu_off,0), + PSCI(0_2_cpu_on,3), + PSCI(0_2_affinity_info,2), + PSCI(0_2_migrate,1), + PSCI(0_2_migrate_info_type,0), + PSCI(0_2_migrate_info_up_cpu,0), + PSCI(0_2_system_off,0), + PSCI(0_2_system_reset,0), + };#ifndef NDEBUG
@@ -1082,24 +1093,37 @@ static void do_debug_trap(struct cpu_user_regs *regs, unsigned int code)#ifdef CONFIG_ARM_64 #define PSCI_OP_REG (r) (r)->x0#define PSCI_RESULT_REG (r) (r)->x0 -#define PSCI_ARGS (r) (r)->x1, (r)->x2 +#define PSCI_ARGS (r) (r)->x1, (r)->x2, (r)->x3#else #define PSCI_OP_REG (r) (r)->r0#define PSCI_RESULT_REG (r) (r)->r0 -#define PSCI_ARGS (r) (r)->r1, (r)->r2 +#define PSCI_ARGS (r) (r)->r1, (r)->r2, (r)->r3#endif static void do_trap_psci (struct cpu_user_regs *regs) {arm_psci_fn_t psci_call =NULL ; +unsigned int fn_index ; +struct domain *d = current->domain; + +if (PSCI_OP_REG (regs) <PSCI_0_1_MAX ) + fn_index =PSCI_OP_REG (regs); +else if (is_64bit_domain (d) ) + { + fn_index = ( (PSCI_OP_REG (regs) -PSCI_0_2_FN_OFFSET ) ); +if ( fn_index >PSCI_0_2_64BIT ) + fn_index -=PSCI_0_2_64BIT ; + } +else + fn_index = (PSCI_OP_REG (regs) -PSCI_0_2_FN_OFFSET ) ; -if (PSCI_OP_REG (regs) >=ARRAY_SIZE (arm_psci_table) ) +if ( fn_index >=ARRAY_SIZE (arm_psci_table) ) {domain_crash_synchronous ();return ; } - psci_call = arm_psci_table[PSCI_OP_REG (regs)].fn; + psci_call = arm_psci_table[fn_index].fn;if ( psci_call ==NULL ) {domain_crash_synchronous ();
xen/arch/arm/vpsci.c +167 -0
179 lines not on this page · raw message
xen/include/asm-arm/event.h +2 -0
@@ -6,6 +6,7 @@void vcpu_kick (struct vcpu *v);void vcpu_mark_events_pending (struct vcpu *v); +void vcpu_block_event (struct vcpu *v);static inline int vcpu_event_delivery_is_enabled (struct vcpu *v) {
@@ -55,6 +56,7 @@ static inline int arch_virq_is_global(int virq) return 1; } +#endif /* * Local variables:
xen/include/asm-arm/processor.h +6 -0
@@ -13,9 +13,15 @@#define _MPIDR_SMP (31)#define MPIDR_SMP (_AC(1,U) << _MPIDR_SMP)#define MPIDR_AFF0_SHIFT (0) +#define MPIDR_AFF1_SHIFT (1) +#define MPIDR_AFF2_SHIFT (2) +#define MPIDR_AFF3_SHIFT (3)#define MPIDR_AFF0_MASK (_AC(0xff,U) << MPIDR_AFF0_SHIFT)#define MPIDR_HWID_MASK _AC(0xffffff,U)#define MPIDR_INVALID (~MPIDR_HWID_MASK) +#define MPIDR_AFF_BIT_SHIFT (8) +#define AFFINITY_MASK (level) (_AC(0xff,U) << ((level)*MPIDR_AFF_BIT_SHIFT)) +/* TTBCR Translation Table Base Control Register */ #define TTBCR_EAE _AC(0x80000000,U)
xen/include/asm-arm/psci.h +117 -5
134 lines not on this page · raw message
xen/include/public/arch-arm.h +1 -0
@@ -385,6 +385,7 @@ typedef uint64_t xen_callback_t;#define PSCI_cpu_off 1#define PSCI_cpu_on 2#define PSCI_migrate 3 +#define PSCI_0_1_MAX 4#endif
Signature · 1 line
1.9.1
Hi Parth,
Thank you for the patch.
xen/arch/arm/domain.c void vcpu_mark_events_pending(struct vcpu *v) · line 790
Quoted 9 lines · Parth Dixit
xen/arch/arm/domain.c +9
-0+void vcpu_block_event (struct vcpu *v) +{ +vcpu_block (); +/* The ARM spec declares that even if local irqs are masked in +* the CPSR register, an irq should wake up a cpu from WFI anyway. +* For this reason we need to check for irqs that need delivery, +* ignoring the CPSR register, *after* calling SCHEDOP_block to +* avoid races with vgic_vcpu_inject_irq. +*/
The comment is out of date here and you should move it on top of the function.
Also, you've introduce this function but didn't replace the code in WFI trap.
Furthermore, I would move this change in a separate patch. It will be more clear.
Quoted 4 lines
xen/arch/arm/domain.c +4
-0+if (local_events_need_delivery_nomask () ) +vcpu_unblock (current); +} +
[..]
xen/arch/arm/vpsci.c int do_psci_cpu_off(uint32_t power_state) · line 118
Quoted 3 lines
xen/arch/arm/vpsci.c +3
-0+int do_psci_0_2_cpu_off (void ) +{ +uint32_t power_state =0 ;
Coding style require a newline between the declarations.
Also, defining power_state looks pointless here.
xen/arch/arm/vpsci.c int do_psci_cpu_off(uint32_t power_state) · line 123
Quoted 5 lines
xen/arch/arm/vpsci.c +5
-0+return do_psci_cpu_off (power_state); +} + +int do_psci_0_2_cpu_on (register_t target_cpu,register_t entry_point, +register_t context_id)
This function is 95% the same code. I would merge as much as possible with do_psci_cpu_on to avoid code duplication.
[..]
xen/arch/arm/vpsci.c int do_psci_cpu_off(uint32_t power_state) · line 227
Quoted 7 lines
xen/arch/arm/vpsci.c +7
-0+ +int do_psci_0_2_migrate (uint32_t target_cpu) +{ +return PSCI_ENOSYS ; +} + +
Only one newline.
xen/arch/arm/vpsci.c int do_psci_cpu_off(uint32_t power_state) · line 233
Quoted 6 lines
xen/arch/arm/vpsci.c +6
-0+int do_psci_0_2_migrate_info_type (void ) +{ +return PSCI_0_2_TOS_MP ; +} + +
Same here.
xen/arch/arm/vpsci.c int do_psci_cpu_off(uint32_t power_state) · line 239
Quoted 6 lines
xen/arch/arm/vpsci.c +6
-0+register_t do_psci_0_2_migrate_info_up_cpu (void ) +{ +return PSCI_ENOSYS ; +} + +
Same here.
xen/arch/arm/vpsci.c int do_psci_cpu_off(uint32_t power_state) · line 246
Quoted 7 lines
xen/arch/arm/vpsci.c +7
-0+void do_psci_0_2_system_off (void ) +{ +struct domain *d = current->domain; +domain_shutdown (d,SHUTDOWN_poweroff); +} + +
Same here.
Quoted 6 lines
xen/arch/arm/vpsci.c +6
-0+void do_psci_0_2_system_reset (void ) +{ +struct domain *d = current->domain; +domain_shutdown (d,SHUTDOWN_reboot); +} +
[..]
xen/include/asm-arm/event.h static inline int arch_virq_is_global(int virq) · line 59
Quoted 7 lines
static inline int
vcpu_event_delivery_is_enabled(struct vcpu *v){xen/include/asm-arm/event.h +1
-0@@ -55,6 +56,7 @@ static inline int arch_virq_is_global(int virq)return 1 ; } +
Spurious change.
xen/include/asm-arm/psci.h line 8
Quoted 13 lines
xen/include/asm-arm/psci.h +0
-5@@ -1,11 +1,6 @@#ifndef __ASM_PSCI_H__#define __ASM_PSCI_H__ -#define PSCI_SUCCESS 0 -#define PSCI_ENOSYS -1 -#define PSCI_EINVAL -2 -#define PSCI_DENIED -3 -
Why did you just moved them at the end of the file and change the indentation?
xen/include/asm-arm/psci.h int do_psci_cpu_off(uint32_t power_state); · line 40
Quoted 2 lines
xen/include/asm-arm/psci.h +2
-0+/* PSCI version */ +#define XEN_PSCI_V_0_1 1
This doesn't seem to be used, right?
xen/include/asm-arm/psci.h int do_psci_cpu_off(uint32_t power_state); · line 68
Quoted 5 lines
xen/include/asm-arm/psci.h +5
-0+ +/* PSCI v0.2 interface */ +#define PSCI_0_2_FN_BASE 0x84000000 +#define PSCI_0_2_FN (n) (PSCI_0_2_FN_BASE + (n)) +#define PSCI_0_2_64BIT 0x40000000
In general we don't use hard-tab in Xen coding style. Can you remove them?
[..]
xen/include/public/arch-arm.h typedef uint64_t xen_callback_t; · line 388
Quoted 9 lines
xen/include/public/arch-arm.h +1
-0@@ -385,6 +385,7 @@ typedef uint64_t xen_callback_t;#define PSCI_cpu_off 1#define PSCI_cpu_on 2#define PSCI_migrate 3 +#define PSCI_0_1_MAX 4
Why do you expose PSCI_0_1_MAX?
Signature · 1 line
Julien Grall
Hi Julien,
Comments are inline, i will try to send a new patch today/weekend after testing.
Quoted 18 lines · Julien Grall
Hi Parth,
Thank you for the patch.
xen/arch/arm/domain.c void vcpu_mark_events_pending(struct vcpu *v) · line 790
Quoted 9 lines · Parth Dixit
xen/arch/arm/domain.c +9
-0+void vcpu_block_event (struct vcpu *v) +{ +vcpu_block (); +/* The ARM spec declares that even if local irqs are masked in +* the CPSR register, an irq should wake up a cpu from WFI anyway. +* For this reason we need to check for irqs that need delivery, +* ignoring the CPSR register, *after* calling SCHEDOP_block to +* avoid races with vgic_vcpu_inject_irq. +*/ The comment is out of date here and you should move it on top of the function.
Quoted 6 lines
Also, you've introduce this function but didn't replace the code in WFI trap.
Furthermore, I would move this change in a separate patch. It will be more clear.
I will create new patch for this and replace WFI with this function -(AI Parth)
Quoted 8 lines
Quoted 5 lines
xen/arch/arm/domain.c +4
-0+if (local_events_need_delivery_nomask () ) +vcpu_unblock (current); +} +[..]
Quoted 7 lines
xen/arch/arm/vpsci.c int do_psci_cpu_off(uint32_t power_state) · line 118
Quoted 3 lines
xen/arch/arm/vpsci.c +3
-0+int do_psci_0_2_cpu_off (void ) +{ +uint32_t power_state =0 ;Coding style require a newline between the declarations.
Also, defining
power_statelooks pointless here.
Agreed will be taken care of in next patchset - (AI Parth)
Quoted 92 lines
xen/arch/arm/vpsci.c int do_psci_cpu_off(uint32_t power_state) · line 123
Quoted 5 lines
xen/arch/arm/vpsci.c +5
-0+return do_psci_cpu_off (power_state); +} + +int do_psci_0_2_cpu_on (register_t target_cpu,register_t entry_point, +register_t context_id)This function is 95% the same code. I would merge as much as possible with
do_psci_cpu_onto avoid code duplication.Ok, i will try to merge the functions together (AI Parth)
[..]
xen/arch/arm/vpsci.c int do_psci_cpu_off(uint32_t power_state) · line 227
Quoted 7 lines
xen/arch/arm/vpsci.c +7
-0+ +int do_psci_0_2_migrate (uint32_t target_cpu) +{ +return PSCI_ENOSYS ; +} + +Only one newline.
xen/arch/arm/vpsci.c int do_psci_cpu_off(uint32_t power_state) · line 233
Quoted 6 lines
xen/arch/arm/vpsci.c +6
-0+int do_psci_0_2_migrate_info_type (void ) +{ +return PSCI_0_2_TOS_MP ; +} + +Same here.
xen/arch/arm/vpsci.c int do_psci_cpu_off(uint32_t power_state) · line 239
Quoted 6 lines
xen/arch/arm/vpsci.c +6
-0+register_t do_psci_0_2_migrate_info_up_cpu (void ) +{ +return PSCI_ENOSYS ; +} + +Same here.
xen/arch/arm/vpsci.c int do_psci_cpu_off(uint32_t power_state) · line 246
Quoted 7 lines
xen/arch/arm/vpsci.c +7
-0+void do_psci_0_2_system_off (void ) +{ +struct domain *d = current->domain; +domain_shutdown (d,SHUTDOWN_poweroff); +} + +Same here.
Will take care in next patch set (AI Parth)
Quoted 6 lines
xen/arch/arm/vpsci.c +6
-0+void do_psci_0_2_system_reset (void ) +{ +struct domain *d = current->domain; +domain_shutdown (d,SHUTDOWN_reboot); +} +[..]
xen/include/asm-arm/event.h static inline int arch_virq_is_global(int virq) · line 59
Quoted 7 lines
static inline int
vcpu_event_delivery_is_enabled(struct vcpu *v){xen/include/asm-arm/event.h +1
-0@@ -55,6 +56,7 @@ static inline int arch_virq_is_global(int virq)return 1 ; } +Spurious change.
Will take care in next patch set (AI Parth)
xen/include/asm-arm/psci.h line 8
Quoted 13 lines
xen/include/asm-arm/psci.h +0
-5@@ -1,11 +1,6 @@#ifndef __ASM_PSCI_H__#define __ASM_PSCI_H__ -#define PSCI_SUCCESS 0 -#define PSCI_ENOSYS -1 -#define PSCI_EINVAL -2 -#define PSCI_DENIED -3 -Why did you just moved them at the end of the file and change the indentation?
Quoted 1 line
This was done to have common return functions between PSCI v0.1 and v 0.2
and to define them at one place
Quoted 6 lines
xen/include/asm-arm/psci.h int do_psci_cpu_off(uint32_t power_state); · line 40
Quoted 2 lines
xen/include/asm-arm/psci.h +2
-0+/* PSCI version */ +#define XEN_PSCI_V_0_1 1This doesn't seem to be used, right?
Yes it is defined for consistency and also for future use in case we
return v0.1, i'd prefer to keep it this way what do you think?
Quoted 16 lines
xen/include/asm-arm/psci.h int do_psci_cpu_off(uint32_t power_state);
Quoted 4 lines
xen/include/asm-arm/psci.h +4
-0+ +/* PSCI v0.2 interface */ +#define PSCI_0_2_FN_BASE 0x84000000 +#define PSCI_0_2_FN (n) (PSCI_0_2_FN_BASE+ (n))
Quoted 1 line
+#define
PSCI_0_2_64BIT0x40000000In general we don't use hard-tab in Xen coding style. Can you remove them?
Will take care in next patchset (AI Parth)
[..]
Review
Quoted 1 line
(quoted diff) +0
-0
b/xen/include/public/arch-arm.h
Quoted 10 lines
xen/include/public/arch-arm.h typedef uint64_t xen_callback_t; · line 388
Quoted 8 lines
index 7496556..93803e4 100644
xen/include/public/arch-arm.h +1
-0@@ -385,6 +385,7 @@ typedef uint64_t xen_callback_t;#define PSCI_cpu_off 1#define PSCI_cpu_on 2#define PSCI_migrate 3 +#define PSCI_0_1_MAX 4Why do you expose
PSCI_0_1_MAX
You are right i think i can get away by treating PSCI_migrate as max value (AI Parth)
Quoted 6 lines
--
Julien Grall
Thanks
parth
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Hi Parth,
Quoted 10 lines · Parth Dixit
On 26 June 2014 21:31, Julien Grall <[email protected] <mailto:[email protected]>> wrote:
> + returndo_psci_cpu_off(power_state);
> +}
> +
> +int do_psci_0_2_cpu_on(register_ttarget_cpu,register_t
entry_point,
> +register_tcontext_id)
Quoted 4 lines
This function is 95% the same code. I would merge as much as possible with
do_psci_cpu_onto avoid code duplication.Ok, i will try to merge the functions together (AI Parth)
FWIW, KVM is using the same PSCI on function on V0.1 and V0.2. I'm wondering if we can assume the same thing here. Of course, you will have to add the few improvement in the function (checking if the VCPU is already online...).
Quoted 17 lines
> diff --git a/xen/include/asm-arm/psci.h b/xen/include/asm-arm/psci.h
> index 189964b..3487380 100644
> --- a/xen/include/asm-arm/psci.h
> +++ b/xen/include/asm-arm/psci.h
> @@ -1,11 +1,6 @@
> #ifndef __ASM_PSCI_H__
> #define __ASM_PSCI_H__
>
> -#define PSCI_SUCCESS 0
> -#define PSCI_ENOSYS -1
> -#define PSCI_EINVAL -2
> -#define PSCI_DENIED -3
> -
Why did you just moved them at the end of the file and change the
indentation?Quoted 2 lines
This was done to have common return functions between PSCI v0.1 and v 0.2 and to define them at one place
Ok... I still don't understand why you can't add the new return value here.
BTW, IIRC there was a copyright int the PSCI header from Linux. I think you have to retain it here.
Quoted 7 lines
> +/* PSCI version */ > +#define XEN_PSCI_V_0_1 1 This doesn't seem to be used, right?Yes it is defined for consistency and also for future use in case we return v0.1, i'd prefer to keep it this way what do you think?
Ok
Quoted 15 lines
[..]
> diff --git a/xen/include/public/arch-arm.h
b/xen/include/public/arch-arm.h
> index 7496556..93803e4 100644
> --- a/xen/include/public/arch-arm.h
> +++ b/xen/include/public/arch-arm.h
> @@ -385,6 +385,7 @@ typedef uint64_t xen_callback_t;
> #define PSCI_cpu_off 1
> #define PSCI_cpu_on 2
> #define PSCI_migrate 3
> +#define PSCI_0_1_MAX 4
Why do you expose PSCI_0_1_MAXQuoted 2 lines
You are right i think i can get away by treating
PSCI_migrateas max value (AI Parth)
Can't you define 2 table in traps.c: one for PSCI v0.1 and one for PSCI v0.2? This would avoid stupid issue later when we will implement a new function for 0.1.
Regards,
Signature · 1 line
Julien Grall
Hi Julien
Quoted 19 lines · Julien Grall
Hi Parth,
Quoted 13 lines · Parth Dixit
On 26 June 2014 21:31, Julien Grall <[email protected] <mailto:[email protected]>> wrote:
> + returndo_psci_cpu_off(power_state);
> +}
> +
> +int do_psci_0_2_cpu_on(register_ttarget_cpu,register_t
entry_point,
> +register_tcontext_id)This function is 95% the same code. I would merge as much as possible with
do_psci_cpu_onto avoid code duplication.
Quoted 7 lines
Quoted 2 lines
Ok, i will try to merge the functions together (AI Parth)
FWIW, KVM is using the same PSCI on function on V0.1 and V0.2. I'm wondering if we can assume the same thing here. Of course, you will have to add the few improvement in the function (checking if the VCPU is already online...).
Implementation of kvm is slightly different, they are setting PSCI version from QEMU through ioctl and then using it to differentiate between the versions at runtime. Are you proposing the same? i.e. setting PSCI version externally using xen tools and then using it throughout ? .(right now i am using function id's to differentiate between the two, i can extend that by introducing some variable in vcpu struct for runtime detection)
Quoted 17 lines
> diff --git a/xen/include/asm-arm/psci.hQuoted 14 lines
b/xen/include/asm-arm/psci.h> index 189964b..3487380 100644 > --- a/xen/include/asm-arm/psci.h > +++ b/xen/include/asm-arm/psci.h > @@ -1,11 +1,6 @@ > #ifndef __ASM_PSCI_H__ > #define __ASM_PSCI_H__ > > -#define PSCI_SUCCESS 0 > -#define PSCI_ENOSYS -1 > -#define PSCI_EINVAL -2 > -#define PSCI_DENIED -3 > -
Quoted 9 lines
Quoted 6 lines
Why did you just moved them at the end of the file and change the indentation?
This was done to have common return functions between PSCI v0.1 and v 0.2 and to define them at one place
Ok... I still don't understand why you can't add the new return value here.
I can :-), I will change it. sorry for the confusion, i thought you were asking why they have been moved...
Quoted 2 lines
BTW, IIRC there was a copyright int the PSCI header from Linux. I think you have to retain it here.
sure will take care in next patchset
Quoted 29 lines
> +/* PSCI version */Quoted 7 lines
> +#define
XEN_PSCI_V_0_11This doesn't seem to be used, right?
Yes it is defined for consistency and also for future use in case we return v0.1, i'd prefer to keep it this way what do you think?
Ok
[..]Quoted 14 lines
> diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h > index 7496556..93803e4 100644 > --- a/xen/include/public/arch-arm.h > +++ b/xen/include/public/arch-arm.h > @@ -385,6 +385,7 @@ typedef uint64_t xen_callback_t; > #define PSCI_cpu_off 1 > #define PSCI_cpu_on 2 > #define PSCI_migrate 3 > +#define PSCI_0_1_MAX 4 Why do you expose PSCI_0_1_MAX
Quoted 8 lines
Quoted 3 lines
You are right i think i can get away by treating
PSCI_migrateas max value (AI Parth)Can't you define 2 table in
traps.c: one for PSCI v0.1 and one for PSCI v0.2? This would avoid stupid issue later when we will implement a new function for 0.1.
Ok, i will create two tables.
Quoted 6 lines
Regards,
--
Julien Grall
Thanks
parth
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 3 lines · Parth Dixit
Arm based virtual machines dom0/guest will request power related functionality from xen through PSCI interface. This patch implements version 0.2 of PSCI standard specified by arm for 64bit and 32 bit arm machines.
At the moment this will only affect dom0 and not guests because you haven't patched tools/libxl/libxl_arm.c:make_psci_node() to expose the new functionality.
Were you intending to do that later (in which case please indicate this is dom0 only in the commit log) or did you just miss the need to do so?
I think it should just be a case of adding the new compatibility string, like you've done in xen/arch/arm/domain_build.c.
Are you also planning to work on host PSCI or is that someone else (just curious).
Quoted 22 lines
Signed-off-by Parth Dixit <[email protected]>--- xen/arch/arm/domain.c | 13 ++++ xen/arch/arm/domain_build.c | 5 +- xen/arch/arm/traps.c | 34 ++++++-- xen/arch/arm/vpsci.c | 167 ++++++++++++++++++++++++++++++++++++++++ xen/include/asm-arm/event.h | 2 + xen/include/asm-arm/processor.h | 6 ++ xen/include/asm-arm/psci.h | 122 +++++++++++++++++++++++++++-- xen/include/public/arch-arm.h | 1 + 8 files changed, 339 insertions(+), 11 deletions(-)xen/arch/arm/domain.c +2
-0@@ -779,6 +779,19 @@ void vcpu_mark_events_pending(struct vcpu *v)vgic_vcpu_inject_irq (v, v->domain->arch.evtchn_irq,1 ); } +void vcpu_block_event (struct vcpu *v) +{
xen/arch/arm/domain.c void vcpu_mark_events_pending(struct vcpu *v) · line 793
Quoted 10 lines
xen/arch/arm/domain.c +10
-0+vcpu_block (); +/* The ARM spec declares that even if local irqs are masked in +* the CPSR register, an irq should wake up a cpu from WFI anyway. +* For this reason we need to check for irqs that need delivery, +* ignoring the CPSR register, *after* calling SCHEDOP_block to +* avoid races with vgic_vcpu_inject_irq. +*/ +if (local_events_need_delivery_nomask () ) +vcpu_unblock (current); +}
You've coped this from the HSR_EC_WFI_WFE handler, I think, but not made that call here. Please can you do that.
Quoted 21 lines
xen/arch/arm/domain.c +1
-0+/* * Local variables: * mode: C xen/arch/arm/traps.c +1
-1@@ -1030,7 +1030,7 @@ static arm_hypercall_t arm_hypercall_table[] = { HYPERCALL_ARM(vcpu_op, 3), }; -typedef int (*arm_psci_fn_t )(uint32_t ,register_t ); +typedef int (*arm_psci_fn_t )(register_t ,register_t ,register_t ); typedef struct { arm_psci_fn_t fn;@@ -1046,6 +1046,17 @@ typedef struct {static arm_psci_t arm_psci_table[] = {PSCI (cpu_off,1 ),PSCI (cpu_on,2 ),
xen/arch/arm/traps.c typedef struct { · line 1058
Quoted 10 lines
xen/arch/arm/traps.c +10
-0+ PSCI(0_2_version,0), + PSCI(0_2_cpu_suspend,3), + PSCI(0_2_cpu_off,0), + PSCI(0_2_cpu_on,3), + PSCI(0_2_affinity_info,2), + PSCI(0_2_migrate,1), + PSCI(0_2_migrate_info_type,0), + PSCI(0_2_migrate_info_up_cpu,0), + PSCI(0_2_system_off,0), + PSCI(0_2_system_reset,0),
The v2 ops are 0x84xxxxxx and 0xc4xxxxxx -- doesn't that end up making this table enormous?
Also AArch32 and Aarch64 have difference function IDs for the various functions -- I don't see that reflected here.
Quoted 23 lines
xen/arch/arm/traps.c +6
-2+ };#ifndef NDEBUG @@ -1082,24 +1093,37 @@ static void do_debug_trap(struct cpu_user_regs *regs, unsigned int code)#ifdef CONFIG_ARM_64 #define PSCI_OP_REG (r) (r)->x0#define PSCI_RESULT_REG (r) (r)->x0 -#define PSCI_ARGS (r) (r)->x1, (r)->x2 +#define PSCI_ARGS (r) (r)->x1, (r)->x2, (r)->x3#else #define PSCI_OP_REG (r) (r)->r0#define PSCI_RESULT_REG (r) (r)->r0 -#define PSCI_ARGS (r) (r)->r1, (r)->r2 +#define PSCI_ARGS (r) (r)->r1, (r)->r2, (r)->r3#endif static void do_trap_psci (struct cpu_user_regs *regs) {arm_psci_fn_t psci_call =NULL ; +unsigned int fn_index ; +struct domain *d = current->domain; +
xen/arch/arm/traps.c static void do_debug_trap(struct cpu_user_regs *regs, unsigned int code) · line 1118
Quoted 10 lines
xen/arch/arm/traps.c +10
-0+if (PSCI_OP_REG (regs) <PSCI_0_1_MAX ) + fn_index =PSCI_OP_REG (regs); +else if (is_64bit_domain (d) ) + { + fn_index = ( (PSCI_OP_REG (regs) -PSCI_0_2_FN_OFFSET ) ); +if ( fn_index >PSCI_0_2_64BIT ) + fn_index -=PSCI_0_2_64BIT ; + } +else + fn_index = (PSCI_OP_REG (regs) -PSCI_0_2_FN_OFFSET ) ;
I think you should stop 64-bit domains calling 32-bit functions and vice versa, shouldn't you?
xen/arch/arm/traps.c static void do_debug_trap(struct cpu_user_regs *regs, unsigned int code) · line 1120
Quoted 2 lines
xen/arch/arm/traps.c +2
-0+int do_psci_0_2_cpu_on (register_t target_cpu,register_t entry_point, +register_t context_id)
This is duplicating a load of do_psci_cpu_on. If you can't call the existing one directly then please refactor it into a common helper.
xen/arch/arm/traps.c static void do_debug_trap(struct cpu_user_regs *regs, unsigned int code) · line 1126
Quoted 6 lines
xen/arch/arm/traps.c +6
-0+ +int do_psci_0_2_affinity_info (register_t target_affinity, +uint32_t lowest_affinity_level) +{ +unsigned long target_affinity_mask; +unsigned int mpidr;
mpidr is 64-bit on aarch64 (use register_t).
xen/arch/arm/traps.c static void do_debug_trap(struct cpu_user_regs *regs, unsigned int code)
Quoted 7 lines
xen/arch/arm/traps.c +7
-0+struct vcpu *v = current; + +switch ( lowest_affinity_level ) + { +case MPIDR_AFF0_SHIFT : +case MPIDR_AFF1_SHIFT : +case MPIDR_AFF2_SHIFT :
I see you've defined these as 0,1,2 etc. Customarily these would be the bit offsets in the register, i.e. 0,8,16, which makes them useless for your purposes (but using MPIDR_* for that was dodgy to start with).
I think you can just
case 0:
target_affinity_mask = MPIDR_AFF0_MASK;
break;
case 1:
target_affinity_mask = MPIDR_AFF1_MASK;
break;etc. (Having defined MPIDR_AFF1_MASK appropriately etc)
Or you could alternatively define a const array indexed by lowest_affinity_level with the appropriate values in it.
xen/arch/arm/traps.c
Quoted 6 lines
xen/arch/arm/traps.c +6
-0+ target_affinity &= target_affinity_mask; + mpidr = v->arch.vmpidr; +if ( ( mpidr & target_affinity_mask ) == target_affinity ) +return PSCI_0_2_AFFINITY_LEVEL_ON ; +else +return PSCI_0_2_AFFINITY_LEVEL_OFF ;
This should return something based upon whether various processors are on or not, not something based on the mpidr of the current vcpu. Or have a I misread the spec?
Given our current level of support for affinity in Xen this case pretty much just return ON for AFF1..AFF3 and consult the appropriate vcpus flags for AFF0.
xen/arch/arm/traps.c
Quoted 6 lines
xen/arch/arm/traps.c +6
-0+ +} + +int do_psci_0_2_migrate (uint32_t target_cpu) +{ +return PSCI_ENOSYS ;
This isn't a name defined in the spec (I think because our 0.1 implementation was based on a draft).
xen/arch/arm/traps.c
Quoted 6 lines
xen/arch/arm/traps.c +6
-0+} + + +int do_psci_0_2_migrate_info_type (void ) +{ +return PSCI_0_2_TOS_MP ;
This isn't a name in the spec either and it's a new one. Please can you use the appropriate names for the new ones, and if you don't mind could you also change the old ones to match the spec too.
I don't think you need to version the names either, at least not until PSCI 0.3 defines something contradictory (lets hope not!)
OK, I read further and realised that this is not an error code but rather is an unnamed constant from the spec. I'm not sure what "MP" is here. Perhaps a better name would be PSCI_MIGRATE_INFO_TYPE_{CAPABLE,INCAPABLE,UNNECESSARY} or something like that?
xen/include/asm-arm/processor.h line 18
Quoted 11 lines
xen/include/asm-arm/processor.h +3
-0@@ -13,9 +13,15 @@#define _MPIDR_SMP (31)#define MPIDR_SMP (_AC(1,U) << _MPIDR_SMP)#define MPIDR_AFF0_SHIFT (0) +#define MPIDR_AFF1_SHIFT (1) +#define MPIDR_AFF2_SHIFT (2) +#define MPIDR_AFF3_SHIFT (3)
As I said before, these should be 8, 16 and 32 respectively.
xen/include/asm-arm/processor.h line 19
Quoted 1 line
xen/include/asm-arm/processor.h +0
-0#define MPIDR_AFF0_MASK (_AC(0xff,U) << MPIDR_AFF0_SHIFT)
And you should then copy this pattern for the others
(you might need to ifdef CONFIG_ARM_64 AFF3 to avoid breaking the compile due to shift larger than type issues)
Quoted 40 lines
xen/include/asm-arm/processor.h +3
-0#define MPIDR_HWID_MASK _AC(0xffffff,U)#define MPIDR_INVALID (~MPIDR_HWID_MASK) +#define MPIDR_AFF_BIT_SHIFT (8) +#define AFFINITY_MASK (level) (_AC(0xff,U) << ((level)*MPIDR_AFF_BIT_SHIFT)) +/* TTBCR Translation Table Base Control Register */ #define TTBCR_EAE _AC(0x80000000,U)xen/include/asm-arm/psci.h +12
-5@@ -1,11 +1,6 @@#ifndef __ASM_PSCI_H__#define __ASM_PSCI_H__ -#define PSCI_SUCCESS 0 -#define PSCI_ENOSYS -1 -#define PSCI_EINVAL -2 -#define PSCI_DENIED -3 -/* availability of PSCI on the host for SMP bringup */ extern bool_t psci_available;@@ -18,6 +13,123 @@ int do_psci_cpu_off(uint32_t power_state);int do_psci_cpu_suspend (uint32_t power_state,register_t entry_point);int do_psci_migrate (uint32_t vcpuid); +/* PSCI 0.2 functions to handle guest PSCI requests */ +int do_psci_0_2_version (void ); +int do_psci_0_2_cpu_suspend (uint32_t power_state,register_t entry_point, +register_t context_id); +int do_psci_0_2_cpu_off (void ); +int do_psci_0_2_cpu_on (register_t target_cpu,register_t entry_point, +register_t context_id); +int do_psci_0_2_affinity_info (register_t target_affinity, +uint32_t lowest_affinity_level); +int do_psci_0_2_migrate (uint32_t target_cpu); +int do_psci_0_2_migrate_info_type (void ); +register_t do_psci_0_2_migrate_info_up_cpu (void );
xen/include/asm-arm/psci.h int do_psci_cpu_off(uint32_t power_state); · line 37
Quoted 10 lines
xen/include/asm-arm/psci.h +10
-0+void do_psci_0_2_system_off (void ); +void do_psci_0_2_system_reset (void ); +int do_psci_0_2_fn64_cpu_suspend (uint32_t power_state, +uint32_t entry_point,register_t context_id); +int do_psci_0_2_fn64_cpu_on (register_t target_cpu,register_t entry_point, +register_t context_id); +int do_psci_0_2_fn64_affinity_info (register_t target_affinity, +uint32_t lowest_affinity_level); +int do_psci_0_2_fn64_migrate (uint32_t target_cpu); +int do_psci_0_2_fn64_migrate_info_up_cpu (void );
This is making me thing that we should move do_psci_trap into vpsci.c so we can keep all this stuff internal.
Either your functions should take uint32_t/uint64_t as per the spec and be duplicated for 32- vs 64-bit *or* they should take register_t for those parameters which are different for 32- vs 64-bit and not be duplicated. You've used register_t *and* duplicated AFAICT.
Ideally I'd prefer not to duplicate, unless the spec makes that hard.
(actually, looking back at the implementation you don't actually defined any fn64 -- so maybe half of these are just redundant?)
Quoted 16 lines
xen/include/asm-arm/psci.h +16
-0+ +/* PSCI version */ +#define XEN_PSCI_V_0_1 1 +#define XEN_PSCI_V_0_2 2 + +/* PSCI v0.2 id's internal to xen */ + +#define PSCI_0_2_version 5 +#define PSCI_0_2_cpu_suspend 6 +#define PSCI_0_2_cpu_off 7 +#define PSCI_0_2_cpu_on 8 +#define PSCI_0_2_affinity_info 9 +#define PSCI_0_2_migrate 10 +#define PSCI_0_2_migrate_info_type 11 +#define PSCI_0_2_migrate_info_up_cpu 12 +#define PSCI_0_2_system_off 13
xen/include/asm-arm/psci.h int do_psci_cpu_off(uint32_t power_state); · line 63
Quoted 10 lines
xen/include/asm-arm/psci.h +10
-0+#define PSCI_0_2_system_reset 14 + +#define PSCI_0_2_fn64_cpu_suspend 15 +#define PSCI_0_2_fn64_cpu_on 16 +#define PSCI_0_2_fn64_affinity_info 17 +#define PSCI_0_2_fn64_migrate 18 +#define PSCI_0_2_fn64_migrate_info_up_cpu 19 + +/* PSCI v0.2 xen mapping mask */ +#define PSCI_0_2_FN_OFFSET 0x83FFFFFB
Err?
I think you should make the defines be the actual PSCI function numbers and then define three separate function call tables and look up the appropriate one based on the range of the function parameter.
TBH given the relatively small number of PSCI calls maybe just switching to a C switch() statement would be best.
xen/include/asm-arm/psci.h int do_psci_cpu_off(uint32_t power_state); · line 108
Quoted 4 lines
xen/include/asm-arm/psci.h +4
-0+/* PSCI v0.2 multicore support in Trusted OS returned by MIGRATE_INFO_TYPE */ +#define PSCI_0_2_TOS_UP_MIGRATE 0 +#define PSCI_0_2_TOS_UP_NO_MIGRATE 1 +#define PSCI_0_2_TOS_MP 2
The first two names are tolerable, but the last one doesn't seem to match the spec.
xen/include/public/arch-arm.h typedef uint64_t xen_callback_t; · line 388
Quoted 9 lines
xen/include/public/arch-arm.h +1
-0@@ -385,6 +385,7 @@ typedef uint64_t xen_callback_t;#define PSCI_cpu_off 1#define PSCI_cpu_on 2#define PSCI_migrate 3 +#define PSCI_0_1_MAX 4
The tools don't need this, so no need to make it public.
Ian.
Hi
Quoted 10 lines · Ian Campbell
Quoted 1 line · Parth Dixit
Arm based virtual machines dom0/guest will request power related
functionality
Quoted 2 lines
from xen through PSCI interface. This patch implements version 0.2 of PSCI standard specified by arm for 64bit and 32 bit arm machines.
At the moment this will only affect dom0 and not guests because you haven't patched tools/libxl/libxl_arm.c:make_psci_node() to expose the new functionality.
Quoted 6 lines
Were you intending to do that later (in which case please indicate this is dom0 only in the commit log) or did you just miss the need to do so?
I think it should just be a case of adding the new compatibility string, like you've done in
xen/arch/arm/domain_build.c.
Thanks, I missed it, i will incorporate it in next patchset.
Quoted 4 lines
Are you also planning to work on host PSCI or is that someone else (just curious).
PSCI host was scoped out because there was no real hardware where we can
test this functionality
Quoted 74 lines
Quoted 6 lines
Signed-off-by Parth Dixit <[email protected]>--- xen/arch/arm/domain.c | 13 ++++ xen/arch/arm/domain_build.c | 5 +- xen/arch/arm/traps.c | 34 ++++++-- xen/arch/arm/vpsci.c | 167++++++++++++++++++++++++++++++++++++++++
Quoted 16 lines
xen/include/asm-arm/event.h | 2 + xen/include/asm-arm/processor.h | 6 ++ xen/include/asm-arm/psci.h | 122 +++++++++++++++++++++++++++-- xen/include/public/arch-arm.h | 1 + 8 files changed, 339 insertions(+), 11 deletions(-)xen/arch/arm/domain.c +2
-0@@ -779,6 +779,19 @@ void vcpu_mark_events_pending(struct vcpu *v)vgic_vcpu_inject_irq (v, v->domain->arch.evtchn_irq,1 ); } +void vcpu_block_event (struct vcpu *v) +{xen/arch/arm/domain.c void vcpu_mark_events_pending(struct vcpu *v) · line 793
Quoted 10 lines
xen/arch/arm/domain.c +10
-0+vcpu_block (); +/* The ARM spec declares that even if local irqs are masked in +* the CPSR register, an irq should wake up a cpu from WFI anyway. +* For this reason we need to check for irqs that need delivery, +* ignoring the CPSR register, *after* calling SCHEDOP_block to +* avoid races with vgic_vcpu_inject_irq. +*/ +if (local_events_need_delivery_nomask () ) +vcpu_unblock (current); +}You've coped this from the
HSR_EC_WFI_WFEhandler, I think, but not made that call here. Please can you do that.sure, i'll add it in next patchset
Quoted 21 lines
xen/arch/arm/domain.c +1
-0+/* * Local variables: * mode: C xen/arch/arm/traps.c +1
-1@@ -1030,7 +1030,7 @@ static arm_hypercall_t arm_hypercall_table[] = { HYPERCALL_ARM(vcpu_op, 3), }; -typedef int (*arm_psci_fn_t )(uint32_t ,register_t ); +typedef int (*arm_psci_fn_t )(register_t ,register_t ,register_t ); typedef struct { arm_psci_fn_t fn;@@ -1046,6 +1046,17 @@ typedef struct {static arm_psci_t arm_psci_table[] = {PSCI (cpu_off,1 ),PSCI (cpu_on,2 ),xen/arch/arm/traps.c typedef struct { · line 1058
Quoted 10 lines
xen/arch/arm/traps.c +10
-0+ PSCI(0_2_version,0), + PSCI(0_2_cpu_suspend,3), + PSCI(0_2_cpu_off,0), + PSCI(0_2_cpu_on,3), + PSCI(0_2_affinity_info,2), + PSCI(0_2_migrate,1), + PSCI(0_2_migrate_info_type,0), + PSCI(0_2_migrate_info_up_cpu,0), + PSCI(0_2_system_off,0), + PSCI(0_2_system_reset,0),The v2 ops are 0x84xxxxxx and 0xc4xxxxxx -- doesn't that end up making this table enormous?
Quoted 4 lines
Also AArch32 and Aarch64 have difference function IDs for the various functions -- I don't see that reflected here.
I am not using function id's directly i am using mask to calculate array
index based on function id's.
32bit and 64 bit are using common functions.
Quoted 216 lines
xen/arch/arm/traps.c static void do_debug_trap(struct cpu_user_regs
Quoted 6 lines
xen/arch/arm/traps.c +1
-0+ };#ifndef NDEBUG @@ -1082,24 +1093,37 @@ static void do_debug_trap(struct cpu_user_regs*regs, unsigned int code)
Quoted 18 lines
xen/arch/arm/traps.c +5
-2#ifdef CONFIG_ARM_64 #define PSCI_OP_REG (r) (r)->x0#define PSCI_RESULT_REG (r) (r)->x0 -#define PSCI_ARGS (r) (r)->x1, (r)->x2 +#define PSCI_ARGS (r) (r)->x1, (r)->x2, (r)->x3#else #define PSCI_OP_REG (r) (r)->r0#define PSCI_RESULT_REG (r) (r)->r0 -#define PSCI_ARGS (r) (r)->r1, (r)->r2 +#define PSCI_ARGS (r) (r)->r1, (r)->r2, (r)->r3#endif static void do_trap_psci (struct cpu_user_regs *regs) {arm_psci_fn_t psci_call =NULL ; +unsigned int fn_index ; +struct domain *d = current->domain; +xen/arch/arm/traps.c static void do_debug_trap(struct cpu_user_regs *regs, unsigned int code) · line 1118
Quoted 10 lines
xen/arch/arm/traps.c +10
-0+if (PSCI_OP_REG (regs) <PSCI_0_1_MAX ) + fn_index =PSCI_OP_REG (regs); +else if (is_64bit_domain (d) ) + { + fn_index = ( (PSCI_OP_REG (regs) -PSCI_0_2_FN_OFFSET ) ); +if ( fn_index >PSCI_0_2_64BIT ) + fn_index -=PSCI_0_2_64BIT ; + } +else + fn_index = (PSCI_OP_REG (regs) -PSCI_0_2_FN_OFFSET ) ;I think you should stop 64-bit domains calling 32-bit functions and vice versa, shouldn't you?
xen/arch/arm/traps.c static void do_debug_trap(struct cpu_user_regs · line 1120
Quoted 2 lines
xen/arch/arm/traps.c +2
-0+int do_psci_0_2_cpu_on (register_t target_cpu,register_t entry_point, +register_t context_id)This is duplicating a load of
do_psci_cpu_on. If you can't call the existing one directly then please refactor it into a common helper.sure..
xen/arch/arm/traps.c static void do_debug_trap(struct cpu_user_regs · line 1126
Quoted 6 lines
xen/arch/arm/traps.c +6
-0+ +int do_psci_0_2_affinity_info (register_t target_affinity, +uint32_t lowest_affinity_level) +{ +unsigned long target_affinity_mask; +unsigned int mpidr;mpidr is 64-bit on aarch64 (use
register_t).xen/arch/arm/traps.c static void do_debug_trap(struct cpu_user_regs
Quoted 7 lines
xen/arch/arm/traps.c +7
-0+struct vcpu *v = current; + +switch ( lowest_affinity_level ) + { +case MPIDR_AFF0_SHIFT : +case MPIDR_AFF1_SHIFT : +case MPIDR_AFF2_SHIFT :I see you've defined these as 0,1,2 etc. Customarily these would be the bit offsets in the register, i.e. 0,8,16, which makes them useless for your purposes (but using MPIDR_* for that was dodgy to start with).
I think you can just
case 0: target_affinity_mask = MPIDR_AFF0_MASK; break; case 1: target_affinity_mask = MPIDR_AFF1_MASK; break;etc. (Having defined
MPIDR_AFF1_MASKappropriately etc)Or you could alternatively define a const array indexed by
lowest_affinity_levelwith the appropriate values in it.xen/arch/arm/traps.c
Quoted 6 lines
xen/arch/arm/traps.c +6
-0+ target_affinity &= target_affinity_mask; + mpidr = v->arch.vmpidr; +if ( ( mpidr & target_affinity_mask ) == target_affinity ) +return PSCI_0_2_AFFINITY_LEVEL_ON ; +else +return PSCI_0_2_AFFINITY_LEVEL_OFF ;This should return something based upon whether various processors are on or not, not something based on the mpidr of the current vcpu. Or have a I misread the spec?
Given our current level of support for affinity in Xen this case pretty much just return ON for AFF1..AFF3 and consult the appropriate vcpus flags for AFF0.
xen/arch/arm/traps.c
Quoted 6 lines
xen/arch/arm/traps.c +6
-0+ +} + +int do_psci_0_2_migrate (uint32_t target_cpu) +{ +return PSCI_ENOSYS ;This isn't a name defined in the spec (I think because our 0.1 implementation was based on a draft).
xen/arch/arm/traps.c
Quoted 6 lines
xen/arch/arm/traps.c +6
-0+} + + +int do_psci_0_2_migrate_info_type (void ) +{ +return PSCI_0_2_TOS_MP ;This isn't a name in the spec either and it's a new one. Please can you use the appropriate names for the new ones, and if you don't mind could you also change the old ones to match the spec too.
I don't think you need to version the names either, at least not until PSCI 0.3 defines something contradictory (lets hope not!)
OK, I read further and realised that this is not an error code but rather is an unnamed constant from the spec. I'm not sure what "MP" is here. Perhaps a better name would be PSCI_MIGRATE_INFO_TYPE_{CAPABLE,INCAPABLE,UNNECESSARY} or something like that?
Ok,i'll change the names
Review
Quoted 1 line
(quoted diff) +0
-0
b/xen/include/asm-arm/processor.hxen/include/asm-arm/processor.h line 18
Quoted 10 lines
index 9267c1b..bf9d782 100644
xen/include/asm-arm/processor.h +3
-0@@ -13,9 +13,15 @@#define _MPIDR_SMP (31)#define MPIDR_SMP (_AC(1,U) << _MPIDR_SMP)#define MPIDR_AFF0_SHIFT (0) +#define MPIDR_AFF1_SHIFT (1) +#define MPIDR_AFF2_SHIFT (2) +#define MPIDR_AFF3_SHIFT (3)As I said before, these should be 8, 16 and 32 respectively.
xen/include/asm-arm/processor.h line 19
Quoted 1 line
xen/include/asm-arm/processor.h +0
-0#define MPIDR_AFF0_MASK (_AC(0xff,U) << MPIDR_AFF0_SHIFT)And you should then copy this pattern for the others
(you might need to ifdef
CONFIG_ARM_64AFF3 to avoid breaking the compile due to shift larger than type issues)I will incorporate it in next patchset
xen/include/asm-arm/processor.h
Quoted 4 lines
xen/include/asm-arm/processor.h +2
-0#define MPIDR_HWID_MASK _AC(0xffffff,U)#define MPIDR_INVALID (~MPIDR_HWID_MASK) +#define MPIDR_AFF_BIT_SHIFT (8) +#define AFFINITY_MASK (level) (_AC(0xff,U) <<((level)*MPIDR_AFF_BIT_SHIFT))
Quoted 21 lines
xen/include/asm-arm/processor.h +1
-0+/* TTBCR Translation Table Base Control Register */ #define TTBCR_EAE _AC(0x80000000,U)xen/include/asm-arm/psci.h +0
-5@@ -1,11 +1,6 @@#ifndef __ASM_PSCI_H__#define __ASM_PSCI_H__ -#define PSCI_SUCCESS 0 -#define PSCI_ENOSYS -1 -#define PSCI_EINVAL -2 -#define PSCI_DENIED -3 -/* availability of PSCI on the host for SMP bringup */ extern bool_t psci_available;xen/include/asm-arm/psci.h int do_psci_cpu_off(uint32_t power_state); · line 18
Quoted 6 lines
xen/include/asm-arm/psci.h +3
-0@@ -18,6 +13,123 @@ int do_psci_cpu_off(uint32_t power_state);int do_psci_cpu_suspend (uint32_t power_state,register_t entry_point);int do_psci_migrate (uint32_t vcpuid); +/* PSCI 0.2 functions to handle guest PSCI requests */ +int do_psci_0_2_version (void ); +int do_psci_0_2_cpu_suspend(uint32_t power_state, register_t
entry_point,xen/include/asm-arm/psci.h int do_psci_cpu_off(uint32_t power_state);
Quoted 13 lines
xen/include/asm-arm/psci.h +13
-0+ register_t context_id); +int do_psci_0_2_cpu_off (void ); +int do_psci_0_2_cpu_on (register_t target_cpu,register_t entry_point, +register_t context_id); +int do_psci_0_2_affinity_info (register_t target_affinity, +uint32_t lowest_affinity_level); +int do_psci_0_2_migrate (uint32_t target_cpu); +int do_psci_0_2_migrate_info_type (void ); +register_t do_psci_0_2_migrate_info_up_cpu (void ); +void do_psci_0_2_system_off (void ); +void do_psci_0_2_system_reset (void ); +int do_psci_0_2_fn64_cpu_suspend (uint32_t power_state, + uint32_t entry_point, register_t
context_id);xen/include/asm-arm/psci.h int do_psci_cpu_off(uint32_t power_state); · line 32
Quoted 1 line
xen/include/asm-arm/psci.h +1
-0+int do_psci_0_2_fn64_cpu_on(register_t target_cpu, register_t
entry_point,xen/include/asm-arm/psci.h int do_psci_cpu_off(uint32_t power_state); · line 37
Quoted 5 lines
xen/include/asm-arm/psci.h +5
-0+ register_t context_id); +int do_psci_0_2_fn64_affinity_info (register_t target_affinity, +uint32_t lowest_affinity_level); +int do_psci_0_2_fn64_migrate (uint32_t target_cpu); +int do_psci_0_2_fn64_migrate_info_up_cpu (void );This is making me thing that we should move
do_psci_trapintovpsci.cso we can keep all this stuff internal.Either your functions should take uint32_t/uint64_t as per the spec and be duplicated for 32- vs 64-bit *or* they should take
register_tfor those parameters which are different for 32- vs 64-bit and not be duplicated. You've usedregister_t*and* duplicated AFAICT.
Quoted 6 lines
Ideally I'd prefer not to duplicate, unless the spec makes that hard.
(actually, looking back at the implementation you don't actually defined any fn64 -- so maybe half of these are just redundant?)
They are there for completion,i am using common functions for 32 bit/64
bit
Quoted 29 lines
Quoted 16 lines
xen/include/asm-arm/psci.h +16
-0+ +/* PSCI version */ +#define XEN_PSCI_V_0_1 1 +#define XEN_PSCI_V_0_2 2 + +/* PSCI v0.2 id's internal to xen */ + +#define PSCI_0_2_version 5 +#define PSCI_0_2_cpu_suspend 6 +#define PSCI_0_2_cpu_off 7 +#define PSCI_0_2_cpu_on 8 +#define PSCI_0_2_affinity_info 9 +#define PSCI_0_2_migrate 10 +#define PSCI_0_2_migrate_info_type 11 +#define PSCI_0_2_migrate_info_up_cpu 12 +#define PSCI_0_2_system_off 13xen/include/asm-arm/psci.h int do_psci_cpu_off(uint32_t power_state); · line 63
Quoted 10 lines
xen/include/asm-arm/psci.h +10
-0+#define PSCI_0_2_system_reset 14 + +#define PSCI_0_2_fn64_cpu_suspend 15 +#define PSCI_0_2_fn64_cpu_on 16 +#define PSCI_0_2_fn64_affinity_info 17 +#define PSCI_0_2_fn64_migrate 18 +#define PSCI_0_2_fn64_migrate_info_up_cpu 19 + +/* PSCI v0.2 xen mapping mask */ +#define PSCI_0_2_FN_OFFSET 0x83FFFFFBErr?
Quoted 7 lines
I think you should make the defines be the actual PSCI function numbers and then define three separate function call tables and look up the appropriate one based on the range of the function parameter.
TBH given the relatively small number of PSCI calls maybe just switching to a C
switch()statement would be best.
patchset v1 was based on switch case it was moved to if/else after review comments, should i change it back to switch case?
Quoted 12 lines
xen/include/asm-arm/psci.h int do_psci_cpu_off(uint32_t power_state); · line 64
Quoted 2 lines
xen/include/asm-arm/psci.h +1
-0+/* PSCI v0.2 multicore support in Trusted OS returned by
MIGRATE_INFO_TYPE*/xen/include/asm-arm/psci.h int do_psci_cpu_off(uint32_t power_state); · line 108
Quoted 3 lines
xen/include/asm-arm/psci.h +3
-0+#define PSCI_0_2_TOS_UP_MIGRATE 0 +#define PSCI_0_2_TOS_UP_NO_MIGRATE 1 +#define PSCI_0_2_TOS_MP 2The first two names are tolerable, but the last one doesn't seem to match the spec.
Review
Quoted 1 line
(quoted diff) +0
-0
b/xen/include/public/arch-arm.h
Quoted 11 lines
xen/include/public/arch-arm.h typedef uint64_t xen_callback_t; · line 388
Quoted 8 lines
index 7496556..93803e4 100644
xen/include/public/arch-arm.h +1
-0@@ -385,6 +385,7 @@ typedef uint64_t xen_callback_t;#define PSCI_cpu_off 1#define PSCI_cpu_on 2#define PSCI_migrate 3 +#define PSCI_0_1_MAX 4The tools don't need this, so no need to make it public.
This was taken as it is from previous implementation should i move it to psci.h?
Quoted 4 lines
Ian.
Thanks
parth
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
On Mon, 2014-06-30 at 10:36 +0530, Parth Dixit wrote:
Can you please try and configure your Linaro mail to send plain text mails and to use the normal ">" quoting style rather than HTML based indentation, which can get unreadable after a few round trips.
Quoted 7 lines
Are you also planning to work on host PSCI or is that someone else (just
curious).PSCI host was scoped out because there was no real hardware where we can test this functionality
OK.
Quoted 45 lines
> +
> /*
> * Local variables:
> * mode: C
> diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
> index 03a3da6..e42fb07 100644
> --- a/xen/arch/arm/traps.c
> +++ b/xen/arch/arm/traps.c
> @@ -1030,7 +1030,7 @@ static arm_hypercall_t
arm_hypercall_table[] = {
> HYPERCALL_ARM(vcpu_op, 3),
> };
>
> -typedef int (*arm_psci_fn_t)(uint32_t, register_t);
> +typedef int (*arm_psci_fn_t)(register_t, register_t,
register_t);
>
> typedef struct {
> arm_psci_fn_t fn;
> @@ -1046,6 +1046,17 @@ typedef struct {
> static arm_psci_t arm_psci_table[] = {
> PSCI(cpu_off, 1),
> PSCI(cpu_on, 2),
> + PSCI(0_2_version,0),
> + PSCI(0_2_cpu_suspend,3),
> + PSCI(0_2_cpu_off,0),
> + PSCI(0_2_cpu_on,3),
> + PSCI(0_2_affinity_info,2),
> + PSCI(0_2_migrate,1),
> + PSCI(0_2_migrate_info_type,0),
> + PSCI(0_2_migrate_info_up_cpu,0),
> + PSCI(0_2_system_off,0),
> + PSCI(0_2_system_reset,0),
The v2 ops are 0x84xxxxxx and 0xc4xxxxxx -- doesn't that end
up making
this table enormous?
Also AArch32 and Aarch64 have difference function IDs for the
various
functions -- I don't see that reflected here.Quoted 3 lines
I am not using function id's directly i am using mask to calculate array index based on function id's.
32bit and 64 bit are using common functions.
Oh, OK. I'm not mad keen on this (see below).
Quoted 84 lines
> #define MPIDR_HWID_MASK _AC(0xffffff,U)
> #define MPIDR_INVALID (~MPIDR_HWID_MASK)
> +#define MPIDR_AFF_BIT_SHIFT (8)
> +#define AFFINITY_MASK(level) (_AC(0xff,U) <<
((level)*MPIDR_AFF_BIT_SHIFT))
> +
>
> /* TTBCR Translation Table Base Control Register */
> #define TTBCR_EAE _AC(0x80000000,U)
> diff --git a/xen/include/asm-arm/psci.h
b/xen/include/asm-arm/psci.h
> index 189964b..3487380 100644
> --- a/xen/include/asm-arm/psci.h
> +++ b/xen/include/asm-arm/psci.h
> @@ -1,11 +1,6 @@
> #ifndef __ASM_PSCI_H__
> #define __ASM_PSCI_H__
>
> -#define PSCI_SUCCESS 0
> -#define PSCI_ENOSYS -1
> -#define PSCI_EINVAL -2
> -#define PSCI_DENIED -3
> -
> /* availability of PSCI on the host for SMP bringup */
> extern bool_t psci_available;
>
> @@ -18,6 +13,123 @@ int do_psci_cpu_off(uint32_t
power_state);
> int do_psci_cpu_suspend(uint32_t power_state, register_t
entry_point);
> int do_psci_migrate(uint32_t vcpuid);
>
> +/* PSCI 0.2 functions to handle guest PSCI requests */
> +int do_psci_0_2_version(void);
> +int do_psci_0_2_cpu_suspend(uint32_t power_state,
register_t entry_point,
> + register_t context_id);
> +int do_psci_0_2_cpu_off(void);
> +int do_psci_0_2_cpu_on(register_t target_cpu, register_t
entry_point,
> + register_t context_id);
> +int do_psci_0_2_affinity_info(register_t target_affinity,
> + uint32_t
lowest_affinity_level);
> +int do_psci_0_2_migrate(uint32_t target_cpu);
> +int do_psci_0_2_migrate_info_type(void);
> +register_t do_psci_0_2_migrate_info_up_cpu(void);
> +void do_psci_0_2_system_off(void);
> +void do_psci_0_2_system_reset(void);
> +int do_psci_0_2_fn64_cpu_suspend(uint32_t power_state,
> + uint32_t entry_point,
register_t context_id);
> +int do_psci_0_2_fn64_cpu_on(register_t target_cpu,
register_t entry_point,
> + register_t context_id);
> +int do_psci_0_2_fn64_affinity_info(register_t
target_affinity,
> + uint32_t
lowest_affinity_level);
> +int do_psci_0_2_fn64_migrate(uint32_t target_cpu);
> +int do_psci_0_2_fn64_migrate_info_up_cpu(void);
This is making me thing that we should move do_psci_trap into
vpsci.c so
we can keep all this stuff internal.
Either your functions should take uint32_t/uint64_t as per the
spec and
be duplicated for 32- vs 64-bit *or* they should take
register_t for
those parameters which are different for 32- vs 64-bit and not
be
duplicated. You've used register_t *and* duplicated AFAICT.
Ideally I'd prefer not to duplicate, unless the spec makes
that hard.
(actually, looking back at the implementation you don't
actually defined
any fn64 -- so maybe half of these are just redundant?)Quoted 2 lines
They are there for completion,i am using common functions for 32 bit/64 bit
What do you mean by "completion"?
If those prototypes do not correspond to some real function which is actually being used then please remove them.
Quoted 39 lines
> +
> +/* PSCI version */
> +#define XEN_PSCI_V_0_1 1
> +#define XEN_PSCI_V_0_2 2
> +
> +/* PSCI v0.2 id's internal to xen */
> +
> +#define PSCI_0_2_version 5
> +#define PSCI_0_2_cpu_suspend 6
> +#define PSCI_0_2_cpu_off 7
> +#define PSCI_0_2_cpu_on 8
> +#define PSCI_0_2_affinity_info 9
> +#define PSCI_0_2_migrate 10
> +#define PSCI_0_2_migrate_info_type 11
> +#define PSCI_0_2_migrate_info_up_cpu 12
> +#define PSCI_0_2_system_off 13
> +#define PSCI_0_2_system_reset 14
> +
> +#define PSCI_0_2_fn64_cpu_suspend 15
> +#define PSCI_0_2_fn64_cpu_on 16
> +#define PSCI_0_2_fn64_affinity_info 17
> +#define PSCI_0_2_fn64_migrate 18
> +#define PSCI_0_2_fn64_migrate_info_up_cpu 19
> +
> +/* PSCI v0.2 xen mapping mask */
> +#define PSCI_0_2_FN_OFFSET 0x83FFFFFB
Err?
I think you should make the defines be the actual PSCI
function numbers
and then define three separate function call tables and look
up the
appropriate one based on the range of the function parameter.
TBH given the relatively small number of PSCI calls maybe just
switching
to a C switch() statement would be best.Quoted 2 lines
patchset v1 was based on switch case it was moved to if/else after review comments, should i change it back to switch case?
Sorry for not getting to this for v1.
v1 had a switch statement to lookup fn_index, which it then looked up again in the op table. I think that approach was the worst of both worlds.
What I was suggesting was a switch statement which actually dispatched the call to the appropriate handler directly, rather than having a second indirection via a table.
The main thing I don't like is macro hoops you are jumping through in order to turn the spec mandated sparse function space into a compact one suitable for placing in an array.
Another viable alternative would be to have separate tables for PSCI 0.1 and PSCSI 0.2 32- and 64-bit and look through each in turn.
Quoted 23 lines
> +/* PSCI v0.2 multicore support in Trusted OS returned by
MIGRATE_INFO_TYPE*/
> +#definePSCI_0_2_TOS_UP_MIGRATE0
> +#definePSCI_0_2_TOS_UP_NO_MIGRATE1
> +#definePSCI_0_2_TOS_MP2The first two names are tolerable, but the last one doesn't seem to
match the spec.> diff --git
a/xen/include/public/arch-arm.hb/xen/include/public/arch-arm.h
> index 7496556..93803e4 100644
> ---a/xen/include/public/arch-arm.h
> +++b/xen/include/public/arch-arm.h
> @@ -385,6 +385,7 @@ typedefuint64_txen_callback_t;
> #definePSCI_cpu_off1
> #definePSCI_cpu_on2
> #definePSCI_migrate3
> +#definePSCI_0_1_MAX4
Quoted 3 lines
The tools don't need this, so no need to make it public.
This was taken as it is from previous implementation should i move it topsci.h?
What previous implementation? I don't see anything like that in the tree right now.
Ian.
Hi,
Quoted 151 lines · Ian Campbell
On Mon, 2014-06-30 at 10:36 +0530, Parth Dixit wrote:
Can you please try and configure your Linaro mail to send plain text mails and to use the normal ">" quoting style rather than HTML based indentation, which can get unreadable after a few round trips.
Quoted 7 lines
Are you also planning to work on host PSCI or is that someone else (just
curious).PSCI host was scoped out because there was no real hardware where we can test this functionality
OK.
Quoted 45 lines
> + > /* > * Local variables: > * mode: C > diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c > index 03a3da6..e42fb07 100644 > --- a/xen/arch/arm/traps.c > +++ b/xen/arch/arm/traps.c > @@ -1030,7 +1030,7 @@ static arm_hypercall_t arm_hypercall_table[] = { > HYPERCALL_ARM(vcpu_op, 3), > }; > > -typedef int (*arm_psci_fn_t)(uint32_t, register_t); > +typedef int (*arm_psci_fn_t)(register_t, register_t, register_t); > > typedef struct { > arm_psci_fn_t fn; > @@ -1046,6 +1046,17 @@ typedef struct { > static arm_psci_t arm_psci_table[] = { > PSCI(cpu_off, 1), > PSCI(cpu_on, 2), > + PSCI(0_2_version,0), > + PSCI(0_2_cpu_suspend,3), > + PSCI(0_2_cpu_off,0), > + PSCI(0_2_cpu_on,3), > + PSCI(0_2_affinity_info,2), > + PSCI(0_2_migrate,1), > + PSCI(0_2_migrate_info_type,0), > + PSCI(0_2_migrate_info_up_cpu,0), > + PSCI(0_2_system_off,0), > + PSCI(0_2_system_reset,0), The v2 ops are 0x84xxxxxx and 0xc4xxxxxx -- doesn't that end up making this table enormous? Also AArch32 and Aarch64 have difference function IDs for the various functions -- I don't see that reflected here.Quoted 3 lines
I am not using function id's directly i am using mask to calculate array index based on function id's.
32bit and 64 bit are using common functions.Oh, OK. I'm not mad keen on this (see below).
Quoted 84 lines
> #define MPIDR_HWID_MASK _AC(0xffffff,U) > #define MPIDR_INVALID (~MPIDR_HWID_MASK) > +#define MPIDR_AFF_BIT_SHIFT (8) > +#define AFFINITY_MASK(level) (_AC(0xff,U) << ((level)*MPIDR_AFF_BIT_SHIFT)) > + > > /* TTBCR Translation Table Base Control Register */ > #define TTBCR_EAE _AC(0x80000000,U) > diff --git a/xen/include/asm-arm/psci.h b/xen/include/asm-arm/psci.h > index 189964b..3487380 100644 > --- a/xen/include/asm-arm/psci.h > +++ b/xen/include/asm-arm/psci.h > @@ -1,11 +1,6 @@ > #ifndef __ASM_PSCI_H__ > #define __ASM_PSCI_H__ > > -#define PSCI_SUCCESS 0 > -#define PSCI_ENOSYS -1 > -#define PSCI_EINVAL -2 > -#define PSCI_DENIED -3 > - > /* availability of PSCI on the host for SMP bringup */ > extern bool_t psci_available; > > @@ -18,6 +13,123 @@ int do_psci_cpu_off(uint32_t power_state); > int do_psci_cpu_suspend(uint32_t power_state, register_t entry_point); > int do_psci_migrate(uint32_t vcpuid); > > +/* PSCI 0.2 functions to handle guest PSCI requests */ > +int do_psci_0_2_version(void); > +int do_psci_0_2_cpu_suspend(uint32_t power_state, register_t entry_point, > + register_t context_id); > +int do_psci_0_2_cpu_off(void); > +int do_psci_0_2_cpu_on(register_t target_cpu, register_t entry_point, > + register_t context_id); > +int do_psci_0_2_affinity_info(register_t target_affinity, > + uint32_t lowest_affinity_level); > +int do_psci_0_2_migrate(uint32_t target_cpu); > +int do_psci_0_2_migrate_info_type(void); > +register_t do_psci_0_2_migrate_info_up_cpu(void); > +void do_psci_0_2_system_off(void); > +void do_psci_0_2_system_reset(void); > +int do_psci_0_2_fn64_cpu_suspend(uint32_t power_state, > + uint32_t entry_point, register_t context_id); > +int do_psci_0_2_fn64_cpu_on(register_t target_cpu, register_t entry_point, > + register_t context_id); > +int do_psci_0_2_fn64_affinity_info(register_t target_affinity, > + uint32_t lowest_affinity_level); > +int do_psci_0_2_fn64_migrate(uint32_t target_cpu); > +int do_psci_0_2_fn64_migrate_info_up_cpu(void); This is making me thing that we should move do_psci_trap into vpsci.c so we can keep all this stuff internal. Either your functions should take uint32_t/uint64_t as per the spec and be duplicated for 32- vs 64-bit *or* they should take register_t for those parameters which are different for 32- vs 64-bit and not be duplicated. You've used register_t *and* duplicated AFAICT. Ideally I'd prefer not to duplicate, unless the spec makes that hard. (actually, looking back at the implementation you don't actually defined any fn64 -- so maybe half of these are just redundant?)
Quoted 7 lines
Quoted 2 lines
They are there for completion,i am using common functions for 32 bit/64 bit
What do you mean by "completion"?
If those prototypes do not correspond to some real function which is actually being used then please remove them
PSCI v0.1 had two functions implemented and two others were declared but not implemented, i was following the same style.
i.e. declaring all the functions in the spec but implementing only the ones that are mandated/used
I will remove the the unused functions.
Quoted 53 lines
Quoted 40 lines
> + > +/* PSCI version */ > +#define XEN_PSCI_V_0_1 1 > +#define XEN_PSCI_V_0_2 2 > + > +/* PSCI v0.2 id's internal to xen */ > + > +#define PSCI_0_2_version 5 > +#define PSCI_0_2_cpu_suspend 6 > +#define PSCI_0_2_cpu_off 7 > +#define PSCI_0_2_cpu_on 8 > +#define PSCI_0_2_affinity_info 9 > +#define PSCI_0_2_migrate 10 > +#define PSCI_0_2_migrate_info_type 11 > +#define PSCI_0_2_migrate_info_up_cpu 12 > +#define PSCI_0_2_system_off 13 > +#define PSCI_0_2_system_reset 14 > + > +#define PSCI_0_2_fn64_cpu_suspend 15 > +#define PSCI_0_2_fn64_cpu_on 16 > +#define PSCI_0_2_fn64_affinity_info 17 > +#define PSCI_0_2_fn64_migrate 18 > +#define PSCI_0_2_fn64_migrate_info_up_cpu 19 > + > +/* PSCI v0.2 xen mapping mask */ > +#define PSCI_0_2_FN_OFFSET 0x83FFFFFB Err? I think you should make the defines be the actual PSCI function numbers and then define three separate function call tables and look up the appropriate one based on the range of the function parameter. TBH given the relatively small number of PSCI calls maybe just switching to a C switch() statement would be best.Quoted 2 lines
patchset v1 was based on switch case it was moved to if/else after review comments, should i change it back to switch case?
Sorry for not getting to this for v1.
v1 had a switch statement to lookup
fn_index, which it then looked up again in the op table. I think that approach was the worst of both worlds.What I was suggesting was a switch statement which actually dispatched the call to the appropriate handler directly, rather than having a second indirection via a table.
Quoted 6 lines
The main thing I don't like is macro hoops you are jumping through in order to turn the spec mandated sparse function space into a compact one suitable for placing in an array.
Another viable alternative would be to have separate tables for PSCI 0.1 and PSCSI 0.2 32- and 64-bit and look through each in turn.
Sure, let me try the two table approach.
Quoted 24 lines
Quoted 24 lines
> +/* PSCI v0.2 multicore support in Trusted OS returned by
MIGRATE_INFO_TYPE*/
> +#definePSCI_0_2_TOS_UP_MIGRATE0
> +#definePSCI_0_2_TOS_UP_NO_MIGRATE1
> +#definePSCI_0_2_TOS_MP2The first two names are tolerable, but the last one doesn't seem to
match the spec.> diff --git
a/xen/include/public/arch-arm.hb/xen/include/public/arch-arm.h
> index 7496556..93803e4 100644
> ---a/xen/include/public/arch-arm.h
> +++b/xen/include/public/arch-arm.h
> @@ -385,6 +385,7 @@ typedefuint64_txen_callback_t;
> #definePSCI_cpu_off1
> #definePSCI_cpu_on2
> #definePSCI_migrate3
> +#definePSCI_0_1_MAX4
Quoted 10 lines
Quoted 3 lines
The tools don't need this, so no need to make it public.
This was taken as it is from previous implementation should i move it topsci.h?What previous implementation? I don't see anything like that in the tree right now.
Ian.
hmmm, just to be sure you are talking about these constants "PSCI_cpu_off,PSCI_cpu_on ..etc." in xen/include/public/arch-arm.h ? i can see them in xen/master branch...or is it something else?
Quoted 5 lines · Parth Dixit
Quoted 5 lines
Quoted 2 lines
They are there for completion,i am using common functions for 32 bit/64 bit
What do you mean by "completion"?
Quoted 7 lines
Quoted 2 lines
If those prototypes do not correspond to some real function which is actually being used then please remove them
PSCI v0.1 had two functions implemented and two others were declared but not implemented, i was following the same style.
i.e. declaring all the functions in the spec but implementing only the ones that are mandated/used
Oh, I think those v0.1 ones are there in error.
Quoted 1 line
I will remove the the unused functions.
Thanks.
Quoted 53 lines
Quoted 53 lines
Quoted 40 lines
> + > +/* PSCI version */ > +#define XEN_PSCI_V_0_1 1 > +#define XEN_PSCI_V_0_2 2 > + > +/* PSCI v0.2 id's internal to xen */ > + > +#define PSCI_0_2_version 5 > +#define PSCI_0_2_cpu_suspend 6 > +#define PSCI_0_2_cpu_off 7 > +#define PSCI_0_2_cpu_on 8 > +#define PSCI_0_2_affinity_info 9 > +#define PSCI_0_2_migrate 10 > +#define PSCI_0_2_migrate_info_type 11 > +#define PSCI_0_2_migrate_info_up_cpu 12 > +#define PSCI_0_2_system_off 13 > +#define PSCI_0_2_system_reset 14 > + > +#define PSCI_0_2_fn64_cpu_suspend 15 > +#define PSCI_0_2_fn64_cpu_on 16 > +#define PSCI_0_2_fn64_affinity_info 17 > +#define PSCI_0_2_fn64_migrate 18 > +#define PSCI_0_2_fn64_migrate_info_up_cpu 19 > + > +/* PSCI v0.2 xen mapping mask */ > +#define PSCI_0_2_FN_OFFSET 0x83FFFFFB Err? I think you should make the defines be the actual PSCI function numbers and then define three separate function call tables and look up the appropriate one based on the range of the function parameter. TBH given the relatively small number of PSCI calls maybe just switching to a C switch() statement would be best.Quoted 2 lines
patchset v1 was based on switch case it was moved to if/else after review comments, should i change it back to switch case?
Sorry for not getting to this for v1.
v1 had a switch statement to lookup
fn_index, which it then looked up again in the op table. I think that approach was the worst of both worlds.What I was suggesting was a switch statement which actually dispatched the call to the appropriate handler directly, rather than having a second indirection via a table.
Quoted 8 lines
Quoted 6 lines
The main thing I don't like is macro hoops you are jumping through in order to turn the spec mandated sparse function space into a compact one suitable for placing in an array.
Another viable alternative would be to have separate tables for PSCI 0.1 and PSCSI 0.2 32- and 64-bit and look through each in turn.
Sure, let me try the two table approach.
NB: Three tables (0.1, 0.2-32bit, 0.2-64bit), unless you are planning something clever with multiple fn ids per table entry.
Quoted 31 lines
Quoted 31 lines
Quoted 24 lines
> +/* PSCI v0.2 multicore support in Trusted OS returned by
MIGRATE_INFO_TYPE*/
> +#definePSCI_0_2_TOS_UP_MIGRATE0
> +#definePSCI_0_2_TOS_UP_NO_MIGRATE1
> +#definePSCI_0_2_TOS_MP2The first two names are tolerable, but the last one doesn't seem to
match the spec.> diff --git
a/xen/include/public/arch-arm.hb/xen/include/public/arch-arm.h
> index 7496556..93803e4 100644
> ---a/xen/include/public/arch-arm.h
> +++b/xen/include/public/arch-arm.h
> @@ -385,6 +385,7 @@ typedefuint64_txen_callback_t;
> #definePSCI_cpu_off1
> #definePSCI_cpu_on2
> #definePSCI_migrate3
> +#definePSCI_0_1_MAX4Quoted 3 lines
The tools don't need this, so no need to make it public.
This was taken as it is from previous implementation should i move it topsci.h?What previous implementation? I don't see anything like that in the tree right now.
Quoted 6 lines
Quoted 3 lines
Ian.
hmmm, just to be sure you are talking about these constants "PSCI_cpu_off,PSCI_cpu_on ..etc." in
xen/include/public/arch-arm.h? i can see them in xen/master branch...or is it something else?
I was talking only about PSCI_0_1_MAX, not the other ones.
(PSCI_migrate isn't used either, it probably shouldn't exist as a #define)
Ian.
Hi,
Quoted 77 lines · Ian Campbell
Quoted 5 lines · Parth Dixit
Quoted 5 lines
Quoted 2 lines
They are there for completion,i am using common functions for 32 bit/64 bit
What do you mean by "completion"?
Quoted 7 lines
Quoted 2 lines
If those prototypes do not correspond to some real function which is actually being used then please remove them
PSCI v0.1 had two functions implemented and two others were declared but not implemented, i was following the same style.
i.e. declaring all the functions in the spec but implementing only the ones that are mandated/usedOh, I think those v0.1 ones are there in error.
Quoted 1 line
I will remove the the unused functions.
Thanks.
Quoted 57 lines
Quoted 57 lines
Quoted 40 lines
> + > +/* PSCI version */ > +#define XEN_PSCI_V_0_1 1 > +#define XEN_PSCI_V_0_2 2 > + > +/* PSCI v0.2 id's internal to xen */ > + > +#define PSCI_0_2_version 5 > +#define PSCI_0_2_cpu_suspend 6 > +#define PSCI_0_2_cpu_off 7 > +#define PSCI_0_2_cpu_on 8 > +#define PSCI_0_2_affinity_info 9 > +#define PSCI_0_2_migrate 10 > +#define PSCI_0_2_migrate_info_type 11 > +#define PSCI_0_2_migrate_info_up_cpu 12 > +#define PSCI_0_2_system_off 13 > +#define PSCI_0_2_system_reset 14 > + > +#define PSCI_0_2_fn64_cpu_suspend 15 > +#define PSCI_0_2_fn64_cpu_on 16 > +#define PSCI_0_2_fn64_affinity_info 17 > +#define PSCI_0_2_fn64_migrate 18 > +#define PSCI_0_2_fn64_migrate_info_up_cpu 19 > + > +/* PSCI v0.2 xen mapping mask */ > +#define PSCI_0_2_FN_OFFSET 0x83FFFFFB Err? I think you should make the defines be the actual PSCI function numbers and then define three separate function call tables and look up the appropriate one based on the range of the function parameter. TBH given the relatively small number of PSCI calls maybe just switching to a C switch() statement would be best.Quoted 2 lines
patchset v1 was based on switch case it was moved to if/else after review comments, should i change it back to switch case?
Sorry for not getting to this for v1.
v1 had a switch statement to lookup
fn_index, which it then looked up again in the op table. I think that approach was the worst of both worlds.What I was suggesting was a switch statement which actually dispatched the call to the appropriate handler directly, rather than having a second indirection via a table.
The main thing I don't like is macro hoops you are jumping through in order to turn the spec mandated sparse function space into a compact one suitable for placing in an array.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Another viable alternative would be to have separate tables for PSCI 0.1 and PSCSI 0.2 32- and 64-bit and look through each in turn.
Sure, let me try the two table approach.
NB: Three tables (0.1, 0.2-32bit, 0.2-64bit), unless you are planning something clever with multiple fn ids per table entry.
As i am using common functions for 32bit as well as 64 bit two tables are sufficient 0.2, 64 bit table for 0.2 would be redundant. On second thought's i can also use the current table with single mask something likepsci_call = arm_psci_table[PSCI_OP_REG(regs) & VERSION_MASK].fn; what do you think? i'll wait for ur opinion
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
Quoted 25 lines
> +/* PSCI v0.2 multicore support in Trusted OS returned by
MIGRATE_INFO_TYPE*/
> +#definePSCI_0_2_TOS_UP_MIGRATE0
> +#definePSCI_0_2_TOS_UP_NO_MIGRATE1
> +#definePSCI_0_2_TOS_MP2The first two names are tolerable, but the last one doesn't seem to
match the spec.> diff --git
a/xen/include/public/arch-arm.hb/xen/include/public/arch-arm.h
> index 7496556..93803e4 100644
> ---a/xen/include/public/arch-arm.h
> +++b/xen/include/public/arch-arm.h
> @@ -385,6 +385,7 @@ typedefuint64_txen_callback_t;
> #definePSCI_cpu_off1
> #definePSCI_cpu_on2
> #definePSCI_migrate3
> +#definePSCI_0_1_MAX4Quoted 3 lines
The tools don't need this, so no need to make it public.
This was taken as it is from previous implementation should i move it topsci.h?What previous implementation? I don't see anything like that in the tree right now.
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
Ian.
hmmm, just to be sure you are talking about these constants "PSCI_cpu_off,PSCI_cpu_on ..etc." in
xen/include/public/arch-arm.h? i can see them in xen/master branch...or is it something else?I was talking only about
PSCI_0_1_MAX, not the other ones.
I will remove it.
Quoted 5 lines
(
PSCI_migrateisn't used either, it probably shouldn't exist as a #define)Ian.
Parth
Quoted 27 lines · Parth Dixit
Hi,
Quoted 24 lines · Ian Campbell
Quoted 23 lines · Parth Dixit
Quoted 22 lines
Quoted 5 lines
TBH given the relatively small number of PSCI calls maybe just switching
to a Cswitch()statement would be best.
patchset v1 was based on switch case it was moved to if/else after review comments, should i change it back to switch case?Sorry for not getting to this for v1.
v1 had a switch statement to lookup
fn_index, which it then looked up again in the op table. I think that approach was the worst of both worlds.What I was suggesting was a switch statement which actually dispatched the call to the appropriate handler directly, rather than having a second indirection via a table.
The main thing I don't like is macro hoops you are jumping through in order to turn the spec mandated sparse function space into a compact one suitable for placing in an array.
Another viable alternative would be to have separate tables for PSCI 0.1 and PSCSI 0.2 32- and 64-bit and look through each in turn.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Sure, let me try the two table approach.
NB: Three tables (0.1, 0.2-32bit, 0.2-64bit), unless you are planning something clever with multiple fn ids per table entry.
As i am using common functions for 32bit as well as 64 bit two tables are sufficient 0.2, 64 bit table for 0.2 would be redundant.
Oh, because the per-funciton offsets from the 32- vs. 64-bit base are all consistent. Yes I think that could work.
Quoted 4 lines
On second thought's i can also use the current table with single mask something like
psci_call= arm_psci_table[PSCI_OP_REG(regs) & VERSION_MASK].fn; what do you think? i'll wait for ur opinion
Are the 0.1 and 0.2 fn numbers not overlapping? I suppose you control the 0.1 numbers so you could make it so if it isn't already.
You would also need to validate that PSCI_OP_REG(regs) & ~VERSION_MASK was one of the acceptable base addresses.
Ian