From: Paolo Bonzini <pbonzini@redhat.com>
To: linmiaohe <linmiaohe@huawei.com>,
rkrcmar@redhat.com, sean.j.christopherson@intel.com,
vkuznets@redhat.com, wanpengli@tencent.com, jmattson@google.com,
joro@8bytes.org, tglx@linutronix.de, mingo@redhat.com,
bp@alien8.de, hpa@zytor.com
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org
Subject: Re: [PATCH] KVM: X86: avoid unused setup_syscalls_segments call when SYSCALL check failed
Date: Mon, 11 Nov 2019 15:08:16 +0100 [thread overview]
Message-ID: <37dcc0bb-b624-4ea2-976a-51f5bfbd81a6@redhat.com> (raw)
In-Reply-To: <1573289934-14430-1-git-send-email-linmiaohe@huawei.com>
On 09/11/19 09:58, linmiaohe wrote:
> From: Miaohe Lin <linmiaohe@huawei.com>
>
> When SYSCALL/SYSENTER ability check failed, cs and ss is inited but
> remain not used. Delay initializing cs and ss until SYSCALL/SYSENTER
> ability check passed.
>
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> ---
> arch/x86/kvm/emulate.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> index 698efb8c3897..952d1a4f4d7e 100644
> --- a/arch/x86/kvm/emulate.c
> +++ b/arch/x86/kvm/emulate.c
> @@ -2770,11 +2770,10 @@ static int em_syscall(struct x86_emulate_ctxt *ctxt)
> return emulate_ud(ctxt);
>
> ops->get_msr(ctxt, MSR_EFER, &efer);
> - setup_syscalls_segments(ctxt, &cs, &ss);
> -
> if (!(efer & EFER_SCE))
> return emulate_ud(ctxt);
>
> + setup_syscalls_segments(ctxt, &cs, &ss);
> ops->get_msr(ctxt, MSR_STAR, &msr_data);
> msr_data >>= 32;
> cs_sel = (u16)(msr_data & 0xfffc);
> @@ -2838,12 +2837,11 @@ static int em_sysenter(struct x86_emulate_ctxt *ctxt)
> if (ctxt->mode == X86EMUL_MODE_PROT64)
> return X86EMUL_UNHANDLEABLE;
>
> - setup_syscalls_segments(ctxt, &cs, &ss);
> -
> ops->get_msr(ctxt, MSR_IA32_SYSENTER_CS, &msr_data);
> if ((msr_data & 0xfffc) == 0x0)
> return emulate_gp(ctxt, 0);
>
> + setup_syscalls_segments(ctxt, &cs, &ss);
> ctxt->eflags &= ~(X86_EFLAGS_VM | X86_EFLAGS_IF);
> cs_sel = (u16)msr_data & ~SEGMENT_RPL_MASK;
> ss_sel = cs_sel + 8;
>
Queued, thanks.
Paolo
prev parent reply other threads:[~2019-11-11 14:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-09 8:58 [PATCH] KVM: X86: avoid unused setup_syscalls_segments call when SYSCALL check failed linmiaohe
2019-11-11 14:08 ` Paolo Bonzini [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=37dcc0bb-b624-4ea2-976a-51f5bfbd81a6@redhat.com \
--to=pbonzini@redhat.com \
--cc=bp@alien8.de \
--cc=hpa@zytor.com \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linmiaohe@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rkrcmar@redhat.com \
--cc=sean.j.christopherson@intel.com \
--cc=tglx@linutronix.de \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.com \
--cc=x86@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).