On 5/28/25 11:55 AM, Claudio Imbrenda wrote:
Refactor some gmap functions; move the implementation into a separate
file with only helper functions. The new helper functions work on vm
addresses, leaving all gmap logic in the gmap functions, which mostly
become just wrappers.
The whole gmap handling is going to be moved inside KVM soon, but the
helper functions need to touch core mm functions, and thus need to
stay in the core of kernel.
Signed-off-by: Claudio Imbrenda <imbrenda@xxxxxxxxxxxxx>
Reviewed-by: Steffen Eiden <seiden@xxxxxxxxxxxxx>
Reviewed-by: Christoph Schlameuss <schlameuss@xxxxxxxxxxxxx>
---
Acked-by: Janosch Frank <frankja@xxxxxxxxxxxxx>
MAINTAINERS | 2 +
arch/s390/include/asm/gmap.h | 2 -
arch/s390/include/asm/gmap_helpers.h | 15 ++
arch/s390/kvm/diag.c | 30 +++-
arch/s390/kvm/kvm-s390.c | 5 +-
arch/s390/mm/Makefile | 2 +
arch/s390/mm/gmap.c | 184 +---------------------
arch/s390/mm/gmap_helpers.c | 221 +++++++++++++++++++++++++++
8 files changed, 274 insertions(+), 187 deletions(-)
create mode 100644 arch/s390/include/asm/gmap_helpers.h
create mode 100644 arch/s390/mm/gmap_helpers.c
[...]
+#endif /* _ASM_S390_GMAP_HELPERS_H */
diff --git a/arch/s390/kvm/diag.c b/arch/s390/kvm/diag.c
index 74f73141f9b9..53233dec8cad 100644
--- a/arch/s390/kvm/diag.c
+++ b/arch/s390/kvm/diag.c
@@ -11,12 +11,30 @@
#include <linux/kvm.h>
#include <linux/kvm_host.h>
#include <asm/gmap.h>
+#include <asm/gmap_helpers.h>
#include <asm/virtio-ccw.h>
#include "kvm-s390.h"
#include "trace.h"
#include "trace-s390.h"
#include "gaccess.h"
+static void do_discard_gfn_range(struct kvm_vcpu *vcpu, gfn_t gfn_start, gfn_t gfn_end)
+{
A helper function for your helper function :)