Patchwork [V2] powerpc/kvm/book3s_hv: propagate H_SET_MODE_RESOURCE_LE to the host

login
register
mail settings
Submitter Laurent Dufour
Date Sept. 27, 2013, 1:59 p.m.
Message ID <20130927135930.10288.86526.stgit@nimbus>
Download mbox | patch
Permalink /patch/278590/
State Not Applicable
Headers show

Comments

Laurent Dufour - Sept. 27, 2013, 1:59 p.m.
Follow-up to Anton's H_SET_MODE patch, the host should be taken aware of
guest endianess change.

The hcall H_SET_MODE/H_SET_MODE_RESOURCE_LE is processed in kvm and then
propagated to the host.

v2: taking in account the Paul Mackerras's comment, using H_TOO_HARD to
propagate only H_SET_MODE_RESOURCE_LE to the host.

Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
---
 arch/powerpc/kvm/book3s_hv.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
Greg Kurz - Sept. 27, 2013, 2:45 p.m.
On Fri, 27 Sep 2013 15:59:30 +0200
Laurent Dufour <ldufour@linux.vnet.ibm.com> wrote:

> Follow-up to Anton's H_SET_MODE patch, the host should be taken aware
> of guest endianess change.
> 
> The hcall H_SET_MODE/H_SET_MODE_RESOURCE_LE is processed in kvm and
> then propagated to the host.
> 

Even if it seems a bit odd to get H_SET_MODE handled both by kvm and
qemu, it is a simple way to get the job done. Unless we expect tons of
calls to H_SET_MODE_RESOURCE_LE to occur, I do not see a better way for
the host code to know the guest endianess.

FYI, with this patch, Rusty's (Cc'ed) virtio endianess patchset for
qemu works like a charm: my guest kernel calls h_set_mode once at boot
time, qemu gets notified and keeps the information. Do we need more ?

> v2: taking in account the Paul Mackerras's comment, using H_TOO_HARD
> to propagate only H_SET_MODE_RESOURCE_LE to the host.
> 
> Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
> ---

Tested-by: Greg Kurz <gkurz@linux.vnet.ibm.com>

>  arch/powerpc/kvm/book3s_hv.c |    6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/powerpc/kvm/book3s_hv.c
> b/arch/powerpc/kvm/book3s_hv.c index 998cad3..be0af39 100644
> --- a/arch/powerpc/kvm/book3s_hv.c
> +++ b/arch/powerpc/kvm/book3s_hv.c
> @@ -523,14 +523,14 @@ static int kvmppc_h_set_mode(struct kvm_vcpu
> *vcpu, unsigned long mflags, kvm_for_each_vcpu(n, v, kvm)
>  				v->arch.intr_msr &= ~MSR_LE;
>  			kick_all_cpus_sync();
> -			return H_SUCCESS;
> +			return H_TOO_HARD; /* propagating to the
> host */
> 
>  		case 1:
>  			kvm->arch.lpcr |= LPCR_ILE;
>  			kvm_for_each_vcpu(n, v, kvm)
>  				v->arch.intr_msr |= MSR_LE;
>  			kick_all_cpus_sync();
> -			return H_SUCCESS;
> +			return H_TOO_HARD; /* propagating to the
> host */
> 
>  		default:
>  			return H_UNSUPPORTED_FLAG_START;
> @@ -599,6 +599,8 @@ int kvmppc_pseries_do_hcall(struct kvm_vcpu *vcpu)
>  					kvmppc_get_gpr(vcpu, 5),
>  					kvmppc_get_gpr(vcpu, 6),
>  					kvmppc_get_gpr(vcpu, 7));
> +		if (ret == H_TOO_HARD)
> +			return RESUME_HOST;
>  		break;
> 
>  	case H_XIRR:
> 
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
>

Patch

diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index 998cad3..be0af39 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -523,14 +523,14 @@  static int kvmppc_h_set_mode(struct kvm_vcpu *vcpu, unsigned long mflags,
 			kvm_for_each_vcpu(n, v, kvm)
 				v->arch.intr_msr &= ~MSR_LE;
 			kick_all_cpus_sync();
-			return H_SUCCESS;
+			return H_TOO_HARD; /* propagating to the host */
 
 		case 1:
 			kvm->arch.lpcr |= LPCR_ILE;
 			kvm_for_each_vcpu(n, v, kvm)
 				v->arch.intr_msr |= MSR_LE;
 			kick_all_cpus_sync();
-			return H_SUCCESS;
+			return H_TOO_HARD; /* propagating to the host */
 
 		default:
 			return H_UNSUPPORTED_FLAG_START;
@@ -599,6 +599,8 @@  int kvmppc_pseries_do_hcall(struct kvm_vcpu *vcpu)
 					kvmppc_get_gpr(vcpu, 5),
 					kvmppc_get_gpr(vcpu, 6),
 					kvmppc_get_gpr(vcpu, 7));
+		if (ret == H_TOO_HARD)
+			return RESUME_HOST;
 		break;
 
 	case H_XIRR: