Re: Deprecation of the LM32 target

2020-12-26 Thread Thomas Huth

On 24/12/2020 10.53, John Paul Adrian Glaubitz wrote:

Hello!

I was just browsing through the QEMU Christmas Calendar [1] and noticed
the announcement for the deprecation of the LM32 target.

I'm not sure what the motivation of the deprecation is, but isn't one of
the big selling points of QEMU to support deprecated targets?

If QEMU eventually ends up supporting commercially available targets only
and kicking out everything that is obsolete, I'm not sure what the point
of QEMU would be in the first place as products like VMWare and VirtualBox
already provide virtualization functionality.

Please don't deprecate targets just because they're old.


 Hi,

the problem is not that the target CPU is old, but rather that according to 
the (former?) maintainer, there are no users left:


 https://www.mail-archive.com/qemu-devel@nongnu.org/msg605024.html

So it got marked as deprecated in this commit here:

 https://git.qemu.org/?p=qemu.git;a=commitdiff;h=d84980051229fa43c96b3

Without maintainer and without users, there is no point in keeping this 
target, is there?


 Thomas




Re: Deprecation of the LM32 target

2020-12-26 Thread John Paul Adrian Glaubitz
Hello!

On 12/26/20 9:39 AM, Thomas Huth wrote:
> the problem is not that the target CPU is old, but rather that according to 
> the (former?) maintainer, there are no users left:
> 
>  https://www.mail-archive.com/qemu-devel@nongnu.org/msg605024.html
> 
> So it got marked as deprecated in this commit here:
> 
>  https://git.qemu.org/?p=qemu.git;a=commitdiff;h=d84980051229fa43c96b3
> 
> Without maintainer and without users, there is no point in keeping this 
> target, is there?

I'm not sure how you determine whether there are people using the code or not. 
There
is no really user tracking in QEMU, is there?

And the maintainer's claim that RISC-V takes over makes no sense either. The 
point of
emulators is to be able to run old and existing software. If a target had only a
justification to exist while it's commercially viable, you would have to remove 
90%
of the targets in QEMU.

I mean, the whole point of an emulator is being able to run existing code on 
modern hardware,
usually because the old hardware is no longer available. And as long as the 
target is
functional, I don't see a point in taking away the functionality.

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaub...@debian.org
`. `'   Freie Universitaet Berlin - glaub...@physik.fu-berlin.de
  `-GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913




Re: Deprecation of the LM32 target

2020-12-26 Thread Michael Walle

Hi,

Am 2020-12-26 10:06, schrieb John Paul Adrian Glaubitz:

Hello!

On 12/26/20 9:39 AM, Thomas Huth wrote:
the problem is not that the target CPU is old, but rather that 
according to the (former?) maintainer, there are no users left:


 https://www.mail-archive.com/qemu-devel@nongnu.org/msg605024.html

So it got marked as deprecated in this commit here:

 https://git.qemu.org/?p=qemu.git;a=commitdiff;h=d84980051229fa43c96b3

Without maintainer and without users, there is no point in keeping 
this target, is there?


I'm not sure how you determine whether there are people using the code
or not. There
is no really user tracking in QEMU, is there?


That is correct, one cannot know if there are actually users of the
milkymist board or the lattice eval board. These are the two only
supported boards. The (or I should better say "my") main purpose to
add a qemu target for milkymist was to help the developers of the
board, e.g. to ease debugging, etc. But development has stopped
long time ago [1]. I've never seen a request to add a new board.


And the maintainer's claim that RISC-V takes over makes no sense
either.


I've meant the ecosystem around the SoC. LM32 on linux never took of,
mostly because there is no MMU (we've worked on one though). There is
no official lm32 support in linux and g++ support is broken (or never
even worked). While for RISC-V there is huge userbase building all sorts
of tooling.

There is a project called LiteX [2], some sort of toolbox to build your
own SoC, which supports the LM32 as a CPU component. But I've never seen
anyone trying to add a board to qemu.


The point of
emulators is to be able to run old and existing software. If a target 
had only a

justification to exist while it's commercially viable, you would have
to remove 90% of the targets in QEMU.
I mean, the whole point of an emulator is being able to run existing
code on modern hardware,
usually because the old hardware is no longer available. And as long
as the target is
functional, I don't see a point in taking away the functionality.


I'm not arguing against this. In fact, I'd also like to keep the lm32
qemu target, but I personally don't have any time for that anymore. And
I don't know if its fair to put the burdon of unmaintained boards to all
the qemu developers. There are a lot of test cases for the LM32
target, but these only cover the CPU instructions. The last time I've
looked audio was broken. So without anyone caring about the target, it
won't also be much help for the user either.

-michael

[1] 
https://github.com/m-labs/milkymist/commit/7d944d3dcffb5e528a44937b10123ff65a0aecbc

[2] https://github.com/enjoy-digital/litex



[PATCH 0/8] Fix memory leak of some device state in migration

2020-12-26 Thread g00517791
From: Jinhao Gao 

For some device state having some fields of VMS_ALLOC flag, they don't
free memory allocated for the fields in vmstate_save_state and vmstate
_load_state. We add funcs or sentences of free memory before allocation
of memory or after load of memory to avoid memory leak.




Jinhao Gao (8):
  vmbus: Fix memory leak of vmstate_gpadl
  virtio-net: Fix memory leak of vmstate_virtio_net_rss
  spapr: Fix memory leak of vmstate_spapr_event_entry
  spapr_pci: Fix memory leak of vmstate_spapr_pci
  savevm: Fix memory leak of vmstate_configuration
  vmbus: Fix memory leak of vmstate_vmbus_chan_req
  tpm_emulator: Fix memory leak of vmstate_tpm_emulator
  dbus-vmstate: Fix memory leak of dbus_vmstate

 backends/dbus-vmstate.c | 11 +++
 backends/tpm/tpm_emulator.c | 13 +
 hw/hyperv/vmbus.c   | 22 ++
 hw/net/virtio-net.c | 11 +++
 hw/ppc/spapr.c  | 12 
 hw/ppc/spapr_pci.c  | 11 +++
 migration/savevm.c  | 31 +++
 7 files changed, 107 insertions(+), 4 deletions(-)

-- 
2.23.0




[PATCH 2/8] virtio-net: Fix memory leak of vmstate_virtio_net_rss

2020-12-26 Thread g00517791
From: Jinhao Gao 

When VM migrate VMState of virtio-net-device/rss, the field(rss_data.
indirections_table) of virtio-net-device/rss having a flag of VMS_ALLOC
needs to allocate memory. If the dst doesn't free memory which has bee
n allocated for SaveStateEntry of virtio-net-device/rss before dst loads
device state, it may result that the pointer of rss_data.indirections_table
is overlaid when vm loads. We add the pre_load func to free memory, which
prevents memory leak.

Signed-off-by: Jinhao Gao 
---
 hw/net/virtio-net.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 044ac95f6f..102e51f32f 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -2957,11 +2957,22 @@ static bool virtio_net_rss_needed(void *opaque)
 return VIRTIO_NET(opaque)->rss_data.enabled;
 }
 
+static int virtio_net_rss_pre_load(void *opaque)
+{
+VirtIONet *n = VIRTIO_NET(opaque);
+
+g_free(n->rss_data.indirections_table);
+n->rss_data.indirections_table = NULL;
+n->rss_data.indirections_len = 0;
+return 0;
+}
+
 static const VMStateDescription vmstate_virtio_net_rss = {
 .name  = "virtio-net-device/rss",
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = virtio_net_rss_needed,
+.pre_load = virtio_net_rss_pre_load,
 .fields = (VMStateField[]) {
 VMSTATE_BOOL(rss_data.enabled, VirtIONet),
 VMSTATE_BOOL(rss_data.redirect, VirtIONet),
-- 
2.23.0




[PATCH 7/8] tpm_emulator: Fix memory leak of vmstate_tpm_emulator

2020-12-26 Thread g00517791
From: Jinhao Gao 

When VM migrate VMState of tpm-emulator, the fields(state_blobs.
permanent.buffer, state_blobs.volatil.buffer and state_blobs.savestate.
buffer) of tpm-emulator having a flag of VMS_ALLOC need to allocate
memory. If the dst doesn't free memory which has been allocated for
SaveStateEntry of tpm-emulator before dst loads device state, it may
result that the pointers of state_blobs.permanent.buffer, state_blobs.
volatil.buffer and state_blobs.savestate.buffer are overlaid when vm
loads. We add the pre_load func to free memory, which prevents memory
leak.

Signed-off-by: Jinhao Gao 
---
 backends/tpm/tpm_emulator.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/backends/tpm/tpm_emulator.c b/backends/tpm/tpm_emulator.c
index a012adc193..7ffa95dbce 100644
--- a/backends/tpm/tpm_emulator.c
+++ b/backends/tpm/tpm_emulator.c
@@ -857,6 +857,18 @@ static int tpm_emulator_pre_save(void *opaque)
 return tpm_emulator_get_state_blobs(tpm_emu);
 }
 
+static int tpm_emulator_pre_load(void *opaque)
+{
+TPMBackend *tb = opaque;
+TPMEmulator *tpm_emu = TPM_EMULATOR(tb);
+TPMBlobBuffers *state_blobs = &tpm_emu->state_blobs;
+
+tpm_sized_buffer_reset(&state_blobs->volatil);
+tpm_sized_buffer_reset(&state_blobs->permanent);
+tpm_sized_buffer_reset(&state_blobs->savestate);
+return 0;
+}
+
 /*
  * Load the TPM state blobs into the TPM.
  *
@@ -883,6 +895,7 @@ static const VMStateDescription vmstate_tpm_emulator = {
 .name = "tpm-emulator",
 .version_id = 0,
 .pre_save = tpm_emulator_pre_save,
+.pre_load = tpm_emulator_pre_load,
 .post_load = tpm_emulator_post_load,
 .fields = (VMStateField[]) {
 VMSTATE_UINT32(state_blobs.permanent_flags, TPMEmulator),
-- 
2.23.0




[PATCH 5/8] savevm: Fix memory leak of vmstate_configuration

2020-12-26 Thread g00517791
From: Jinhao Gao 

When VM migrate VMState of configuration, the fields(name and capabilities)
of configuration having a flag of VMS_ALLOC need to allocate memory. If the
src doesn't free memory of capabilities in SaveState after save VMState of
configuration, or the dst doesn't free memory of name and capabilities in post
load of configuration, it may result in memory leak of name and capabilities.
We free memory in configuration_post_save and configuration_post_load func,
which prevents memory leak.

Signed-off-by: Jinhao Gao 
---
 migration/savevm.c | 31 +++
 1 file changed, 27 insertions(+), 4 deletions(-)

diff --git a/migration/savevm.c b/migration/savevm.c
index 5f937a2762..13f1a5dab7 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -314,6 +314,16 @@ static int configuration_pre_save(void *opaque)
 return 0;
 }
 
+static int configuration_post_save(void *opaque)
+{
+SaveState *state = opaque;
+
+g_free(state->capabilities);
+state->capabilities = NULL;
+state->caps_count = 0;
+return 0;
+}
+
 static int configuration_pre_load(void *opaque)
 {
 SaveState *state = opaque;
@@ -364,24 +374,36 @@ static int configuration_post_load(void *opaque, int 
version_id)
 {
 SaveState *state = opaque;
 const char *current_name = MACHINE_GET_CLASS(current_machine)->name;
+int ret = 0;
 
 if (strncmp(state->name, current_name, state->len) != 0) {
 error_report("Machine type received is '%.*s' and local is '%s'",
  (int) state->len, state->name, current_name);
-return -EINVAL;
+ret = -EINVAL;
+goto out;
 }
 
 if (state->target_page_bits != qemu_target_page_bits()) {
 error_report("Received TARGET_PAGE_BITS is %d but local is %d",
  state->target_page_bits, qemu_target_page_bits());
-return -EINVAL;
+ret = -EINVAL;
+goto out;
 }
 
 if (!configuration_validate_capabilities(state)) {
-return -EINVAL;
+ret = -EINVAL;
+goto out;
 }
 
-return 0;
+out:
+g_free((void *)state->name);
+state->name = NULL;
+state->len = 0;
+g_free(state->capabilities);
+state->capabilities = NULL;
+state->caps_count = 0;
+
+return ret;
 }
 
 static int get_capability(QEMUFile *f, void *pv, size_t size,
@@ -515,6 +537,7 @@ static const VMStateDescription vmstate_configuration = {
 .pre_load = configuration_pre_load,
 .post_load = configuration_post_load,
 .pre_save = configuration_pre_save,
+.post_save = configuration_post_save,
 .fields = (VMStateField[]) {
 VMSTATE_UINT32(len, SaveState),
 VMSTATE_VBUFFER_ALLOC_UINT32(name, SaveState, 0, NULL, len),
-- 
2.23.0




[PATCH 1/8] vmbus: Fix memory leak of vmstate_gpadl

2020-12-26 Thread g00517791
From: Jinhao Gao 

When VM migrate VMState of vmbus/gpadl, the field(gfns) of vmbus/
gpadl having a flag of VMS_ALLOC needs to allocate memory. If the
dst doesn't free memory which has been allocated for SaveStateEntry
of vmbus/gpadl before dst loads device state, it may result that
the pointer of gfns is overlaid when vm loads. We add the pre_load
func to free memory, which prevents memory leak.

Signed-off-by: Jinhao Gao 
---
 hw/hyperv/vmbus.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/hw/hyperv/vmbus.c b/hw/hyperv/vmbus.c
index 896e981f85..a91623aaac 100644
--- a/hw/hyperv/vmbus.c
+++ b/hw/hyperv/vmbus.c
@@ -519,10 +519,21 @@ void vmbus_unmap_sgl(VMBusChanReq *req, DMADirection dir, 
struct iovec *iov,
 }
 }
 
+static int vmbus_gpadl_pre_load(void *opaque)
+{
+VMBusGpadl *gpadl = VMBusGpadl(opaque);
+
+g_free(gpadl->gfns);
+gpadl->gfns = NULL;
+gpadl->num_gfns =0;
+return 0;
+}
+
 static const VMStateDescription vmstate_gpadl = {
 .name = "vmbus/gpadl",
 .version_id = 0,
 .minimum_version_id = 0,
+.pre_load = vmbus_gpadl_pre_load,
 .fields = (VMStateField[]) {
 VMSTATE_UINT32(id, VMBusGpadl),
 VMSTATE_UINT32(child_relid, VMBusGpadl),
-- 
2.23.0




[PATCH 8/8] dbus-vmstate: Fix memory leak of dbus_vmstate

2020-12-26 Thread g00517791
From: Jinhao Gao 

When VM migrate VMState of dbus_vmstate, the field(data) of
dbus_vmstate having a flag of VMS_ALLOC needs to allocate memory.
If the dst doesn't free memory which has been allocated for
SaveStateEntry of dbus_vmstate before dst loads device state, it may
result that the pointer of data is overlaid when vm loads. We add
the pre_load func to free memory, which prevents memory leak.

Signed-off-by: Jinhao Gao 
---
 backends/dbus-vmstate.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/backends/dbus-vmstate.c b/backends/dbus-vmstate.c
index bd050e8e9c..c13fbee760 100644
--- a/backends/dbus-vmstate.c
+++ b/backends/dbus-vmstate.c
@@ -366,10 +366,21 @@ static int dbus_vmstate_pre_save(void *opaque)
 return 0;
 }
 
+static int dbus_vmstate_pre_load(void *opaque)
+{
+DBusVMState *self = DBUS_VMSTATE(opaque);
+
+g_free(self->data);
+self->data = NULL;
+self->data_size = 0;
+return 0;
+}
+
 static const VMStateDescription dbus_vmstate = {
 .name = TYPE_DBUS_VMSTATE,
 .version_id = 0,
 .pre_save = dbus_vmstate_pre_save,
+.pre_load = dbus_vmstate_pre_load,
 .post_load = dbus_vmstate_post_load,
 .fields = (VMStateField[]) {
 VMSTATE_UINT32(data_size, DBusVMState),
-- 
2.23.0




[PATCH 4/8] spapr_pci: Fix memory leak of vmstate_spapr_pci

2020-12-26 Thread g00517791
From: Jinhao Gao 

When VM migrate VMState of spapr_pci, the field(msi_devs) of spapr_pci
having a flag of VMS_ALLOC need to allocate memory. If the src doesn't free
memory of msi_devs in SaveStateEntry of spapr_pci after QEMUFile save
VMState of spapr_pci, it may result in memory leak of msi_devs. We add the
post_save func to free memory, which prevents memory leak.

Signed-off-by: Jinhao Gao 
---
 hw/ppc/spapr_pci.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index 76d7c91e9c..1b2b940606 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -2173,6 +2173,16 @@ static int spapr_pci_pre_save(void *opaque)
 return 0;
 }
 
+static int spapr_pci_post_save(void *opaque)
+{
+SpaprPhbState *sphb = opaque;
+
+g_free(sphb->msi_devs);
+sphb->msi_devs = NULL;
+sphb->msi_devs_num = 0;
+return 0;
+}
+
 static int spapr_pci_post_load(void *opaque, int version_id)
 {
 SpaprPhbState *sphb = opaque;
@@ -2205,6 +2215,7 @@ static const VMStateDescription vmstate_spapr_pci = {
 .version_id = 2,
 .minimum_version_id = 2,
 .pre_save = spapr_pci_pre_save,
+.post_save = spapr_pci_post_save,
 .post_load = spapr_pci_post_load,
 .fields = (VMStateField[]) {
 VMSTATE_UINT64_EQUAL(buid, SpaprPhbState, NULL),
-- 
2.23.0




[PATCH 3/8] spapr: Fix memory leak of vmstate_spapr_event_entry

2020-12-26 Thread g00517791
From: Jinhao Gao 

When VM migrate VMState of spapr_event_log_entry, the field(extended_log)
of spapr_event_log_entry having a flag of VMS_ALLOC needs to allocate
memory. If the dst doesn't free memory which has been allocated for
SaveStateEntry of spapr_event_log_entry before dst loads device state,
it may result that the pointer of extended_log is overlaid when vm loads.
We add the pre_load func to free memory, which prevents memory leak.

Signed-off-by: Jinhao Gao 
---
 hw/ppc/spapr.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 489cefcb81..ddfed1e7ca 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -1799,10 +1799,22 @@ static bool spapr_pending_events_needed(void *opaque)
 return !QTAILQ_EMPTY(&spapr->pending_events);
 }
 
+static int spapr_event_log_entry_pre_load(void *opaque)
+{
+SpaprEventLogEntry *entry = opaque;
+
+g_free(entry->extended_log);
+entry->extended_log = NULL;
+entry->extended_length = 0;
+
+return 0;
+}
+
 static const VMStateDescription vmstate_spapr_event_entry = {
 .name = "spapr_event_log_entry",
 .version_id = 1,
 .minimum_version_id = 1,
+.pre_load = spapr_event_log_entry_pre_load,
 .fields = (VMStateField[]) {
 VMSTATE_UINT32(summary, SpaprEventLogEntry),
 VMSTATE_UINT32(extended_length, SpaprEventLogEntry),
-- 
2.23.0




[PATCH 6/8] vmbus: Fix memory leak of vmstate_vmbus_chan_req

2020-12-26 Thread g00517791
From: Jinhao Gao 

When VM migrate VMState of vmbus/vmbus_chan_req, the field(msg) of
vmbus/vmbus_chan_req having a flag of VMS_ALLOC needs to allocate
memory. If the dst doesn't free memory which has been allocated for
SaveStateEntry of vmbus/vmbus_chan_req before dst loads device state,
it may result that the pointer of msg is overlaid when vm loads.
We add the pre_load func to free memory, which prevents memory leak.

Signed-off-by: Jinhao Gao 
---
 hw/hyperv/vmbus.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/hw/hyperv/vmbus.c b/hw/hyperv/vmbus.c
index a91623aaac..9eda2341f3 100644
--- a/hw/hyperv/vmbus.c
+++ b/hw/hyperv/vmbus.c
@@ -1303,10 +1303,21 @@ typedef struct VMBusChanReqSave {
 ScatterGatherEntry *sgl;
 } VMBusChanReqSave;
 
+static int vmbus_chan_req_pre_load(void *opaque)
+{
+VMBusChanReqSave *req_save = VMBusChanReqSave(opaque);
+
+g_free(req_save.msg);
+req_save.msg = NULL;
+req_save.msglen = 0;
+return 0;
+}
+
 static const VMStateDescription vmstate_vmbus_chan_req = {
 .name = "vmbus/vmbus_chan_req",
 .version_id = 0,
 .minimum_version_id = 0,
+.pre_load = vmbus_chan_req_pre_load,
 .fields = (VMStateField[]) {
 VMSTATE_UINT16(chan_idx, VMBusChanReqSave),
 VMSTATE_UINT16(pkt_type, VMBusChanReqSave),
-- 
2.23.0




Re: [PATCH 0/8] Fix memory leak of some device state in migration

2020-12-26 Thread no-reply
Patchew URL: https://patchew.org/QEMU/20201226103347.868-1-gaojin...@huawei.com/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Type: series
Message-id: 20201226103347.868-1-gaojin...@huawei.com
Subject: [PATCH 0/8] Fix memory leak of some device state in migration

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 * [new tag] patchew/20201226103347.868-1-gaojin...@huawei.com -> 
patchew/20201226103347.868-1-gaojin...@huawei.com
Switched to a new branch 'test'
0a34e05 dbus-vmstate: Fix memory leak of dbus_vmstate
1e7ce1c tpm_emulator: Fix memory leak of vmstate_tpm_emulator
e5e20f9 vmbus: Fix memory leak of vmstate_vmbus_chan_req
0cfbfe6 savevm: Fix memory leak of vmstate_configuration
0d767d2 spapr_pci: Fix memory leak of vmstate_spapr_pci
729d773 spapr: Fix memory leak of vmstate_spapr_event_entry
bd9decd virtio-net: Fix memory leak of vmstate_virtio_net_rss
a7debfa vmbus: Fix memory leak of vmstate_gpadl

=== OUTPUT BEGIN ===
1/8 Checking commit a7debfa33be6 (vmbus: Fix memory leak of vmstate_gpadl)
ERROR: spaces required around that '=' (ctx:WxV)
#31: FILE: hw/hyperv/vmbus.c:528:
+gpadl->num_gfns =0;
 ^

total: 1 errors, 0 warnings, 21 lines checked

Patch 1/8 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

2/8 Checking commit bd9decdc8d81 (virtio-net: Fix memory leak of 
vmstate_virtio_net_rss)
3/8 Checking commit 729d7739521c (spapr: Fix memory leak of 
vmstate_spapr_event_entry)
4/8 Checking commit 0d767d2f6f68 (spapr_pci: Fix memory leak of 
vmstate_spapr_pci)
5/8 Checking commit 0cfbfe6f37d9 (savevm: Fix memory leak of 
vmstate_configuration)
6/8 Checking commit e5e20f91e7ae (vmbus: Fix memory leak of 
vmstate_vmbus_chan_req)
7/8 Checking commit 1e7ce1c84602 (tpm_emulator: Fix memory leak of 
vmstate_tpm_emulator)
8/8 Checking commit 0a34e0598fb9 (dbus-vmstate: Fix memory leak of dbus_vmstate)
=== OUTPUT END ===

Test command exited with code: 1


The full log is available at
http://patchew.org/logs/20201226103347.868-1-gaojin...@huawei.com/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-de...@redhat.com

[Bug 1906193] Re: riscv32 user mode emulation: fork return values broken

2020-12-26 Thread Andreas K . Hüttel
Just as a general remark, while this specific problem seems to be
solved, there may still be issues surrounding waitid().

(With this patch applied, in a rather complex environment I see bash
processes hanging in an infinite loop, with waitid involved. I am
working on isolating the problem and providing a simple test case, but
so far I have not even found the code triggering it.)

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1906193

Title:
  riscv32 user mode emulation: fork return values broken

Status in QEMU:
  Confirmed

Bug description:
  When running in a chroot with riscv32 (on x86_64; qemu git master as
  of today):

  The following short program forks; the child immediately returns with
  exit(42). The parent checks for the return value - and obtains 40!

  gcc-10.2

  ===
  #include 
  #include 
  #include 
  #include 

  main(c, v)
   int c;
   char **v;
  {
pid_t pid, p;
int s, i, n;

s = 0;
pid = fork();
if (pid == 0)
  exit(42);

/* wait for the process */
p = wait(&s);
if (p != pid)
  exit (255);

if (WIFEXITED(s))
{
   int r=WEXITSTATUS(s);
   if (r!=42) {
printf("child wants to return %i (0x%X), parent received %i (0x%X), 
difference %i\n",42,42,r,r,r-42);
   }
}
  }
  ===

  (riscv-ilp32 chroot) farino /tmp # ./wait-test-short 
  child wants to return 42 (0x2A), parent received 40 (0x28), difference -2

  ===
  (riscv-ilp32 chroot) farino /tmp # gcc --version
  gcc (Gentoo 10.2.0-r1 p2) 10.2.0
  Copyright (C) 2020 Free Software Foundation, Inc.
  Dies ist freie Software; die Kopierbedingungen stehen in den Quellen. Es
  gibt KEINE Garantie; auch nicht für MARKTGÄNGIGKEIT oder FÜR SPEZIELLE ZWECKE.

  (riscv-ilp32 chroot) farino /tmp # ld --version
  GNU ld (Gentoo 2.34 p6) 2.34.0
  Copyright (C) 2020 Free Software Foundation, Inc.
  This program is free software; you may redistribute it under the terms of
  the GNU General Public License version 3 or (at your option) a later version.
  This program has absolutely no warranty.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1906193/+subscriptions



[Bug 1908369] Re: deleted

2020-12-26 Thread Peter Maydell
** Changed in: qemu
   Status: New => Invalid

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1908369

Title:
  deleted

Status in QEMU:
  Invalid

Bug description:
  sorry

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1908369/+subscriptions



[PATCH 05/12] vt82c686: Split off via-[am]c97 into separate file in hw/audio

2020-12-26 Thread BALATON Zoltan via
These supposed to implement audio part used in VIA south bridges so
they are better placed under hw/audio.

Signed-off-by: BALATON Zoltan 
---
 hw/audio/meson.build |   1 +
 hw/audio/via-ac97.c  | 106 +++
 hw/isa/vt82c686.c|  91 -
 3 files changed, 107 insertions(+), 91 deletions(-)
 create mode 100644 hw/audio/via-ac97.c

diff --git a/hw/audio/meson.build b/hw/audio/meson.build
index 549e9a0396..32c42bdebe 100644
--- a/hw/audio/meson.build
+++ b/hw/audio/meson.build
@@ -11,4 +11,5 @@ softmmu_ss.add(when: 'CONFIG_MILKYMIST', if_true: 
files('milkymist-ac97.c'))
 softmmu_ss.add(when: 'CONFIG_PCSPK', if_true: files('pcspk.c'))
 softmmu_ss.add(when: 'CONFIG_PL041', if_true: files('pl041.c', 'lm4549.c'))
 softmmu_ss.add(when: 'CONFIG_SB16', if_true: files('sb16.c'))
+softmmu_ss.add(when: 'CONFIG_VT82C686', if_true: files('via-ac97.c'))
 softmmu_ss.add(when: 'CONFIG_WM8750', if_true: files('wm8750.c'))
diff --git a/hw/audio/via-ac97.c b/hw/audio/via-ac97.c
new file mode 100644
index 00..e617416ff7
--- /dev/null
+++ b/hw/audio/via-ac97.c
@@ -0,0 +1,106 @@
+/*
+ * VIA south bridges sound support
+ *
+ * This work is licensed under the GNU GPL license version 2 or later.
+ */
+
+/*
+ * TODO: This is entirely boiler plate just registering empty PCI devices
+ * with the right ID guests expect, functionality should be added here.
+ */
+
+#include "qemu/osdep.h"
+#include "hw/isa/vt82c686.h"
+#include "hw/pci/pci.h"
+
+struct VIAAC97State {
+PCIDevice dev;
+};
+
+struct VIAMC97State {
+PCIDevice dev;
+};
+
+OBJECT_DECLARE_SIMPLE_TYPE(VIAAC97State, VIA_AC97)
+OBJECT_DECLARE_SIMPLE_TYPE(VIAMC97State, VIA_MC97)
+
+static void via_ac97_realize(PCIDevice *dev, Error **errp)
+{
+VIAAC97State *s = VIA_AC97(dev);
+uint8_t *pci_conf = s->dev.config;
+
+pci_set_word(pci_conf + PCI_COMMAND, PCI_COMMAND_INVALIDATE |
+ PCI_COMMAND_PARITY);
+pci_set_word(pci_conf + PCI_STATUS, PCI_STATUS_CAP_LIST |
+ PCI_STATUS_DEVSEL_MEDIUM);
+pci_set_long(pci_conf + PCI_INTERRUPT_PIN, 0x03);
+}
+
+static void via_ac97_class_init(ObjectClass *klass, void *data)
+{
+DeviceClass *dc = DEVICE_CLASS(klass);
+PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
+
+k->realize = via_ac97_realize;
+k->vendor_id = PCI_VENDOR_ID_VIA;
+k->device_id = PCI_DEVICE_ID_VIA_AC97;
+k->revision = 0x50;
+k->class_id = PCI_CLASS_MULTIMEDIA_AUDIO;
+set_bit(DEVICE_CATEGORY_SOUND, dc->categories);
+dc->desc = "AC97";
+}
+
+static const TypeInfo via_ac97_info = {
+.name  = TYPE_VIA_AC97,
+.parent= TYPE_PCI_DEVICE,
+.instance_size = sizeof(VIAAC97State),
+.class_init= via_ac97_class_init,
+.interfaces = (InterfaceInfo[]) {
+{ INTERFACE_CONVENTIONAL_PCI_DEVICE },
+{ },
+},
+};
+
+static void via_mc97_realize(PCIDevice *dev, Error **errp)
+{
+VIAMC97State *s = VIA_MC97(dev);
+uint8_t *pci_conf = s->dev.config;
+
+pci_set_word(pci_conf + PCI_COMMAND, PCI_COMMAND_INVALIDATE |
+ PCI_COMMAND_VGA_PALETTE);
+pci_set_word(pci_conf + PCI_STATUS, PCI_STATUS_DEVSEL_MEDIUM);
+pci_set_long(pci_conf + PCI_INTERRUPT_PIN, 0x03);
+}
+
+static void via_mc97_class_init(ObjectClass *klass, void *data)
+{
+DeviceClass *dc = DEVICE_CLASS(klass);
+PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
+
+k->realize = via_mc97_realize;
+k->vendor_id = PCI_VENDOR_ID_VIA;
+k->device_id = PCI_DEVICE_ID_VIA_MC97;
+k->class_id = PCI_CLASS_COMMUNICATION_OTHER;
+k->revision = 0x30;
+set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
+dc->desc = "MC97";
+}
+
+static const TypeInfo via_mc97_info = {
+.name  = TYPE_VIA_MC97,
+.parent= TYPE_PCI_DEVICE,
+.instance_size = sizeof(VIAMC97State),
+.class_init= via_mc97_class_init,
+.interfaces = (InterfaceInfo[]) {
+{ INTERFACE_CONVENTIONAL_PCI_DEVICE },
+{ },
+},
+};
+
+static void via_ac97_register_types(void)
+{
+type_register_static(&via_ac97_info);
+type_register_static(&via_mc97_info);
+}
+
+type_init(via_ac97_register_types)
diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c
index de772262bc..758c54172b 100644
--- a/hw/isa/vt82c686.c
+++ b/hw/isa/vt82c686.c
@@ -168,14 +168,6 @@ struct VT686PMState {
 uint32_t smb_io_base;
 };
 
-struct VIAAC97State {
-PCIDevice dev;
-};
-
-struct VIAMC97State {
-PCIDevice dev;
-};
-
 #define TYPE_VT82C686B_PM "VT82C686B_PM"
 OBJECT_DECLARE_SIMPLE_TYPE(VT686PMState, VT82C686B_PM)
 
@@ -247,87 +239,6 @@ static const VMStateDescription vmstate_acpi = {
 }
 };
 
-/*
- * TODO: VIA_AC97 and VIA_MC97
- * just register a PCI device now, functionalities will be implemented later.
- */
-
-OBJECT_DECLARE_SIMPLE_TYPE(VIAMC97State, VIA_MC97)
-OBJECT_DECLARE_SIMPLE_TYPE(VIAAC97State, VIA_AC97)
-
-static void vt82c686b_ac97_realize(PCIDevice *dev, Error **errp)
-{

[PATCH 02/12] vt82c686: Rename AC97/MC97 parts from VT82C686B to VIA

2020-12-26 Thread BALATON Zoltan via
These parts are common between VT82C686B and VT8231 so can be shared
in the future. Rename them to VIA prefix accordingly.

Signed-off-by: BALATON Zoltan 
---
 hw/isa/vt82c686.c | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c
index b3170c70c3..2a0f85dea9 100644
--- a/hw/isa/vt82c686.c
+++ b/hw/isa/vt82c686.c
@@ -168,22 +168,22 @@ struct VT686PMState {
 uint32_t smb_io_base;
 };
 
-struct VT686AC97State {
+struct VIAAC97State {
 PCIDevice dev;
 };
 
-struct VT686MC97State {
+struct VIAMC97State {
 PCIDevice dev;
 };
 
 #define TYPE_VT82C686B_PM_DEVICE "VT82C686B_PM"
 OBJECT_DECLARE_SIMPLE_TYPE(VT686PMState, VT82C686B_PM_DEVICE)
 
-#define TYPE_VT82C686B_MC97_DEVICE "VT82C686B_MC97"
-OBJECT_DECLARE_SIMPLE_TYPE(VT686MC97State, VT82C686B_MC97_DEVICE)
+#define TYPE_VIA_MC97_DEVICE "VIA_MC97"
+OBJECT_DECLARE_SIMPLE_TYPE(VIAMC97State, VIA_MC97_DEVICE)
 
-#define TYPE_VT82C686B_AC97_DEVICE "VT82C686B_AC97"
-OBJECT_DECLARE_SIMPLE_TYPE(VT686AC97State, VT82C686B_AC97_DEVICE)
+#define TYPE_VIA_AC97_DEVICE "VIA_AC97"
+OBJECT_DECLARE_SIMPLE_TYPE(VIAAC97State, VIA_AC97_DEVICE)
 
 static void pm_update_sci(VT686PMState *s)
 {
@@ -260,7 +260,7 @@ static const VMStateDescription vmstate_acpi = {
 
 static void vt82c686b_ac97_realize(PCIDevice *dev, Error **errp)
 {
-VT686AC97State *s = VT82C686B_AC97_DEVICE(dev);
+VIAAC97State *s = VIA_AC97_DEVICE(dev);
 uint8_t *pci_conf = s->dev.config;
 
 pci_set_word(pci_conf + PCI_COMMAND, PCI_COMMAND_INVALIDATE |
@@ -274,7 +274,7 @@ void vt82c686b_ac97_init(PCIBus *bus, int devfn)
 {
 PCIDevice *dev;
 
-dev = pci_new(devfn, TYPE_VT82C686B_AC97_DEVICE);
+dev = pci_new(devfn, TYPE_VIA_AC97_DEVICE);
 pci_realize_and_unref(dev, bus, &error_fatal);
 }
 
@@ -293,9 +293,9 @@ static void via_ac97_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo via_ac97_info = {
-.name  = TYPE_VT82C686B_AC97_DEVICE,
+.name  = TYPE_VIA_AC97_DEVICE,
 .parent= TYPE_PCI_DEVICE,
-.instance_size = sizeof(VT686AC97State),
+.instance_size = sizeof(VIAAC97State),
 .class_init= via_ac97_class_init,
 .interfaces = (InterfaceInfo[]) {
 { INTERFACE_CONVENTIONAL_PCI_DEVICE },
@@ -305,7 +305,7 @@ static const TypeInfo via_ac97_info = {
 
 static void vt82c686b_mc97_realize(PCIDevice *dev, Error **errp)
 {
-VT686MC97State *s = VT82C686B_MC97_DEVICE(dev);
+VIAMC97State *s = VIA_MC97_DEVICE(dev);
 uint8_t *pci_conf = s->dev.config;
 
 pci_set_word(pci_conf + PCI_COMMAND, PCI_COMMAND_INVALIDATE |
@@ -318,7 +318,7 @@ void vt82c686b_mc97_init(PCIBus *bus, int devfn)
 {
 PCIDevice *dev;
 
-dev = pci_new(devfn, TYPE_VT82C686B_MC97_DEVICE);
+dev = pci_new(devfn, TYPE_VIA_MC97_DEVICE);
 pci_realize_and_unref(dev, bus, &error_fatal);
 }
 
@@ -337,9 +337,9 @@ static void via_mc97_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo via_mc97_info = {
-.name  = TYPE_VT82C686B_MC97_DEVICE,
+.name  = TYPE_VIA_MC97_DEVICE,
 .parent= TYPE_PCI_DEVICE,
-.instance_size = sizeof(VT686MC97State),
+.instance_size = sizeof(VIAMC97State),
 .class_init= via_mc97_class_init,
 .interfaces = (InterfaceInfo[]) {
 { INTERFACE_CONVENTIONAL_PCI_DEVICE },
-- 
2.21.3




[PATCH 01/12] vt82c686: Add APM and ACPI dependencies for VT82C686

2020-12-26 Thread BALATON Zoltan via
Compiling vt82c686.c fails without APM and ACPI_PM functions. Add
dependency on these in Kconfig to fix this.

Signed-off-by: BALATON Zoltan 
---
 hw/isa/Kconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/hw/isa/Kconfig b/hw/isa/Kconfig
index c7f07854f7..2ca2593ee6 100644
--- a/hw/isa/Kconfig
+++ b/hw/isa/Kconfig
@@ -47,6 +47,8 @@ config VT82C686
 select ACPI_SMBUS
 select SERIAL_ISA
 select FDC
+select APM
+select ACPI_X86
 
 config SMC37C669
 bool
-- 
2.21.3




[PATCH 11/12] vt82c686: Rename some functions to better show where they belong

2020-12-26 Thread BALATON Zoltan via
This groups identifiers related to the ISA bridge part and superio
part also in their naming.

Signed-off-by: BALATON Zoltan 
---
 hw/isa/vt82c686.c | 48 ++-
 hw/mips/fuloong2e.c   |  2 +-
 include/hw/isa/vt82c686.h |  2 +-
 3 files changed, 24 insertions(+), 28 deletions(-)

diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c
index 6dff2bc67d..698627d1b5 100644
--- a/hw/isa/vt82c686.c
+++ b/hw/isa/vt82c686.c
@@ -36,10 +36,10 @@ struct VT82C686BState {
 SuperIOConfig superio_conf;
 };
 
-OBJECT_DECLARE_SIMPLE_TYPE(VT82C686BState, VT82C686B)
+OBJECT_DECLARE_SIMPLE_TYPE(VT82C686BState, VT82C686B_ISA)
 
-static void superio_ioport_writeb(void *opaque, hwaddr addr, uint64_t data,
-  unsigned size)
+static void vt82c686b_superio_writeb(void *opaque, hwaddr addr, uint64_t data,
+ unsigned size)
 {
 SuperIOConfig *superio_conf = opaque;
 
@@ -72,7 +72,8 @@ static void superio_ioport_writeb(void *opaque, hwaddr addr, 
uint64_t data,
 }
 }
 
-static uint64_t superio_ioport_readb(void *opaque, hwaddr addr, unsigned size)
+static uint64_t vt82c686b_superio_readb(void *opaque, hwaddr addr,
+unsigned size)
 {
 SuperIOConfig *superio_conf = opaque;
 uint8_t val = superio_conf->config[superio_conf->index];
@@ -81,9 +82,9 @@ static uint64_t superio_ioport_readb(void *opaque, hwaddr 
addr, unsigned size)
 return val;
 }
 
-static const MemoryRegionOps superio_ops = {
-.read = superio_ioport_readb,
-.write = superio_ioport_writeb,
+static const MemoryRegionOps vt82c686b_superio_ops = {
+.read = vt82c686b_superio_readb,
+.write = vt82c686b_superio_writeb,
 .endianness = DEVICE_NATIVE_ENDIAN,
 .impl = {
 .min_access_size = 1,
@@ -93,7 +94,7 @@ static const MemoryRegionOps superio_ops = {
 
 static void vt82c686b_isa_reset(DeviceState *dev)
 {
-VT82C686BState *vt82c = VT82C686B(dev);
+VT82C686BState *vt82c = VT82C686B_ISA(dev);
 uint8_t *pci_conf = vt82c->dev.config;
 
 pci_set_long(pci_conf + PCI_CAPABILITY_LIST, 0x00c0);
@@ -118,11 +119,10 @@ static void vt82c686b_isa_reset(DeviceState *dev)
 vt82c->superio_conf.config[0xe8] = 0xbe;
 }
 
-/* write config pci function0 registers. PCI-ISA bridge */
-static void vt82c686b_write_config(PCIDevice *d, uint32_t addr,
+static void vt82c686b_isa_write_config(PCIDevice *d, uint32_t addr,
uint32_t val, int len)
 {
-VT82C686BState *vt686 = VT82C686B(d);
+VT82C686BState *vt686 = VT82C686B_ISA(d);
 
 trace_via_isa_write(addr, val, len);
 pci_default_write_config(d, addr, val, len);
@@ -284,10 +284,9 @@ static const VMStateDescription vmstate_via = {
 }
 };
 
-/* init the PCI-to-ISA bridge */
-static void vt82c686b_realize(PCIDevice *d, Error **errp)
+static void vt82c686b_isa_realize(PCIDevice *d, Error **errp)
 {
-VT82C686BState *vt82c = VT82C686B(d);
+VT82C686BState *vt82c = VT82C686B_ISA(d);
 uint8_t *pci_conf;
 ISABus *isa_bus;
 uint8_t *wmask;
@@ -309,7 +308,7 @@ static void vt82c686b_realize(PCIDevice *d, Error **errp)
 }
 }
 
-memory_region_init_io(&vt82c->superio, OBJECT(d), &superio_ops,
+memory_region_init_io(&vt82c->superio, OBJECT(d), &vt82c686b_superio_ops,
   &vt82c->superio_conf, "superio", 2);
 memory_region_set_enabled(&vt82c->superio, false);
 /*
@@ -320,13 +319,13 @@ static void vt82c686b_realize(PCIDevice *d, Error **errp)
 &vt82c->superio);
 }
 
-static void via_class_init(ObjectClass *klass, void *data)
+static void via_isa_class_init(ObjectClass *klass, void *data)
 {
 DeviceClass *dc = DEVICE_CLASS(klass);
 PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
 
-k->realize = vt82c686b_realize;
-k->config_write = vt82c686b_write_config;
+k->realize = vt82c686b_isa_realize;
+k->config_write = vt82c686b_isa_write_config;
 k->vendor_id = PCI_VENDOR_ID_VIA;
 k->device_id = PCI_DEVICE_ID_VIA_ISA_BRIDGE;
 k->class_id = PCI_CLASS_BRIDGE_ISA;
@@ -334,18 +333,15 @@ static void via_class_init(ObjectClass *klass, void *data)
 dc->reset = vt82c686b_isa_reset;
 dc->desc = "ISA bridge";
 dc->vmsd = &vmstate_via;
-/*
- * Reason: part of VIA VT82C686 southbridge, needs to be wired up,
- * e.g. by mips_fuloong2e_init()
- */
+/* Reason: Part of VIA southbridge, needs to be wired up by board code */
 dc->user_creatable = false;
 }
 
-static const TypeInfo via_info = {
-.name  = TYPE_VT82C686B,
+static const TypeInfo via_isa_info = {
+.name  = TYPE_VT82C686B_ISA,
 .parent= TYPE_PCI_DEVICE,
 .instance_size = sizeof(VT82C686BState),
-.class_init= via_class_init,
+.class_init= via_isa_class_init,
 .interfaces = (InterfaceInfo[]) {
 { INTERFACE_CONVENTIONAL_PCI_DEVICE },
 

[PATCH 06/12] audio/via-ac97: Simplify code and set user_creatable to false

2020-12-26 Thread BALATON Zoltan via
Remove some unneded, empty code and set user_creatable to false
(besides being not implemented yet, so does nothing anyway) it's also
normally part of VIA south bridge chips so no need to confuse users
showing them these devices.

Signed-off-by: BALATON Zoltan 
---
 hw/audio/via-ac97.c | 51 +
 1 file changed, 19 insertions(+), 32 deletions(-)

diff --git a/hw/audio/via-ac97.c b/hw/audio/via-ac97.c
index e617416ff7..6d556f74fc 100644
--- a/hw/audio/via-ac97.c
+++ b/hw/audio/via-ac97.c
@@ -13,27 +13,13 @@
 #include "hw/isa/vt82c686.h"
 #include "hw/pci/pci.h"
 
-struct VIAAC97State {
-PCIDevice dev;
-};
-
-struct VIAMC97State {
-PCIDevice dev;
-};
-
-OBJECT_DECLARE_SIMPLE_TYPE(VIAAC97State, VIA_AC97)
-OBJECT_DECLARE_SIMPLE_TYPE(VIAMC97State, VIA_MC97)
-
-static void via_ac97_realize(PCIDevice *dev, Error **errp)
+static void via_ac97_realize(PCIDevice *pci_dev, Error **errp)
 {
-VIAAC97State *s = VIA_AC97(dev);
-uint8_t *pci_conf = s->dev.config;
-
-pci_set_word(pci_conf + PCI_COMMAND, PCI_COMMAND_INVALIDATE |
- PCI_COMMAND_PARITY);
-pci_set_word(pci_conf + PCI_STATUS, PCI_STATUS_CAP_LIST |
- PCI_STATUS_DEVSEL_MEDIUM);
-pci_set_long(pci_conf + PCI_INTERRUPT_PIN, 0x03);
+pci_set_word(pci_dev->config + PCI_COMMAND,
+ PCI_COMMAND_INVALIDATE | PCI_COMMAND_PARITY);
+pci_set_word(pci_dev->config + PCI_STATUS,
+ PCI_STATUS_CAP_LIST | PCI_STATUS_DEVSEL_MEDIUM);
+pci_set_long(pci_dev->config + PCI_INTERRUPT_PIN, 0x03);
 }
 
 static void via_ac97_class_init(ObjectClass *klass, void *data)
@@ -47,13 +33,15 @@ static void via_ac97_class_init(ObjectClass *klass, void 
*data)
 k->revision = 0x50;
 k->class_id = PCI_CLASS_MULTIMEDIA_AUDIO;
 set_bit(DEVICE_CATEGORY_SOUND, dc->categories);
-dc->desc = "AC97";
+dc->desc = "VIA AC97";
+/* Reason: Part of a south bridge chip */
+dc->user_creatable = false;
 }
 
 static const TypeInfo via_ac97_info = {
 .name  = TYPE_VIA_AC97,
 .parent= TYPE_PCI_DEVICE,
-.instance_size = sizeof(VIAAC97State),
+.instance_size = sizeof(PCIDevice),
 .class_init= via_ac97_class_init,
 .interfaces = (InterfaceInfo[]) {
 { INTERFACE_CONVENTIONAL_PCI_DEVICE },
@@ -61,15 +49,12 @@ static const TypeInfo via_ac97_info = {
 },
 };
 
-static void via_mc97_realize(PCIDevice *dev, Error **errp)
+static void via_mc97_realize(PCIDevice *pci_dev, Error **errp)
 {
-VIAMC97State *s = VIA_MC97(dev);
-uint8_t *pci_conf = s->dev.config;
-
-pci_set_word(pci_conf + PCI_COMMAND, PCI_COMMAND_INVALIDATE |
- PCI_COMMAND_VGA_PALETTE);
-pci_set_word(pci_conf + PCI_STATUS, PCI_STATUS_DEVSEL_MEDIUM);
-pci_set_long(pci_conf + PCI_INTERRUPT_PIN, 0x03);
+pci_set_word(pci_dev->config + PCI_COMMAND,
+ PCI_COMMAND_INVALIDATE | PCI_COMMAND_VGA_PALETTE);
+pci_set_word(pci_dev->config + PCI_STATUS, PCI_STATUS_DEVSEL_MEDIUM);
+pci_set_long(pci_dev->config + PCI_INTERRUPT_PIN, 0x03);
 }
 
 static void via_mc97_class_init(ObjectClass *klass, void *data)
@@ -83,13 +68,15 @@ static void via_mc97_class_init(ObjectClass *klass, void 
*data)
 k->class_id = PCI_CLASS_COMMUNICATION_OTHER;
 k->revision = 0x30;
 set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
-dc->desc = "MC97";
+dc->desc = "VIA MC97";
+/* Reason: Part of a south bridge chip */
+dc->user_creatable = false;
 }
 
 static const TypeInfo via_mc97_info = {
 .name  = TYPE_VIA_MC97,
 .parent= TYPE_PCI_DEVICE,
-.instance_size = sizeof(VIAMC97State),
+.instance_size = sizeof(PCIDevice),
 .class_init= via_mc97_class_init,
 .interfaces = (InterfaceInfo[]) {
 { INTERFACE_CONVENTIONAL_PCI_DEVICE },
-- 
2.21.3




[PATCH 09/12] vt82c686: Convert debug printf to trace points

2020-12-26 Thread BALATON Zoltan via
Signed-off-by: BALATON Zoltan 
---
 hw/isa/trace-events |  6 ++
 hw/isa/vt82c686.c   | 51 +
 2 files changed, 21 insertions(+), 36 deletions(-)

diff --git a/hw/isa/trace-events b/hw/isa/trace-events
index 3544c6213c..d267d3e652 100644
--- a/hw/isa/trace-events
+++ b/hw/isa/trace-events
@@ -13,3 +13,9 @@ pc87312_io_write(uint32_t addr, uint32_t val) "write 
addr=0x%x val=0x%x"
 # apm.c
 apm_io_read(uint8_t addr, uint8_t val) "read addr=0x%x val=0x%02x"
 apm_io_write(uint8_t addr, uint8_t val) "write addr=0x%x val=0x%02x"
+
+# vt82c686.c
+via_isa_write(uint32_t addr, uint32_t val, int len) "addr 0x%x val 0x%x len 
0x%x"
+via_pm_write(uint32_t addr, uint32_t val, int len) "addr 0x%x val 0x%x len 
0x%x"
+via_superio_read(uint8_t addr, uint8_t val) "addr 0x%x val 0x%x"
+via_superio_write(uint8_t addr, uint32_t val) "addr 0x%x val 0x%x"
diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c
index b138838400..789459bcae 100644
--- a/hw/isa/vt82c686.c
+++ b/hw/isa/vt82c686.c
@@ -28,14 +28,7 @@
 #include "qemu/timer.h"
 #include "exec/address-spaces.h"
 #include "qom/object.h"
-
-/* #define DEBUG_VT82C686B */
-
-#ifdef DEBUG_VT82C686B
-#define DPRINTF(fmt, ...) fprintf(stderr, "%s: " fmt, __func__, ##__VA_ARGS__)
-#else
-#define DPRINTF(fmt, ...)
-#endif
+#include "trace.h"
 
 typedef struct SuperIOConfig {
 uint8_t config[0x100];
@@ -56,16 +49,17 @@ static void superio_ioport_writeb(void *opaque, hwaddr 
addr, uint64_t data,
 {
 SuperIOConfig *superio_conf = opaque;
 
-DPRINTF("superio_ioport_writeb  address 0x%x  val 0x%x\n", addr, data);
-if (addr == 0x3f0) {
+if (addr == 0x3f0) { /* config index register */
 superio_conf->index = data & 0xff;
 } else {
 bool can_write = true;
-/* 0x3f1 */
+/* 0x3f1, config data register */
+trace_via_superio_write(superio_conf->index, data & 0xff);
 switch (superio_conf->index) {
 case 0x00 ... 0xdf:
 case 0xe4:
 case 0xe5:
+case 0xe6 ... 0xe8: /* Should set base port of parallel and serial */
 case 0xe9 ... 0xed:
 case 0xf3:
 case 0xf5:
@@ -74,18 +68,6 @@ static void superio_ioport_writeb(void *opaque, hwaddr addr, 
uint64_t data,
 case 0xfd ... 0xff:
 can_write = false;
 break;
-case 0xe7:
-if ((data & 0xff) != 0xfe) {
-DPRINTF("change uart 1 base. unsupported yet\n");
-can_write = false;
-}
-break;
-case 0xe8:
-if ((data & 0xff) != 0xbe) {
-DPRINTF("change uart 2 base. unsupported yet\n");
-can_write = false;
-}
-break;
 default:
 break;
 
@@ -99,9 +81,10 @@ static void superio_ioport_writeb(void *opaque, hwaddr addr, 
uint64_t data,
 static uint64_t superio_ioport_readb(void *opaque, hwaddr addr, unsigned size)
 {
 SuperIOConfig *superio_conf = opaque;
+uint8_t val = superio_conf->config[superio_conf->index];
 
-DPRINTF("superio_ioport_readb  address 0x%x\n", addr);
-return superio_conf->config[superio_conf->index];
+trace_via_superio_read(superio_conf->index, val);
+return val;
 }
 
 static const MemoryRegionOps superio_ops = {
@@ -142,16 +125,14 @@ static void vt82c686b_isa_reset(DeviceState *dev)
 }
 
 /* write config pci function0 registers. PCI-ISA bridge */
-static void vt82c686b_write_config(PCIDevice *d, uint32_t address,
+static void vt82c686b_write_config(PCIDevice *d, uint32_t addr,
uint32_t val, int len)
 {
 VT82C686BState *vt686 = VT82C686B(d);
 
-DPRINTF("vt82c686b_write_config  address 0x%x  val 0x%x len 0x%x\n",
-   address, val, len);
-
-pci_default_write_config(d, address, val, len);
-if (address == 0x85) {  /* enable or disable super IO configure */
+trace_via_isa_write(addr, val, len);
+pci_default_write_config(d, addr, val, len);
+if (addr == 0x85) {  /* enable or disable super IO configure */
 memory_region_set_enabled(&vt686->superio, val & 0x2);
 }
 }
@@ -204,12 +185,10 @@ static void pm_io_space_update(VT686PMState *s)
 memory_region_transaction_commit();
 }
 
-static void pm_write_config(PCIDevice *d,
-uint32_t address, uint32_t val, int len)
+static void pm_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int len)
 {
-DPRINTF("pm_write_config  address 0x%x  val 0x%x len 0x%x\n",
-   address, val, len);
-pci_default_write_config(d, address, val, len);
+trace_via_pm_write(addr, val, len);
+pci_default_write_config(d, addr, val, len);
 }
 
 static int vmstate_acpi_post_load(void *opaque, int version_id)
-- 
2.21.3




[PATCH 04/12] vt82c686: Remove vt82c686b_[am]c97_init() functions

2020-12-26 Thread BALATON Zoltan via
These are legacy init functions that are just equivalent to directly
calling pci_create_simple so do that instead. Also rename objects to
lower case via-ac97 and via-mc97 matching naming of other devices.

Signed-off-by: BALATON Zoltan 
---
 hw/isa/vt82c686.c | 27 ---
 hw/mips/fuloong2e.c   |  4 ++--
 include/hw/isa/vt82c686.h |  4 ++--
 3 files changed, 8 insertions(+), 27 deletions(-)

diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c
index 1be1169f83..de772262bc 100644
--- a/hw/isa/vt82c686.c
+++ b/hw/isa/vt82c686.c
@@ -179,12 +179,6 @@ struct VIAMC97State {
 #define TYPE_VT82C686B_PM "VT82C686B_PM"
 OBJECT_DECLARE_SIMPLE_TYPE(VT686PMState, VT82C686B_PM)
 
-#define TYPE_VIA_MC97 "VIA_MC97"
-OBJECT_DECLARE_SIMPLE_TYPE(VIAMC97State, VIA_MC97)
-
-#define TYPE_VIA_AC97 "VIA_AC97"
-OBJECT_DECLARE_SIMPLE_TYPE(VIAAC97State, VIA_AC97)
-
 static void pm_update_sci(VT686PMState *s)
 {
 int sci_level, pmsts;
@@ -254,10 +248,13 @@ static const VMStateDescription vmstate_acpi = {
 };
 
 /*
- * TODO: vt82c686b_ac97_init() and vt82c686b_mc97_init()
+ * TODO: VIA_AC97 and VIA_MC97
  * just register a PCI device now, functionalities will be implemented later.
  */
 
+OBJECT_DECLARE_SIMPLE_TYPE(VIAMC97State, VIA_MC97)
+OBJECT_DECLARE_SIMPLE_TYPE(VIAAC97State, VIA_AC97)
+
 static void vt82c686b_ac97_realize(PCIDevice *dev, Error **errp)
 {
 VIAAC97State *s = VIA_AC97(dev);
@@ -270,14 +267,6 @@ static void vt82c686b_ac97_realize(PCIDevice *dev, Error 
**errp)
 pci_set_long(pci_conf + PCI_INTERRUPT_PIN, 0x03);
 }
 
-void vt82c686b_ac97_init(PCIBus *bus, int devfn)
-{
-PCIDevice *dev;
-
-dev = pci_new(devfn, TYPE_VIA_AC97);
-pci_realize_and_unref(dev, bus, &error_fatal);
-}
-
 static void via_ac97_class_init(ObjectClass *klass, void *data)
 {
 DeviceClass *dc = DEVICE_CLASS(klass);
@@ -314,14 +303,6 @@ static void vt82c686b_mc97_realize(PCIDevice *dev, Error 
**errp)
 pci_set_long(pci_conf + PCI_INTERRUPT_PIN, 0x03);
 }
 
-void vt82c686b_mc97_init(PCIBus *bus, int devfn)
-{
-PCIDevice *dev;
-
-dev = pci_new(devfn, TYPE_VIA_MC97);
-pci_realize_and_unref(dev, bus, &error_fatal);
-}
-
 static void via_mc97_class_init(ObjectClass *klass, void *data)
 {
 DeviceClass *dc = DEVICE_CLASS(klass);
diff --git a/hw/mips/fuloong2e.c b/hw/mips/fuloong2e.c
index f0733e87b7..3b0489f781 100644
--- a/hw/mips/fuloong2e.c
+++ b/hw/mips/fuloong2e.c
@@ -264,8 +264,8 @@ static void vt82c686b_southbridge_init(PCIBus *pci_bus, int 
slot, qemu_irq intc,
 *i2c_bus = vt82c686b_pm_init(pci_bus, PCI_DEVFN(slot, 4), 0xeee1, NULL);
 
 /* Audio support */
-vt82c686b_ac97_init(pci_bus, PCI_DEVFN(slot, 5));
-vt82c686b_mc97_init(pci_bus, PCI_DEVFN(slot, 6));
+pci_create_simple(pci_bus, PCI_DEVFN(slot, 5), TYPE_VIA_AC97);
+pci_create_simple(pci_bus, PCI_DEVFN(slot, 6), TYPE_VIA_MC97);
 }
 
 /* Network support */
diff --git a/include/hw/isa/vt82c686.h b/include/hw/isa/vt82c686.h
index f23f45dfb1..ff80a926dc 100644
--- a/include/hw/isa/vt82c686.h
+++ b/include/hw/isa/vt82c686.h
@@ -3,11 +3,11 @@
 
 
 #define TYPE_VT82C686B_SUPERIO "vt82c686b-superio"
+#define TYPE_VIA_AC97 "via-ac97"
+#define TYPE_VIA_MC97 "via-mc97"
 
 /* vt82c686.c */
 ISABus *vt82c686b_isa_init(PCIBus * bus, int devfn);
-void vt82c686b_ac97_init(PCIBus *bus, int devfn);
-void vt82c686b_mc97_init(PCIBus *bus, int devfn);
 I2CBus *vt82c686b_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
   qemu_irq sci_irq);
 
-- 
2.21.3




[PATCH 03/12] vt82c686: Remove unnecessary _DEVICE suffix from type macros

2020-12-26 Thread BALATON Zoltan via
There's no reason to suffix everything with _DEVICE when the names are
already unique without it and shorter names are more readable.

Signed-off-by: BALATON Zoltan 
---
 hw/isa/vt82c686.c | 48 +++
 1 file changed, 23 insertions(+), 25 deletions(-)

diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c
index 2a0f85dea9..1be1169f83 100644
--- a/hw/isa/vt82c686.c
+++ b/hw/isa/vt82c686.c
@@ -49,8 +49,8 @@ struct VT82C686BState {
 SuperIOConfig superio_conf;
 };
 
-#define TYPE_VT82C686B_DEVICE "VT82C686B"
-OBJECT_DECLARE_SIMPLE_TYPE(VT82C686BState, VT82C686B_DEVICE)
+#define TYPE_VT82C686B "VT82C686B"
+OBJECT_DECLARE_SIMPLE_TYPE(VT82C686BState, VT82C686B)
 
 static void superio_ioport_writeb(void *opaque, hwaddr addr, uint64_t data,
   unsigned size)
@@ -117,7 +117,7 @@ static const MemoryRegionOps superio_ops = {
 
 static void vt82c686b_isa_reset(DeviceState *dev)
 {
-VT82C686BState *vt82c = VT82C686B_DEVICE(dev);
+VT82C686BState *vt82c = VT82C686B(dev);
 uint8_t *pci_conf = vt82c->dev.config;
 
 pci_set_long(pci_conf + PCI_CAPABILITY_LIST, 0x00c0);
@@ -146,7 +146,7 @@ static void vt82c686b_isa_reset(DeviceState *dev)
 static void vt82c686b_write_config(PCIDevice *d, uint32_t address,
uint32_t val, int len)
 {
-VT82C686BState *vt686 = VT82C686B_DEVICE(d);
+VT82C686BState *vt686 = VT82C686B(d);
 
 DPRINTF("vt82c686b_write_config  address 0x%x  val 0x%x len 0x%x\n",
address, val, len);
@@ -176,14 +176,14 @@ struct VIAMC97State {
 PCIDevice dev;
 };
 
-#define TYPE_VT82C686B_PM_DEVICE "VT82C686B_PM"
-OBJECT_DECLARE_SIMPLE_TYPE(VT686PMState, VT82C686B_PM_DEVICE)
+#define TYPE_VT82C686B_PM "VT82C686B_PM"
+OBJECT_DECLARE_SIMPLE_TYPE(VT686PMState, VT82C686B_PM)
 
-#define TYPE_VIA_MC97_DEVICE "VIA_MC97"
-OBJECT_DECLARE_SIMPLE_TYPE(VIAMC97State, VIA_MC97_DEVICE)
+#define TYPE_VIA_MC97 "VIA_MC97"
+OBJECT_DECLARE_SIMPLE_TYPE(VIAMC97State, VIA_MC97)
 
-#define TYPE_VIA_AC97_DEVICE "VIA_AC97"
-OBJECT_DECLARE_SIMPLE_TYPE(VIAAC97State, VIA_AC97_DEVICE)
+#define TYPE_VIA_AC97 "VIA_AC97"
+OBJECT_DECLARE_SIMPLE_TYPE(VIAAC97State, VIA_AC97)
 
 static void pm_update_sci(VT686PMState *s)
 {
@@ -260,7 +260,7 @@ static const VMStateDescription vmstate_acpi = {
 
 static void vt82c686b_ac97_realize(PCIDevice *dev, Error **errp)
 {
-VIAAC97State *s = VIA_AC97_DEVICE(dev);
+VIAAC97State *s = VIA_AC97(dev);
 uint8_t *pci_conf = s->dev.config;
 
 pci_set_word(pci_conf + PCI_COMMAND, PCI_COMMAND_INVALIDATE |
@@ -274,7 +274,7 @@ void vt82c686b_ac97_init(PCIBus *bus, int devfn)
 {
 PCIDevice *dev;
 
-dev = pci_new(devfn, TYPE_VIA_AC97_DEVICE);
+dev = pci_new(devfn, TYPE_VIA_AC97);
 pci_realize_and_unref(dev, bus, &error_fatal);
 }
 
@@ -293,7 +293,7 @@ static void via_ac97_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo via_ac97_info = {
-.name  = TYPE_VIA_AC97_DEVICE,
+.name  = TYPE_VIA_AC97,
 .parent= TYPE_PCI_DEVICE,
 .instance_size = sizeof(VIAAC97State),
 .class_init= via_ac97_class_init,
@@ -305,7 +305,7 @@ static const TypeInfo via_ac97_info = {
 
 static void vt82c686b_mc97_realize(PCIDevice *dev, Error **errp)
 {
-VIAMC97State *s = VIA_MC97_DEVICE(dev);
+VIAMC97State *s = VIA_MC97(dev);
 uint8_t *pci_conf = s->dev.config;
 
 pci_set_word(pci_conf + PCI_COMMAND, PCI_COMMAND_INVALIDATE |
@@ -318,7 +318,7 @@ void vt82c686b_mc97_init(PCIBus *bus, int devfn)
 {
 PCIDevice *dev;
 
-dev = pci_new(devfn, TYPE_VIA_MC97_DEVICE);
+dev = pci_new(devfn, TYPE_VIA_MC97);
 pci_realize_and_unref(dev, bus, &error_fatal);
 }
 
@@ -337,7 +337,7 @@ static void via_mc97_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo via_mc97_info = {
-.name  = TYPE_VIA_MC97_DEVICE,
+.name  = TYPE_VIA_MC97,
 .parent= TYPE_PCI_DEVICE,
 .instance_size = sizeof(VIAMC97State),
 .class_init= via_mc97_class_init,
@@ -350,7 +350,7 @@ static const TypeInfo via_mc97_info = {
 /* vt82c686 pm init */
 static void vt82c686b_pm_realize(PCIDevice *dev, Error **errp)
 {
-VT686PMState *s = VT82C686B_PM_DEVICE(dev);
+VT686PMState *s = VT82C686B_PM(dev);
 uint8_t *pci_conf;
 
 pci_conf = s->dev.config;
@@ -386,10 +386,10 @@ I2CBus *vt82c686b_pm_init(PCIBus *bus, int devfn, 
uint32_t smb_io_base,
 PCIDevice *dev;
 VT686PMState *s;
 
-dev = pci_new(devfn, TYPE_VT82C686B_PM_DEVICE);
+dev = pci_new(devfn, TYPE_VT82C686B_PM);
 qdev_prop_set_uint32(&dev->qdev, "smb_io_base", smb_io_base);
 
-s = VT82C686B_PM_DEVICE(dev);
+s = VT82C686B_PM(dev);
 
 pci_realize_and_unref(dev, bus, &error_fatal);
 
@@ -419,7 +419,7 @@ static void via_pm_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo via_pm_info = {
-.name  = TYPE_VT82C686B_PM_DEVICE,
+.name   

[PATCH 00/12] Misc vt82c686b clean ups

2020-12-26 Thread BALATON Zoltan via
This series are some small clean ups to the vt82c686b south bridge and
superio chip model that is only used by the mips/fuloong2e machine.
These are also in preparation to add emulation of the very similar
vt8231 later that will be used by ppc/pegasos2.

Regards,
BALATON Zoltan

BALATON Zoltan (12):
  vt82c686: Add APM and ACPI dependencies for VT82C686
  vt82c686: Rename AC97/MC97 parts from VT82C686B to VIA
  vt82c686: Remove unnecessary _DEVICE suffix from type macros
  vt82c686: Remove vt82c686b_[am]c97_init() functions
  vt82c686: Split off via-[am]c97 into separate file in hw/audio
  audio/via-ac97: Simplify code and set user_creatable to false
  vt82c686: Remove vt82c686b_isa_init() function
  vt82c686: Remove vt82c686b_pm_init() function
  vt82c686: Convert debug printf to trace points
  vt82c686: Remove unneeded includes and defines
  vt82c686: Rename some functions to better show where they belong
  vt82c686: Do not add floppy

 hw/audio/meson.build  |   1 +
 hw/audio/via-ac97.c   |  93 ++
 hw/isa/Kconfig|   2 +
 hw/isa/trace-events   |   6 +
 hw/isa/vt82c686.c | 258 +++---
 hw/mips/fuloong2e.c   |  13 +-
 include/hw/isa/vt82c686.h |  12 +-
 7 files changed, 161 insertions(+), 224 deletions(-)
 create mode 100644 hw/audio/via-ac97.c

-- 
2.21.3




[PATCH 07/12] vt82c686: Remove vt82c686b_isa_init() function

2020-12-26 Thread BALATON Zoltan via
Also rename VT82C686B type to lower case to match other device names.

Signed-off-by: BALATON Zoltan 
---
 hw/isa/vt82c686.c | 9 -
 hw/mips/fuloong2e.c   | 4 +++-
 include/hw/isa/vt82c686.h | 3 +--
 3 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c
index 758c54172b..1c1239cade 100644
--- a/hw/isa/vt82c686.c
+++ b/hw/isa/vt82c686.c
@@ -49,7 +49,6 @@ struct VT82C686BState {
 SuperIOConfig superio_conf;
 };
 
-#define TYPE_VT82C686B "VT82C686B"
 OBJECT_DECLARE_SIMPLE_TYPE(VT82C686BState, VT82C686B)
 
 static void superio_ioport_writeb(void *opaque, hwaddr addr, uint64_t data,
@@ -367,14 +366,6 @@ static void vt82c686b_realize(PCIDevice *d, Error **errp)
 &vt82c->superio);
 }
 
-ISABus *vt82c686b_isa_init(PCIBus *bus, int devfn)
-{
-PCIDevice *d;
-
-d = pci_create_simple_multifunction(bus, devfn, true, TYPE_VT82C686B);
-return ISA_BUS(qdev_get_child_bus(DEVICE(d), "isa.0"));
-}
-
 static void via_class_init(ObjectClass *klass, void *data)
 {
 DeviceClass *dc = DEVICE_CLASS(klass);
diff --git a/hw/mips/fuloong2e.c b/hw/mips/fuloong2e.c
index 3b0489f781..60d2020033 100644
--- a/hw/mips/fuloong2e.c
+++ b/hw/mips/fuloong2e.c
@@ -240,7 +240,9 @@ static void vt82c686b_southbridge_init(PCIBus *pci_bus, int 
slot, qemu_irq intc,
 ISABus *isa_bus;
 PCIDevice *dev;
 
-isa_bus = vt82c686b_isa_init(pci_bus, PCI_DEVFN(slot, 0));
+dev = pci_create_simple_multifunction(pci_bus, PCI_DEVFN(slot, 0), true,
+  TYPE_VT82C686B);
+isa_bus = ISA_BUS(qdev_get_child_bus(DEVICE(dev), "isa.0"));
 assert(isa_bus);
 *p_isa_bus = isa_bus;
 /* Interrupt controller */
diff --git a/include/hw/isa/vt82c686.h b/include/hw/isa/vt82c686.h
index ff80a926dc..89e205a1be 100644
--- a/include/hw/isa/vt82c686.h
+++ b/include/hw/isa/vt82c686.h
@@ -1,13 +1,12 @@
 #ifndef HW_VT82C686_H
 #define HW_VT82C686_H
 
-
+#define TYPE_VT82C686B "vt82c686b"
 #define TYPE_VT82C686B_SUPERIO "vt82c686b-superio"
 #define TYPE_VIA_AC97 "via-ac97"
 #define TYPE_VIA_MC97 "via-mc97"
 
 /* vt82c686.c */
-ISABus *vt82c686b_isa_init(PCIBus * bus, int devfn);
 I2CBus *vt82c686b_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
   qemu_irq sci_irq);
 
-- 
2.21.3




[PATCH 08/12] vt82c686: Remove vt82c686b_pm_init() function

2020-12-26 Thread BALATON Zoltan via
Also rename VT82C686B_PM to match other device names.

Signed-off-by: BALATON Zoltan 
---
 hw/isa/vt82c686.c | 17 -
 hw/mips/fuloong2e.c   |  5 -
 include/hw/isa/vt82c686.h |  5 +
 3 files changed, 5 insertions(+), 22 deletions(-)

diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c
index 1c1239cade..b138838400 100644
--- a/hw/isa/vt82c686.c
+++ b/hw/isa/vt82c686.c
@@ -167,7 +167,6 @@ struct VT686PMState {
 uint32_t smb_io_base;
 };
 
-#define TYPE_VT82C686B_PM "VT82C686B_PM"
 OBJECT_DECLARE_SIMPLE_TYPE(VT686PMState, VT82C686B_PM)
 
 static void pm_update_sci(VT686PMState *s)
@@ -271,22 +270,6 @@ static void vt82c686b_pm_realize(PCIDevice *dev, Error 
**errp)
 acpi_pm1_cnt_init(&s->ar, &s->io, false, false, 2);
 }
 
-I2CBus *vt82c686b_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
-  qemu_irq sci_irq)
-{
-PCIDevice *dev;
-VT686PMState *s;
-
-dev = pci_new(devfn, TYPE_VT82C686B_PM);
-qdev_prop_set_uint32(&dev->qdev, "smb_io_base", smb_io_base);
-
-s = VT82C686B_PM(dev);
-
-pci_realize_and_unref(dev, bus, &error_fatal);
-
-return s->smb.smbus;
-}
-
 static Property via_pm_properties[] = {
 DEFINE_PROP_UINT32("smb_io_base", VT686PMState, smb_io_base, 0),
 DEFINE_PROP_END_OF_LIST(),
diff --git a/hw/mips/fuloong2e.c b/hw/mips/fuloong2e.c
index 60d2020033..d275038830 100644
--- a/hw/mips/fuloong2e.c
+++ b/hw/mips/fuloong2e.c
@@ -263,7 +263,10 @@ static void vt82c686b_southbridge_init(PCIBus *pci_bus, 
int slot, qemu_irq intc,
 pci_create_simple(pci_bus, PCI_DEVFN(slot, 2), "vt82c686b-usb-uhci");
 pci_create_simple(pci_bus, PCI_DEVFN(slot, 3), "vt82c686b-usb-uhci");
 
-*i2c_bus = vt82c686b_pm_init(pci_bus, PCI_DEVFN(slot, 4), 0xeee1, NULL);
+dev = pci_new(PCI_DEVFN(slot, 4), TYPE_VT82C686B_PM);
+qdev_prop_set_uint32(DEVICE(dev), "smb_io_base", 0xeee1);
+pci_realize_and_unref(dev, pci_bus, &error_fatal);
+*i2c_bus = I2C_BUS(qdev_get_child_bus(DEVICE(dev), "i2c"));
 
 /* Audio support */
 pci_create_simple(pci_bus, PCI_DEVFN(slot, 5), TYPE_VIA_AC97);
diff --git a/include/hw/isa/vt82c686.h b/include/hw/isa/vt82c686.h
index 89e205a1be..080ee8fc59 100644
--- a/include/hw/isa/vt82c686.h
+++ b/include/hw/isa/vt82c686.h
@@ -3,11 +3,8 @@
 
 #define TYPE_VT82C686B "vt82c686b"
 #define TYPE_VT82C686B_SUPERIO "vt82c686b-superio"
+#define TYPE_VT82C686B_PM "vt82c686b-pm"
 #define TYPE_VIA_AC97 "via-ac97"
 #define TYPE_VIA_MC97 "via-mc97"
 
-/* vt82c686.c */
-I2CBus *vt82c686b_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
-  qemu_irq sci_irq);
-
 #endif
-- 
2.21.3




[PATCH 10/12] vt82c686: Remove unneeded includes and defines

2020-12-26 Thread BALATON Zoltan via
These are not used or not needed.

Signed-off-by: BALATON Zoltan 
---
 hw/isa/vt82c686.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c
index 789459bcae..6dff2bc67d 100644
--- a/hw/isa/vt82c686.c
+++ b/hw/isa/vt82c686.c
@@ -12,22 +12,16 @@
 
 #include "qemu/osdep.h"
 #include "hw/isa/vt82c686.h"
-#include "hw/i2c/i2c.h"
 #include "hw/pci/pci.h"
 #include "hw/qdev-properties.h"
-#include "hw/isa/isa.h"
 #include "hw/isa/superio.h"
-#include "hw/sysbus.h"
 #include "migration/vmstate.h"
-#include "hw/mips/mips.h"
 #include "hw/isa/apm.h"
 #include "hw/acpi/acpi.h"
 #include "hw/i2c/pm_smbus.h"
 #include "qapi/error.h"
-#include "qemu/module.h"
 #include "qemu/timer.h"
 #include "exec/address-spaces.h"
-#include "qom/object.h"
 #include "trace.h"
 
 typedef struct SuperIOConfig {
@@ -137,8 +131,6 @@ static void vt82c686b_write_config(PCIDevice *d, uint32_t 
addr,
 }
 }
 
-#define ACPI_DBG_IO_ADDR  0xb044
-
 struct VT686PMState {
 PCIDevice dev;
 MemoryRegion io;
-- 
2.21.3




[PATCH 12/12] vt82c686: Do not add floppy

2020-12-26 Thread BALATON Zoltan via
The floppy is inaccessible because its ports are shadowed by the
config registers of the superio part (switchable on the real chip but
we don't model that) so disable adding the floppy matching the
existing comment in vt82c686b_isa_realize() as it's not usable.

Signed-off-by: BALATON Zoltan 
---
 hw/isa/vt82c686.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c
index 698627d1b5..2b7a3bdba1 100644
--- a/hw/isa/vt82c686.c
+++ b/hw/isa/vt82c686.c
@@ -348,14 +348,19 @@ static const TypeInfo via_isa_info = {
 },
 };
 
+static bool vt82c686b_superio_floppy_is_enabled(ISASuperIODevice *sio, uint8_t 
index)
+{
+return false; /* Disabled due to clash with SuperIO Config reg ports */
+}
+
 static void vt82c686b_superio_class_init(ObjectClass *klass, void *data)
 {
 ISASuperIOClass *sc = ISA_SUPERIO_CLASS(klass);
 
 sc->serial.count = 2;
 sc->parallel.count = 1;
-sc->ide.count = 0;
-sc->floppy.count = 1;
+sc->ide.count = 0; /* Emulated by via-ide */
+sc->floppy.is_enabled = vt82c686b_superio_floppy_is_enabled;
 }
 
 static const TypeInfo via_superio_info = {
-- 
2.21.3