[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [XTF PATCH 07/16] vvmx: test vmxon in CPL=3 and out of VMX operation



On 16/12/16 13:43, Haozhong Zhang wrote:
> diff --git a/tests/vvmx/vmxon.c b/tests/vvmx/vmxon.c
> index 31f074c..ca33b3c 100644
> --- a/tests/vvmx/vmxon.c
> +++ b/tests/vvmx/vmxon.c
> @@ -28,11 +28,42 @@ static bool test_vmxon_novmxe(void)
>                                VMXERR_FAULT, EXINFO_SYM(UD, 0), 0);
>  }
>  
> +static unsigned long vmxon_in_user(void)

I'd name this user_vmxon() as it is slightly shorter, but I'm not
terribly fussed.

> +{
> +    exinfo_t fault;
> +    unsigned long ret = vmxon((uint64_t)vmxon_region, &fault);
> +
> +    return (ret << 32) | fault;
> +}
> +
> +/**
> + * vmxon in CPL=3 and out of VMX operation
> + *
> + * Expect: #GP(0)
> + */
> +static bool test_vmxon_in_user(void)

Similarly, test_user_vmxon()

> +{
> +    clear_vmcs(vmxon_region, get_vmcs_revid());
> +
> +    unsigned long ret = exec_user(vmxon_in_user);
> +    uint8_t err = (ret >> 32) & 0xff;
> +    exinfo_t fault = ret & 0xFFFFFFFF;
> +
> +    return handle_vmxinsn_err(__func__, err, fault,
> +                              VMXERR_FAULT, EXINFO_SYM(GP, 0), 0);
> +}
> +
>  bool test_vmxon(void)
>  {
>      if ( !test_vmxon_novmxe() )
>          return false;

Your subject says out of VMX operation, but the implementation is inside
VMX operation.

It would be worth testing both scenarios, as they should be
distinguished by #UD vs #GP[0].

~Andrew

>  
> +    unsigned long cr4 = read_cr4();
> +    write_cr4(cr4 | X86_CR4_VMXE);
> +
> +    if ( !test_vmxon_in_user() )
> +        return false;
> +
>      return true;
>  }
>  


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.