All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Borntraeger <borntraeger@de.ibm.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: KVM <kvm@vger.kernel.org>, Janosch Frank <frankja@linux.ibm.com>,
	David Hildenbrand <david@redhat.com>,
	Cornelia Huck <cohuck@redhat.com>,
	linux-s390 <linux-s390@vger.kernel.org>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	Claudio Imbrenda <imbrenda@linux.ibm.com>,
	Thomas Huth <thuth@redhat.com>
Subject: [GIT PULL 6/7] KVM: s390: split kvm_s390_real_to_abs
Date: Mon, 12 Apr 2021 18:05:44 +0200	[thread overview]
Message-ID: <20210412160545.231194-7-borntraeger@de.ibm.com> (raw)
In-Reply-To: <20210412160545.231194-1-borntraeger@de.ibm.com>

From: Claudio Imbrenda <imbrenda@linux.ibm.com>

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.

Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20210322140559.500716-2-imbrenda@linux.ibm.com
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 arch/s390/kvm/gaccess.h | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 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
@@ -16,6 +16,23 @@
 #include <linux/ptrace.h>
 #include "kvm-s390.h"
 
+/**
+ * kvm_s390_real_to_abs - convert guest real address to guest absolute address
+ * @prefix - guest prefix
+ * @gra - guest real address
+ *
+ * Returns the guest absolute address that corresponds to the passed guest real
+ * address @gra of by applying the given prefix.
+ */
+static inline unsigned long _kvm_s390_real_to_abs(u32 prefix, unsigned long gra)
+{
+	if (gra < 2 * PAGE_SIZE)
+		gra += prefix;
+	else if (gra >= prefix && gra < prefix + 2 * PAGE_SIZE)
+		gra -= prefix;
+	return gra;
+}
+
 /**
  * kvm_s390_real_to_abs - convert guest real address to guest absolute address
  * @vcpu - guest virtual cpu
@@ -27,13 +44,7 @@
 static inline unsigned long kvm_s390_real_to_abs(struct kvm_vcpu *vcpu,
 						 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)
-		gra -= prefix;
-	return gra;
+	return _kvm_s390_real_to_abs(kvm_s390_get_prefix(vcpu), gra);
 }
 
 /**
-- 
2.30.2


  parent reply	other threads:[~2021-04-12 16:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-12 16:05 [GIT PULL 0/7] KVM: s390: Updates for 5.13 Christian Borntraeger
2021-04-12 16:05 ` [GIT PULL 1/7] KVM: s390: Fix comment spelling in kvm_s390_vcpu_start() Christian Borntraeger
2021-04-12 16:05 ` [GIT PULL 2/7] KVM: s390: diag9c (directed yield) forwarding Christian Borntraeger
2021-04-12 16:05 ` [GIT PULL 3/7] KVM: s390: split kvm_s390_logical_to_effective Christian Borntraeger
2021-04-12 16:05 ` [GIT PULL 4/7] KVM: s390: extend kvm_s390_shadow_fault to return entry pointer Christian Borntraeger
2021-04-12 16:05 ` [GIT PULL 5/7] KVM: s390: VSIE: correctly handle MVPG when in VSIE Christian Borntraeger
2021-04-12 16:05 ` Christian Borntraeger [this message]
2021-04-12 16:05 ` [GIT PULL 7/7] KVM: s390: VSIE: fix MVPG handling for prefixing and MSO Christian Borntraeger
2021-04-15 17:02 ` [GIT PULL 0/7] KVM: s390: Updates for 5.13 Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210412160545.231194-7-borntraeger@de.ibm.com \
    --to=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=david@redhat.com \
    --cc=frankja@linux.ibm.com \
    --cc=imbrenda@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.