From: "Radim Krčmář" <rkrcmar@redhat.com>
To: Peng Hao <peng.hao2@zte.com.cn>
Cc: pbonzini@redhat.com, tglx@linutronix.de, x86@kernel.org,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RESEND PATCH] kvm/x86: propagate fetch fault into guest
Date: Fri, 11 Jan 2019 14:30:03 +0100 [thread overview]
Message-ID: <20190111133002.GA14852@flask> (raw)
In-Reply-To: <1545652830-65253-1-git-send-email-peng.hao2@zte.com.cn>
2018-12-24 20:00+0800, Peng Hao:
> When handling ept misconfig exit, it will call emulate instruction
> with insn_len = 0. The decode instruction function may return a fetch
> fault and should propagate to guest.
>
> The problem will result to emulation fail.
> KVM internal error. Suberror: 1
> emulation failure
> EAX=f81a0024 EBX=f6a07000 ECX=f6a0737c EDX=f8be0118
> ESI=f6a0737c EDI=00000021 EBP=f6929f98 ESP=f6929f98
> EIP=f8bdd141 EFL=00010086 [--S--P-] CPL=0 II=0 A20=1 SMM=0 HLT=0
> ES =007b 00000000 ffffffff 00c0f300 DPL=3 DS [-WA]
> CS =0060 00000000 ffffffff 00c09b00 DPL=0 CS32 [-RA]
> SS =0068 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
> DS =007b 00000000 ffffffff 00c0f300 DPL=3 DS [-WA]
> FS =00d8 2c044000 ffffffff 00809300 DPL=0 DS16 [-WA]
> GS =0033 081a44c8 01000fff 00d0f300 DPL=3 DS [-WA]
> LDT=0000 00000000 ffffffff 00000000
> TR =0080 f6ea0c80 0000206b 00008b00 DPL=0 TSS32-busy
> GDT= f6e99000 000000ff
> IDT= fffbb000 000007ff
> CR0=80050033 CR2=b757d000 CR3=35d31000 CR4=001406d0
Do you have a test case for this?
> Signed-off-by: Peng Hao <peng.hao2@zte.com.cn>
> ---
> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> @@ -5114,8 +5114,11 @@ int x86_decode_insn(struct x86_emulate_ctxt *ctxt, void *insn, int insn_len)
> memcpy(ctxt->fetch.data, insn, insn_len);
> else {
> rc = __do_insn_fetch_bytes(ctxt, 1);
> - if (rc != X86EMUL_CONTINUE)
> + if (rc != X86EMUL_CONTINUE) {
> + if (rc == X86EMUL_PROPAGATE_FAULT)
> + ctxt->have_exception = true;
> return rc;
(Ugh, the caller expects EMULATION_FAILED instead of rc.)
> + }
> }
>
> switch (mode) {
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> @@ -6333,8 +6333,10 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu,
> if (reexecute_instruction(vcpu, cr2, write_fault_to_spt,
> emulation_type))
> return EMULATE_DONE;
> - if (ctxt->have_exception && inject_emulated_exception(vcpu))
I don't understand what that return value check was supposed to do, but
yours version seems good.
I have queued it for rc3 to get some extra testing,
thanks.
prev parent reply other threads:[~2019-01-11 13:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-24 12:00 [RESEND PATCH] kvm/x86: propagate fetch fault into guest Peng Hao
2019-01-11 13:30 ` Radim Krčmář [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=20190111133002.GA14852@flask \
--to=rkrcmar@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=peng.hao2@zte.com.cn \
--cc=tglx@linutronix.de \
--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 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.