[PATCH v4 04/46] KVM: PPC: Book3S HV: Prevent radix guests from setting LPCR[TC]
Alexey Kardashevskiy
aik at ozlabs.ru
Tue Mar 23 19:36:54 AEDT 2021
On 23/03/2021 12:02, Nicholas Piggin wrote:
> This bit only applies to hash partitions.
>
> Signed-off-by: Nicholas Piggin <npiggin at gmail.com>
Reviewed-by: Alexey Kardashevskiy <aik at ozlabs.ru>
> ---
> arch/powerpc/kvm/book3s_hv.c | 6 ++++++
> arch/powerpc/kvm/book3s_hv_nested.c | 3 +--
> 2 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
> index c5de7e3f22b6..1ffb0902e779 100644
> --- a/arch/powerpc/kvm/book3s_hv.c
> +++ b/arch/powerpc/kvm/book3s_hv.c
> @@ -1645,6 +1645,12 @@ static int kvm_arch_vcpu_ioctl_set_sregs_hv(struct kvm_vcpu *vcpu,
> */
> unsigned long kvmppc_filter_lpcr_hv(struct kvmppc_vcore *vc, unsigned long lpcr)
> {
> + struct kvm *kvm = vc->kvm;
> +
> + /* LPCR_TC only applies to HPT guests */
> + if (kvm_is_radix(kvm))
> + lpcr &= ~LPCR_TC;
> +
> /* On POWER8 and above, userspace can modify AIL */
> if (!cpu_has_feature(CPU_FTR_ARCH_207S))
> lpcr &= ~LPCR_AIL;
> diff --git a/arch/powerpc/kvm/book3s_hv_nested.c b/arch/powerpc/kvm/book3s_hv_nested.c
> index f7b441b3eb17..851e3f527eb2 100644
> --- a/arch/powerpc/kvm/book3s_hv_nested.c
> +++ b/arch/powerpc/kvm/book3s_hv_nested.c
> @@ -140,8 +140,7 @@ static void sanitise_hv_regs(struct kvm_vcpu *vcpu, struct hv_guest_state *hr)
> /*
> * Don't let L1 change LPCR bits for the L2 except these:
> */
> - mask = LPCR_DPFD | LPCR_ILE | LPCR_TC | LPCR_AIL | LPCR_LD |
> - LPCR_LPES | LPCR_MER;
> + mask = LPCR_DPFD | LPCR_ILE | LPCR_AIL | LPCR_LD | LPCR_LPES | LPCR_MER;
> hr->lpcr = kvmppc_filter_lpcr_hv(vc,
> (vc->lpcr & ~mask) | (hr->lpcr & mask));
>
>
--
Alexey
More information about the Linuxppc-dev
mailing list