From: "Radim Krčmář" <rkrcmar@redhat.com>
To: "Longpeng(Mike)" <longpeng2@huawei.com>
Cc: pbonzini@redhat.com, tglx@linutronix.de, mingo@redhat.com,
hpa@zytor.com, x86@kernel.org, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org, zhaoshenglong@huawei.com,
richard.weiyang@huawei.com
Subject: Re: [PATCH] kvm: x86: correct the misleading comment in vmx_handle_external_intr
Date: Tue, 11 Oct 2016 20:23:37 +0200 [thread overview]
Message-ID: <20161011182337.GB16406@potion> (raw)
In-Reply-To: <1476059023-33224-1-git-send-email-longpeng2@huawei.com>
2016-10-10 08:23+0800, Longpeng(Mike):
> Since Paolo has removed irq-enable-operation in vmx_handle_external_intr
> (KVM: x86: use guest_exit_irqoff), the original comment about the IF bit
> in rflags is incorrect now.
>
> Signed-off-by: Longpeng(Mike) <longpeng2@huawei.com>
> ---
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> @@ -8647,9 +8647,12 @@ static void vmx_handle_external_intr(struct kvm_vcpu *vcpu)
> register void *__sp asm(_ASM_SP);
>
> /*
> - * If external interrupt exists, IF bit is set in rflags/eflags on the
> - * interrupt stack frame, and interrupt will be enabled on a return
> - * from interrupt handler.
Good catch, thanks.
We want to change it, but I think that the new comment is an overkill.
I am generally not a fan of code comments that describe what the code
does; code speaks for itself and it is better to fix the code, e.g.
split into well named functions, instead of duplicating it.
> + * If external interrupt exists, fakes an interrupt stack and jump to
> + * idt table to let real handler to handle it.
This is the duplication I was talking about. If the corresponding part
of the code is not obvious, it would be better to rework it instead.
> Because most of bits in
> + * rflags are cleared when VM exit(Intel SDM volum 3, chapter 27.5.3),
> + * the IF bit is 0 in rflags on the interrupt stack frame, so interrupt
> + * is still disabled when return from the irq handler, but it will be
> + * enabled later by the caller.
This part is acceptable as it gives a new information code, yet the
function does not modify flags, which makes it unremarkable.
And dependencies on the caller would be better described in a header
(if we cannot express them well in the code).
The most comment-worthy thing about this function is the reason why we
execute the interrupt handler manually, i.e. the dependency on
VM_EXIT_ACK_INTR_ON_EXIT, but that is easy to tell from the commit
message and convenient access to git history is essential in a workflow,
so providing a leeway could be counter-productive.
I would go with no comment for now.
next prev parent reply other threads:[~2016-10-11 18:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-10 0:23 [PATCH] kvm: x86: correct the misleading comment in vmx_handle_external_intr Longpeng(Mike)
2016-10-11 18:23 ` Radim Krčmář [this message]
2016-10-12 1:15 ` Longpeng (Mike)
2016-10-12 14:05 ` Radim Krčmář
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=20161011182337.GB16406@potion \
--to=rkrcmar@redhat.com \
--cc=hpa@zytor.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=longpeng2@huawei.com \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=richard.weiyang@huawei.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
--cc=zhaoshenglong@huawei.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;
as well as URLs for NNTP newsgroup(s).