]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: s390: fix memory overwrites when vx is disabled
authorDavid Hildenbrand <dahi@linux.vnet.ibm.com>
Thu, 14 Jan 2016 21:12:47 +0000 (22:12 +0100)
committerChristian Borntraeger <borntraeger@de.ibm.com>
Tue, 26 Jan 2016 14:40:21 +0000 (15:40 +0100)
commitd9c9124c2b377628f35c5397f95836665500e0d2
tree16b5d27bc327754fc87c261551c55dffd44497b3
parenta099e8ca707a5fa4899863ab02ae41c78d9321a8
KVM: s390: fix memory overwrites when vx is disabled

The kernel now always uses vector registers when available, however KVM
has special logic if support is really enabled for a guest. If support
is disabled, guest_fpregs.fregs will only contain memory for the fpu.
The kernel, however, will store vector registers into that area,
resulting in crazy memory overwrites.

Simply extending that area is not enough, because the format of the
registers also changes. We would have to do additional conversions, making
the code even more complex. Therefore let's directly use one place for
the vector/fpu registers + fpc (in kvm_run). We just have to convert the
data properly when accessing it. This makes current code much easier.

Please note that vector/fpu registers are now always stored to
vcpu->run->s.regs.vrs. Although this data is visible to QEMU and
used for migration, we only guarantee valid values to user space  when
KVM_SYNC_VRS is set. As that is only the case when we have vector
register support, we are on the safe side.

Fixes: 2ea76f7932df ("s390/fpu: always enable the vector facility if it is available")
Cc: stable@vger.kernel.org # v4.4 6dc641916c43 s390/kvm: remove dependency on struct save_area definition
Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
[adopt to 6dc641916c43]
arch/s390/include/asm/kvm_host.h
arch/s390/kvm/kvm-s390.c