]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: arm64: Allow setting of ID_AA64PFR0_EL1.CSV2 from userspace
authorMarc Zyngier <maz@kernel.org>
Tue, 10 Nov 2020 14:13:06 +0000 (14:13 +0000)
committerMarc Zyngier <maz@kernel.org>
Thu, 12 Nov 2020 21:22:22 +0000 (21:22 +0000)
commit0ebb0c7def939b4d4accd4dec5681d9f475896b5
treeeebbef5dcbc9d2d098e1112c8c5149d1232daf5e
parent094c0ea6f74c8c0ec25cb11ac01d5b4e40ffe7cc
KVM: arm64: Allow setting of ID_AA64PFR0_EL1.CSV2 from userspace

We now expose ID_AA64PFR0_EL1.CSV2=1 to guests running on hosts
that are immune to Spectre-v2, but that don't have this field set,
most likely because they predate the specification.

However, this prevents the migration of guests that have started on
a host the doesn't fake this CSV2 setting to one that does, as KVM
rejects the write to ID_AA64PFR0_EL2 on the grounds that it isn't
what is already there.

In order to fix this, allow userspace to set this field as long as
this doesn't result in a promising more than what is already there
(setting CSV2 to 0 is acceptable, but setting it to 1 when it is
already set to 0 isn't).

Fixes: 1d6c752dce7f3 ("KVM: arm64: Set CSV2 for guests on hardware unaffected by Spectre-v2")
Reported-by: Peng Liang <liangpeng10@huawei.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Acked-by: Will Deacon <will@kernel.org>
Link: https://lore.kernel.org/r/20201110141308.451654-2-maz@kernel.org
arch/arm64/include/asm/kvm_host.h
arch/arm64/kvm/arm.c
arch/arm64/kvm/sys_regs.c