priv.c (f7b1a77d3bfbdc7e91a1e48e0a3dc10e7d890e04) priv.c (730cd632c4e485b90f97fe998e300045da094938)
1/*
2 * handling privileged instructions
3 *
4 * Copyright IBM Corp. 2008, 2013
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License (version 2 only)
8 * as published by the Free Software Foundation.

--- 184 unchanged lines hidden (view full) ---

193 if (rc)
194 return kvm_s390_inject_prog_cond(vcpu, rc);
195
196 VCPU_EVENT(vcpu, 3, "STAP: storing cpu address (%u) to 0x%llx", vcpu_id, ga);
197 trace_kvm_s390_handle_stap(vcpu, ga);
198 return 0;
199}
200
1/*
2 * handling privileged instructions
3 *
4 * Copyright IBM Corp. 2008, 2013
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License (version 2 only)
8 * as published by the Free Software Foundation.

--- 184 unchanged lines hidden (view full) ---

193 if (rc)
194 return kvm_s390_inject_prog_cond(vcpu, rc);
195
196 VCPU_EVENT(vcpu, 3, "STAP: storing cpu address (%u) to 0x%llx", vcpu_id, ga);
197 trace_kvm_s390_handle_stap(vcpu, ga);
198 return 0;
199}
200
201static int __skey_check_enable(struct kvm_vcpu *vcpu)
201int kvm_s390_skey_check_enable(struct kvm_vcpu *vcpu)
202{
203 int rc = 0;
202{
203 int rc = 0;
204 struct kvm_s390_sie_block *sie_block = vcpu->arch.sie_block;
204
205 trace_kvm_s390_skey_related_inst(vcpu);
205
206 trace_kvm_s390_skey_related_inst(vcpu);
206 if (!(vcpu->arch.sie_block->ictl & (ICTL_ISKE | ICTL_SSKE | ICTL_RRBE)))
207 if (!(sie_block->ictl & (ICTL_ISKE | ICTL_SSKE | ICTL_RRBE)) &&
208 !(atomic_read(&sie_block->cpuflags) & CPUSTAT_KSS))
207 return rc;
208
209 rc = s390_enable_skey();
210 VCPU_EVENT(vcpu, 3, "enabling storage keys for guest: %d", rc);
209 return rc;
210
211 rc = s390_enable_skey();
212 VCPU_EVENT(vcpu, 3, "enabling storage keys for guest: %d", rc);
211 if (!rc)
212 vcpu->arch.sie_block->ictl &= ~(ICTL_ISKE | ICTL_SSKE | ICTL_RRBE);
213 if (!rc) {
214 if (atomic_read(&sie_block->cpuflags) & CPUSTAT_KSS)
215 atomic_andnot(CPUSTAT_KSS, &sie_block->cpuflags);
216 else
217 sie_block->ictl &= ~(ICTL_ISKE | ICTL_SSKE |
218 ICTL_RRBE);
219 }
213 return rc;
214}
215
216static int try_handle_skey(struct kvm_vcpu *vcpu)
217{
218 int rc;
219
220 vcpu->stat.instruction_storage_key++;
220 return rc;
221}
222
223static int try_handle_skey(struct kvm_vcpu *vcpu)
224{
225 int rc;
226
227 vcpu->stat.instruction_storage_key++;
221 rc = __skey_check_enable(vcpu);
228 rc = kvm_s390_skey_check_enable(vcpu);
222 if (rc)
223 return rc;
224 if (sclp.has_skey) {
225 /* with storage-key facility, SIE interprets it for us */
226 kvm_s390_retry_instr(vcpu);
227 VCPU_EVENT(vcpu, 4, "%s", "retrying storage key operation");
228 return -EAGAIN;
229 }

--- 681 unchanged lines hidden (view full) ---

911 return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
912
913 if (vcpu->run->s.regs.gprs[reg1] & PFMF_CF) {
914 if (clear_user((void __user *)useraddr, PAGE_SIZE))
915 return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
916 }
917
918 if (vcpu->run->s.regs.gprs[reg1] & PFMF_SK) {
229 if (rc)
230 return rc;
231 if (sclp.has_skey) {
232 /* with storage-key facility, SIE interprets it for us */
233 kvm_s390_retry_instr(vcpu);
234 VCPU_EVENT(vcpu, 4, "%s", "retrying storage key operation");
235 return -EAGAIN;
236 }

--- 681 unchanged lines hidden (view full) ---

918 return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
919
920 if (vcpu->run->s.regs.gprs[reg1] & PFMF_CF) {
921 if (clear_user((void __user *)useraddr, PAGE_SIZE))
922 return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
923 }
924
925 if (vcpu->run->s.regs.gprs[reg1] & PFMF_SK) {
919 int rc = __skey_check_enable(vcpu);
926 int rc = kvm_s390_skey_check_enable(vcpu);
920
921 if (rc)
922 return rc;
923 down_read(&current->mm->mmap_sem);
924 rc = cond_set_guest_storage_key(current->mm, useraddr,
925 key, NULL, nq, mr, mc);
926 up_read(&current->mm->mmap_sem);
927 if (rc < 0)

--- 333 unchanged lines hidden ---
927
928 if (rc)
929 return rc;
930 down_read(&current->mm->mmap_sem);
931 rc = cond_set_guest_storage_key(current->mm, useraddr,
932 key, NULL, nq, mr, mc);
933 up_read(&current->mm->mmap_sem);
934 if (rc < 0)

--- 333 unchanged lines hidden ---