From mboxrd@z Thu Jan 1 00:00:00 1970 From: Liran Alon Subject: Re: [kvm-unit-t)ests PATCH] kvm-unit-tests: vmx: add a test for injecting events to halted L2 Date: Sun, 11 Feb 2018 01:01:56 -0800 (PST) Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: , , To: Return-path: Received: from aserp2130.oracle.com ([141.146.126.79]:33840 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752085AbeBKJKE (ORCPT ); Sun, 11 Feb 2018 04:10:04 -0500 Content-Disposition: inline Sender: kvm-owner@vger.kernel.org List-ID: ----- chao.gao@intel.com wrote: > This patch leverages existing "interrupt" tests. What the patch does > is L1 > puts L2 in halt state and injects an event to L2. Then check a flag > to > identify whether event injection succeeds or not. >=20 > Cc: Liran Alon > Signed-off-by: Chao Gao > --- > x86/vmx_tests.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) >=20 > diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c > index 0c3b5a7..3c46d3a 100644 > --- a/x86/vmx_tests.c > +++ b/x86/vmx_tests.c > @@ -1584,6 +1584,12 @@ static void interrupt_main(void) > =09for (loops =3D 0; loops < 10000000 && !timer_fired; loops++) > =09=09asm volatile ("nop"); > =09report("running a guest with interrupt acknowledgement set", > timer_fired); > + > +=09apic_write(APIC_TMICT, 0); > +=09irq_enable(); > +=09timer_fired =3D false; > +=09vmcall(); > +=09report("Inject an event to a halted guest", timer_fired); > } > =20 > static int interrupt_exit_handler(void) > @@ -1615,6 +1621,12 @@ static int interrupt_exit_handler(void) > =09=09case 6: > =09=09=09vmcs_write(GUEST_ACTV_STATE, ACTV_HLT); > =09=09=09break; > + > +=09=09case 8: > +=09=09=09vmcs_write(GUEST_ACTV_STATE, ACTV_HLT); > +=09=09=09vmcs_write(ENT_INTR_INFO, > +=09=09=09=09 TIMER_VECTOR | INTR_INFO_VALID_MASK); I would specify interrupt-type explicitly rather than implicitly. Meaning passing here: (TIMER_VECTOR | (VMX_INTR_TYPE_EXT_INTR << INTR_INFO_INTR_TYPE_SHIFT) | INTR_INFO_VALID_MASK) > +=09=09=09break; > =09=09} > =09=09vmx_inc_test_stage(); > =09=09vmcs_write(GUEST_RIP, guest_rip + insn_len); > --=20 > 1.9.1 Besides small comment above, looks good to me. Reviewed-by: Liran Alon