From: Wanpeng Li <kernellwp@gmail.com>
To: David Hildenbrand <david@redhat.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kvm <kvm@vger.kernel.org>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Radim Krčmář" <rkrcmar@redhat.com>,
"Andrew Cooper" <andrew.cooper3@citrix.com>,
"Konrad Rzeszutek Wilk" <konrad.wilk@oracle.com>,
"Liran Alon" <liran.alon@oracle.com>
Subject: Re: [PATCH v5 1/2] KVM: X86: Introduce handle_ud()
Date: Wed, 4 Apr 2018 21:28:28 +0800 [thread overview]
Message-ID: <CANRm+Cxc9uVqS9J98qLTCg3WHDef1G6-AZT0TOgT_FQ3DsWFAQ@mail.gmail.com> (raw)
In-Reply-To: <9d68b1b4-04e6-46d6-70b4-6ebcb0a0c4aa@redhat.com>
2018-04-04 19:54 GMT+08:00 David Hildenbrand <david@redhat.com>:
> On 04.04.2018 01:28, Wanpeng Li wrote:
>> From: Wanpeng Li <wanpengli@tencent.com>
>>
>> Introduce handle_ud() to handle invalid opcode, this function will be
>> used by later patches.
>>
>> Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
>> Reviewed-by: Liran Alon <liran.alon@oracle.com>
>> Cc: Paolo Bonzini <pbonzini@redhat.com>
>> Cc: Radim Krčmář <rkrcmar@redhat.com>
>> Cc: Andrew Cooper <andrew.cooper3@citrix.com>
>> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
>> Cc: Liran Alon <liran.alon@oracle.com>
>> Signed-off-by: Wanpeng Li <wanpengli@tencent.com>
>> ---
>> arch/x86/kvm/svm.c | 9 +--------
>> arch/x86/kvm/vmx.c | 10 ++--------
>> arch/x86/kvm/x86.c | 13 +++++++++++++
>> arch/x86/kvm/x86.h | 2 ++
>> 4 files changed, 18 insertions(+), 16 deletions(-)
>>
>> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
>> index f66fc2e..e0a3f56 100644
>> --- a/arch/x86/kvm/svm.c
>> +++ b/arch/x86/kvm/svm.c
>> @@ -2676,14 +2676,7 @@ static int bp_interception(struct vcpu_svm *svm)
>>
>> static int ud_interception(struct vcpu_svm *svm)
>> {
>> - int er;
>> -
>> - er = emulate_instruction(&svm->vcpu, EMULTYPE_TRAP_UD);
>> - if (er == EMULATE_USER_EXIT)
>> - return 0;
>> - if (er != EMULATE_DONE)
>> - kvm_queue_exception(&svm->vcpu, UD_VECTOR);
>> - return 1;
>> + return handle_ud(&svm->vcpu);
>> }
>>
>> static int ac_interception(struct vcpu_svm *svm)
>> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
>> index b2f8a70..0f11243 100644
>> --- a/arch/x86/kvm/vmx.c
>> +++ b/arch/x86/kvm/vmx.c
>> @@ -6436,14 +6436,8 @@ static int handle_exception(struct kvm_vcpu *vcpu)
>> if (is_nmi(intr_info))
>> return 1; /* already handled by vmx_vcpu_run() */
>>
>> - if (is_invalid_opcode(intr_info)) {
>> - er = emulate_instruction(vcpu, EMULTYPE_TRAP_UD);
>> - if (er == EMULATE_USER_EXIT)
>> - return 0;
>> - if (er != EMULATE_DONE)
>> - kvm_queue_exception(vcpu, UD_VECTOR);
>> - return 1;
>> - }
>> + if (is_invalid_opcode(intr_info))
>> + return handle_ud(vcpu);
>
> (maybe different on this branch) isn't "er" now unused?
Hmm, It is used in other place of the function handle_exception.
>
>>
>> error_code = 0;
>> if (intr_info & INTR_INFO_DELIVER_CODE_MASK)
>> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
>> index 7d9a444..1eb495e 100644
>> --- a/arch/x86/kvm/x86.c
>> +++ b/arch/x86/kvm/x86.c
>> @@ -4840,6 +4840,19 @@ int kvm_write_guest_virt_system(struct x86_emulate_ctxt *ctxt,
>> }
>> EXPORT_SYMBOL_GPL(kvm_write_guest_virt_system);
>>
>> +int handle_ud(struct kvm_vcpu *vcpu)
>> +{
>> + enum emulation_result er;
>> +
>> + er = emulate_instruction(vcpu, EMULTYPE_TRAP_UD);
>> + if (er == EMULATE_USER_EXIT)
>> + return 0;
>> + if (er != EMULATE_DONE)
>> + kvm_queue_exception(vcpu, UD_VECTOR);
>> + return 1;
>
> I would now actually prefer
>
> if (er == EMULATE_DONE)
> return 1 ...
Keep the original one I think.
Regards,
Wanpeng Li
next prev parent reply other threads:[~2018-04-04 13:28 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-03 23:28 [PATCH v5 0/2] KVM: X86: Add Force Emulation Prefix for "emulate the next instruction" Wanpeng Li
2018-04-03 23:28 ` [PATCH v5 1/2] KVM: X86: Introduce handle_ud() Wanpeng Li
2018-04-04 11:54 ` David Hildenbrand
2018-04-04 13:28 ` Wanpeng Li [this message]
2018-04-04 17:12 ` Paolo Bonzini
2018-04-04 17:43 ` David Hildenbrand
2018-04-03 23:28 ` [PATCH v5 2/2] KVM: X86: Add Force Emulation Prefix for "emulate the next instruction" Wanpeng Li
2018-04-04 11:59 ` David Hildenbrand
2018-04-04 13:35 ` Wanpeng Li
2018-04-04 17:09 ` Paolo Bonzini
2018-04-05 0:04 ` Wanpeng Li
2018-04-05 8:51 ` Paolo Bonzini
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=CANRm+Cxc9uVqS9J98qLTCg3WHDef1G6-AZT0TOgT_FQ3DsWFAQ@mail.gmail.com \
--to=kernellwp@gmail.com \
--cc=andrew.cooper3@citrix.com \
--cc=david@redhat.com \
--cc=konrad.wilk@oracle.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liran.alon@oracle.com \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.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
all inboxes | Powered by JetHome®