From: Avi Kivity <avi@qumranet.com>
To: Mohammed Gamal <m.gamal005@gmail.com>
Cc: kvm@vger.kernel.org, riel@surriel.com, andrea@qumranet.com,
guillaume.thouvenin@ext.bull.net
Subject: Re: [RFC][PATCH] VMX: Invalid guest state emulation
Date: Mon, 11 Aug 2008 11:53:30 +0300 [thread overview]
Message-ID: <489FFE0A.2020001@qumranet.com> (raw)
In-Reply-To: <52d4a3890808101145m6316994dx2b171677b647917b@mail.gmail.com>
Mohammed Gamal wrote:
> On Sun, Aug 10, 2008 at 11:09 AM, Avi Kivity <avi@qumranet.com> wrote:
>
>> Mohammed Gamal wrote:
>>
>>> This patch aims to allow emulation whenever guest state is not valid for
>>> VMX operation. This usually happens in mode switches with guests such as
>>> older versions of gfxboot and FreeDOS with HIMEM.
>>> The patch aims to address this issue, it introduces the following:
>>>
>>> - A function that invokes the x86 emulator when the guest state is not
>>> valid (borrowed from Guillaume Thouvenin's real mode patches)
>>> - A function that checks that guest register state is VMX compliant
>>> - A module parameter that enables these operations. It is disabled by
>>> default, in order not to intervene with KVM's normal operation
>>>
>>>
>>> +/*
>>> + * Check if guest state is valid. Returns true if valid, false if
>>> + * not.
>>> + * We assume that registers are always usable
>>> + */
>>> +static bool guest_state_valid(struct kvm_vcpu *vcpu)
>>> +{
>>>
...
>>> + /* vm86 mode guest state checks */
>>> + if(vcpu->arch.rmode.active) {
>>>
>>>
>> Better to check cr0 here.
>>
>
> Why? when cr0.PE bit is cleared, enter_rmode() is called and
> vcpu->arch.rmode.active is set, or do you mean it should be checked in
> addition?
>
>
No, instead. If we check cr0 then the function only depends on guest
state and is therefore easier to understand.
Eventually rmode.active will go away.
>>> + /* Check segment limits */
>>> + if( (cs_limit != 0xffff) || (ds_limit != 0xffff) ||
>>> + (ss_limit != 0xffff) || (es_limit != 0xffff) ||
>>> + (fs_limit != 0xffff) || (gs_limit != 0xffff) )
>>> + return false;
>>>
>>>
>> Would be nice to get code reuse, here and below (i.e. data_segment_valid()
>> for ds,es..gs.). Also, vmx_get_segment() will make the code tidier.
>>
>
> I think the function can be further broken down into smaller functions
> each checking for a certain segment parameter (e.g.
> segment_limit_valid(), segment_ar_valid(), rip_valid() ...etc.) and
> then call all these functions in guest_state_valid().
>
>
Sure.
--
error compiling committee.c: too many arguments to function
prev parent reply other threads:[~2008-08-11 8:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-03 2:08 [RFC][PATCH] VMX: Invalid guest state emulation Mohammed Gamal
2008-08-03 13:26 ` Mohammed Gamal
2008-08-04 8:48 ` Guillaume Thouvenin
2008-08-04 10:46 ` Mohammed Gamal
2008-08-10 8:09 ` Avi Kivity
2008-08-10 18:45 ` Mohammed Gamal
2008-08-11 8:53 ` Avi Kivity [this message]
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=489FFE0A.2020001@qumranet.com \
--to=avi@qumranet.com \
--cc=andrea@qumranet.com \
--cc=guillaume.thouvenin@ext.bull.net \
--cc=kvm@vger.kernel.org \
--cc=m.gamal005@gmail.com \
--cc=riel@surriel.com \
/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