All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] target/ppc: Fix nested-hv HEAI delivery
@ 2023-05-05 12:56 Nicholas Piggin
  2023-05-05 13:36 ` Fabiano Rosas
  2023-05-05 16:06 ` BALATON Zoltan
  0 siblings, 2 replies; 3+ messages in thread
From: Nicholas Piggin @ 2023-05-05 12:56 UTC (permalink / raw)
  To: qemu-ppc; +Cc: Nicholas Piggin, qemu-devel

ppc hypervisors turn HEAI interrupts into program interrupts injected
into the guest that executed the illegal instruction, if the hypervisor
doesn't handle it some other way.

The nexted-hv implementation failed to account for this HEAI->program
conversion. The virtual hypervisor wants to see the HEAI when running
a nested guest, so that interrupt type can be returned to its KVM
caller.

Fixes: 7cebc5db2eba6 ("target/ppc: Introduce a vhyp framework for nested HV support")
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 target/ppc/excp_helper.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c
index 199328f4b6..a833efa8f9 100644
--- a/target/ppc/excp_helper.c
+++ b/target/ppc/excp_helper.c
@@ -1358,10 +1358,13 @@ static void powerpc_excp_books(PowerPCCPU *cpu, int excp)
 
     /*
      * We don't want to generate a Hypervisor Emulation Assistance
-     * Interrupt if we don't have HVB in msr_mask (PAPR mode).
+     * Interrupt if we don't have HVB in msr_mask (PAPR mode),
+     * unless running a nested-hv guest, in which case the L1
+     * kernel wants the interrupt.
      */
     if (excp == POWERPC_EXCP_HV_EMU && !(env->msr_mask & MSR_HVB)) {
-        excp = POWERPC_EXCP_PROGRAM;
+        if (!books_vhyp_handles_hv_excp(cpu))
+            excp = POWERPC_EXCP_PROGRAM;
     }
 
     vector = env->excp_vectors[excp];
-- 
2.40.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] target/ppc: Fix nested-hv HEAI delivery
  2023-05-05 12:56 [PATCH] target/ppc: Fix nested-hv HEAI delivery Nicholas Piggin
@ 2023-05-05 13:36 ` Fabiano Rosas
  2023-05-05 16:06 ` BALATON Zoltan
  1 sibling, 0 replies; 3+ messages in thread
From: Fabiano Rosas @ 2023-05-05 13:36 UTC (permalink / raw)
  To: Nicholas Piggin, qemu-ppc; +Cc: Nicholas Piggin, qemu-devel

Nicholas Piggin <npiggin@gmail.com> writes:

> ppc hypervisors turn HEAI interrupts into program interrupts injected
> into the guest that executed the illegal instruction, if the hypervisor
> doesn't handle it some other way.
>
> The nexted-hv implementation failed to account for this HEAI->program
> conversion. The virtual hypervisor wants to see the HEAI when running
> a nested guest, so that interrupt type can be returned to its KVM
> caller.
>
> Fixes: 7cebc5db2eba6 ("target/ppc: Introduce a vhyp framework for nested HV support")
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>

Reviewed-by: Fabiano Rosas <farosas@suse.de>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] target/ppc: Fix nested-hv HEAI delivery
  2023-05-05 12:56 [PATCH] target/ppc: Fix nested-hv HEAI delivery Nicholas Piggin
  2023-05-05 13:36 ` Fabiano Rosas
@ 2023-05-05 16:06 ` BALATON Zoltan
  1 sibling, 0 replies; 3+ messages in thread
From: BALATON Zoltan @ 2023-05-05 16:06 UTC (permalink / raw)
  To: Nicholas Piggin; +Cc: qemu-ppc, qemu-devel

On Fri, 5 May 2023, Nicholas Piggin wrote:
> ppc hypervisors turn HEAI interrupts into program interrupts injected
> into the guest that executed the illegal instruction, if the hypervisor
> doesn't handle it some other way.
>
> The nexted-hv implementation failed to account for this HEAI->program

Typo: nested-hv?

> conversion. The virtual hypervisor wants to see the HEAI when running
> a nested guest, so that interrupt type can be returned to its KVM
> caller.
>
> Fixes: 7cebc5db2eba6 ("target/ppc: Introduce a vhyp framework for nested HV support")
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
> target/ppc/excp_helper.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c
> index 199328f4b6..a833efa8f9 100644
> --- a/target/ppc/excp_helper.c
> +++ b/target/ppc/excp_helper.c
> @@ -1358,10 +1358,13 @@ static void powerpc_excp_books(PowerPCCPU *cpu, int excp)
>
>     /*
>      * We don't want to generate a Hypervisor Emulation Assistance
> -     * Interrupt if we don't have HVB in msr_mask (PAPR mode).
> +     * Interrupt if we don't have HVB in msr_mask (PAPR mode),
> +     * unless running a nested-hv guest, in which case the L1
> +     * kernel wants the interrupt.
>      */
>     if (excp == POWERPC_EXCP_HV_EMU && !(env->msr_mask & MSR_HVB)) {
> -        excp = POWERPC_EXCP_PROGRAM;
> +        if (!books_vhyp_handles_hv_excp(cpu))

You could instead write:

      if (excp == POWERPC_EXCP_HV_EMU && !(env->msr_mask & MSR_HVB) &&
          !books_vhyp_handles_hv_excp(cpu)) {

Regards.
BALATON Zoltan

> +            excp = POWERPC_EXCP_PROGRAM;
>     }
>
>     vector = env->excp_vectors[excp];
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-05-05 16:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-05 12:56 [PATCH] target/ppc: Fix nested-hv HEAI delivery Nicholas Piggin
2023-05-05 13:36 ` Fabiano Rosas
2023-05-05 16:06 ` BALATON Zoltan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.