From: Wei Liu <wei.liu2@citrix.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>, Jan Beulich <JBeulich@suse.com>,
Xen-devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH v2 for-4.8] x86/emul: Move CPUID Faulting fault generation into the emulator
Date: Wed, 26 Oct 2016 14:05:20 +0100 [thread overview]
Message-ID: <20161026130520.GO30231@citrix.com> (raw)
In-Reply-To: <1477486682-17874-1-git-send-email-andrew.cooper3@citrix.com>
On Wed, Oct 26, 2016 at 01:58:02PM +0100, Andrew Cooper wrote:
> In hindsight, this is a better position for it, as it avoids opencoding
> hvmemul_inject_hw_exception() in hvmemul_cpuid(), and reduces the requirements
> on other ops->cpuid() hooks wanting to implement cpuid faulting in the future.
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Subject to Jan's review / ack:
Release-acked-by: Wei Liu <wei.liu2@citrix.com>
> ---
> CC: Jan Beulich <JBeulich@suse.com>
> CC: Wei Liu <wei.liu2@citrix.com>
>
> v2:
> * Expand the cpuid() hook comment in x86_emulate.h
> * Adjust how the exception is generated
> ---
> xen/arch/x86/hvm/emulate.c | 11 -----------
> xen/arch/x86/x86_emulate/x86_emulate.c | 5 ++++-
> xen/arch/x86/x86_emulate/x86_emulate.h | 7 ++++++-
> 3 files changed, 10 insertions(+), 13 deletions(-)
>
> diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c
> index 70c8d44..5b408f8 100644
> --- a/xen/arch/x86/hvm/emulate.c
> +++ b/xen/arch/x86/hvm/emulate.c
> @@ -1556,18 +1556,7 @@ static int hvmemul_cpuid(
> */
> if ( ctxt->opcode == X86EMUL_OPC(0x0f, 0xa2) &&
> hvm_check_cpuid_faulting(current) )
> - {
> - struct hvm_emulate_ctxt *hvmemul_ctxt =
> - container_of(ctxt, struct hvm_emulate_ctxt, ctxt);
> -
> - hvmemul_ctxt->exn_pending = 1;
> - hvmemul_ctxt->trap.vector = TRAP_gp_fault;
> - hvmemul_ctxt->trap.type = X86_EVENTTYPE_HW_EXCEPTION;
> - hvmemul_ctxt->trap.error_code = 0;
> - hvmemul_ctxt->trap.insn_len = 0;
> -
> return X86EMUL_EXCEPTION;
> - }
>
> hvm_funcs.cpuid_intercept(eax, ebx, ecx, edx);
> return X86EMUL_OKAY;
> diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c b/xen/arch/x86/x86_emulate/x86_emulate.c
> index a1821d5..2b087e5 100644
> --- a/xen/arch/x86/x86_emulate/x86_emulate.c
> +++ b/xen/arch/x86/x86_emulate/x86_emulate.c
> @@ -5011,7 +5011,10 @@ x86_emulate(
> unsigned int eax = _regs.eax, ebx = _regs.ebx;
> unsigned int ecx = _regs.ecx, edx = _regs.edx;
> fail_if(ops->cpuid == NULL);
> - if ( (rc = ops->cpuid(&eax, &ebx, &ecx, &edx, ctxt)) != 0 )
> + rc = ops->cpuid(&eax, &ebx, &ecx, &edx, ctxt);
> + generate_exception_if(rc == X86EMUL_EXCEPTION,
> + EXC_GP, 0); /* CPUID Faulting? */
> + if ( rc != X86EMUL_OKAY )
> goto done;
> _regs.eax = eax; _regs.ebx = ebx;
> _regs.ecx = ecx; _regs.edx = edx;
> diff --git a/xen/arch/x86/x86_emulate/x86_emulate.h b/xen/arch/x86/x86_emulate/x86_emulate.h
> index 641711e..fc8d234 100644
> --- a/xen/arch/x86/x86_emulate/x86_emulate.h
> +++ b/xen/arch/x86/x86_emulate/x86_emulate.h
> @@ -352,7 +352,12 @@ struct x86_emulate_ops
> int (*wbinvd)(
> struct x86_emulate_ctxt *ctxt);
>
> - /* cpuid: Emulate CPUID via given set of EAX-EDX inputs/outputs. */
> + /*
> + * cpuid: Emulate CPUID via given set of EAX-EDX inputs/outputs.
> + *
> + * May return X86EMUL_EXCEPTION, which causes the emulator to inject
> + * #GP[0]. Used to implement CPUID faulting.
> + */
> int (*cpuid)(
> unsigned int *eax,
> unsigned int *ebx,
> --
> 2.1.4
>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-10-26 13:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-26 11:09 [PATCH for-4.8] x86/emul: Move CPUID Faulting fault generation into the emulator Andrew Cooper
2016-10-26 12:26 ` Jan Beulich
2016-10-26 12:58 ` [PATCH v2 " Andrew Cooper
2016-10-26 13:05 ` Wei Liu [this message]
2016-10-26 13:40 ` Jan Beulich
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=20161026130520.GO30231@citrix.com \
--to=wei.liu2@citrix.com \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.