From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Paul Durrant <paul.durrant@citrix.com>,
Xen-devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH v2 3/3] x86/emul: Support CPUID faulting via a speculative MSR read
Date: Mon, 20 Feb 2017 11:04:49 +0000 [thread overview]
Message-ID: <27f43a8c-7adf-a73d-4799-64499b8686f1@citrix.com> (raw)
In-Reply-To: <58AADA2D020000780013BBAA@prv-mh.provo.novell.com>
On 20/02/17 10:59, Jan Beulich wrote:
>>>> On 20.02.17 at 11:28, <andrew.cooper3@citrix.com> wrote:
>> --- a/xen/arch/x86/x86_emulate/x86_emulate.c
>> +++ b/xen/arch/x86/x86_emulate/x86_emulate.c
>> @@ -5424,10 +5424,25 @@ x86_emulate(
>> break;
>>
>> case X86EMUL_OPC(0x0f, 0xa2): /* cpuid */
>> + msr_val = 0;
>> fail_if(ops->cpuid == NULL);
>> +
>> + /* Speculatively read MSR_INTEL_MISC_FEATURES_ENABLES. */
>> + if ( ops->read_msr &&
>> + (rc = ops->read_msr(MSR_INTEL_MISC_FEATURES_ENABLES,
>> + &msr_val, ctxt)) == X86EMUL_EXCEPTION )
>> + {
>> + /* Not implemented. Squash the exception and proceed normally. */
>> + x86_emul_reset_event(ctxt);
>> + rc = X86EMUL_OKAY;
>> + }
>> + if ( rc != X86EMUL_OKAY )
>> + goto done;
>> +
>> + generate_exception_if((msr_val & MSR_MISC_FEATURES_CPUID_FAULTING) &&
>> + !mode_ring0(), EXC_GP, 0); /* Faulting active? */
> Could you please move the mode_ring0() check up to bypass the
> MSR read in the first place?
Ok.
>
>> --- a/xen/arch/x86/x86_emulate/x86_emulate.h
>> +++ b/xen/arch/x86/x86_emulate/x86_emulate.h
>> @@ -413,12 +413,7 @@ struct x86_emulate_ops
>> int (*wbinvd)(
>> struct x86_emulate_ctxt *ctxt);
>>
>> - /*
>> - * 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.
>> - */
>> + /* cpuid: Emulate CPUID via given set of EAX-EDX inputs/outputs. */
>> int (*cpuid)(
>> uint32_t leaf,
>> uint32_t subleaf,
> Are there any ways left for the hook to fail? IOW, should its return
> type become void now?
In principle, it should return RETRY when putting a cpuid entry into the
vmevent ring. At the moment, that logic is wedged into the vmx hook, so
emulated cpuid instructions don't generate events, but I am looking to
fix this (mis)behaviour in the long run.
~Andrew
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-02-20 11:04 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-20 10:28 [PATCH v2 0/3] x86/emul: MSR emulation improvements Andrew Cooper
2017-02-20 10:28 ` [PATCH v2 1/3] x86/hvm: Don't raise #GP behind the emulators back for MSR accesses Andrew Cooper
2017-02-20 10:34 ` Paul Durrant
2017-02-21 13:46 ` Boris Ostrovsky
2017-02-21 13:50 ` Andrew Cooper
2017-02-20 10:28 ` [PATCH v2 2/3] x86/emul: Introduce common msr_val for emulation Andrew Cooper
2017-02-20 10:55 ` Jan Beulich
2017-02-20 10:28 ` [PATCH v2 3/3] x86/emul: Support CPUID faulting via a speculative MSR read Andrew Cooper
2017-02-20 10:32 ` Paul Durrant
2017-02-20 10:59 ` Jan Beulich
2017-02-20 11:04 ` Andrew Cooper [this message]
2017-02-20 11:13 ` 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=27f43a8c-7adf-a73d-4799-64499b8686f1@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=paul.durrant@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).