public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] KVM: x86: Fix poll command
@ 2023-04-13 12:11 alexjlzheng
  2023-04-14 17:50 ` Sean Christopherson
  0 siblings, 1 reply; 5+ messages in thread
From: alexjlzheng @ 2023-04-13 12:11 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 pic_poll_read():
1. Set Bit 7 when there is an interrupt
2. Return 0 when there is no interrupt

Signed-off-by: Jinliang Zheng <alexjlzheng@tencent.com>
---
Changes since Version V2:
- Keep the logic of pic_poll_read(), only fix the return value
---
 arch/x86/kvm/i8259.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kvm/i8259.c b/arch/x86/kvm/i8259.c
index 4756bcb5724f..6627f8a52f23 100644
--- a/arch/x86/kvm/i8259.c
+++ b/arch/x86/kvm/i8259.c
@@ -411,8 +411,9 @@ static u32 pic_poll_read(struct kvm_kpic_state *s, u32 addr1)
 		pic_clear_isr(s, ret);
 		if (addr1 >> 7 || ret != 2)
 			pic_update_irq(s->pics_state);
+		ret |= 0x80;
 	} else {
-		ret = 0x07;
+		ret = 0x00;
 		pic_update_irq(s->pics_state);
 	}
 
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-04-18  7:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-13 12:11 [PATCH v2] KVM: x86: Fix poll command alexjlzheng
2023-04-14 17:50 ` Sean Christopherson
2023-04-15  3:30   ` alexjlzheng
2023-04-17 16:51     ` Sean Christopherson
2023-04-18  7:59       ` alexjlzheng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox