priv.c (f26e8817b235d8764363bffcc9cbfc61867371f2) priv.c (0b92515916799ca2711c7c46abccb96c275cc88a)
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.

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

27#include <asm/io.h>
28#include <asm/ptrace.h>
29#include <asm/compat.h>
30#include <asm/sclp.h>
31#include "gaccess.h"
32#include "kvm-s390.h"
33#include "trace.h"
34
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.

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

27#include <asm/io.h>
28#include <asm/ptrace.h>
29#include <asm/compat.h>
30#include <asm/sclp.h>
31#include "gaccess.h"
32#include "kvm-s390.h"
33#include "trace.h"
34
35static int handle_ri(struct kvm_vcpu *vcpu)
36{
37 if (test_kvm_facility(vcpu->kvm, 64)) {
38 vcpu->arch.sie_block->ecb3 |= 0x01;
39 kvm_s390_retry_instr(vcpu);
40 return 0;
41 } else
42 return kvm_s390_inject_program_int(vcpu, PGM_OPERATION);
43}
44
45int kvm_s390_handle_aa(struct kvm_vcpu *vcpu)
46{
47 if ((vcpu->arch.sie_block->ipa & 0xf) <= 4)
48 return handle_ri(vcpu);
49 else
50 return -EOPNOTSUPP;
51}
52
35/* Handle SCK (SET CLOCK) interception */
36static int handle_set_clock(struct kvm_vcpu *vcpu)
37{
38 int rc;
39 ar_t ar;
40 u64 op2, val;
41
42 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE)

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

288 down_read(&current->mm->mmap_sem);
289 rc = cond_set_guest_storage_key(current->mm, addr, key, &oldkey,
290 m3 & SSKE_NQ, m3 & SSKE_MR,
291 m3 & SSKE_MC);
292 up_read(&current->mm->mmap_sem);
293 if (rc < 0)
294 return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
295 start += PAGE_SIZE;
53/* Handle SCK (SET CLOCK) interception */
54static int handle_set_clock(struct kvm_vcpu *vcpu)
55{
56 int rc;
57 ar_t ar;
58 u64 op2, val;
59
60 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE)

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

306 down_read(&current->mm->mmap_sem);
307 rc = cond_set_guest_storage_key(current->mm, addr, key, &oldkey,
308 m3 & SSKE_NQ, m3 & SSKE_MR,
309 m3 & SSKE_MC);
310 up_read(&current->mm->mmap_sem);
311 if (rc < 0)
312 return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
313 start += PAGE_SIZE;
296 };
314 }
297
298 if (m3 & (SSKE_MC | SSKE_MR)) {
299 if (m3 & SSKE_MB) {
300 /* skey in reg1 is unpredictable */
301 kvm_s390_set_psw_cc(vcpu, 3);
302 } else {
303 kvm_s390_set_psw_cc(vcpu, rc);
304 vcpu->run->s.regs.gprs[reg1] &= ~0xff00UL;

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

1088 } while (1);
1089 rc = write_guest(vcpu, ga, ar, ctl_array, nr_regs * sizeof(u64));
1090 return rc ? kvm_s390_inject_prog_cond(vcpu, rc) : 0;
1091}
1092
1093static const intercept_handler_t eb_handlers[256] = {
1094 [0x2f] = handle_lctlg,
1095 [0x25] = handle_stctg,
315
316 if (m3 & (SSKE_MC | SSKE_MR)) {
317 if (m3 & SSKE_MB) {
318 /* skey in reg1 is unpredictable */
319 kvm_s390_set_psw_cc(vcpu, 3);
320 } else {
321 kvm_s390_set_psw_cc(vcpu, rc);
322 vcpu->run->s.regs.gprs[reg1] &= ~0xff00UL;

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

1106 } while (1);
1107 rc = write_guest(vcpu, ga, ar, ctl_array, nr_regs * sizeof(u64));
1108 return rc ? kvm_s390_inject_prog_cond(vcpu, rc) : 0;
1109}
1110
1111static const intercept_handler_t eb_handlers[256] = {
1112 [0x2f] = handle_lctlg,
1113 [0x25] = handle_stctg,
1114 [0x60] = handle_ri,
1115 [0x61] = handle_ri,
1116 [0x62] = handle_ri,
1096};
1097
1098int kvm_s390_handle_eb(struct kvm_vcpu *vcpu)
1099{
1100 intercept_handler_t handler;
1101
1102 handler = eb_handlers[vcpu->arch.sie_block->ipb & 0xff];
1103 if (handler)

--- 105 unchanged lines hidden ---
1117};
1118
1119int kvm_s390_handle_eb(struct kvm_vcpu *vcpu)
1120{
1121 intercept_handler_t handler;
1122
1123 handler = eb_handlers[vcpu->arch.sie_block->ipb & 0xff];
1124 if (handler)

--- 105 unchanged lines hidden ---