linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] KVM: PPC: Book3S HV: Refactor HFSCR emulation for KVM guests
@ 2024-07-16 11:52 Gautam Menghani
  2024-07-18  3:51 ` Madhavan Srinivasan
  2024-08-13 12:44 ` Michael Ellerman
  0 siblings, 2 replies; 3+ messages in thread
From: Gautam Menghani @ 2024-07-16 11:52 UTC (permalink / raw)
  To: mpe, npiggin, christophe.leroy, naveen.n.rao
  Cc: Gautam Menghani, linuxppc-dev, linux-kernel, kvm

Refactor HFSCR emulation for KVM guests when they exit out with
H_FAC_UNAVAIL to use a switch case instead of checking all "cause"
values, since the "cause" values are mutually exclusive; and this is 
better expressed with a switch case.

Signed-off-by: Gautam Menghani <gautam@linux.ibm.com>
---
V1 -> V2:
1. Reword changelog to point out mutual exclusivity of HFSCR bits.
2. Reword commit message to match other commits in book3s_hv.c

 arch/powerpc/kvm/book3s_hv.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index daaf7faf21a5..50797b0611a2 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -1922,14 +1922,22 @@ static int kvmppc_handle_exit_hv(struct kvm_vcpu *vcpu,
 
 		r = EMULATE_FAIL;
 		if (cpu_has_feature(CPU_FTR_ARCH_300)) {
-			if (cause == FSCR_MSGP_LG)
+			switch (cause) {
+			case FSCR_MSGP_LG:
 				r = kvmppc_emulate_doorbell_instr(vcpu);
-			if (cause == FSCR_PM_LG)
+				break;
+			case FSCR_PM_LG:
 				r = kvmppc_pmu_unavailable(vcpu);
-			if (cause == FSCR_EBB_LG)
+				break;
+			case FSCR_EBB_LG:
 				r = kvmppc_ebb_unavailable(vcpu);
-			if (cause == FSCR_TM_LG)
+				break;
+			case FSCR_TM_LG:
 				r = kvmppc_tm_unavailable(vcpu);
+				break;
+			default:
+				break;
+			}
 		}
 		if (r == EMULATE_FAIL) {
 			kvmppc_core_queue_program(vcpu, SRR1_PROGILL |
-- 
2.45.1


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

* Re: [PATCH v2] KVM: PPC: Book3S HV: Refactor HFSCR emulation for KVM guests
  2024-07-16 11:52 [PATCH v2] KVM: PPC: Book3S HV: Refactor HFSCR emulation for KVM guests Gautam Menghani
@ 2024-07-18  3:51 ` Madhavan Srinivasan
  2024-08-13 12:44 ` Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Madhavan Srinivasan @ 2024-07-18  3:51 UTC (permalink / raw)
  To: Gautam Menghani, mpe, npiggin, christophe.leroy, naveen.n.rao
  Cc: linuxppc-dev, linux-kernel, kvm


On 7/16/24 5:22 PM, Gautam Menghani wrote:
> Refactor HFSCR emulation for KVM guests when they exit out with
> H_FAC_UNAVAIL to use a switch case instead of checking all "cause"
> values, since the "cause" values are mutually exclusive; and this is
> better expressed with a switch case.
>
> Signed-off-by: Gautam Menghani <gautam@linux.ibm.com>
> ---
> V1 -> V2:
> 1. Reword changelog to point out mutual exclusivity of HFSCR bits.
> 2. Reword commit message to match other commits in book3s_hv.c


Minor: I guess you mean "Reword the subject line"

Reviewed-by: Madhavan Srinivasan <maddy@linux.ibm.com>



>
>   arch/powerpc/kvm/book3s_hv.c | 16 ++++++++++++----
>   1 file changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
> index daaf7faf21a5..50797b0611a2 100644
> --- a/arch/powerpc/kvm/book3s_hv.c
> +++ b/arch/powerpc/kvm/book3s_hv.c
> @@ -1922,14 +1922,22 @@ static int kvmppc_handle_exit_hv(struct kvm_vcpu *vcpu,
>   
>   		r = EMULATE_FAIL;
>   		if (cpu_has_feature(CPU_FTR_ARCH_300)) {
> -			if (cause == FSCR_MSGP_LG)
> +			switch (cause) {
> +			case FSCR_MSGP_LG:
>   				r = kvmppc_emulate_doorbell_instr(vcpu);
> -			if (cause == FSCR_PM_LG)
> +				break;
> +			case FSCR_PM_LG:
>   				r = kvmppc_pmu_unavailable(vcpu);
> -			if (cause == FSCR_EBB_LG)
> +				break;
> +			case FSCR_EBB_LG:
>   				r = kvmppc_ebb_unavailable(vcpu);
> -			if (cause == FSCR_TM_LG)
> +				break;
> +			case FSCR_TM_LG:
>   				r = kvmppc_tm_unavailable(vcpu);
> +				break;
> +			default:
> +				break;
> +			}
>   		}
>   		if (r == EMULATE_FAIL) {
>   			kvmppc_core_queue_program(vcpu, SRR1_PROGILL |

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

* Re: [PATCH v2] KVM: PPC: Book3S HV: Refactor HFSCR emulation for KVM guests
  2024-07-16 11:52 [PATCH v2] KVM: PPC: Book3S HV: Refactor HFSCR emulation for KVM guests Gautam Menghani
  2024-07-18  3:51 ` Madhavan Srinivasan
@ 2024-08-13 12:44 ` Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2024-08-13 12:44 UTC (permalink / raw)
  To: mpe, npiggin, christophe.leroy, Naveen N Rao, Gautam Menghani
  Cc: linuxppc-dev, kvm, linux-kernel

On Tue, 16 Jul 2024 17:22:04 +0530, Gautam Menghani wrote:
> Refactor HFSCR emulation for KVM guests when they exit out with
> H_FAC_UNAVAIL to use a switch case instead of checking all "cause"
> values, since the "cause" values are mutually exclusive; and this is
> better expressed with a switch case.
> 
> 

Applied to powerpc/topic/ppc-kvm.

[1/1] KVM: PPC: Book3S HV: Refactor HFSCR emulation for KVM guests
      https://git.kernel.org/powerpc/c/9739ff4887c77a38575c23b12766b0a37c8be13c

cheers


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

end of thread, other threads:[~2024-08-13 12:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-16 11:52 [PATCH v2] KVM: PPC: Book3S HV: Refactor HFSCR emulation for KVM guests Gautam Menghani
2024-07-18  3:51 ` Madhavan Srinivasan
2024-08-13 12:44 ` Michael Ellerman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).