[PATCH v3 00/10] Cleanup patches, mostly PC-related

Bernhard Beschow posted 10 patches 3 weeks, 4 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20251019210303.104718-1-shentey@gmail.com
Maintainers: Gerd Hoffmann <kraxel@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Richard Henderson <richard.henderson@linaro.org>, Eduardo Habkost <eduardo@habkost.net>, "Michael S. Tsirkin" <mst@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, John Snow <jsnow@redhat.com>, Zhao Liu <zhao1.liu@intel.com>, Cameron Esfahani <dirty@apple.com>, Roman Bolshakov <rbolshakov@ddn.com>, Phil Dennis-Jordan <phil@philjordan.eu>, Marcelo Tosatti <mtosatti@redhat.com>, Sunil Muthuswamy <sunilmut@microsoft.com>, Fabiano Rosas <farosas@suse.de>, Laurent Vivier <lvivier@redhat.com>
hw/ide/ide-internal.h                |   2 +-
include/hw/i386/apic.h               |  37 ++++----
include/hw/i386/apic_internal.h      |   7 +-
target/i386/cpu.h                    |   4 +-
target/i386/kvm/kvm_i386.h           |   2 +-
target/i386/whpx/whpx-internal.h     |   2 +-
hw/audio/pcspk.c                     |  10 ++-
hw/i386/kvm/apic.c                   |   3 +-
hw/i386/vapic.c                      |   2 +-
hw/i386/x86-cpu.c                    |   2 +-
hw/ide/ahci.c                        |   8 +-
hw/ide/core.c                        |  10 +--
hw/intc/apic.c                       | 126 ++++++++++-----------------
hw/intc/apic_common.c                |  56 ++++--------
hw/rtc/mc146818rtc.c                 |  20 ++---
hw/timer/i8254.c                     |   6 ++
target/i386/cpu-apic.c               |  18 ++--
target/i386/cpu-dump.c               |   2 +-
target/i386/cpu.c                    |   2 +-
target/i386/hvf/hvf.c                |   4 +-
target/i386/kvm/kvm.c                |   2 +-
target/i386/tcg/system/misc_helper.c |   4 +-
target/i386/whpx/whpx-apic.c         |   3 +-
tests/qtest/ds1338-test.c            |  12 +--
hw/audio/trace-events                |   4 +
hw/rtc/trace-events                  |   4 +
hw/timer/trace-events                |   4 +
27 files changed, 158 insertions(+), 198 deletions(-)
[PATCH v3 00/10] Cleanup patches, mostly PC-related
Posted by Bernhard Beschow 3 weeks, 4 days ago
This series mostly contains PC-related patches I came up with when doing
"virtual retrocomputing" with my via-apollo-pro-133t branch [1]. It includes
improved tracing and reduced usage of cpu_get_current_apic(). The remaining
patch resolves duplicate code in the test of DS1338 RTC which is used in e500
machines.

v3:
* Don't remove cpu_get_current_apic() since it is needed in
  apic_mem_{read,write} (the local APIC memory regions aren't per CPU)

v2:
* Remove some redundant APIC_COMMON(cpu->apic_state) casts
* Resolve cpu_get_current_apic()

Testing done:
* make check
* Work with recent x86_64 Linux distribution running on WHPX

[1] https://github.com/shentok/qemu/tree/via-apollo-pro-133t

Bernhard Beschow (10):
  hw/timer/i8254: Add I/O trace events
  hw/audio/pcspk: Add I/O trace events
  hw/rtc/mc146818rtc: Convert CMOS_DPRINTF() into trace events
  hw/rtc/mc146818rtc: Use ARRAY_SIZE macro
  hw/rtc/mc146818rtc: Assert correct usage of
    mc146818rtc_set_cmos_data()
  hw/ide/ide-internal: Move dma_buf_commit() into ide "namespace"
  hw/i386/apic: Prefer APICCommonState over DeviceState
  hw/i386/apic: Ensure own APIC use in apic_msr_{read,write}
  hw/intc/apic: Pass APICCommonState to apic_register_{read,write}
  tests/qtest/ds1338-test: Reuse from_bcd()

 hw/ide/ide-internal.h                |   2 +-
 include/hw/i386/apic.h               |  37 ++++----
 include/hw/i386/apic_internal.h      |   7 +-
 target/i386/cpu.h                    |   4 +-
 target/i386/kvm/kvm_i386.h           |   2 +-
 target/i386/whpx/whpx-internal.h     |   2 +-
 hw/audio/pcspk.c                     |  10 ++-
 hw/i386/kvm/apic.c                   |   3 +-
 hw/i386/vapic.c                      |   2 +-
 hw/i386/x86-cpu.c                    |   2 +-
 hw/ide/ahci.c                        |   8 +-
 hw/ide/core.c                        |  10 +--
 hw/intc/apic.c                       | 126 ++++++++++-----------------
 hw/intc/apic_common.c                |  56 ++++--------
 hw/rtc/mc146818rtc.c                 |  20 ++---
 hw/timer/i8254.c                     |   6 ++
 target/i386/cpu-apic.c               |  18 ++--
 target/i386/cpu-dump.c               |   2 +-
 target/i386/cpu.c                    |   2 +-
 target/i386/hvf/hvf.c                |   4 +-
 target/i386/kvm/kvm.c                |   2 +-
 target/i386/tcg/system/misc_helper.c |   4 +-
 target/i386/whpx/whpx-apic.c         |   3 +-
 tests/qtest/ds1338-test.c            |  12 +--
 hw/audio/trace-events                |   4 +
 hw/rtc/trace-events                  |   4 +
 hw/timer/trace-events                |   4 +
 27 files changed, 158 insertions(+), 198 deletions(-)

-- 
2.51.1.dirty

Re: [PATCH v3 00/10] Cleanup patches, mostly PC-related
Posted by Philippe Mathieu-Daudé 3 weeks, 2 days ago
On 19/10/25 23:02, Bernhard Beschow wrote:

> Bernhard Beschow (10):
>    hw/timer/i8254: Add I/O trace events
>    hw/audio/pcspk: Add I/O trace events
>    hw/rtc/mc146818rtc: Convert CMOS_DPRINTF() into trace events
>    hw/rtc/mc146818rtc: Use ARRAY_SIZE macro
>    hw/rtc/mc146818rtc: Assert correct usage of
>      mc146818rtc_set_cmos_data()
>    hw/ide/ide-internal: Move dma_buf_commit() into ide "namespace"
>    hw/i386/apic: Prefer APICCommonState over DeviceState
>    hw/i386/apic: Ensure own APIC use in apic_msr_{read,write}
>    hw/intc/apic: Pass APICCommonState to apic_register_{read,write}
>    tests/qtest/ds1338-test: Reuse from_bcd()

Thanks, except if Paolo/MST/Igor object, series queued squashing:

-- >8 --
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index 67ff52a8b40..d981ca05977 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -29,2 +29,3 @@
  #include "exec/memop.h"
+#include "hw/i386/apic.h"
  #include "hw/i386/topology.h"
@@ -2352,3 +2352,3 @@ struct ArchCPU {
         user */
-    struct APICCommonState *apic_state;
+    APICCommonState *apic_state;
      struct MemoryRegion *cpu_as_root, *cpu_as_mem, *smram;
diff --git a/target/i386/whpx/whpx-internal.h 
b/target/i386/whpx/whpx-internal.h
index 066e16bd8e2..2dcad1f5650 100644
--- a/target/i386/whpx/whpx-internal.h
+++ b/target/i386/whpx/whpx-internal.h
@@ -7,2 +7,4 @@

+#include "hw/i386/apic.h"
+
  typedef enum WhpxBreakpointState {
@@ -46,3 +48,3 @@ struct whpx_state {
  extern struct whpx_state whpx_global;
-void whpx_apic_get(struct APICCommonState *s);
+void whpx_apic_get(APICCommonState *s);

---
Re: [PATCH v3 00/10] Cleanup patches, mostly PC-related
Posted by Philippe Mathieu-Daudé 3 weeks, 2 days ago
On 21/10/25 18:07, Philippe Mathieu-Daudé wrote:
> On 19/10/25 23:02, Bernhard Beschow wrote:
> 
>> Bernhard Beschow (10):
>>    hw/timer/i8254: Add I/O trace events
>>    hw/audio/pcspk: Add I/O trace events
>>    hw/rtc/mc146818rtc: Convert CMOS_DPRINTF() into trace events
>>    hw/rtc/mc146818rtc: Use ARRAY_SIZE macro
>>    hw/rtc/mc146818rtc: Assert correct usage of
>>      mc146818rtc_set_cmos_data()
>>    hw/ide/ide-internal: Move dma_buf_commit() into ide "namespace"
>>    hw/i386/apic: Prefer APICCommonState over DeviceState
>>    hw/i386/apic: Ensure own APIC use in apic_msr_{read,write}
>>    hw/intc/apic: Pass APICCommonState to apic_register_{read,write}
>>    tests/qtest/ds1338-test: Reuse from_bcd()
> 
> Thanks, except if Paolo/MST/Igor object, series queued squashing:
> 
> -- >8 --
> diff --git a/target/i386/cpu.h b/target/i386/cpu.h
> index 67ff52a8b40..d981ca05977 100644
> --- a/target/i386/cpu.h
> +++ b/target/i386/cpu.h
> @@ -29,2 +29,3 @@
>   #include "exec/memop.h"
> +#include "hw/i386/apic.h"
>   #include "hw/i386/topology.h"
> @@ -2352,3 +2352,3 @@ struct ArchCPU {
>          user */
> -    struct APICCommonState *apic_state;
> +    APICCommonState *apic_state;
>       struct MemoryRegion *cpu_as_root, *cpu_as_mem, *smram;
> diff --git a/target/i386/whpx/whpx-internal.h b/target/i386/whpx/whpx- 
> internal.h
> index 066e16bd8e2..2dcad1f5650 100644
> --- a/target/i386/whpx/whpx-internal.h
> +++ b/target/i386/whpx/whpx-internal.h
> @@ -7,2 +7,4 @@
> 
> +#include "hw/i386/apic.h"
> +
>   typedef enum WhpxBreakpointState {
> @@ -46,3 +48,3 @@ struct whpx_state {
>   extern struct whpx_state whpx_global;
> -void whpx_apic_get(struct APICCommonState *s);
> +void whpx_apic_get(APICCommonState *s);
> 
> ---

Also squashing:

-- >8 --
diff --git a/hw/intc/apic.c b/hw/intc/apic.c
index 077ef18686b..aad253af158 100644
--- a/hw/intc/apic.c
+++ b/hw/intc/apic.c
@@ -1056,4 +1055,0 @@ static void apic_mem_write(void *opaque, hwaddr 
addr, uint64_t val,
-    if (!s) {
-        return;
-    }
-
@@ -1072,0 +1069,4 @@ static void apic_mem_write(void *opaque, hwaddr 
addr, uint64_t val,
+    if (!s) {
+        return;
+    }
+
---