diff mbox

[v7,04/16] arm64: kvm: Move the do_el2_call macro to a header file

Message ID 1459529620-22150-5-git-send-email-james.morse@arm.com (mailing list archive)
State New, archived
Headers show

Commit Message

James Morse April 1, 2016, 4:53 p.m. UTC
The hyp-stub could make use of the do_el2_call(), move it to a header file.

Signed-off-by: James Morse <james.morse@arm.com>
---
 arch/arm64/include/asm/virt.h  | 18 +++++++++++++++++-
 arch/arm64/kvm/hyp/hyp-entry.S | 17 +----------------
 2 files changed, 18 insertions(+), 17 deletions(-)

Comments

Marc Zyngier April 19, 2016, 3:02 p.m. UTC | #1
On 01/04/16 17:53, James Morse wrote:
> The hyp-stub could make use of the do_el2_call(), move it to a header file.
> 
> Signed-off-by: James Morse <james.morse@arm.com>
> ---
>  arch/arm64/include/asm/virt.h  | 18 +++++++++++++++++-
>  arch/arm64/kvm/hyp/hyp-entry.S | 17 +----------------
>  2 files changed, 18 insertions(+), 17 deletions(-)
> 
> diff --git a/arch/arm64/include/asm/virt.h b/arch/arm64/include/asm/virt.h
> index 9f22dd607958..b8fdddeca71b 100644
> --- a/arch/arm64/include/asm/virt.h
> +++ b/arch/arm64/include/asm/virt.h
> @@ -21,7 +21,23 @@
>  #define BOOT_CPU_MODE_EL1	(0xe11)
>  #define BOOT_CPU_MODE_EL2	(0xe12)
>  
> -#ifndef __ASSEMBLY__
> +#ifdef __ASSEMBLY__
> +.macro do_el2_call
> +	/*
> +	 * Shuffle the parameters before calling the function
> +	 * pointed to in x0. Assumes parameters in x[1,2,3].
> +	 */
> +	sub	sp, sp, #16
> +	str	lr, [sp]
> +	mov	lr, x0
> +	mov	x0, x1
> +	mov	x1, x2
> +	mov	x2, x3
> +	blr	lr
> +	ldr	lr, [sp]
> +	add	sp, sp, #16
> +.endm
> +#else

So while I'm not opposed to this macro being reused, the name is
slightly misleading out of the original context. This macro doesn't take
you to EL2, but implements a very peculiar calling convention that only
the HYP code is expecting.

Could we have a disclaimer saying something along the lines of "Don't
you dare using this macro!"?

Otherwise:

Acked-by: Marc Zyngier <marc.zyngier@arm.com>

	M.
James Morse April 19, 2016, 3:05 p.m. UTC | #2
Hi Marc,

On 19/04/16 16:02, Marc Zyngier wrote:
> On 01/04/16 17:53, James Morse wrote:
>> diff --git a/arch/arm64/include/asm/virt.h b/arch/arm64/include/asm/virt.h
>> index 9f22dd607958..b8fdddeca71b 100644
>> --- a/arch/arm64/include/asm/virt.h
>> +++ b/arch/arm64/include/asm/virt.h
>> @@ -21,7 +21,23 @@
>>  #define BOOT_CPU_MODE_EL1	(0xe11)
>>  #define BOOT_CPU_MODE_EL2	(0xe12)
>>  
>> -#ifndef __ASSEMBLY__
>> +#ifdef __ASSEMBLY__
>> +.macro do_el2_call
>> +	/*
>> +	 * Shuffle the parameters before calling the function
>> +	 * pointed to in x0. Assumes parameters in x[1,2,3].
>> +	 */
>> +	sub	sp, sp, #16
>> +	str	lr, [sp]
>> +	mov	lr, x0
>> +	mov	x0, x1
>> +	mov	x1, x2
>> +	mov	x2, x3
>> +	blr	lr
>> +	ldr	lr, [sp]
>> +	add	sp, sp, #16
>> +.endm
>> +#else
> 
> So while I'm not opposed to this macro being reused, the name is
> slightly misleading out of the original context. This macro doesn't take
> you to EL2, but implements a very peculiar calling convention that only
> the HYP code is expecting.

Ah, I hadn't thought of it like that!


> Could we have a disclaimer saying something along the lines of "Don't
> you dare using this macro!"?

Or rename it? Something like 'unpack_el2_call'.



Thanks,

James
Marc Zyngier April 19, 2016, 3:10 p.m. UTC | #3
On 19/04/16 16:05, James Morse wrote:
> Hi Marc,
> 
> On 19/04/16 16:02, Marc Zyngier wrote:
>> On 01/04/16 17:53, James Morse wrote:
>>> diff --git a/arch/arm64/include/asm/virt.h b/arch/arm64/include/asm/virt.h
>>> index 9f22dd607958..b8fdddeca71b 100644
>>> --- a/arch/arm64/include/asm/virt.h
>>> +++ b/arch/arm64/include/asm/virt.h
>>> @@ -21,7 +21,23 @@
>>>  #define BOOT_CPU_MODE_EL1	(0xe11)
>>>  #define BOOT_CPU_MODE_EL2	(0xe12)
>>>  
>>> -#ifndef __ASSEMBLY__
>>> +#ifdef __ASSEMBLY__
>>> +.macro do_el2_call
>>> +	/*
>>> +	 * Shuffle the parameters before calling the function
>>> +	 * pointed to in x0. Assumes parameters in x[1,2,3].
>>> +	 */
>>> +	sub	sp, sp, #16
>>> +	str	lr, [sp]
>>> +	mov	lr, x0
>>> +	mov	x0, x1
>>> +	mov	x1, x2
>>> +	mov	x2, x3
>>> +	blr	lr
>>> +	ldr	lr, [sp]
>>> +	add	sp, sp, #16
>>> +.endm
>>> +#else
>>
>> So while I'm not opposed to this macro being reused, the name is
>> slightly misleading out of the original context. This macro doesn't take
>> you to EL2, but implements a very peculiar calling convention that only
>> the HYP code is expecting.
> 
> Ah, I hadn't thought of it like that!
> 
> 
>> Could we have a disclaimer saying something along the lines of "Don't
>> you dare using this macro!"?
> 
> Or rename it? Something like 'unpack_el2_call'.

Works for me!

	M.
diff mbox

Patch

diff --git a/arch/arm64/include/asm/virt.h b/arch/arm64/include/asm/virt.h
index 9f22dd607958..b8fdddeca71b 100644
--- a/arch/arm64/include/asm/virt.h
+++ b/arch/arm64/include/asm/virt.h
@@ -21,7 +21,23 @@ 
 #define BOOT_CPU_MODE_EL1	(0xe11)
 #define BOOT_CPU_MODE_EL2	(0xe12)
 
-#ifndef __ASSEMBLY__
+#ifdef __ASSEMBLY__
+.macro do_el2_call
+	/*
+	 * Shuffle the parameters before calling the function
+	 * pointed to in x0. Assumes parameters in x[1,2,3].
+	 */
+	sub	sp, sp, #16
+	str	lr, [sp]
+	mov	lr, x0
+	mov	x0, x1
+	mov	x1, x2
+	mov	x2, x3
+	blr	lr
+	ldr	lr, [sp]
+	add	sp, sp, #16
+.endm
+#else
 
 #include <asm/ptrace.h>
 
diff --git a/arch/arm64/kvm/hyp/hyp-entry.S b/arch/arm64/kvm/hyp/hyp-entry.S
index 3488894397ff..358f27a1edc2 100644
--- a/arch/arm64/kvm/hyp/hyp-entry.S
+++ b/arch/arm64/kvm/hyp/hyp-entry.S
@@ -23,6 +23,7 @@ 
 #include <asm/kvm_arm.h>
 #include <asm/kvm_asm.h>
 #include <asm/kvm_mmu.h>
+#include <asm/virt.h>
 
 	.text
 	.pushsection	.hyp.text, "ax"
@@ -37,22 +38,6 @@ 
 	ldp	x0, x1, [sp], #16
 .endm
 
-.macro do_el2_call
-	/*
-	 * Shuffle the parameters before calling the function
-	 * pointed to in x0. Assumes parameters in x[1,2,3].
-	 */
-	sub	sp, sp, #16
-	str	lr, [sp]
-	mov	lr, x0
-	mov	x0, x1
-	mov	x1, x2
-	mov	x2, x3
-	blr	lr
-	ldr	lr, [sp]
-	add	sp, sp, #16
-.endm
-
 ENTRY(__vhe_hyp_call)
 	do_el2_call
 	/*