[5/7] KVM: s390: provide query function for instructions returning 32 byte
diff mbox series

Message ID 20190417152842.71730-6-borntraeger@de.ibm.com
State New
Headers show
Series
  • KVM: s390: new guest facilities
Related show

Commit Message

Christian Borntraeger April 17, 2019, 3:28 p.m. UTC
Some of the new features have a 32byte response for the query function.
Provide a new wrapper similar to __cpacf_query. We might want to factor
this out if other users come up, as of today there is none. So let us
keep the function within KVM.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Collin Walling <walling@linux.ibm.com>
---
 arch/s390/kvm/kvm-s390.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Comments

David Hildenbrand April 17, 2019, 3:42 p.m. UTC | #1
On 17.04.19 17:28, Christian Borntraeger wrote:
> Some of the new features have a 32byte response for the query function.
> Provide a new wrapper similar to __cpacf_query. We might want to factor
> this out if other users come up, as of today there is none. So let us
> keep the function within KVM.
> 
> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
> Reviewed-by: Collin Walling <walling@linux.ibm.com>
> ---
>  arch/s390/kvm/kvm-s390.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
> index ff2444d935fd..f0404960a715 100644
> --- a/arch/s390/kvm/kvm-s390.c
> +++ b/arch/s390/kvm/kvm-s390.c
> @@ -321,6 +321,19 @@ static inline int plo_test_bit(unsigned char nr)
>  	return cc == 0;
>  }
>  
> +static inline void __insn32_query(unsigned int opcode, u8 query[32])
> +{
> +	register unsigned long r0 asm("0") = 0;	/* query function */
> +	register unsigned long r1 asm("1") = (unsigned long) query;
> +
> +	asm volatile(
> +		/* Parameter regs are ignored */
> +		"	.insn	rrf,%[opc] << 16,2,4,6,0\n"
> +		: "=m" (*query)
> +		: "d" (r0), "a" (r1), [opc] "i" (opcode)
> +		: "cc");
> +}
> +
>  static void kvm_s390_cpu_feat_init(void)
>  {
>  	int i;
> 

Are these !cpacf functions, so the generic name "__insn32" is preferred
over e.g. __cpacf_query32 ?

Looks sane to me.
Christian Borntraeger April 17, 2019, 3:43 p.m. UTC | #2
On 17.04.19 17:42, David Hildenbrand wrote:
> On 17.04.19 17:28, Christian Borntraeger wrote:
>> Some of the new features have a 32byte response for the query function.
>> Provide a new wrapper similar to __cpacf_query. We might want to factor
>> this out if other users come up, as of today there is none. So let us
>> keep the function within KVM.
>>
>> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
>> Reviewed-by: Collin Walling <walling@linux.ibm.com>
>> ---
>>  arch/s390/kvm/kvm-s390.c | 13 +++++++++++++
>>  1 file changed, 13 insertions(+)
>>
>> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
>> index ff2444d935fd..f0404960a715 100644
>> --- a/arch/s390/kvm/kvm-s390.c
>> +++ b/arch/s390/kvm/kvm-s390.c
>> @@ -321,6 +321,19 @@ static inline int plo_test_bit(unsigned char nr)
>>  	return cc == 0;
>>  }
>>  
>> +static inline void __insn32_query(unsigned int opcode, u8 query[32])
>> +{
>> +	register unsigned long r0 asm("0") = 0;	/* query function */
>> +	register unsigned long r1 asm("1") = (unsigned long) query;
>> +
>> +	asm volatile(
>> +		/* Parameter regs are ignored */
>> +		"	.insn	rrf,%[opc] << 16,2,4,6,0\n"
>> +		: "=m" (*query)
>> +		: "d" (r0), "a" (r1), [opc] "i" (opcode)
>> +		: "cc");
>> +}
>> +
>>  static void kvm_s390_cpu_feat_init(void)
>>  {
>>  	int i;
>>
> 
> Are these !cpacf functions, so the generic name "__insn32" is preferred
> over e.g. __cpacf_query32 ?

yes, not cpacf.

> 
> Looks sane to me.
>
David Hildenbrand April 17, 2019, 3:45 p.m. UTC | #3
On 17.04.19 17:43, Christian Borntraeger wrote:
> 
> 
> On 17.04.19 17:42, David Hildenbrand wrote:
>> On 17.04.19 17:28, Christian Borntraeger wrote:
>>> Some of the new features have a 32byte response for the query function.
>>> Provide a new wrapper similar to __cpacf_query. We might want to factor
>>> this out if other users come up, as of today there is none. So let us
>>> keep the function within KVM.
>>>
>>> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
>>> Reviewed-by: Collin Walling <walling@linux.ibm.com>
>>> ---
>>>  arch/s390/kvm/kvm-s390.c | 13 +++++++++++++
>>>  1 file changed, 13 insertions(+)
>>>
>>> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
>>> index ff2444d935fd..f0404960a715 100644
>>> --- a/arch/s390/kvm/kvm-s390.c
>>> +++ b/arch/s390/kvm/kvm-s390.c
>>> @@ -321,6 +321,19 @@ static inline int plo_test_bit(unsigned char nr)
>>>  	return cc == 0;
>>>  }
>>>  
>>> +static inline void __insn32_query(unsigned int opcode, u8 query[32])
>>> +{
>>> +	register unsigned long r0 asm("0") = 0;	/* query function */
>>> +	register unsigned long r1 asm("1") = (unsigned long) query;
>>> +
>>> +	asm volatile(
>>> +		/* Parameter regs are ignored */
>>> +		"	.insn	rrf,%[opc] << 16,2,4,6,0\n"
>>> +		: "=m" (*query)
>>> +		: "d" (r0), "a" (r1), [opc] "i" (opcode)
>>> +		: "cc");
>>> +}
>>> +
>>>  static void kvm_s390_cpu_feat_init(void)
>>>  {
>>>  	int i;
>>>
>>
>> Are these !cpacf functions, so the generic name "__insn32" is preferred
>> over e.g. __cpacf_query32 ?
> 
> yes, not cpacf.

Reviewed-by: David Hildenbrand <david@redhat.com>

Patch
diff mbox series

diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index ff2444d935fd..f0404960a715 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -321,6 +321,19 @@  static inline int plo_test_bit(unsigned char nr)
 	return cc == 0;
 }
 
+static inline void __insn32_query(unsigned int opcode, u8 query[32])
+{
+	register unsigned long r0 asm("0") = 0;	/* query function */
+	register unsigned long r1 asm("1") = (unsigned long) query;
+
+	asm volatile(
+		/* Parameter regs are ignored */
+		"	.insn	rrf,%[opc] << 16,2,4,6,0\n"
+		: "=m" (*query)
+		: "d" (r0), "a" (r1), [opc] "i" (opcode)
+		: "cc");
+}
+
 static void kvm_s390_cpu_feat_init(void)
 {
 	int i;