android_kernel_xiaomi_sm8450/arch/s390/kvm
Claudio Imbrenda 9d216035d1 KVM: s390: pv: leak the topmost page table when destroy fails
[ Upstream commit faa2f72cb3569256480c5540d242c84e99965160 ]

Each secure guest must have a unique ASCE (address space control
element); we must avoid that new guests use the same page for their
ASCE, to avoid errors.

Since the ASCE mostly consists of the address of the topmost page table
(plus some flags), we must not return that memory to the pool unless
the ASCE is no longer in use.

Only a successful Destroy Secure Configuration UVC will make the ASCE
reusable again.

If the Destroy Configuration UVC fails, the ASCE cannot be reused for a
secure guest (either for the ASCE or for other memory areas). To avoid
a collision, it must not be used again. This is a permanent error and
the page becomes in practice unusable, so we set it aside and leak it.
On failure we already leak other memory that belongs to the ultravisor
(i.e. the variable and base storage for a guest) and not leaking the
topmost page table was an oversight.

This error (and thus the leakage) should not happen unless the hardware
is broken or KVM has some unknown serious bug.

Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Fixes: 29b40f105e ("KVM: s390: protvirt: Add initial vm and cpu lifecycle handling")
Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
Link: https://lore.kernel.org/r/20220628135619.32410-2-imbrenda@linux.ibm.com
Message-Id: <20220628135619.32410-2-imbrenda@linux.ibm.com>
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-08-21 15:15:58 +02:00
..
diag.c mm: remove unneeded includes of <asm/pgalloc.h> 2020-08-07 11:33:26 -07:00
gaccess.c KVM: s390: extend kvm_s390_shadow_fault to return entry pointer 2021-05-14 09:50:03 +02:00
gaccess.h KVM: s390: extend kvm_s390_shadow_fault to return entry pointer 2021-05-14 09:50:03 +02:00
guestdbg.c KVM: s390: introduce defines for control registers 2018-05-17 09:02:27 +02:00
intercept.c KVM: s390: pv: don't present the ecall interrupt twice 2022-08-21 15:15:20 +02:00
interrupt.c KVM: s390: Clarify SIGP orders versus STOP/RESTART 2022-01-20 09:17:50 +01:00
irq.h KVM: s390: Remove redundant license text 2017-12-06 09:18:42 +01:00
Kconfig treewide: replace '---help---' in Kconfig files with 'help' 2020-06-14 01:57:21 +09:00
kvm-s390.c KVM: s390: Return error on SIDA memop on normal guest 2022-02-11 09:09:03 +01:00
kvm-s390.h KVM: s390: Clarify SIGP orders versus STOP/RESTART 2022-01-20 09:17:50 +01:00
Makefile KVM: s390: protvirt: Add initial vm and cpu lifecycle handling 2020-02-27 19:47:11 +01:00
priv.c KVM: s390: Fix handle_sske page fault handling 2021-11-18 14:04:11 +01:00
pv.c KVM: s390: pv: leak the topmost page table when destroy fails 2022-08-21 15:15:58 +02:00
sigp.c KVM: s390: pv: don't present the ecall interrupt twice 2022-08-21 15:15:20 +02:00
trace-s390.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
trace.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
vsie.c KVM: s390: extend kvm_s390_shadow_fault to return entry pointer 2021-05-14 09:50:03 +02:00