Commit 173ede4d authored by Paolo Bonzini's avatar Paolo Bonzini

Merge tag 'kvm-s390-next-20141107' of...

Merge tag 'kvm-s390-next-20141107' of git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux into HEAD

KVM: s390: Fixes for kvm/next (3.19) and stable

1. We should flush TLBs for load control instruction emulation (stable)
2. A workaround for a compiler bug that renders ACCESS_ONCE broken (stable)
3. Fix program check handling for load control
4. Documentation Fix
parents c6338ce4 365dc163
...@@ -12,14 +12,14 @@ specific. ...@@ -12,14 +12,14 @@ specific.
1. GROUP: KVM_S390_VM_MEM_CTRL 1. GROUP: KVM_S390_VM_MEM_CTRL
Architectures: s390 Architectures: s390
1.1. ATTRIBUTE: KVM_S390_VM_MEM_CTRL 1.1. ATTRIBUTE: KVM_S390_VM_MEM_ENABLE_CMMA
Parameters: none Parameters: none
Returns: -EBUSY if already a vcpus is defined, otherwise 0 Returns: -EBUSY if a vcpu is already defined, otherwise 0
Enables CMMA for the virtual machine Enables Collaborative Memory Management Assist (CMMA) for the virtual machine.
1.2. ATTRIBUTE: KVM_S390_VM_CLR_CMMA 1.2. ATTRIBUTE: KVM_S390_VM_MEM_CLR_CMMA
Parameteres: none Parameters: none
Returns: 0 Returns: 0
Clear the CMMA status for all guest pages, so any pages the guest marked Clear the CMMA status for all guest pages, so any pages the guest marked
......
...@@ -227,10 +227,12 @@ static void ipte_lock_simple(struct kvm_vcpu *vcpu) ...@@ -227,10 +227,12 @@ static void ipte_lock_simple(struct kvm_vcpu *vcpu)
goto out; goto out;
ic = &vcpu->kvm->arch.sca->ipte_control; ic = &vcpu->kvm->arch.sca->ipte_control;
do { do {
old = ACCESS_ONCE(*ic); old = *ic;
barrier();
while (old.k) { while (old.k) {
cond_resched(); cond_resched();
old = ACCESS_ONCE(*ic); old = *ic;
barrier();
} }
new = old; new = old;
new.k = 1; new.k = 1;
...@@ -249,7 +251,9 @@ static void ipte_unlock_simple(struct kvm_vcpu *vcpu) ...@@ -249,7 +251,9 @@ static void ipte_unlock_simple(struct kvm_vcpu *vcpu)
goto out; goto out;
ic = &vcpu->kvm->arch.sca->ipte_control; ic = &vcpu->kvm->arch.sca->ipte_control;
do { do {
new = old = ACCESS_ONCE(*ic); old = *ic;
barrier();
new = old;
new.k = 0; new.k = 0;
} while (cmpxchg(&ic->val, old.val, new.val) != old.val); } while (cmpxchg(&ic->val, old.val, new.val) != old.val);
wake_up(&vcpu->kvm->arch.ipte_wq); wake_up(&vcpu->kvm->arch.ipte_wq);
...@@ -263,10 +267,12 @@ static void ipte_lock_siif(struct kvm_vcpu *vcpu) ...@@ -263,10 +267,12 @@ static void ipte_lock_siif(struct kvm_vcpu *vcpu)
ic = &vcpu->kvm->arch.sca->ipte_control; ic = &vcpu->kvm->arch.sca->ipte_control;
do { do {
old = ACCESS_ONCE(*ic); old = *ic;
barrier();
while (old.kg) { while (old.kg) {
cond_resched(); cond_resched();
old = ACCESS_ONCE(*ic); old = *ic;
barrier();
} }
new = old; new = old;
new.k = 1; new.k = 1;
...@@ -280,7 +286,9 @@ static void ipte_unlock_siif(struct kvm_vcpu *vcpu) ...@@ -280,7 +286,9 @@ static void ipte_unlock_siif(struct kvm_vcpu *vcpu)
ic = &vcpu->kvm->arch.sca->ipte_control; ic = &vcpu->kvm->arch.sca->ipte_control;
do { do {
new = old = ACCESS_ONCE(*ic); old = *ic;
barrier();
new = old;
new.kh--; new.kh--;
if (!new.kh) if (!new.kh)
new.k = 0; new.k = 0;
......
...@@ -762,8 +762,8 @@ int kvm_s390_handle_lctl(struct kvm_vcpu *vcpu) ...@@ -762,8 +762,8 @@ int kvm_s390_handle_lctl(struct kvm_vcpu *vcpu)
{ {
int reg1 = (vcpu->arch.sie_block->ipa & 0x00f0) >> 4; int reg1 = (vcpu->arch.sie_block->ipa & 0x00f0) >> 4;
int reg3 = vcpu->arch.sie_block->ipa & 0x000f; int reg3 = vcpu->arch.sie_block->ipa & 0x000f;
u32 val = 0; int reg, rc, nr_regs;
int reg, rc; u32 ctl_array[16];
u64 ga; u64 ga;
vcpu->stat.instruction_lctl++; vcpu->stat.instruction_lctl++;
...@@ -779,19 +779,20 @@ int kvm_s390_handle_lctl(struct kvm_vcpu *vcpu) ...@@ -779,19 +779,20 @@ int kvm_s390_handle_lctl(struct kvm_vcpu *vcpu)
VCPU_EVENT(vcpu, 5, "lctl r1:%x, r3:%x, addr:%llx", reg1, reg3, ga); VCPU_EVENT(vcpu, 5, "lctl r1:%x, r3:%x, addr:%llx", reg1, reg3, ga);
trace_kvm_s390_handle_lctl(vcpu, 0, reg1, reg3, ga); trace_kvm_s390_handle_lctl(vcpu, 0, reg1, reg3, ga);
reg = reg1; nr_regs = ((reg3 - reg1) & 0xf) + 1;
do { rc = read_guest(vcpu, ga, ctl_array, nr_regs * sizeof(u32));
rc = read_guest(vcpu, ga, &val, sizeof(val));
if (rc) if (rc)
return kvm_s390_inject_prog_cond(vcpu, rc); return kvm_s390_inject_prog_cond(vcpu, rc);
reg = reg1;
nr_regs = 0;
do {
vcpu->arch.sie_block->gcr[reg] &= 0xffffffff00000000ul; vcpu->arch.sie_block->gcr[reg] &= 0xffffffff00000000ul;
vcpu->arch.sie_block->gcr[reg] |= val; vcpu->arch.sie_block->gcr[reg] |= ctl_array[nr_regs++];
ga += 4;
if (reg == reg3) if (reg == reg3)
break; break;
reg = (reg + 1) % 16; reg = (reg + 1) % 16;
} while (1); } while (1);
kvm_make_request(KVM_REQ_TLB_FLUSH, vcpu);
return 0; return 0;
} }
...@@ -799,9 +800,9 @@ int kvm_s390_handle_stctl(struct kvm_vcpu *vcpu) ...@@ -799,9 +800,9 @@ int kvm_s390_handle_stctl(struct kvm_vcpu *vcpu)
{ {
int reg1 = (vcpu->arch.sie_block->ipa & 0x00f0) >> 4; int reg1 = (vcpu->arch.sie_block->ipa & 0x00f0) >> 4;
int reg3 = vcpu->arch.sie_block->ipa & 0x000f; int reg3 = vcpu->arch.sie_block->ipa & 0x000f;
int reg, rc, nr_regs;
u32 ctl_array[16];
u64 ga; u64 ga;
u32 val;
int reg, rc;
vcpu->stat.instruction_stctl++; vcpu->stat.instruction_stctl++;
...@@ -817,26 +818,24 @@ int kvm_s390_handle_stctl(struct kvm_vcpu *vcpu) ...@@ -817,26 +818,24 @@ int kvm_s390_handle_stctl(struct kvm_vcpu *vcpu)
trace_kvm_s390_handle_stctl(vcpu, 0, reg1, reg3, ga); trace_kvm_s390_handle_stctl(vcpu, 0, reg1, reg3, ga);
reg = reg1; reg = reg1;
nr_regs = 0;
do { do {
val = vcpu->arch.sie_block->gcr[reg] & 0x00000000fffffffful; ctl_array[nr_regs++] = vcpu->arch.sie_block->gcr[reg];
rc = write_guest(vcpu, ga, &val, sizeof(val));
if (rc)
return kvm_s390_inject_prog_cond(vcpu, rc);
ga += 4;
if (reg == reg3) if (reg == reg3)
break; break;
reg = (reg + 1) % 16; reg = (reg + 1) % 16;
} while (1); } while (1);
rc = write_guest(vcpu, ga, ctl_array, nr_regs * sizeof(u32));
return 0; return rc ? kvm_s390_inject_prog_cond(vcpu, rc) : 0;
} }
static int handle_lctlg(struct kvm_vcpu *vcpu) static int handle_lctlg(struct kvm_vcpu *vcpu)
{ {
int reg1 = (vcpu->arch.sie_block->ipa & 0x00f0) >> 4; int reg1 = (vcpu->arch.sie_block->ipa & 0x00f0) >> 4;
int reg3 = vcpu->arch.sie_block->ipa & 0x000f; int reg3 = vcpu->arch.sie_block->ipa & 0x000f;
u64 ga, val; int reg, rc, nr_regs;
int reg, rc; u64 ctl_array[16];
u64 ga;
vcpu->stat.instruction_lctlg++; vcpu->stat.instruction_lctlg++;
...@@ -848,22 +847,22 @@ static int handle_lctlg(struct kvm_vcpu *vcpu) ...@@ -848,22 +847,22 @@ static int handle_lctlg(struct kvm_vcpu *vcpu)
if (ga & 7) if (ga & 7)
return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
reg = reg1;
VCPU_EVENT(vcpu, 5, "lctlg r1:%x, r3:%x, addr:%llx", reg1, reg3, ga); VCPU_EVENT(vcpu, 5, "lctlg r1:%x, r3:%x, addr:%llx", reg1, reg3, ga);
trace_kvm_s390_handle_lctl(vcpu, 1, reg1, reg3, ga); trace_kvm_s390_handle_lctl(vcpu, 1, reg1, reg3, ga);
do { nr_regs = ((reg3 - reg1) & 0xf) + 1;
rc = read_guest(vcpu, ga, &val, sizeof(val)); rc = read_guest(vcpu, ga, ctl_array, nr_regs * sizeof(u64));
if (rc) if (rc)
return kvm_s390_inject_prog_cond(vcpu, rc); return kvm_s390_inject_prog_cond(vcpu, rc);
vcpu->arch.sie_block->gcr[reg] = val; reg = reg1;
ga += 8; nr_regs = 0;
do {
vcpu->arch.sie_block->gcr[reg] = ctl_array[nr_regs++];
if (reg == reg3) if (reg == reg3)
break; break;
reg = (reg + 1) % 16; reg = (reg + 1) % 16;
} while (1); } while (1);
kvm_make_request(KVM_REQ_TLB_FLUSH, vcpu);
return 0; return 0;
} }
...@@ -871,8 +870,9 @@ static int handle_stctg(struct kvm_vcpu *vcpu) ...@@ -871,8 +870,9 @@ static int handle_stctg(struct kvm_vcpu *vcpu)
{ {
int reg1 = (vcpu->arch.sie_block->ipa & 0x00f0) >> 4; int reg1 = (vcpu->arch.sie_block->ipa & 0x00f0) >> 4;
int reg3 = vcpu->arch.sie_block->ipa & 0x000f; int reg3 = vcpu->arch.sie_block->ipa & 0x000f;
u64 ga, val; int reg, rc, nr_regs;
int reg, rc; u64 ctl_array[16];
u64 ga;
vcpu->stat.instruction_stctg++; vcpu->stat.instruction_stctg++;
...@@ -884,23 +884,19 @@ static int handle_stctg(struct kvm_vcpu *vcpu) ...@@ -884,23 +884,19 @@ static int handle_stctg(struct kvm_vcpu *vcpu)
if (ga & 7) if (ga & 7)
return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
reg = reg1;
VCPU_EVENT(vcpu, 5, "stctg r1:%x, r3:%x, addr:%llx", reg1, reg3, ga); VCPU_EVENT(vcpu, 5, "stctg r1:%x, r3:%x, addr:%llx", reg1, reg3, ga);
trace_kvm_s390_handle_stctl(vcpu, 1, reg1, reg3, ga); trace_kvm_s390_handle_stctl(vcpu, 1, reg1, reg3, ga);
reg = reg1;
nr_regs = 0;
do { do {
val = vcpu->arch.sie_block->gcr[reg]; ctl_array[nr_regs++] = vcpu->arch.sie_block->gcr[reg];
rc = write_guest(vcpu, ga, &val, sizeof(val));
if (rc)
return kvm_s390_inject_prog_cond(vcpu, rc);
ga += 8;
if (reg == reg3) if (reg == reg3)
break; break;
reg = (reg + 1) % 16; reg = (reg + 1) % 16;
} while (1); } while (1);
rc = write_guest(vcpu, ga, ctl_array, nr_regs * sizeof(u64));
return 0; return rc ? kvm_s390_inject_prog_cond(vcpu, rc) : 0;
} }
static const intercept_handler_t eb_handlers[256] = { static const intercept_handler_t eb_handlers[256] = {
......
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