diff mbox series

[v2,1/2] s390/kvm: split kvm_s390_real_to_abs

Message ID 20210322140559.500716-2-imbrenda@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series s390/kvm: VSIE: fix prefixing and MSO for MVPG | expand

Commit Message

Claudio Imbrenda March 22, 2021, 2:05 p.m. UTC
A new function _kvm_s390_real_to_abs will apply prefixing to a real address
with a given prefix value.

The old kvm_s390_real_to_abs becomes now a wrapper around the new function.

This is needed to avoid code duplication in vSIE.

Cc: stable@vger.kernel.org
Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
---
 arch/s390/kvm/gaccess.h | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

Comments

Christian Borntraeger March 23, 2021, 3:01 p.m. UTC | #1
On 22.03.21 15:05, Claudio Imbrenda wrote:
> A new function _kvm_s390_real_to_abs will apply prefixing to a real address
> with a given prefix value.
> 
> The old kvm_s390_real_to_abs becomes now a wrapper around the new function.
> 
> This is needed to avoid code duplication in vSIE.
> 
> Cc: stable@vger.kernel.org
> Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
> Reviewed-by: David Hildenbrand <david@redhat.com>
> Reviewed-by: Thomas Huth <thuth@redhat.com>

Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>

> ---
>   arch/s390/kvm/gaccess.h | 23 +++++++++++++++++------
>   1 file changed, 17 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/s390/kvm/gaccess.h b/arch/s390/kvm/gaccess.h
> index daba10f76936..7c72a5e3449f 100644
> --- a/arch/s390/kvm/gaccess.h
> +++ b/arch/s390/kvm/gaccess.h
> @@ -18,17 +18,14 @@
>   
>   /**
>    * kvm_s390_real_to_abs - convert guest real address to guest absolute address
> - * @vcpu - guest virtual cpu
> + * @prefix - guest prefix
>    * @gra - guest real address
>    *
>    * Returns the guest absolute address that corresponds to the passed guest real
> - * address @gra of a virtual guest cpu by applying its prefix.
> + * address @gra of by applying the given prefix.
>    */
> -static inline unsigned long kvm_s390_real_to_abs(struct kvm_vcpu *vcpu,
> -						 unsigned long gra)
> +static inline unsigned long _kvm_s390_real_to_abs(u32 prefix, unsigned long gra)
>   {
> -	unsigned long prefix  = kvm_s390_get_prefix(vcpu);
> -
>   	if (gra < 2 * PAGE_SIZE)
>   		gra += prefix;
>   	else if (gra >= prefix && gra < prefix + 2 * PAGE_SIZE)
> @@ -36,6 +33,20 @@ static inline unsigned long kvm_s390_real_to_abs(struct kvm_vcpu *vcpu,
>   	return gra;
>   }
>   
> +/**
> + * kvm_s390_real_to_abs - convert guest real address to guest absolute address
> + * @vcpu - guest virtual cpu
> + * @gra - guest real address
> + *
> + * Returns the guest absolute address that corresponds to the passed guest real
> + * address @gra of a virtual guest cpu by applying its prefix.
> + */
> +static inline unsigned long kvm_s390_real_to_abs(struct kvm_vcpu *vcpu,
> +						 unsigned long gra)
> +{
> +	return _kvm_s390_real_to_abs(kvm_s390_get_prefix(vcpu), gra);
> +}
> +
>   /**
>    * _kvm_s390_logical_to_effective - convert guest logical to effective address
>    * @psw: psw of the guest
>
diff mbox series

Patch

diff --git a/arch/s390/kvm/gaccess.h b/arch/s390/kvm/gaccess.h
index daba10f76936..7c72a5e3449f 100644
--- a/arch/s390/kvm/gaccess.h
+++ b/arch/s390/kvm/gaccess.h
@@ -18,17 +18,14 @@ 
 
 /**
  * kvm_s390_real_to_abs - convert guest real address to guest absolute address
- * @vcpu - guest virtual cpu
+ * @prefix - guest prefix
  * @gra - guest real address
  *
  * Returns the guest absolute address that corresponds to the passed guest real
- * address @gra of a virtual guest cpu by applying its prefix.
+ * address @gra of by applying the given prefix.
  */
-static inline unsigned long kvm_s390_real_to_abs(struct kvm_vcpu *vcpu,
-						 unsigned long gra)
+static inline unsigned long _kvm_s390_real_to_abs(u32 prefix, unsigned long gra)
 {
-	unsigned long prefix  = kvm_s390_get_prefix(vcpu);
-
 	if (gra < 2 * PAGE_SIZE)
 		gra += prefix;
 	else if (gra >= prefix && gra < prefix + 2 * PAGE_SIZE)
@@ -36,6 +33,20 @@  static inline unsigned long kvm_s390_real_to_abs(struct kvm_vcpu *vcpu,
 	return gra;
 }
 
+/**
+ * kvm_s390_real_to_abs - convert guest real address to guest absolute address
+ * @vcpu - guest virtual cpu
+ * @gra - guest real address
+ *
+ * Returns the guest absolute address that corresponds to the passed guest real
+ * address @gra of a virtual guest cpu by applying its prefix.
+ */
+static inline unsigned long kvm_s390_real_to_abs(struct kvm_vcpu *vcpu,
+						 unsigned long gra)
+{
+	return _kvm_s390_real_to_abs(kvm_s390_get_prefix(vcpu), gra);
+}
+
 /**
  * _kvm_s390_logical_to_effective - convert guest logical to effective address
  * @psw: psw of the guest