KVM: s390: Fix prefix register checking in arch/s390/kvm/sigp.c
commitf7b0fd208527e8f755e06411821efb5cc89c0868
authorCarsten Otte <carsteno@de.ibm.com>
Mon, 30 Nov 2009 16:14:41 +0000 (30 17:14 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 18 Dec 2009 22:03:34 +0000 (18 14:03 -0800)
tree2274eac7507fb3dee90b4943b4c21759e739ea54
parentb63569376aeca6300e10bf9e5ccfc49758407dbf
KVM: s390: Fix prefix register checking in arch/s390/kvm/sigp.c

commit f50146bd7bdb75435638e60d4960edd9bcdf88b8 upstream.

This patch corrects the checking of the new address for the prefix register.
On s390, the prefix register is used to address the cpu's lowcore (address
0...8k). This check is supposed to verify that the memory is readable and
present.
copy_from_guest is a helper function, that can be used to read from guest
memory. It applies prefixing, adds the start address of the guest memory in
user, and then calls copy_from_user. Previous code was obviously broken for
two reasons:
- prefixing should not be applied here. The current prefix register is
  going to be updated soon, and the address we're looking for will be
  0..8k after we've updated the register
- we're adding the guest origin (gmsor) twice: once in subject code
  and once in copy_from_guest

With kuli, we did not hit this problem because (a) we were lucky with
previous prefix register content, and (b) our guest memory was mmaped
very low into user address space.

Signed-off-by: Carsten Otte <cotte@de.ibm.com>
Reported-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
arch/s390/kvm/sigp.c