Commit 7cb70266 authored by David Hildenbrand's avatar David Hildenbrand Committed by Christian Borntraeger

s390/mm: optimize set_guest_storage_key()

We already optimize get_guest_storage_key() to assume that if we don't have
a PTE table and don't have a huge page mapped that the storage key is 0.

Similarly, optimize set_guest_storage_key() to simply do nothing in case
the key to set is 0.
Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
Reviewed-by: default avatarClaudio Imbrenda <imbrenda@linux.ibm.com>
Acked-by: default avatarHeiko Carstens <hca@linux.ibm.com>
Link: https://lore.kernel.org/r/20210909162248.14969-9-david@redhat.comSigned-off-by: default avatarChristian Borntraeger <borntraeger@de.ibm.com>
parent 8318c404
...@@ -792,13 +792,23 @@ int set_guest_storage_key(struct mm_struct *mm, unsigned long addr, ...@@ -792,13 +792,23 @@ int set_guest_storage_key(struct mm_struct *mm, unsigned long addr,
pmd_t *pmdp; pmd_t *pmdp;
pte_t *ptep; pte_t *ptep;
if (pmd_lookup(mm, addr, &pmdp)) /*
* If we don't have a PTE table and if there is no huge page mapped,
* we can ignore attempts to set the key to 0, because it already is 0.
*/
switch (pmd_lookup(mm, addr, &pmdp)) {
case -ENOENT:
return key ? -EFAULT : 0;
case 0:
break;
default:
return -EFAULT; return -EFAULT;
}
ptl = pmd_lock(mm, pmdp); ptl = pmd_lock(mm, pmdp);
if (!pmd_present(*pmdp)) { if (!pmd_present(*pmdp)) {
spin_unlock(ptl); spin_unlock(ptl);
return -EFAULT; return key ? -EFAULT : 0;
} }
if (pmd_large(*pmdp)) { if (pmd_large(*pmdp)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment