提交 2c46e974 编写于 作者: J Janosch Frank

s390/mm: Abstract gmap notify bit setting

Currently we use the software PGSTE bits PGSTE_IN_BIT and
PGSTE_VSIE_BIT to notify before an invalidation occurs on a prefix
page or a VSIE page respectively. Both bits are pgste specific, but
are used when protecting a memory range.

Let's introduce abstract GMAP_NOTIFY_* bits that will be realized into
the respective bits when gmap DAT table entries are protected.
Signed-off-by: NJanosch Frank <frankja@linux.vnet.ibm.com>
Reviewed-by: NChristian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: NDavid Hildenbrand <david@redhat.com>
上级 5a045bb9
...@@ -9,6 +9,10 @@ ...@@ -9,6 +9,10 @@
#ifndef _ASM_S390_GMAP_H #ifndef _ASM_S390_GMAP_H
#define _ASM_S390_GMAP_H #define _ASM_S390_GMAP_H
/* Generic bits for GMAP notification on DAT table entry changes. */
#define GMAP_NOTIFY_SHADOW 0x2
#define GMAP_NOTIFY_MPROT 0x1
/** /**
* struct gmap_struct - guest address space * struct gmap_struct - guest address space
* @list: list head for the mm->context gmap list * @list: list head for the mm->context gmap list
......
...@@ -912,7 +912,7 @@ static inline void gmap_pmd_op_end(struct gmap *gmap, pmd_t *pmdp) ...@@ -912,7 +912,7 @@ static inline void gmap_pmd_op_end(struct gmap *gmap, pmd_t *pmdp)
* @gaddr: virtual address in the guest address space * @gaddr: virtual address in the guest address space
* @pmdp: pointer to the pmd associated with the pte * @pmdp: pointer to the pmd associated with the pte
* @prot: indicates access rights: PROT_NONE, PROT_READ or PROT_WRITE * @prot: indicates access rights: PROT_NONE, PROT_READ or PROT_WRITE
* @bits: pgste notification bits to set * @bits: notification bits to set
* *
* Returns 0 if successfully protected, -ENOMEM if out of memory and * Returns 0 if successfully protected, -ENOMEM if out of memory and
* -EAGAIN if a fixup is needed. * -EAGAIN if a fixup is needed.
...@@ -925,6 +925,7 @@ static int gmap_protect_pte(struct gmap *gmap, unsigned long gaddr, ...@@ -925,6 +925,7 @@ static int gmap_protect_pte(struct gmap *gmap, unsigned long gaddr,
int rc; int rc;
pte_t *ptep; pte_t *ptep;
spinlock_t *ptl = NULL; spinlock_t *ptl = NULL;
unsigned long pbits = 0;
if (pmd_val(*pmdp) & _SEGMENT_ENTRY_INVALID) if (pmd_val(*pmdp) & _SEGMENT_ENTRY_INVALID)
return -EAGAIN; return -EAGAIN;
...@@ -933,8 +934,10 @@ static int gmap_protect_pte(struct gmap *gmap, unsigned long gaddr, ...@@ -933,8 +934,10 @@ static int gmap_protect_pte(struct gmap *gmap, unsigned long gaddr,
if (!ptep) if (!ptep)
return -ENOMEM; return -ENOMEM;
pbits |= (bits & GMAP_NOTIFY_MPROT) ? PGSTE_IN_BIT : 0;
pbits |= (bits & GMAP_NOTIFY_SHADOW) ? PGSTE_VSIE_BIT : 0;
/* Protect and unlock. */ /* Protect and unlock. */
rc = ptep_force_prot(gmap->mm, gaddr, ptep, prot, bits); rc = ptep_force_prot(gmap->mm, gaddr, ptep, prot, pbits);
gmap_pte_op_end(ptl); gmap_pte_op_end(ptl);
return rc; return rc;
} }
...@@ -1008,7 +1011,7 @@ int gmap_mprotect_notify(struct gmap *gmap, unsigned long gaddr, ...@@ -1008,7 +1011,7 @@ int gmap_mprotect_notify(struct gmap *gmap, unsigned long gaddr,
if (!MACHINE_HAS_ESOP && prot == PROT_READ) if (!MACHINE_HAS_ESOP && prot == PROT_READ)
return -EINVAL; return -EINVAL;
down_read(&gmap->mm->mmap_sem); down_read(&gmap->mm->mmap_sem);
rc = gmap_protect_range(gmap, gaddr, len, prot, PGSTE_IN_BIT); rc = gmap_protect_range(gmap, gaddr, len, prot, GMAP_NOTIFY_MPROT);
up_read(&gmap->mm->mmap_sem); up_read(&gmap->mm->mmap_sem);
return rc; return rc;
} }
...@@ -1599,7 +1602,7 @@ struct gmap *gmap_shadow(struct gmap *parent, unsigned long asce, ...@@ -1599,7 +1602,7 @@ struct gmap *gmap_shadow(struct gmap *parent, unsigned long asce,
down_read(&parent->mm->mmap_sem); down_read(&parent->mm->mmap_sem);
rc = gmap_protect_range(parent, asce & _ASCE_ORIGIN, rc = gmap_protect_range(parent, asce & _ASCE_ORIGIN,
((asce & _ASCE_TABLE_LENGTH) + 1) * PAGE_SIZE, ((asce & _ASCE_TABLE_LENGTH) + 1) * PAGE_SIZE,
PROT_READ, PGSTE_VSIE_BIT); PROT_READ, GMAP_NOTIFY_SHADOW);
up_read(&parent->mm->mmap_sem); up_read(&parent->mm->mmap_sem);
spin_lock(&parent->shadow_lock); spin_lock(&parent->shadow_lock);
new->initialized = true; new->initialized = true;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册