xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@suse.com>
To: Ed White <edmund.h.white@intel.com>
Cc: Tim Deegan <tim@xen.org>, Ravi Sahita <ravi.sahita@intel.com>,
	Wei Liu <wei.liu2@citrix.com>,
	George Dunlap <george.dunlap@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	xen-devel@lists.xen.org, tlengyel@novetta.com,
	Daniel De Graaf <dgdegra@tycho.nsa.gov>
Subject: Re: [PATCH v4 07/15] VMX: add VMFUNC leaf 0 (EPTP switching) to emulator.
Date: Fri, 10 Jul 2015 10:30:40 +0100	[thread overview]
Message-ID: <559FACE0020000780008F53F@mail.emea.novell.com> (raw)
In-Reply-To: <1436489553-6300-8-git-send-email-edmund.h.white@intel.com>

>>> On 10.07.15 at 02:52, <edmund.h.white@intel.com> wrote:
> @@ -3234,6 +3256,13 @@ void vmx_vmexit_handler(struct cpu_user_regs *regs)
>              update_guest_eip();
>          break;
>  
> +    case EXIT_REASON_VMFUNC:
> +        if ( vmx_vmfunc_intercept(regs) == X86EMUL_EXCEPTION )
> +            hvm_inject_hw_exception(TRAP_invalid_op, HVM_DELIVER_NO_ERROR_CODE);
> +        else
> +            update_guest_eip();
> +        break;

How about X86EMUL_UNHANDLEABLE and X86EMUL_RETRY? As said
before, either get this right, or simply fold the relatively pointless
helper into here.

> --- a/xen/arch/x86/x86_emulate/x86_emulate.c
> +++ b/xen/arch/x86/x86_emulate/x86_emulate.c
> @@ -3816,8 +3816,9 @@ x86_emulate(
>          struct segment_register reg;
>          unsigned long base, limit, cr0, cr0w;
>  
> -        if ( modrm == 0xdf ) /* invlpga */
> +        switch( modrm )
>          {
> +        case 0xdf: /* invlpga AMD */
>              generate_exception_if(!in_protmode(ctxt, ops), EXC_UD, -1);
>              generate_exception_if(!mode_ring0(), EXC_GP, 0);
>              fail_if(ops->invlpg == NULL);

The diff now looks much better. Yet I don't see why you added "AMD"
to the comment - we don't elsewhere note that certain instructions
are vendor specific (and really which ones are also changes over time,
see RDTSCP for a prominent example).

> @@ -3825,10 +3826,7 @@ x86_emulate(
>                                     ctxt)) )
>                  goto done;
>              break;
> -        }
> -
> -        if ( modrm == 0xf9 ) /* rdtscp */
> -        {
> +        case 0xf9: /* rdtscp */ {
>              uint64_t tsc_aux;
>              fail_if(ops->read_msr == NULL);
>              if ( (rc = ops->read_msr(MSR_TSC_AUX, &tsc_aux, ctxt)) != 0 )
> @@ -3836,7 +3834,19 @@ x86_emulate(
>              _regs.ecx = (uint32_t)tsc_aux;
>              goto rdtsc;
>          }
> +        case 0xd4: /* vmfunc */
> +            generate_exception_if(lock_prefix | rep_prefix() | (vex.pfx == vex_66),
> +                                  EXC_UD, -1);
> +            fail_if(ops->vmfunc == NULL);
> +            if ( (rc = ops->vmfunc(ctxt) != X86EMUL_OKAY) )
> +                goto done;
> +            break;
> +        default:
> +            goto continue_grp7;
> +        }
> +        break;
>  
> + continue_grp7:

Already when first looking at this I disliked this label. Looking at it
again, I'd really like to see it gone: RDTSCP handling already ends
in a goto. Since the only VMFUNC currently implemented doesn't
modify any register state either, its handling could end in an
unconditional "goto done" too for now. And INVLPG, not modifying
any register state, could follow suit.

And even if you really wanted to cater for future VMFUNCs to alter
register state, I'd still like this ugliness to be avoided - e.g. by
setting rc to a negative value before the switch and break-ing
afterwards when it's no longer negative.

Jan

  reply	other threads:[~2015-07-10  9:30 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-10  0:52 [PATCH v4 00/15] Alternate p2m: support multiple copies of host p2m Ed White
2015-07-10  0:52 ` [PATCH v4 01/15] common/domain: Helpers to pause a domain while in context Ed White
2015-07-10  0:52 ` [PATCH v4 02/15] VMX: VMFUNC and #VE definitions and detection Ed White
2015-07-10  0:52 ` [PATCH v4 03/15] VMX: implement suppress #VE Ed White
2015-07-10  9:09   ` Jan Beulich
2015-07-10 19:22     ` Sahita, Ravi
2015-07-10  0:52 ` [PATCH v4 04/15] x86/HVM: Hardware alternate p2m support detection Ed White
2015-07-10  0:52 ` [PATCH v4 05/15] x86/altp2m: basic data structures and support routines Ed White
2015-07-10  9:13   ` Jan Beulich
2015-07-10  0:52 ` [PATCH v4 06/15] VMX/altp2m: add code to support EPTP switching and #VE Ed White
2015-07-10 16:48   ` George Dunlap
2015-07-10  0:52 ` [PATCH v4 07/15] VMX: add VMFUNC leaf 0 (EPTP switching) to emulator Ed White
2015-07-10  9:30   ` Jan Beulich [this message]
2015-07-11 20:01     ` Sahita, Ravi
2015-07-11 21:25       ` Sahita, Ravi
2015-07-13  7:18         ` Jan Beulich
2015-07-13  7:13       ` Jan Beulich
2015-07-10  0:52 ` [PATCH v4 08/15] x86/altp2m: add control of suppress_ve Ed White
2015-07-10  9:39   ` Jan Beulich
2015-07-10 11:11     ` George Dunlap
2015-07-10 11:49       ` Jan Beulich
2015-07-10 11:56         ` George Dunlap
2015-07-10 17:02   ` George Dunlap
2015-07-11 21:29     ` Sahita, Ravi
2015-07-10  0:52 ` [PATCH v4 09/15] x86/altp2m: alternate p2m memory events Ed White
2015-07-10  1:01   ` Lengyel, Tamas
2015-07-10  0:52 ` [PATCH v4 10/15] x86/altp2m: add remaining support routines Ed White
2015-07-10  9:41   ` Jan Beulich
2015-07-10 17:15     ` George Dunlap
2015-07-11 20:20       ` Sahita, Ravi
2015-07-10  0:52 ` [PATCH v4 11/15] x86/altp2m: define and implement alternate p2m HVMOP types Ed White
2015-07-10 10:01   ` Jan Beulich
2015-07-10 22:03     ` Sahita, Ravi
2015-07-13  7:25       ` Jan Beulich
2015-07-13 23:39         ` Sahita, Ravi
2015-07-14  8:58           ` Jan Beulich
2015-07-10  0:52 ` [PATCH v4 12/15] x86/altp2m: Add altp2mhvm HVM domain parameter Ed White
2015-07-10  8:53   ` Wei Liu
2015-07-10 17:32   ` George Dunlap
2015-07-10 22:12     ` Sahita, Ravi
2015-07-14 11:50       ` George Dunlap
2015-07-10  0:52 ` [PATCH v4 13/15] x86/altp2m: XSM hooks for altp2m HVM ops Ed White
2015-07-10  0:52 ` [PATCH v4 14/15] tools/libxc: add support to altp2m hvmops Ed White
2015-07-10  8:46   ` Ian Campbell
2015-07-10  0:52 ` [PATCH v4 15/15] tools/xen-access: altp2m testcases Ed White
2015-07-10  1:35   ` Lengyel, Tamas
2015-07-11  6:06     ` Razvan Cojocaru
2015-07-10  8:50   ` Ian Campbell
2015-07-10  8:55     ` Wei Liu
2015-07-10  9:12       ` Wei Liu
2015-07-10  9:20       ` Ian Campbell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=559FACE0020000780008F53F@mail.emea.novell.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=dgdegra@tycho.nsa.gov \
    --cc=edmund.h.white@intel.com \
    --cc=george.dunlap@eu.citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=ravi.sahita@intel.com \
    --cc=tim@xen.org \
    --cc=tlengyel@novetta.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).