* [PATCH kvm RESEND] KVM: i8259: Fix poll command
@ 2023-04-10 3:10 alexjlzheng
2023-04-10 16:32 ` Sean Christopherson
0 siblings, 1 reply; 2+ messages in thread
From: alexjlzheng @ 2023-04-10 3:10 UTC (permalink / raw)
To: seanjc, pbonzini, tglx, mingo, bp, dave.hansen, x86, hpa
Cc: kvm, linux-kernel, Jinliang Zheng
From: Jinliang Zheng <alexjlzheng@tencent.com>
According to the hardware manual, when the Poll command is issued, the
byte returned by the I/O read is 1 in Bit 7 when there is an interrupt,
and the highest priority binary code in Bits 2:0. The current pic
simulation code is not implemented strictly according to the above
expression.
Fix the implementation of poll mode in pic simulation by pic_intack,
and remove redundant pic_poll_read code.
Signed-off-by: Jinliang Zheng <alexjlzheng@tencent.com>
---
arch/x86/kvm/i8259.c | 29 ++++++-----------------------
1 file changed, 6 insertions(+), 23 deletions(-)
diff --git a/arch/x86/kvm/i8259.c b/arch/x86/kvm/i8259.c
index 4756bcb5724f..bc5b758e8f73 100644
--- a/arch/x86/kvm/i8259.c
+++ b/arch/x86/kvm/i8259.c
@@ -397,35 +397,18 @@ static void pic_ioport_write(void *opaque, u32 addr, u32 val)
}
}
-static u32 pic_poll_read(struct kvm_kpic_state *s, u32 addr1)
-{
- int ret;
-
- ret = pic_get_irq(s);
- if (ret >= 0) {
- if (addr1 >> 7) {
- s->pics_state->pics[0].isr &= ~(1 << 2);
- s->pics_state->pics[0].irr &= ~(1 << 2);
- }
- s->irr &= ~(1 << ret);
- pic_clear_isr(s, ret);
- if (addr1 >> 7 || ret != 2)
- pic_update_irq(s->pics_state);
- } else {
- ret = 0x07;
- pic_update_irq(s->pics_state);
- }
-
- return ret;
-}
-
static u32 pic_ioport_read(void *opaque, u32 addr)
{
struct kvm_kpic_state *s = opaque;
int ret;
if (s->poll) {
- ret = pic_poll_read(s, addr);
+ ret = pic_get_irq(s);
+ if (ret >= 0) {
+ pic_intack(s, ret);
+ ret |= 0x80;
+ } else
+ ret = 0;
s->poll = 0;
} else
if ((addr & 1) == 0)
--
2.37.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH kvm RESEND] KVM: i8259: Fix poll command
2023-04-10 3:10 [PATCH kvm RESEND] KVM: i8259: Fix poll command alexjlzheng
@ 2023-04-10 16:32 ` Sean Christopherson
0 siblings, 0 replies; 2+ messages in thread
From: Sean Christopherson @ 2023-04-10 16:32 UTC (permalink / raw)
To: alexjlzheng
Cc: pbonzini, tglx, mingo, bp, dave.hansen, x86, hpa, kvm,
linux-kernel, Jinliang Zheng
Please don't use RESEND as a ping, just respond to the original patch with a "Ping",
or any question you might have. I know Documentation/process/submitting-patches.rst
says its ok to RESEND after a couple of weeks, but IMO that's overly aggressive
and just creates noise, e.g. your original patch was in my todo list, I just hadn't
gotten too it. If you can't get a response after multiple pings, then by all means
RESEND, but in the future, please try pinging first.
For the patch context, there's no need to put "kvm" after patch, i.e. [PATCH], or
in this case [PATCH RESEND]. The "KVM:" namespace in the shortlog provides
sufficient context.
Regarding the shortlog, if a v2 is needed, ignore the somewhat messy history of
this file and use "KVM: x86:".
On Mon, Apr 10, 2023, alexjlzheng@gmail.com wrote:
> From: Jinliang Zheng <alexjlzheng@tencent.com>
>
> According to the hardware manual, when the Poll command is issued, the
> byte returned by the I/O read is 1 in Bit 7 when there is an interrupt,
> and the highest priority binary code in Bits 2:0. The current pic
> simulation code is not implemented strictly according to the above
> expression.
There is way too much going on in this patch for this to be a sufficient description.
pic_intack() is not a direct replacement for the open coded logic in pic_poll_read(),
modulo the setting of bit 7. E.g. there's no explanation for the "addr1 >> 7"
logic, pic_clear_isr() is conditionally called on auto_eoi, priority_add is now
modified, pic_update_irq() is no longer called, and so on and so forth.
Maybe the patch is correct and pic_poll_read() was completely broken, but if that's
the case, the changelog needs to be _much_ more verbose in explaining everything.
> Fix the implementation of poll mode in pic simulation by pic_intack,
Add () when referencing functions by name, i.e. pic_intack().
> and remove redundant pic_poll_read code.
Removing pic_poll() needs to be done in a separate patch. Removing the helper
while simultaneously modifying its effective code makes the patch unnecessarily
difficult to review.
> Signed-off-by: Jinliang Zheng <alexjlzheng@tencent.com>
> ---
> arch/x86/kvm/i8259.c | 29 ++++++-----------------------
> 1 file changed, 6 insertions(+), 23 deletions(-)
>
> diff --git a/arch/x86/kvm/i8259.c b/arch/x86/kvm/i8259.c
> index 4756bcb5724f..bc5b758e8f73 100644
> --- a/arch/x86/kvm/i8259.c
> +++ b/arch/x86/kvm/i8259.c
> @@ -397,35 +397,18 @@ static void pic_ioport_write(void *opaque, u32 addr, u32 val)
> }
> }
>
> -static u32 pic_poll_read(struct kvm_kpic_state *s, u32 addr1)
> -{
> - int ret;
> -
> - ret = pic_get_irq(s);
> - if (ret >= 0) {
> - if (addr1 >> 7) {
> - s->pics_state->pics[0].isr &= ~(1 << 2);
> - s->pics_state->pics[0].irr &= ~(1 << 2);
> - }
> - s->irr &= ~(1 << ret);
> - pic_clear_isr(s, ret);
> - if (addr1 >> 7 || ret != 2)
> - pic_update_irq(s->pics_state);
> - } else {
> - ret = 0x07;
> - pic_update_irq(s->pics_state);
> - }
> -
> - return ret;
> -}
> -
> static u32 pic_ioport_read(void *opaque, u32 addr)
> {
> struct kvm_kpic_state *s = opaque;
> int ret;
>
> if (s->poll) {
> - ret = pic_poll_read(s, addr);
> + ret = pic_get_irq(s);
> + if (ret >= 0) {
> + pic_intack(s, ret);
> + ret |= 0x80;
> + } else
All branches in an if-elif-else statment need curly braces if any branch needs
statements (again, ignore the bad "prior art" in this file), i.e.
if (ret >= 0) {
...
} else {
ret = 0;
}
> + ret = 0;
> s->poll = 0;
> } else
> if ((addr & 1) == 0)
> --
> 2.37.3
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-04-10 16:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-10 3:10 [PATCH kvm RESEND] KVM: i8259: Fix poll command alexjlzheng
2023-04-10 16:32 ` Sean Christopherson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox