All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Gleb Natapov <gleb@redhat.com>
Cc: kvm@vger.kernel.org, joerg.roedel@amd.com,
	yoshikawa.takuya@oss.ntt.co.jp, avi@redhat.com,
	mtosatti@redhat.com
Subject: Re: [PATCH v3 3/4] KVM: SVM: Fix CPL updates
Date: Mon, 06 Feb 2012 10:18:35 +0100	[thread overview]
Message-ID: <4F2F9AEB.9080406@redhat.com> (raw)
In-Reply-To: <20120205111617.GT23536@redhat.com>

Am 05.02.2012 12:16, schrieb Gleb Natapov:
> On Fri, Feb 03, 2012 at 07:29:24PM +0100, Kevin Wolf wrote:
>> Keep CPL at 0 in real mode and at 3 in VM86. In protected/long mode, use
>> RPL rather than DPL of the code segment.
>>
>> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
>> ---
>>  arch/x86/kvm/svm.c |   19 ++++++++++++++++---
>>  1 files changed, 16 insertions(+), 3 deletions(-)
>>
>> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
>> index 6a977c1..4124a7e 100644
>> --- a/arch/x86/kvm/svm.c
>> +++ b/arch/x86/kvm/svm.c
>> @@ -1263,6 +1263,21 @@ static void svm_vcpu_put(struct kvm_vcpu *vcpu)
>>  		wrmsrl(host_save_user_msrs[i], svm->host_user_msrs[i]);
>>  }
>>  
>> +static void svm_update_cpl(struct kvm_vcpu *vcpu)
>> +{
>> +	struct vcpu_svm *svm = to_svm(vcpu);
>> +	int cpl;
>> +
>> +	if (!is_protmode(vcpu))
>> +		cpl = 0;
>> +	else if (svm->vmcb->save.rflags & X86_EFLAGS_VM)
>> +		cpl = 3;
>> +	else
>> +		cpl = svm->vmcb->save.cs.selector & 0x3;
>> +
>> +	svm->vmcb->save.cpl = cpl;
>> +}
>> +
> As you probably know already I think cpl should be updated in
> svm_get_rflags() too. With current patch restoring CS segment
> register before rflags register after migration may cause cpl
> to get wrong value for instance.

I think you mean set_rflags rather than get_rflags?

Patch 4 adds this with the set_rflags emulator callback.

Kevin

  reply	other threads:[~2012-02-06  9:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-03 18:29 [PATCH v3 0/4] Fix task switches into/out of VM86 Kevin Wolf
2012-02-03 18:29 ` [PATCH v3 1/4] KVM: x86 emulator: Fix task switch privilege checks Kevin Wolf
2012-02-03 18:29 ` [PATCH v3 2/4] KVM: x86 emulator: VM86 segments must have DPL 3 Kevin Wolf
2012-02-03 18:29 ` [PATCH v3 3/4] KVM: SVM: Fix CPL updates Kevin Wolf
2012-02-05 11:16   ` Gleb Natapov
2012-02-06  9:18     ` Kevin Wolf [this message]
2012-02-06  9:57       ` Gleb Natapov
2012-02-06 10:40         ` Kevin Wolf
2012-02-03 18:29 ` [PATCH v3 4/4] KVM: x86 emulator: Allow PM/VM86 switch during task switch Kevin Wolf
2012-02-06 10:32   ` Avi Kivity
2012-02-06 10:54     ` Kevin Wolf

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=4F2F9AEB.9080406@redhat.com \
    --to=kwolf@redhat.com \
    --cc=avi@redhat.com \
    --cc=gleb@redhat.com \
    --cc=joerg.roedel@amd.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=yoshikawa.takuya@oss.ntt.co.jp \
    /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.