public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: PPC: Fix contents of SRR1 when injecting a program exception in kvm-pr
@ 2016-05-19  8:44 Thomas Huth
  2016-05-19  9:04 ` Alexander Graf
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Huth @ 2016-05-19  8:44 UTC (permalink / raw)
  To: Alexander Graf, Paul Mackerras, kvm-ppc; +Cc: kvm, lvivier

vcpu->arch.shadow_srr1 only contains usable values for injecting
a program exception into the guest if we entered the function
kvmppc_handle_exit_pr() with exit_nr == BOOK3S_INTERRUPT_PROGRAM.
In other cases, the shadow_srr1 bits are zero. Since we want to
pass an illegal-instruction program check to the guest, set
"flags" to SRR1_PROGILL for these other cases.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 arch/powerpc/kvm/book3s_pr.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c
index 95bceca..b12e80a 100644
--- a/arch/powerpc/kvm/book3s_pr.c
+++ b/arch/powerpc/kvm/book3s_pr.c
@@ -1031,7 +1031,10 @@ int kvmppc_handle_exit_pr(struct kvm_run *run, struct kvm_vcpu *vcpu,
 		int emul;
 
 program_interrupt:
-		flags = vcpu->arch.shadow_srr1 & 0x1f0000ull;
+		if (exit_nr == BOOK3S_INTERRUPT_PROGRAM)
+			flags = vcpu->arch.shadow_srr1 & 0x1f0000ull;
+		else
+			flags = SRR1_PROGILL;
 
 		emul = kvmppc_get_last_inst(vcpu, INST_GENERIC, &last_inst);
 		if (emul != EMULATE_DONE) {
-- 
1.8.3.1


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

* Re: [PATCH] KVM: PPC: Fix contents of SRR1 when injecting a program exception in kvm-pr
  2016-05-19  8:44 [PATCH] KVM: PPC: Fix contents of SRR1 when injecting a program exception in kvm-pr Thomas Huth
@ 2016-05-19  9:04 ` Alexander Graf
  0 siblings, 0 replies; 2+ messages in thread
From: Alexander Graf @ 2016-05-19  9:04 UTC (permalink / raw)
  To: Thomas Huth, Alexander Graf, Paul Mackerras, kvm-ppc; +Cc: kvm, lvivier

On 05/19/2016 10:44 AM, Thomas Huth wrote:
> vcpu->arch.shadow_srr1 only contains usable values for injecting
> a program exception into the guest if we entered the function
> kvmppc_handle_exit_pr() with exit_nr == BOOK3S_INTERRUPT_PROGRAM.
> In other cases, the shadow_srr1 bits are zero. Since we want to
> pass an illegal-instruction program check to the guest, set
> "flags" to SRR1_PROGILL for these other cases.
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>

Looks good, but please add a comment that H_EMUL_ASSIST doesn't provide 
the flags inside the code ;)


Alex

> ---
>   arch/powerpc/kvm/book3s_pr.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c
> index 95bceca..b12e80a 100644
> --- a/arch/powerpc/kvm/book3s_pr.c
> +++ b/arch/powerpc/kvm/book3s_pr.c
> @@ -1031,7 +1031,10 @@ int kvmppc_handle_exit_pr(struct kvm_run *run, struct kvm_vcpu *vcpu,
>   		int emul;
>   
>   program_interrupt:
> -		flags = vcpu->arch.shadow_srr1 & 0x1f0000ull;
> +		if (exit_nr == BOOK3S_INTERRUPT_PROGRAM)
> +			flags = vcpu->arch.shadow_srr1 & 0x1f0000ull;
> +		else
> +			flags = SRR1_PROGILL;
>   
>   		emul = kvmppc_get_last_inst(vcpu, INST_GENERIC, &last_inst);
>   		if (emul != EMULATE_DONE) {


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

end of thread, other threads:[~2016-05-19  9:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-19  8:44 [PATCH] KVM: PPC: Fix contents of SRR1 when injecting a program exception in kvm-pr Thomas Huth
2016-05-19  9:04 ` Alexander Graf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox