1 | Since v1 (Thomas review comments) | ||
---|---|---|---|
2 | - Move s390_set_qemu_cpu_model/s390_cpu_list to "cpu_models.h" | ||
3 | - Correct 'target/s390x: Register CPUClass:list_cpus' subject | ||
4 | |||
1 | 'cpu_list' might be defined per target, and force code to be | 5 | 'cpu_list' might be defined per target, and force code to be |
2 | built per-target. We can avoid that by introducing a CPUClass | 6 | built per-target. We can avoid that by introducing a CPUClass |
3 | callback. | 7 | callback. |
4 | 8 | ||
5 | This series combined with another which converts CPU_RESOLVING_TYPE | 9 | This series combined with another which converts CPU_RESOLVING_TYPE |
6 | to a runtime helper, allows to move most of cpu-target to common. | 10 | to a runtime helper, allows to move most of cpu-target to common. |
7 | 11 | ||
8 | Philippe Mathieu-Daudé (6): | 12 | Based-on: <20250324165356.39540-1-philmd@linaro.org> |
13 | |||
14 | Philippe Mathieu-Daudé (7): | ||
9 | cpus: Introduce CPUClass::list_cpus() callback | 15 | cpus: Introduce CPUClass::list_cpus() callback |
10 | target/i386: Register CPUClass:list_cpus | 16 | target/i386: Register CPUClass:list_cpus |
11 | target/ppc: Register CPUClass:list_cpus | 17 | target/ppc: Register CPUClass:list_cpus |
12 | target/sparc: Register CPUClass:list_cpus | 18 | target/sparc: Register CPUClass:list_cpus |
13 | target/sparc: Register CPUClass:list_cpus | 19 | target/s390x: Declare s390_set_qemu_cpu_model/cpu_list in cpu_models.h |
20 | target/s390x: Register CPUClass:list_cpus | ||
14 | cpus: Remove #ifdef check on cpu_list definition | 21 | cpus: Remove #ifdef check on cpu_list definition |
15 | 22 | ||
16 | include/hw/core/cpu.h | 2 ++ | 23 | include/hw/core/cpu.h | 2 ++ |
17 | target/i386/cpu.h | 3 --- | 24 | target/i386/cpu.h | 3 --- |
18 | target/ppc/cpu.h | 4 ---- | 25 | target/ppc/cpu.h | 4 ---- |
19 | target/s390x/cpu.h | 1 - | 26 | target/s390x/cpu.h | 4 ---- |
20 | target/sparc/cpu.h | 3 --- | 27 | target/s390x/cpu_models.h | 3 +++ |
21 | cpu-target.c | 25 ++++++++++++------------- | 28 | target/sparc/cpu.h | 3 --- |
22 | target/i386/cpu.c | 3 ++- | 29 | cpu-target.c | 25 ++++++++++++------------- |
23 | target/ppc/cpu_init.c | 3 ++- | 30 | hw/s390x/s390-virtio-ccw.c | 2 +- |
24 | target/s390x/cpu.c | 1 + | 31 | target/i386/cpu.c | 3 ++- |
25 | target/sparc/cpu.c | 3 ++- | 32 | target/ppc/cpu_init.c | 3 ++- |
26 | 10 files changed, 21 insertions(+), 27 deletions(-) | 33 | target/s390x/cpu.c | 1 + |
34 | target/sparc/cpu.c | 3 ++- | ||
35 | 12 files changed, 25 insertions(+), 31 deletions(-) | ||
27 | 36 | ||
28 | -- | 37 | -- |
29 | 2.47.1 | 38 | 2.47.1 |
30 | 39 | ||
31 | 40 | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
3 | introduce the CPUClass::list_cpus() callback. | 3 | introduce the CPUClass::list_cpus() callback. |
4 | When no callback is registered, list_cpus() defaults | 4 | When no callback is registered, list_cpus() defaults |
5 | to the cpu_list definition. | 5 | to the cpu_list definition. |
6 | 6 | ||
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
8 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
8 | --- | 9 | --- |
9 | include/hw/core/cpu.h | 2 ++ | 10 | include/hw/core/cpu.h | 2 ++ |
10 | cpu-target.c | 8 +++++++- | 11 | cpu-target.c | 8 +++++++- |
11 | 2 files changed, 9 insertions(+), 1 deletion(-) | 12 | 2 files changed, 9 insertions(+), 1 deletion(-) |
12 | 13 | ||
... | ... | diff view generated by jsdifflib |
1 | Register x86_cpu_list() as CPUClass:list_cpus callback. | 1 | Register x86_cpu_list() as CPUClass:list_cpus callback. |
---|---|---|---|
2 | Reduce its scope and remove the cpu_list definition. | 2 | Reduce its scope and remove the cpu_list definition. |
3 | 3 | ||
4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
5 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
5 | --- | 6 | --- |
6 | target/i386/cpu.h | 3 --- | 7 | target/i386/cpu.h | 3 --- |
7 | target/i386/cpu.c | 3 ++- | 8 | target/i386/cpu.c | 3 ++- |
8 | 2 files changed, 2 insertions(+), 4 deletions(-) | 9 | 2 files changed, 2 insertions(+), 4 deletions(-) |
9 | 10 | ||
... | ... | diff view generated by jsdifflib |
1 | Register ppc_cpu_list() as CPUClass:list_cpus callback. | 1 | Register ppc_cpu_list() as CPUClass:list_cpus callback. |
---|---|---|---|
2 | Reduce its scope and remove the cpu_list definition. | 2 | Reduce its scope and remove the cpu_list definition. |
3 | 3 | ||
4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
5 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
5 | --- | 6 | --- |
6 | target/ppc/cpu.h | 4 ---- | 7 | target/ppc/cpu.h | 4 ---- |
7 | target/ppc/cpu_init.c | 3 ++- | 8 | target/ppc/cpu_init.c | 3 ++- |
8 | 2 files changed, 2 insertions(+), 5 deletions(-) | 9 | 2 files changed, 2 insertions(+), 5 deletions(-) |
9 | 10 | ||
... | ... | diff view generated by jsdifflib |
1 | Register sparc_cpu_list() as CPUClass:list_cpus callback. | 1 | Register sparc_cpu_list() as CPUClass:list_cpus callback. |
---|---|---|---|
2 | Reduce its scope and remove the cpu_list definition. | 2 | Reduce its scope and remove the cpu_list definition. |
3 | 3 | ||
4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
5 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
5 | --- | 6 | --- |
6 | target/sparc/cpu.h | 3 --- | 7 | target/sparc/cpu.h | 3 --- |
7 | target/sparc/cpu.c | 3 ++- | 8 | target/sparc/cpu.c | 3 ++- |
8 | 2 files changed, 2 insertions(+), 4 deletions(-) | 9 | 2 files changed, 2 insertions(+), 4 deletions(-) |
9 | 10 | ||
... | ... | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Both s390_cpu_list() and s390_set_qemu_cpu_model() are | ||
2 | defined in cpu_models.c, move their declarations in the | ||
3 | related "cpu_models.h" header. Use full path to header | ||
4 | in s390-virtio-ccw.c file. | ||
1 | 5 | ||
6 | Suggested-by: Thomas Huth <thuth@redhat.com> | ||
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
8 | --- | ||
9 | target/s390x/cpu.h | 4 ---- | ||
10 | target/s390x/cpu_models.h | 3 +++ | ||
11 | hw/s390x/s390-virtio-ccw.c | 2 +- | ||
12 | 3 files changed, 4 insertions(+), 5 deletions(-) | ||
13 | |||
14 | diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/s390x/cpu.h | ||
17 | +++ b/target/s390x/cpu.h | ||
18 | @@ -XXX,XX +XXX,XX @@ static inline uint8_t s390_cpu_get_state(S390CPU *cpu) | ||
19 | } | ||
20 | |||
21 | |||
22 | -/* cpu_models.c */ | ||
23 | -void s390_cpu_list(void); | ||
24 | #define cpu_list s390_cpu_list | ||
25 | -void s390_set_qemu_cpu_model(uint16_t type, uint8_t gen, uint8_t ec_ga, | ||
26 | - const S390FeatInit feat_init); | ||
27 | |||
28 | |||
29 | /* helper.c */ | ||
30 | diff --git a/target/s390x/cpu_models.h b/target/s390x/cpu_models.h | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/target/s390x/cpu_models.h | ||
33 | +++ b/target/s390x/cpu_models.h | ||
34 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t s390_cpuid_from_cpu_model(const S390CPUModel *model) | ||
35 | } | ||
36 | S390CPUDef const *s390_find_cpu_def(uint16_t type, uint8_t gen, uint8_t ec_ga, | ||
37 | S390FeatBitmap features); | ||
38 | +void s390_set_qemu_cpu_model(uint16_t type, uint8_t gen, uint8_t ec_ga, | ||
39 | + const S390FeatInit feat_init); | ||
40 | +void s390_cpu_list(void); | ||
41 | |||
42 | bool kvm_s390_cpu_models_supported(void); | ||
43 | bool kvm_s390_get_host_cpu_model(S390CPUModel *model, Error **errp); | ||
44 | diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/hw/s390x/s390-virtio-ccw.c | ||
47 | +++ b/hw/s390x/s390-virtio-ccw.c | ||
48 | @@ -XXX,XX +XXX,XX @@ | ||
49 | #include "hw/s390x/css-bridge.h" | ||
50 | #include "hw/s390x/ap-bridge.h" | ||
51 | #include "migration/register.h" | ||
52 | -#include "cpu_models.h" | ||
53 | +#include "target/s390x/cpu_models.h" | ||
54 | #include "hw/nmi.h" | ||
55 | #include "hw/qdev-properties.h" | ||
56 | #include "hw/s390x/tod.h" | ||
57 | -- | ||
58 | 2.47.1 | ||
59 | |||
60 | diff view generated by jsdifflib |
1 | Register sparc_cpu_list() as CPUClass:list_cpus callback | 1 | Register s390_cpu_list() as CPUClass:list_cpus callback |
---|---|---|---|
2 | and remove the cpu_list definition. | 2 | and remove the cpu_list definition. |
3 | 3 | ||
4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
5 | --- | 5 | --- |
6 | target/s390x/cpu.h | 1 - | ||
7 | target/s390x/cpu.c | 1 + | 6 | target/s390x/cpu.c | 1 + |
8 | 2 files changed, 1 insertion(+), 1 deletion(-) | 7 | 1 file changed, 1 insertion(+) |
9 | 8 | ||
10 | diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/target/s390x/cpu.h | ||
13 | +++ b/target/s390x/cpu.h | ||
14 | @@ -XXX,XX +XXX,XX @@ static inline uint8_t s390_cpu_get_state(S390CPU *cpu) | ||
15 | |||
16 | /* cpu_models.c */ | ||
17 | void s390_cpu_list(void); | ||
18 | -#define cpu_list s390_cpu_list | ||
19 | void s390_set_qemu_cpu_model(uint16_t type, uint8_t gen, uint8_t ec_ga, | ||
20 | const S390FeatInit feat_init); | ||
21 | |||
22 | diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c | 9 | diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c |
23 | index XXXXXXX..XXXXXXX 100644 | 10 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/target/s390x/cpu.c | 11 | --- a/target/s390x/cpu.c |
25 | +++ b/target/s390x/cpu.c | 12 | +++ b/target/s390x/cpu.c |
26 | @@ -XXX,XX +XXX,XX @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) | 13 | @@ -XXX,XX +XXX,XX @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) |
... | ... | diff view generated by jsdifflib |
1 | Since we removed all definitions of cpu_list, the #ifdef | 1 | Since we removed all definitions of cpu_list, the #ifdef |
---|---|---|---|
2 | check is always true. Remove it, inlining cpu_list(). | 2 | check is always true. Remove it, inlining cpu_list(). |
3 | 3 | ||
4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
5 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
5 | --- | 6 | --- |
6 | cpu-target.c | 19 ++++++------------- | 7 | cpu-target.c | 19 ++++++------------- |
7 | 1 file changed, 6 insertions(+), 13 deletions(-) | 8 | 1 file changed, 6 insertions(+), 13 deletions(-) |
8 | 9 | ||
9 | diff --git a/cpu-target.c b/cpu-target.c | 10 | diff --git a/cpu-target.c b/cpu-target.c |
... | ... | diff view generated by jsdifflib |