xref: /linux/arch/s390/kvm/gmap.h (revision 954a209f431c06b62718a49b403bd4c549f0d6fb)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  *  KVM guest address space mapping code
4  *
5  *    Copyright IBM Corp. 2007, 2016, 2025
6  *    Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
7  *               Claudio Imbrenda <imbrenda@linux.ibm.com>
8  */
9 
10 #ifndef ARCH_KVM_S390_GMAP_H
11 #define ARCH_KVM_S390_GMAP_H
12 
13 #define GMAP_SHADOW_FAKE_TABLE 1ULL
14 
15 int gmap_make_secure(struct gmap *gmap, unsigned long gaddr, void *uvcb);
16 int gmap_convert_to_secure(struct gmap *gmap, unsigned long gaddr);
17 int gmap_destroy_page(struct gmap *gmap, unsigned long gaddr);
18 struct gmap *gmap_shadow(struct gmap *parent, unsigned long asce, int edat_level);
19 
20 /**
21  * gmap_shadow_valid - check if a shadow guest address space matches the
22  *                     given properties and is still valid
23  * @sg: pointer to the shadow guest address space structure
24  * @asce: ASCE for which the shadow table is requested
25  * @edat_level: edat level to be used for the shadow translation
26  *
27  * Returns 1 if the gmap shadow is still valid and matches the given
28  * properties, the caller can continue using it. Returns 0 otherwise, the
29  * caller has to request a new shadow gmap in this case.
30  *
31  */
gmap_shadow_valid(struct gmap * sg,unsigned long asce,int edat_level)32 static inline int gmap_shadow_valid(struct gmap *sg, unsigned long asce, int edat_level)
33 {
34 	if (sg->removed)
35 		return 0;
36 	return sg->orig_asce == asce && sg->edat_level == edat_level;
37 }
38 
39 #endif
40