From: Avi Kivity <avi@redhat.com>
To: Andre Przywara <andre.przywara@amd.com>
Cc: kvm@vger.kernel.org, Amit Shah <amit.shah@redhat.com>,
Christoph Egger <christoph.egger@amd.com>
Subject: Re: [PATCH 2/2] add sysenter/syscall emulation for 32bit compat mode
Date: Sun, 07 Jun 2009 10:09:26 +0300 [thread overview]
Message-ID: <4A2B67A6.80206@redhat.com> (raw)
In-Reply-To: <4A290E46.8010107@amd.com>
Andre Przywara wrote:
>
>>
>>> @@ -1985,10 +1992,114 @@ twobyte_insn:
>>> goto cannot_emulate;
>>> }
>>> break;
>>> + case 0x05: { /* syscall */
>>> + unsigned long cr0 = ctxt->vcpu->arch.cr0;
>>> + struct kvm_segment cs, ss;
>>> +
>>> + memset(&cs, 0, sizeof(struct kvm_segment));
>>> + memset(&ss, 0, sizeof(struct kvm_segment));
>>> +
>>> + /* inject #UD if
>>> + * 1. we are in real mode
>>> + * 2. protected mode is not enabled
>>> + * 3. LOCK prefix is used
>>> + */
>>> + if ((ctxt->mode == X86EMUL_MODE_REAL)
>>> + || (!(cr0 & X86_CR0_PE))
>>> + || (c->lock_prefix)) {
>>> + /* we don't need to inject #UD here, because
>>> + * when emulate_instruction() returns something else
>>> + * than EMULATE_DONE, then svm.c:ud_interception()
>>> + * will do that for us.
>>> + */
>>> + goto cannot_emulate;
>>>
>>
>> I prefer explicit injection, relying on the caller is tricky and may
>> change.
> I don't agree. If this function cannot emulate an instruction, it
> returns -1 and lets the upper levels handle this. If we cannot rely on
> this, what else can we rely on? I could remove the comment in case
> this is confusing. The same functionality (return -1 to inject UD into
> the guest) is used in other places in this same file.
We return -1, but that doesn't mean we inject #UD. For some cases (page
table emulation), we unshadow the page and retry (letting the guest
execute natively).
We only inject #UD from that specific call site. If we somehow emulated
from another call site, we'd get different behaviour.
>
>>
>>> + cs.limit = 0xffffffff;
>>> + ss.base = 0;
>>> + ss.limit = 0xffffffff;
>>>
>>
>> Once is enough.
> You are right about the ss.base assignment. But the limit goes from
> five f's to eight f's. On a first glance this should not matter (as
> the granularity bit is set), but exactly here are differences between
> VMX and SVM, so I'd like to leave it this way.
I misread, I thought you were setting ss.limit twice. Certainly the
code is correct as is and should not be modified. Sorry about the
confusion.
--
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
next prev parent reply other threads:[~2009-06-07 7:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-28 9:56 [PATCH 1/2] use explicit 64bit storage for sysenter values Andre Przywara
2009-05-28 9:56 ` [PATCH 2/2] add sysenter/syscall emulation for 32bit compat mode Andre Przywara
2009-05-31 8:59 ` Avi Kivity
2009-06-05 12:23 ` Andre Przywara
2009-06-07 7:09 ` Avi Kivity [this message]
2009-05-31 8:53 ` [PATCH 1/2] use explicit 64bit storage for sysenter values Avi Kivity
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=4A2B67A6.80206@redhat.com \
--to=avi@redhat.com \
--cc=amit.shah@redhat.com \
--cc=andre.przywara@amd.com \
--cc=christoph.egger@amd.com \
--cc=kvm@vger.kernel.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.