[PATCH v2 0/2] Require hypervisor privilege for tlbie[l] when PSR=0 and HR=1.

matheus.ferst@eldorado.org.br posted 2 patches 2 years, 7 months ago
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20210917114751.206845-1-matheus.ferst@eldorado.org.br
Maintainers: David Gibson <david@gibson.dropbear.id.au>, Greg Kurz <groug@kaod.org>
target/ppc/cpu.h         |  1 +
target/ppc/helper_regs.c |  3 +++
target/ppc/translate.c   | 28 +++++++++++++++++++++++-----
3 files changed, 27 insertions(+), 5 deletions(-)
[PATCH v2 0/2] Require hypervisor privilege for tlbie[l] when PSR=0 and HR=1.
Posted by matheus.ferst@eldorado.org.br 2 years, 7 months ago
From: Matheus Ferst <matheus.ferst@eldorado.org.br>

While working on FreeBSD radix support, Leandro Lupori (CC'ed) noticed
that the latest build still fails in KVM but works in TCG[1]. This
difference occurs because the current implementation of "tlbiel" does
not validate the instruction parameters and always check for supervisor
privilege.

This patch series partially address this problem by requiring hypervisor
privilege for radix mode when PSR=0. The validation of other parameters
can be done when we move storage control instructions to decodetree.

[1] To reproduce the issue, grab an ISO from [2] run qemu as

qemu-system-ppc64 -cpu power9 -m 2G \
    -machine pseries,cap-cfpc=broken,cap-sbbc=broken,cap-ibs=broken,cap-ccf-assist=off \
    -boot d -vga none -nographic -cdrom FreeBSD-14.0-CURRENT-powerpc-*.iso

or

qemu-system-ppc64 -cpu power9 -m 2G -enable-kvm \
    -machine pseries,cap-cfpc=broken,cap-sbbc=broken,cap-ibs=broken,cap-ccf-assist=off \
    -boot d -vga none -nographic -cdrom FreeBSD-14.0-CURRENT-powerpc-*.iso

Stop the boot at the prompt and use

OK set radix_mmu=1
OK boot

[2] https://download.freebsd.org/ftp/snapshots/powerpc/powerpc64/ISO-IMAGES/14.0/

Matheus Ferst (2):
  target/ppc: add LPCR[HR] to DisasContext and hflags
  target/ppc: Check privilege level based on PSR and LPCR[HR] in
    tlbie[l]

 target/ppc/cpu.h         |  1 +
 target/ppc/helper_regs.c |  3 +++
 target/ppc/translate.c   | 28 +++++++++++++++++++++++-----
 3 files changed, 27 insertions(+), 5 deletions(-)

-- 
2.25.1


Re: [PATCH v2 0/2] Require hypervisor privilege for tlbie[l] when PSR=0 and HR=1.
Posted by Daniel Henrique Barboza 2 years, 7 months ago

On 9/17/21 08:47, matheus.ferst@eldorado.org.br wrote:
> From: Matheus Ferst <matheus.ferst@eldorado.org.br>
> 
> While working on FreeBSD radix support, Leandro Lupori (CC'ed) noticed
> that the latest build still fails in KVM but works in TCG[1]. This
> difference occurs because the current implementation of "tlbiel" does
> not validate the instruction parameters and always check for supervisor
> privilege.
> 
> This patch series partially address this problem by requiring hypervisor
> privilege for radix mode when PSR=0. The validation of other parameters
> can be done when we move storage control instructions to decodetree.
> 
> [1] To reproduce the issue, grab an ISO from [2] run qemu as
> 
> qemu-system-ppc64 -cpu power9 -m 2G \
>      -machine pseries,cap-cfpc=broken,cap-sbbc=broken,cap-ibs=broken,cap-ccf-assist=off \
>      -boot d -vga none -nographic -cdrom FreeBSD-14.0-CURRENT-powerpc-*.iso
> 
> or
> 
> qemu-system-ppc64 -cpu power9 -m 2G -enable-kvm \
>      -machine pseries,cap-cfpc=broken,cap-sbbc=broken,cap-ibs=broken,cap-ccf-assist=off \
>      -boot d -vga none -nographic -cdrom FreeBSD-14.0-CURRENT-powerpc-*.iso
> 
> Stop the boot at the prompt and use
> 
> OK set radix_mmu=1
> OK boot
> 
> [2] https://download.freebsd.org/ftp/snapshots/powerpc/powerpc64/ISO-IMAGES/14.0/
> 
> Matheus Ferst (2):
>    target/ppc: add LPCR[HR] to DisasContext and hflags
>    target/ppc: Check privilege level based on PSR and LPCR[HR] in
>      tlbie[l]


For some reason I didn't receive these 2 patches in my mailbox, just this cover
letter. I reviewed both using the qemu-devel archives.


Both patches:

Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>



Thanks,


Daniel


> 
>   target/ppc/cpu.h         |  1 +
>   target/ppc/helper_regs.c |  3 +++
>   target/ppc/translate.c   | 28 +++++++++++++++++++++++-----
>   3 files changed, 27 insertions(+), 5 deletions(-)
> 

Re: [PATCH v2 0/2] Require hypervisor privilege for tlbie[l] when PSR=0 and HR=1.
Posted by David Gibson 2 years, 7 months ago
On Fri, Sep 17, 2021 at 08:47:49AM -0300, matheus.ferst@eldorado.org.br wrote:
> From: Matheus Ferst <matheus.ferst@eldorado.org.br>
> 
> While working on FreeBSD radix support, Leandro Lupori (CC'ed) noticed
> that the latest build still fails in KVM but works in TCG[1]. This
> difference occurs because the current implementation of "tlbiel" does
> not validate the instruction parameters and always check for supervisor
> privilege.
> 
> This patch series partially address this problem by requiring hypervisor
> privilege for radix mode when PSR=0. The validation of other parameters
> can be done when we move storage control instructions to decodetree.
> 
> [1] To reproduce the issue, grab an ISO from [2] run qemu as
> 
> qemu-system-ppc64 -cpu power9 -m 2G \
>     -machine pseries,cap-cfpc=broken,cap-sbbc=broken,cap-ibs=broken,cap-ccf-assist=off \
>     -boot d -vga none -nographic -cdrom FreeBSD-14.0-CURRENT-powerpc-*.iso
> 
> or
> 
> qemu-system-ppc64 -cpu power9 -m 2G -enable-kvm \
>     -machine pseries,cap-cfpc=broken,cap-sbbc=broken,cap-ibs=broken,cap-ccf-assist=off \
>     -boot d -vga none -nographic -cdrom FreeBSD-14.0-CURRENT-powerpc-*.iso
> 
> Stop the boot at the prompt and use
> 
> OK set radix_mmu=1
> OK boot
> 
> [2]
> https://download.freebsd.org/ftp/snapshots/powerpc/powerpc64/ISO-IMAGES/14.0/

Applied to ppc-for-6.2, thanks.

> 
> Matheus Ferst (2):
>   target/ppc: add LPCR[HR] to DisasContext and hflags
>   target/ppc: Check privilege level based on PSR and LPCR[HR] in
>     tlbie[l]
> 
>  target/ppc/cpu.h         |  1 +
>  target/ppc/helper_regs.c |  3 +++
>  target/ppc/translate.c   | 28 +++++++++++++++++++++++-----
>  3 files changed, 27 insertions(+), 5 deletions(-)
> 

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson