From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35034) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpkt6-0004Ma-60 for qemu-devel@nongnu.org; Thu, 29 Sep 2016 19:37:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bpkt4-0006Dz-Sr for qemu-devel@nongnu.org; Thu, 29 Sep 2016 19:37:12 -0400 Date: Fri, 30 Sep 2016 09:23:09 +1000 From: David Gibson Message-ID: <20160929232309.GG30519@umbus.fritz.box> References: <1475146087-19865-1-git-send-email-thuth@redhat.com> <1475146087-19865-2-git-send-email-thuth@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="p7qwJlK53pWzbayA" Content-Disposition: inline In-Reply-To: <1475146087-19865-2-git-send-email-thuth@redhat.com> Subject: Re: [Qemu-devel] [PATCH 1/2] target-ppc/kvm: Add a wrapper function to check for KVM-PR List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Thomas Huth Cc: qemu-ppc@nongnu.org, Alexander Graf , qemu-devel@nongnu.org --p7qwJlK53pWzbayA Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Sep 29, 2016 at 12:48:06PM +0200, Thomas Huth wrote: > It makes more sense if we have a proper function to check > for KVM-PR than to check for the GET_PVINFO extension all > over the place. >=20 > Signed-off-by: Thomas Huth Applied to ppc-for-2.8. I expanded your comment to say this should only be used for fallback tests, though. > --- > target-ppc/kvm.c | 23 +++++++++++++---------- > 1 file changed, 13 insertions(+), 10 deletions(-) >=20 > diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c > index e9a9faf..dca50bc 100644 > --- a/target-ppc/kvm.c > +++ b/target-ppc/kvm.c > @@ -102,6 +102,13 @@ static void kvm_kick_cpu(void *opaque) > qemu_cpu_kick(CPU(cpu)); > } > =20 > +/* Check whether we are running with KVM-PR (instead of KVM-HV) */ > +static bool kvmppc_is_pr(KVMState *ks) > +{ > + /* Assume KVM-PR if the GET_PVINFO capability is available */ > + return kvm_check_extension(ks, KVM_CAP_PPC_GET_PVINFO) !=3D 0; > +} > + > static int kvm_ppc_register_host_cpu_type(void); > =20 > int kvm_arch_init(MachineState *ms, KVMState *s) > @@ -223,10 +230,9 @@ static void kvm_get_fallback_smmu_info(PowerPCCPU *c= pu, > * > * For that to work we make a few assumptions: > * > - * - If KVM_CAP_PPC_GET_PVINFO is supported we are running "PR" > - * KVM which only supports 4K and 16M pages, but supports them > - * regardless of the backing store characteritics. We also don't > - * support 1T segments. > + * - Check whether we are running "PR" KVM which only supports 4K > + * and 16M pages, but supports them regardless of the backing > + * store characteritics. We also don't support 1T segments. > * > * This is safe as if HV KVM ever supports that capability or PR > * KVM grows supports for more page/segment sizes, those versions > @@ -241,7 +247,7 @@ static void kvm_get_fallback_smmu_info(PowerPCCPU *cp= u, > * implements KVM_CAP_PPC_GET_SMMU_INFO and thus doesn't hit > * this fallback. > */ > - if (kvm_check_extension(cs->kvm_state, KVM_CAP_PPC_GET_PVINFO)) { > + if (kvmppc_is_pr(cs->kvm_state)) { > /* No flags */ > info->flags =3D 0; > info->slb_size =3D 64; > @@ -2270,11 +2276,8 @@ int kvmppc_reset_htab(int shift_hint) > =20 > /* We have a kernel that predates the htab reset calls. For PR > * KVM, we need to allocate the htab ourselves, for an HV KVM of > - * this era, it has allocated a 16MB fixed size hash table > - * already. Kernels of this era have the GET_PVINFO capability > - * only on PR, so we use this hack to determine the right > - * answer */ > - if (kvm_check_extension(kvm_state, KVM_CAP_PPC_GET_PVINFO)) { > + * this era, it has allocated a 16MB fixed size hash table already. = */ > + if (kvmppc_is_pr(kvm_state)) { > /* PR - tell caller to allocate htab */ > return 0; > } else { --=20 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 --p7qwJlK53pWzbayA Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJX7aJbAAoJEGw4ysog2bOSsd0QAJJ6z2hHZ6iWUwKHHtqEVOvj DR/d6ykEwaI0clAvZVZYA6N8q/AZXFe6yssdEI5iMQvDINaCqwwdVbzmaLqsPhWc KIp6fPBvirhzufl0GYgWdw233hi1sxzRbUUgwya9AyCr4i7gj5DfIxCuOeqA5DR0 uLyRIZvtqU0vjdx6PILBc/+uSnRlgn9gIBKypTP/KQe6FLC4eqigc2HOO8SEsEzB B+HZKWxBuzgCRBQrz6zulkgoiC24qVULzQkLRApXKNndnKjryb+mfnQTQwxfvwAX elkPNXZC//MS9Efzx3cSn6493eqypWFqMfLfYswAUfSXcRB0P2j9iRPymNm2FWCt hIbb7h4/JV42xPOubaWt0nMDvflskTxhY45ATVJ3evOQsXLp9lFfAwT3YbmvJV59 XFbLQcsGgzS+MHsKlL9qBDAgyPHtbmaajDbfvdti8Q1R4XhdxGZcN3YC0Yn6L4ks ajwsgachyjvzJNMJ136UNC4GRqRevQ99DdPhD43cVrpPFwGNgPbPzRezQq/RDNvL /oxCQKwgMLb+L+cl51iplE/telcTztcI97cIBsaU//KvGZo4SicK9S5gidpAc4we DtTEQZ2RyGHiTFye4Af144rW4OXWJmvmowu/oSbgwGburgpqVwrBCDGLUifiLyaP xkmp5mg3WreurM5DfpvW =oAEJ -----END PGP SIGNATURE----- --p7qwJlK53pWzbayA--