]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
s390/mm: return key via pointer in get_guest_storage_key
authorDavid Hildenbrand <dahi@linux.vnet.ibm.com>
Mon, 9 May 2016 09:22:34 +0000 (11:22 +0200)
committerChristian Borntraeger <borntraeger@de.ibm.com>
Fri, 10 Jun 2016 10:07:28 +0000 (12:07 +0200)
Let's just split returning the key and reporting errors. This makes calling
code easier and avoids bugs as happened already.

Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
arch/s390/include/asm/pgtable.h
arch/s390/kvm/kvm-s390.c
arch/s390/mm/pgtable.c

index 42b968a85863041a98e393ec800a4c34cb1c1736..91f0e7b79821bd9273e5d82881922a7904180795 100644 (file)
@@ -893,7 +893,8 @@ void ptep_zap_key(struct mm_struct *mm, unsigned long addr, pte_t *ptep);
 bool test_and_clear_guest_dirty(struct mm_struct *mm, unsigned long address);
 int set_guest_storage_key(struct mm_struct *mm, unsigned long addr,
                          unsigned char key, bool nq);
-unsigned long get_guest_storage_key(struct mm_struct *mm, unsigned long addr);
+int get_guest_storage_key(struct mm_struct *mm, unsigned long addr,
+                         unsigned char *key);
 
 /*
  * Certain architectures need to do special things when PTEs
index d0156d7969e039b0807b53d63f915781255005c8..ad166c6698e07b05a4eb8317fd6724c11ea3a576 100644 (file)
@@ -1029,7 +1029,6 @@ static long kvm_s390_get_skeys(struct kvm *kvm, struct kvm_s390_skeys *args)
 {
        uint8_t *keys;
        uint64_t hva;
-       unsigned long curkey;
        int i, r = 0;
 
        if (args->flags != 0)
@@ -1058,12 +1057,9 @@ static long kvm_s390_get_skeys(struct kvm *kvm, struct kvm_s390_skeys *args)
                        break;
                }
 
-               curkey = get_guest_storage_key(current->mm, hva);
-               if (IS_ERR_VALUE(curkey)) {
-                       r = curkey;
+               r = get_guest_storage_key(current->mm, hva, &keys[i]);
+               if (r)
                        break;
-               }
-               keys[i] = curkey;
        }
        up_read(&current->mm->mmap_sem);
 
index 4c8d572d59cc548e9048719eefea20f52682a5f4..3e35298758d6dbef3848332c2554390358c104b4 100644 (file)
@@ -539,9 +539,9 @@ int set_guest_storage_key(struct mm_struct *mm, unsigned long addr,
 }
 EXPORT_SYMBOL(set_guest_storage_key);
 
-unsigned long get_guest_storage_key(struct mm_struct *mm, unsigned long addr)
+int get_guest_storage_key(struct mm_struct *mm, unsigned long addr,
+                         unsigned char *key)
 {
-       unsigned char key;
        spinlock_t *ptl;
        pgste_t pgste;
        pte_t *ptep;
@@ -551,14 +551,14 @@ unsigned long get_guest_storage_key(struct mm_struct *mm, unsigned long addr)
                return -EFAULT;
 
        pgste = pgste_get_lock(ptep);
-       key = (pgste_val(pgste) & (PGSTE_ACC_BITS | PGSTE_FP_BIT)) >> 56;
+       *key = (pgste_val(pgste) & (PGSTE_ACC_BITS | PGSTE_FP_BIT)) >> 56;
        if (!(pte_val(*ptep) & _PAGE_INVALID))
-               key = page_get_storage_key(pte_val(*ptep) & PAGE_MASK);
+               *key = page_get_storage_key(pte_val(*ptep) & PAGE_MASK);
        /* Reflect guest's logical view, not physical */
-       key |= (pgste_val(pgste) & (PGSTE_GR_BIT | PGSTE_GC_BIT)) >> 48;
+       *key |= (pgste_val(pgste) & (PGSTE_GR_BIT | PGSTE_GC_BIT)) >> 48;
        pgste_set_unlock(ptep, pgste);
        pte_unmap_unlock(ptep, ptl);
-       return key;
+       return 0;
 }
 EXPORT_SYMBOL(get_guest_storage_key);
 #endif