Commit 3edbcff9 authored by Carsten Otte's avatar Carsten Otte Committed by Avi Kivity

KVM: s390: Sanity check on validity intercept

This patch adds a sanity check for the content of the guest
prefix register content before faulting in the cpu lowcore
that it refers to. The guest might end up in an endless loop
where SIE complains about missing lowcore with incorrect
content of the prefix register without this fix.
Reported-by: default avatarMijo Safradin <mijo@linux.vnet.ibm.com>
Signed-off-by: default avatarCarsten Otte <cotte@de.ibm.com>
Signed-off-by: default avatarChristian Ehrhardt <ehrhardt@de.ibm.com>
Signed-off-by: default avatarAvi Kivity <avi@redhat.com>
parent abf4a71e
...@@ -154,17 +154,25 @@ static int handle_stop(struct kvm_vcpu *vcpu) ...@@ -154,17 +154,25 @@ static int handle_stop(struct kvm_vcpu *vcpu)
static int handle_validity(struct kvm_vcpu *vcpu) static int handle_validity(struct kvm_vcpu *vcpu)
{ {
int viwhy = vcpu->arch.sie_block->ipb >> 16; int viwhy = vcpu->arch.sie_block->ipb >> 16;
int rc;
vcpu->stat.exit_validity++; vcpu->stat.exit_validity++;
if (viwhy == 0x37) { if ((viwhy == 0x37) && (vcpu->arch.sie_block->prefix
fault_in_pages_writeable((char __user *) <= vcpu->kvm->arch.guest_memsize - 2*PAGE_SIZE)){
vcpu->kvm->arch.guest_origin + rc = fault_in_pages_writeable((char __user *)
vcpu->arch.sie_block->prefix, vcpu->kvm->arch.guest_origin +
PAGE_SIZE); vcpu->arch.sie_block->prefix,
return 0; 2*PAGE_SIZE);
} if (rc)
VCPU_EVENT(vcpu, 2, "unhandled validity intercept code %d", /* user will receive sigsegv, exit to user */
viwhy); rc = -ENOTSUPP;
return -ENOTSUPP; } else
rc = -ENOTSUPP;
if (rc)
VCPU_EVENT(vcpu, 2, "unhandled validity intercept code %d",
viwhy);
return rc;
} }
static int handle_instruction(struct kvm_vcpu *vcpu) static int handle_instruction(struct kvm_vcpu *vcpu)
......
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