From: "Radim Krčmář" <rkrcmar@redhat.com>
To: Gioh Kim <gi-oh.kim@profitbricks.com>
Cc: andre.przywara@amd.com, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [RFC] KVM: SVM: ignore type when setting segment registers
Date: Tue, 30 May 2017 14:54:21 +0200 [thread overview]
Message-ID: <20170530125420.GA19724@potion> (raw)
In-Reply-To: <1496064244-14785-1-git-send-email-gi-oh.kim@profitbricks.com>
2017-05-29 15:24+0200, Gioh Kim:
> Current code sets unusable as 1 if present is 1 and type is 0.
> In Long mode, type value in segment descriptor is ignored.
> So I think type should be ignored when setting the segment registers,
> if type means the descriptor type in the segment descriptor.
>
> Is the type field of struct kvm_segment the descriptor type?
Yes.
> If so, why type is checked when setting segment registers?
No idea. 19bca6ab75d8 ("KVM: SVM: Fix cross vendor migration issue with
unusable bit") also moved the assigment up to initialize it before use
and I think that is enough.
> If the type field is not the descriptor type,
> is it ok to set unusable when present is 1?
Looks like a bug. type = 0 can be a usable read-only data segment.
> I'm copying a code as following to show what code I'm asking.
Please send it as a patch,
thanks.
> ----------------------------- 8< ---------------------------------
> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
> index 5f48f62..0133f6f 100644
> --- a/arch/x86/kvm/svm.c
> +++ b/arch/x86/kvm/svm.c
> @@ -1803,7 +1803,7 @@ static void svm_get_segment(struct kvm_vcpu *vcpu,
> * AMD's VMCB does not have an explicit unusable field, so emulate it
> * for cross vendor migration purposes by "not present"
> */
> - var->unusable = !var->present || (var->type == 0);
> + var->unusable = !var->present;
>
> switch (seg) {
> case VCPU_SREG_TR:
> --
> 2.5.0
>
next prev parent reply other threads:[~2017-05-30 12:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-29 13:24 [RFC] KVM: SVM: ignore type when setting segment registers Gioh Kim
2017-05-30 12:54 ` Radim Krčmář [this message]
2017-05-30 13:37 ` Gioh Kim
2017-05-30 18:03 ` Matt Mullins
2017-05-31 6:42 ` Gi-Oh Kim
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=20170530125420.GA19724@potion \
--to=rkrcmar@redhat.com \
--cc=andre.przywara@amd.com \
--cc=gi-oh.kim@profitbricks.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@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 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).