qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] target/i386/monitor: synchronize cpu before printing lapic state
@ 2023-10-26 15:39 David Woodhouse
  2023-10-26 16:39 ` Dongli Zhang
  0 siblings, 1 reply; 3+ messages in thread
From: David Woodhouse @ 2023-10-26 15:39 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Marcelo Tosatti, kvm, Richard Henderson,
	Philippe Mathieu-Daudé, Thomas Huth

[-- Attachment #1: Type: text/plain, Size: 1058 bytes --]

From: David Woodhouse <dwmw@amazon.co.uk>

Where the local APIC is emulated by KVM, we need kvm_get_apic() to pull
the current state into userspace before it's printed. Otherwise we get
stale values.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
---
 target/i386/monitor.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/target/i386/monitor.c b/target/i386/monitor.c
index 6512846327..0754d699ba 100644
--- a/target/i386/monitor.c
+++ b/target/i386/monitor.c
@@ -29,6 +29,7 @@
 #include "monitor/hmp.h"
 #include "qapi/qmp/qdict.h"
 #include "sysemu/kvm.h"
+#include "sysemu/hw_accel.h"
 #include "qapi/error.h"
 #include "qapi/qapi-commands-misc-target.h"
 #include "qapi/qapi-commands-misc.h"
@@ -655,6 +656,7 @@ void hmp_info_local_apic(Monitor *mon, const QDict *qdict)
     if (qdict_haskey(qdict, "apic-id")) {
         int id = qdict_get_try_int(qdict, "apic-id", 0);
         cs = cpu_by_arch_id(id);
+        cpu_synchronize_state(cs);
     } else {
         cs = mon_get_cpu(mon);
     }
-- 
2.34.1



[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5965 bytes --]

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

* Re: [PATCH] target/i386/monitor: synchronize cpu before printing lapic state
  2023-10-26 15:39 [PATCH] target/i386/monitor: synchronize cpu before printing lapic state David Woodhouse
@ 2023-10-26 16:39 ` Dongli Zhang
  2023-10-26 21:33   ` Dongli Zhang
  0 siblings, 1 reply; 3+ messages in thread
From: Dongli Zhang @ 2023-10-26 16:39 UTC (permalink / raw)
  To: David Woodhouse, qemu-devel
  Cc: Paolo Bonzini, Marcelo Tosatti, kvm, Richard Henderson,
	Philippe Mathieu-Daudé, Thomas Huth

Hi David,

On 10/26/23 08:39, David Woodhouse wrote:
> From: David Woodhouse <dwmw@amazon.co.uk>
> 
> Where the local APIC is emulated by KVM, we need kvm_get_apic() to pull
> the current state into userspace before it's printed. Otherwise we get
> stale values.
> 
> Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
> ---
>  target/i386/monitor.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/target/i386/monitor.c b/target/i386/monitor.c
> index 6512846327..0754d699ba 100644
> --- a/target/i386/monitor.c
> +++ b/target/i386/monitor.c
> @@ -29,6 +29,7 @@
>  #include "monitor/hmp.h"
>  #include "qapi/qmp/qdict.h"
>  #include "sysemu/kvm.h"
> +#include "sysemu/hw_accel.h"
>  #include "qapi/error.h"
>  #include "qapi/qapi-commands-misc-target.h"
>  #include "qapi/qapi-commands-misc.h"
> @@ -655,6 +656,7 @@ void hmp_info_local_apic(Monitor *mon, const QDict *qdict)
>      if (qdict_haskey(qdict, "apic-id")) {
>          int id = qdict_get_try_int(qdict, "apic-id", 0);
>          cs = cpu_by_arch_id(id);
> +        cpu_synchronize_state(cs);

AFAIR, there is a case that cs may be NULL here when I was sending the similar
bugfix long time ago.

https://lore.kernel.org/qemu-devel/20210701214051.1588-1-dongli.zhang@oracle.com/

... and resend:

https://lore.kernel.org/qemu-devel/20210908143803.29191-1-dongli.zhang@oracle.com/

... and resent by Daniel as part of another patchset (after review):

https://lore.kernel.org/qemu-devel/20211028155457.967291-19-berrange@redhat.com/


This utility is helpful for the diagnostic of loss of interrupt issue.

Dongli Zhang

>      } else {
>          cs = mon_get_cpu(mon);
>      }


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

* Re: [PATCH] target/i386/monitor: synchronize cpu before printing lapic state
  2023-10-26 16:39 ` Dongli Zhang
@ 2023-10-26 21:33   ` Dongli Zhang
  0 siblings, 0 replies; 3+ messages in thread
From: Dongli Zhang @ 2023-10-26 21:33 UTC (permalink / raw)
  To: David Woodhouse, qemu-devel
  Cc: Paolo Bonzini, Marcelo Tosatti, kvm, Richard Henderson,
	Philippe Mathieu-Daudé, Thomas Huth

Hi David,

Thank you very much for the Reviewed-by in another thread.

I have re-based the patch and sent again.

https://lore.kernel.org/all/20231026211938.162815-1-dongli.zhang@oracle.com/

Dongli Zhang

On 10/26/23 09:39, Dongli Zhang wrote:
> Hi David,
> 
> On 10/26/23 08:39, David Woodhouse wrote:
>> From: David Woodhouse <dwmw@amazon.co.uk>
>>
>> Where the local APIC is emulated by KVM, we need kvm_get_apic() to pull
>> the current state into userspace before it's printed. Otherwise we get
>> stale values.
>>
>> Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
>> ---
>>  target/i386/monitor.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/target/i386/monitor.c b/target/i386/monitor.c
>> index 6512846327..0754d699ba 100644
>> --- a/target/i386/monitor.c
>> +++ b/target/i386/monitor.c
>> @@ -29,6 +29,7 @@
>>  #include "monitor/hmp.h"
>>  #include "qapi/qmp/qdict.h"
>>  #include "sysemu/kvm.h"
>> +#include "sysemu/hw_accel.h"
>>  #include "qapi/error.h"
>>  #include "qapi/qapi-commands-misc-target.h"
>>  #include "qapi/qapi-commands-misc.h"
>> @@ -655,6 +656,7 @@ void hmp_info_local_apic(Monitor *mon, const QDict *qdict)
>>      if (qdict_haskey(qdict, "apic-id")) {
>>          int id = qdict_get_try_int(qdict, "apic-id", 0);
>>          cs = cpu_by_arch_id(id);
>> +        cpu_synchronize_state(cs);
> 
> AFAIR, there is a case that cs may be NULL here when I was sending the similar
> bugfix long time ago.
> 
> https://lore.kernel.org/qemu-devel/20210701214051.1588-1-dongli.zhang@oracle.com/
> 
> ... and resend:
> 
> https://lore.kernel.org/qemu-devel/20210908143803.29191-1-dongli.zhang@oracle.com/
> 
> ... and resent by Daniel as part of another patchset (after review):
> 
> https://lore.kernel.org/qemu-devel/20211028155457.967291-19-berrange@redhat.com/
> 
> 
> This utility is helpful for the diagnostic of loss of interrupt issue.
> 
> Dongli Zhang
> 
>>      } else {
>>          cs = mon_get_cpu(mon);
>>      }


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

end of thread, other threads:[~2023-10-26 21:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-26 15:39 [PATCH] target/i386/monitor: synchronize cpu before printing lapic state David Woodhouse
2023-10-26 16:39 ` Dongli Zhang
2023-10-26 21:33   ` Dongli Zhang

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).