From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: Re: [PATCH 1/4] kvm-unit-tests: VMX: Add test cases for PAT and EFER Date: Thu, 15 Aug 2013 09:48:56 +0200 Message-ID: <520C87E8.3050107@web.de> References: <1376409368-7016-1-git-send-email-yzt356@gmail.com> <1376409368-7016-2-git-send-email-yzt356@gmail.com> <520C8088.6070607@web.de> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="vcEAMJM6pUTpmLMsfRhShBwpGRGPFNTX5" Cc: kvm , Gleb Natapov , Paolo Bonzini To: Arthur Chunqi Li Return-path: Received: from mout.web.de ([212.227.15.3]:52881 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750938Ab3HOHs7 (ORCPT ); Thu, 15 Aug 2013 03:48:59 -0400 Received: from mchn199C.mchp.siemens.de ([95.157.58.223]) by smtp.web.de (mrweb101) with ESMTPSA (Nemesis) id 0Lvjiy-1WAYb70hx6-017SkI for ; Thu, 15 Aug 2013 09:48:58 +0200 In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --vcEAMJM6pUTpmLMsfRhShBwpGRGPFNTX5 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 2013-08-15 09:41, Arthur Chunqi Li wrote: > On Thu, Aug 15, 2013 at 3:17 PM, Jan Kiszka wrote: >> On 2013-08-13 17:56, Arthur Chunqi Li wrote: >>> Add test cases for ENT_LOAD_PAT, ENT_LOAD_EFER, EXI_LOAD_PAT, >>> EXI_SAVE_PAT, EXI_LOAD_EFER, EXI_SAVE_PAT flags in enter/exit >>> control fields. >>> >>> Signed-off-by: Arthur Chunqi Li >>> --- >>> x86/vmx.h | 7 +++ >>> x86/vmx_tests.c | 185 +++++++++++++++++++++++++++++++++++++++++++++= ++++++++++ >>> 2 files changed, 192 insertions(+) >>> >>> diff --git a/x86/vmx.h b/x86/vmx.h >>> index 28595d8..18961f1 100644 >>> --- a/x86/vmx.h >>> +++ b/x86/vmx.h >>> @@ -152,10 +152,12 @@ enum Encoding { >>> GUEST_DEBUGCTL =3D 0x2802ul, >>> GUEST_DEBUGCTL_HI =3D 0x2803ul, >>> GUEST_EFER =3D 0x2806ul, >>> + GUEST_PAT =3D 0x2804ul, >>> GUEST_PERF_GLOBAL_CTRL =3D 0x2808ul, >>> GUEST_PDPTE =3D 0x280aul, >>> >>> /* 64-Bit Host State */ >>> + HOST_PAT =3D 0x2c00ul, >>> HOST_EFER =3D 0x2c02ul, >>> HOST_PERF_GLOBAL_CTRL =3D 0x2c04ul, >>> >>> @@ -330,11 +332,15 @@ enum Ctrl_exi { >>> EXI_HOST_64 =3D 1UL << 9, >>> EXI_LOAD_PERF =3D 1UL << 12, >>> EXI_INTA =3D 1UL << 15, >>> + EXI_SAVE_PAT =3D 1UL << 18, >>> + EXI_LOAD_PAT =3D 1UL << 19, >>> + EXI_SAVE_EFER =3D 1UL << 20, >>> EXI_LOAD_EFER =3D 1UL << 21, >>> }; >>> >>> enum Ctrl_ent { >>> ENT_GUEST_64 =3D 1UL << 9, >>> + ENT_LOAD_PAT =3D 1UL << 14, >>> ENT_LOAD_EFER =3D 1UL << 15, >>> }; >>> >>> @@ -354,6 +360,7 @@ enum Ctrl0 { >>> CPU_NMI_WINDOW =3D 1ul << 22, >>> CPU_IO =3D 1ul << 24, >>> CPU_IO_BITMAP =3D 1ul << 25, >>> + CPU_MSR_BITMAP =3D 1ul << 28, >>> CPU_SECONDARY =3D 1ul << 31, >>> }; >>> >>> diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c >>> index c1b39f4..61b0cef 100644 >>> --- a/x86/vmx_tests.c >>> +++ b/x86/vmx_tests.c >>> @@ -1,4 +1,15 @@ >>> #include "vmx.h" >>> +#include "msr.h" >>> +#include "processor.h" >>> +#include "vm.h" >>> + >>> +u64 ia32_pat; >>> +u64 ia32_efer; >>> + >>> +static inline void vmcall() >>> +{ >>> + asm volatile("vmcall"); >>> +} >>> >>> void basic_init() >>> { >>> @@ -76,6 +87,176 @@ int vmenter_exit_handler() >>> return VMX_TEST_VMEXIT; >>> } >>> >>> +void msr_bmp_init() >>> +{ >>> + void *msr_bitmap; >>> + u32 ctrl_cpu0; >>> + >>> + msr_bitmap =3D alloc_page(); >>> + memset(msr_bitmap, 0x0, PAGE_SIZE); >>> + ctrl_cpu0 =3D vmcs_read(CPU_EXEC_CTRL0); >>> + ctrl_cpu0 |=3D CPU_MSR_BITMAP; >>> + vmcs_write(CPU_EXEC_CTRL0, ctrl_cpu0); >>> + vmcs_write(MSR_BITMAP, (u64)msr_bitmap); >>> +} >> >> Better safe this function for the test case where you actually stress >> the bitmap. > What do you mean by "safe"? I meant the other "save": This function serves no purpose here. Let's only introduce it when that changes, i.e. when you actually test the MSR bitmap. Jan --vcEAMJM6pUTpmLMsfRhShBwpGRGPFNTX5 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iEYEARECAAYFAlIMh+gACgkQitSsb3rl5xTcewCdGKfkH8KmkRb9hGwfieu26x9U WC4AoOfGyWKGupvNupfmtaQvzpizv1vM =rAWj -----END PGP SIGNATURE----- --vcEAMJM6pUTpmLMsfRhShBwpGRGPFNTX5--