From: David Gibson Subject: Re: [kvm-unit-tests PATCH] powerpc: Add SPRs migration test Date: Mon, 11 Apr 2016 11:55:07 +1000 Message-ID: <20160411115507.524f8f9f@voom.fritz.box> References: <1460115329-21611-1-git-send-email-thuth@redhat.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; boundary="Sig_/hmAd1iRwX58T9CelsMP54ag"; protocol="application/pgp-signature" Cc: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, pbonzini@redhat.com, lvivier@redhat.com, clg@fr.ibm.com, drjones@redhat.com To: Thomas Huth Return-path: Received: from mx1.redhat.com ([209.132.183.28]:41116 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750705AbcDKByC (ORCPT ); Sun, 10 Apr 2016 21:54:02 -0400 In-Reply-To: <1460115329-21611-1-git-send-email-thuth@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: --Sig_/hmAd1iRwX58T9CelsMP54ag Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Fri, 8 Apr 2016 13:35:29 +0200 Thomas Huth wrote: > This test can be used to check whether the SPR (special purpose > registers) of the PowerPC CPU are migrated right. It first fills > the various SPRs with some non-zero value, then reads the values > back into a first array, then waits for a key (with the '-w' option) > so that it is possible to migrate the VM, and finally reads the > values from the SPRs back into another array and then compares it > with the initial values. > Currently the test only supports the SPRs from the PowerISA v2.07 > specification (i.e. POWER8 CPUs), but other versions should be > pretty easy to add later. >=20 > Signed-off-by: Thomas Huth So, the main concern I have about this is that while writing an arbitrary value is ok for quite a few SPRs, there's a significant number where that's not safe: either because it could actually cause some sort of exception interrupting the test, or because the value will get masked or otherwise modifier on write. I think at the very least we should separate out the code dealing with the safe-to-write-anything SPRs from the others as a form of internal documentation. Then we probably want some sort of table of safe non-default values for the other SPRs. [snip] > +/* Common SPRs for all PowerPC CPUs */ > +static void set_sprs_common(uint64_t val) > +{ > + mtspr(1, val); /* XER */ > + mtspr(9, val); /* CTR */ > + mtspr(273, val); /* SPRG1 */ > + mtspr(274, val); /* SPRG2 */ > + mtspr(275, val); /* SPRG3 */ > +} > + > +/* SPRs from PowerISA 2.07 Book III-S */ > +static void set_sprs_book3s_207(uint64_t val) > +{ > + mtspr(3, val); /* DSCR */ > + mtspr(13, val); /* AMR */ > + mtspr(17, val); /* DSCR */ > + mtspr(18, val); /* DSISR */ > + mtspr(19, val); /* DAR */ > + mtspr(29, val); /* AMR */ AMR seems to be listed twice.. > + mtspr(61, val); /* IAMR */ > + mtspr(152, val); /* CTRL */ > + mtspr(153, val); /* FSCR */ > + mtspr(157, val); /* UAMOR */ > + mtspr(159, val); /* PSPB */ > + mtspr(256, val); /* VRSAVE */ > + mtspr(272, val); /* SPRG0 */ > + mtspr(512, val); /* SPEFSCR */ > + mtspr(769, val); /* MMCR2 */ > + mtspr(770, val); /* MMCRA */ > + mtspr(771, val); /* PMC1 */ > + mtspr(772, val); /* PMC2 */ > + mtspr(773, val); /* PMC3 */ > + mtspr(774, val); /* PMC4 */ > + mtspr(775, val); /* PMC5 */ > + mtspr(776, val); /* PMC6 */ > + mtspr(779, val); /* MMCR0 */ > + mtspr(784, val); /* SIER */ > + mtspr(785, val); /* MMCR2 */ > + mtspr(786, val); /* MMCRA */ > + mtspr(787, val); /* PMC1 */ > + mtspr(788, val); /* PMC2 */ > + mtspr(789, val); /* PMC3 */ > + mtspr(790, val); /* PMC4 */ > + mtspr(791, val); /* PMC5 */ > + mtspr(792, val); /* PMC6 */ > + mtspr(795, val); /* MMCR0 */ > + mtspr(796, val); /* SIAR */ > + mtspr(798, val); /* SDAR */ > + mtspr(800, val); /* BESCRS */ > + mtspr(801, val); /* BESCCRSU */ > + mtspr(802, val); /* BESCRR */ > + mtspr(803, val); /* BESCRRU */ > + mtspr(804, val); /* EBBHR */ > + mtspr(805, val); /* EBBRR */ > + mtspr(806, val); /* BESCR */ > + mtspr(815, val); /* TAR */ > +} At a glance SPRs above where writing an arbitrary value might not be safe include AMR, IAMR, UAMOR, and MMCR*. --=20 David Gibson Senior Software Engineer, Virtualization, Red Hat --Sig_/hmAd1iRwX58T9CelsMP54ag Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJXCwP7AAoJEGw4ysog2bOSLLwQAKFC4Hvc5HddsKSqqoviwhCm Z2DySva//mESSJKUptv0LljoGusKE3uRA1dupveWFxqFhlCTzo0yqtbew9ExCsTh 2g7akKoSXUR/k9TcrQspZed0TSxHARJ4RzTmwSKdVBV/imWWHKyQ8nGxErO+qG/r be5OK4l/VyVk1e2ocXFHZNVuvnNMAE0lF5eZUR8bRxfBICwd4FKChP1XGF9gKo0b vS7+fgbIJmMpi3T/DkwPaxM51n9npUV3sei+CqDkCg1JwWEvQB0q++F+TM25DzJB FG/qiXo9LCqc0FIAoeJbRpSvoyBQUmwP9ScHMg4+O3ESuZ1HbOOtCPZO/OClPDtW BhhS/vz+iGkZDloG5aEK/bk3JD0ld/452XjbzMYGugjf8RV9rBaQy0k6hWXGc2SJ Bx9rDxBojZRSQn63RY8zzVuu10k+C/7dqBv9zlw5sTa6RZuM84Ej2QbjtM7I+Hvc zmeD4PJwAvFh7ixdM9ntXGhs+7zFL8DXb4/5ZRiKmnwueklglJqo4SeDq+Fj51lv ETsC0xrBSBSWnzFtbEWeQsHnw0fs91cvud96lnR9b+SheqJu91+QoswrRCSzFZK9 2VXMh/RE1LM8wm/CkRPZeSAmPFgBCFO8Xq183rz1zzPliPgRdmE38yNeOezTlVyB xTO3bMFTdKY3lYb4OGu0 =A7kn -----END PGP SIGNATURE----- --Sig_/hmAd1iRwX58T9CelsMP54ag--