target/s390x: Header cleanups around "cpu.h"
v2 cover target/s390x: Header cleanups around "cpu.h"
These patches are part of a big refactor cleanup around "cpu.h". Most changes should be trivial IMHO.
Since v1:
- Fixed s390_pv_init() on non-KVM hosts
- Keep "exec/cpu_ldst.h" in user-emu (rth)
Philippe Mathieu-Daudé (5):
exec/memory: Expose memory_region_access_valid() hw/s390x/pv: Un-inline s390_pv_init()
hw/s390x/pv: Restrict Protected Virtualization to sysemu target/s390x/tcg/misc_helper: Remove unused "memory.h" include target/s390x/tcg/excp_helper: Restrict system headers to sysemu
hw/s390x/pv.c | 4 +++- hw/s390x/s390-pci-inst.c | 2 +- hw/s390x/s390-virtio-ccw.c | 6 ++++-- include/exec/memory-internal.h | 4 ---- include/exec/memory.h | 4 ++++ include/hw/s390x/pv.h | 13 ------------- target/s390x/cpu_features.c | 4 ++++ target/s390x/cpu_models.c | 4 +++- target/s390x/tcg/excp_helper.c | 8 ++++---- target/s390x/tcg/misc_helper.c | 1 - 10 files changed, 23 insertions(+), 27 deletions(-)
Signature · 1 line
2.38.1
PATCH v2 1/5 exec/memory: Expose memory_region_access_valid()
Instead of having hardware device poking into memory internal API, expose memory_region_access_valid().
--- hw/s390x/s390-pci-inst.c | 2 +- include/exec/memory-internal.h | 4 ---- include/exec/memory.h | 4 ++++ 3 files changed, 5 insertions(+), 5 deletions(-)
hw/s390x/s390-pci-inst.c +1 -1
@@ -13,7 +13,7 @@#include "qemu/osdep.h" #include "exec/memop.h" -#include "exec/memory-internal.h" +#include "exec/memory.h" #include "qemu/error-report.h" #include "sysemu/hw_accel.h" #include "hw/s390x/s390-pci-inst.h"
include/exec/memory-internal.h +0 -4
@@ -38,10 +38,6 @@ void flatview_unref(FlatView *view);extern const MemoryRegionOps unassigned_mem_ops; -bool memory_region_access_valid (MemoryRegion *mr,hwaddr addr, -unsigned size,bool is_write, -MemTxAttrs attrs); -void flatview_add_to_dispatch (FlatView *fv,MemoryRegionSection *section);AddressSpaceDispatch *address_space_dispatch_new (FlatView *fv);void address_space_dispatch_compact (AddressSpaceDispatch *d);
include/exec/memory.h +4 -0
@@ -2442,6 +2442,10 @@ void memory_global_dirty_log_stop(unsigned int flags);void mtree_info (bool flatview,bool dispatch_tree,bool owner,bool disabled); +bool memory_region_access_valid (MemoryRegion *mr,hwaddr addr, +unsigned size,bool is_write, +MemTxAttrs attrs); +/** * memory_region_dispatch_read: perform a read directly to the specified * MemoryRegion.
Signature · 1 line
2.38.1
Re: [PATCH v2 1/5] exec/memory: Expose memory_region_access_valid()
Quoted 5 lines · Philippe Mathieu-Daudé
Instead of having hardware device poking into memory internal API, expose
memory_region_access_valid().Reviewed-by Richard Henderson <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>
That's the only memory_region_ function s390 calls that isn't already in memory.h, so makes sense to me.
Quoted 54 lines
---
hw/s390x/s390-pci-inst.c | 2 +-
include/exec/memory-internal.h | 4 ----
include/exec/memory.h | 4 ++++3 files changed, 5 insertions(+), 5 deletions(-)hw/s390x/s390-pci-inst.c +0
-0@@ -13,7 +13,7 @@
#include "qemu/osdep.h"
#include "exec/memop.h"hw/s390x/s390-pci-inst.c +1
-1-#include "exec/memory-internal.h" +#include "exec/memory.h" #include "
qemu/error-report.h"
#include "sysemu/hw_accel.h"
#include "hw/s390x/s390-pci-inst.h"include/exec/memory- renamed from include/exec/memory-internal.h +0
-0
internal.h
index9fcc2af25c..100c1237ac100644include/exec/memory-internal.h +0
-0@@ -38,10 +38,6 @@ void flatview_unref(FlatView *view);
extern const MemoryRegionOpsunassigned_mem_ops;include/exec/memory-internal.h +0
-4-bool memory_region_access_valid (MemoryRegion *mr,hwaddr addr, - unsigned size, bool is_write, - MemTxAttrs attrs); -void
flatview_add_to_dispatch(FlatView *fv, MemoryRegionSection *section);
AddressSpaceDispatch *address_space_dispatch_new(FlatView *fv); voidaddress_space_dispatch_compact(AddressSpaceDispatch *d);include/exec/memory.h +0
-0@@ -2442,6 +2442,10 @@ void memory_global_dirty_log_stop(unsigned int flags);
voidmtree_info(bool flatview, bool dispatch_tree, bool owner, bool disabled);include/exec/memory.h +4
-0+bool memory_region_access_valid (MemoryRegion *mr,hwaddr addr, + unsigned size, bool is_write, + MemTxAttrs attrs); +/**
*memory_region_dispatch_read: perform a read directly to the specified
* MemoryRegion.
Re: [PATCH v2 1/5] exec/memory: Expose memory_region_access_valid()
In reply to Philippe Mathieu-DaudéQuoted 10 lines · Philippe Mathieu-Daudé
Instead of having hardware device poking into memory internal API, expose
memory_region_access_valid().Reviewed-by Richard Henderson <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/s390x/s390-pci-inst.c | 2 +- include/exec/memory-internal.h | 4 ---- include/exec/memory.h | 4 ++++ 3 files changed, 5 insertions(+), 5 deletions(-)
PATCH v2 2/5 hw/s390x/pv: Un-inline s390_pv_init()
In reply to Philippe Mathieu-DaudéThere is no point in having s390_pv_init() inlined. Directly call s390_pv_kvm_init() guarded by kvm_enabled() so the compiler can elide when CONFIG_KVM is not set.
--- hw/s390x/pv.c | 4 +++- hw/s390x/s390-virtio-ccw.c | 6 ++++-- include/hw/s390x/pv.h | 13 ------------- 3 files changed, 7 insertions(+), 16 deletions(-)
hw/s390x/pv.c +3 -1
@@ -251,7 +251,9 @@ struct S390PVGuestClass {int s390_pv_kvm_init (ConfidentialGuestSupport *cgs,Error **errp) { -if (!object_dynamic_cast (OBJECT (cgs),TYPE_S390_PV_GUEST )) { +assert (kvm_enabled ()); + +if (!cgs || !object_dynamic_cast (OBJECT (cgs),TYPE_S390_PV_GUEST )) {return 0 ; }
hw/s390x/s390-virtio-ccw.c +4 -2
@@ -255,8 +255,10 @@ static void ccw_init(MachineState *machine)/* init CPUs (incl. CPU model) early so s390_has_feature() works */ s390_init_cpus (machine); -/* Need CPU model to be determined before we can set up PV */ -s390_pv_init (machine->cgs, &error_fatal); +if (kvm_enabled ()) { +/* Need CPU model to be determined before we can set up PV */ +s390_pv_kvm_init (machine->cgs, &error_fatal); + }s390_flic_init ();
include/hw/s390x/pv.h +0 -13
@@ -12,7 +12,6 @@#ifndef HW_S390_PV_H #define HW_S390_PV_H -#include "qapi/error.h" #include "sysemu/kvm.h" #ifdef CONFIG_KVM
@@ -78,17 +77,5 @@ static inline int kvm_s390_dump_completion_data(void *buff) { return 0; }#endif /* CONFIG_KVM */ int s390_pv_kvm_init (ConfidentialGuestSupport *cgs,Error **errp); -static inline int s390_pv_init (ConfidentialGuestSupport *cgs,Error **errp) -{ -if (!cgs) { -return 0 ; - } -if (kvm_enabled ()) { -return s390_pv_kvm_init (cgs, errp); - } - -error_setg (errp,"Protected Virtualization requires KVM" ); -return -1 ; -}#endif /* HW_S390_PV_H */
Signature · 1 line
2.38.1
Re: [PATCH v2 2/5] hw/s390x/pv: Un-inline s390_pv_init()
Quoted 29 lines · Philippe Mathieu-Daudé
hw/s390x/pv.c +3
-1@@ -251,7 +251,9 @@ struct S390PVGuestClass {int s390_pv_kvm_init (ConfidentialGuestSupport *cgs,Error **errp) { -if (!object_dynamic_cast (OBJECT (cgs),TYPE_S390_PV_GUEST )) { +assert (kvm_enabled ()); + +if (!cgs || !object_dynamic_cast (OBJECT (cgs),TYPE_S390_PV_GUEST )) {return 0 ; }hw/s390x/s390-virtio-ccw.c +4
-4@@ -255,8 +255,10 @@ static void ccw_init(MachineState *machine)/* init CPUs (incl. CPU model) early so s390_has_feature() works */ s390_init_cpus (machine); -/* Need CPU model to be determined before we can set up PV */ -s390_pv_init (machine->cgs, &error_fatal); +if (kvm_enabled ()) { +/* Need CPU model to be determined before we can set up PV */ +s390_pv_kvm_init (machine->cgs, &error_fatal); + } s390_flic_init();... -static inline int s390_pv_init (ConfidentialGuestSupport *cgs,Error **errp) -{
hw/s390x/s390-virtio-ccw.c static void ccw_init(MachineState *machine)
Quoted 10 lines
hw/s390x/s390-virtio-ccw.c +0
-10-if (!cgs) { -return 0 ; - } -if (kvm_enabled ()) { -return s390_pv_kvm_init (cgs, errp); - } - -error_setg (errp,"Protected Virtualization requires KVM" ); -return -1 ; -}
You've lost the error path above. And it seems like we could just handle null cgs early. E.g.
if (machine->cgs) {
if (kvm_enabled()) {
s390_pv_kvm_init(machine->cgs, &error_fatal);
} else {
error_report(...);
exit(EXIT_FAILURE);
}
}(since qabi/error.h says not to use error_setg(&error_fatal, ...)).
r~
Re: [PATCH v2 2/5] hw/s390x/pv: Un-inline s390_pv_init()
In reply to Philippe Mathieu-DaudéQuoted 31 lines · Philippe Mathieu-Daudé
There is no point in having
s390_pv_init()inlined. Directly calls390_pv_kvm_init()guarded bykvm_enabled()so the compiler can elide whenCONFIG_KVMis not set.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/s390x/pv.c | 4 +++- hw/s390x/s390-virtio-ccw.c | 6 ++++-- include/hw/s390x/pv.h | 13 ------------- 3 files changed, 7 insertions(+), 16 deletions(-)hw/s390x/pv.c +3
-1@@ -251,7 +251,9 @@ struct S390PVGuestClass {int s390_pv_kvm_init (ConfidentialGuestSupport *cgs,Error **errp) { -if (!object_dynamic_cast (OBJECT (cgs),TYPE_S390_PV_GUEST )) { +assert (kvm_enabled ()); + +if (!cgs || !object_dynamic_cast (OBJECT (cgs),TYPE_S390_PV_GUEST )) {return 0 ; }hw/s390x/s390-virtio-ccw.c +0
-0
hw/s390x/s390-virtio-ccw.c static void ccw_init(MachineState *machine) · line 261
Quoted 9 lines
hw/s390x/s390-virtio-ccw.c +4
-2@@ -255,8 +255,10 @@ static void ccw_init(MachineState *machine)/* init CPUs (incl. CPU model) early so s390_has_feature() works */ s390_init_cpus (machine); -/* Need CPU model to be determined before we can set up PV */ -s390_pv_init (machine->cgs, &error_fatal); +if (kvm_enabled ()) { +/* Need CPU model to be determined before we can set up PV */ +s390_pv_kvm_init (machine->cgs, &error_fatal); + }
This now slightly changed the order of the checks ... if cgs is set, but kvm is disabled, there is now no error message anymore and the code continues silently. That sounds wrong?
Thomas
Quoted 32 lines
hw/s390x/s390-virtio-ccw.c +0
-0s390_flic_init ();include/hw/s390x/pv.h +0
-13@@ -12,7 +12,6 @@#ifndef HW_S390_PV_H #define HW_S390_PV_H -#include "qapi/error.h" #include "sysemu/kvm.h" #ifdef CONFIG_KVM @@ -78,17 +77,5 @@ static inline int kvm_s390_dump_completion_data(void *buff) { return 0; }#endif /* CONFIG_KVM */ int s390_pv_kvm_init (ConfidentialGuestSupport *cgs,Error **errp); -static inline int s390_pv_init (ConfidentialGuestSupport *cgs,Error **errp) -{ -if (!cgs) { -return 0 ; - } -if (kvm_enabled ()) { -return s390_pv_kvm_init (cgs, errp); - } - -error_setg (errp,"Protected Virtualization requires KVM" ); -return -1 ; -}#endif /* HW_S390_PV_H */
PATCH v2 3/5 hw/s390x/pv: Restrict Protected Virtualization to sysemu
In reply to Philippe Mathieu-DaudéProtected Virtualization is irrelevant in user emulation.
--- target/s390x/cpu_features.c | 4 ++++ target/s390x/cpu_models.c | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-)
target/s390x/cpu_features.c +4 -0
@@ -14,7 +14,9 @@#include "qemu/osdep.h" #include "qemu/module.h" #include "cpu_features.h" +#ifndef CONFIG_USER_ONLY #include "hw/s390x/pv.h" +#endif #define DEF_FEAT (_FEAT, _NAME, _TYPE, _BIT, _DESC) \ [S390_FEAT_##_FEAT] = { \
@@ -107,6 +109,7 @@ void s390_fill_feat_block(const S390FeatBitmap features, S390FeatType type, feat =find_next_bit (features,S390_FEAT_MAX , feat +1 ); } +#ifndef CONFIG_USER_ONLY if (!s390_is_pv ()) {return ; }
@@ -147,6 +150,7 @@ void s390_fill_feat_block(const S390FeatBitmap features, S390FeatType type,default :return ; } +#endif } void s390_add_from_feat_block(S390FeatBitmap features, S390FeatType type,
target/s390x/cpu_models.c +3 -1
@@ -23,8 +23,8 @@#include "qemu/qemu-print.h" #ifndef CONFIG_USER_ONLY #include "sysemu/sysemu.h" -#endif #include "hw/s390x/pv.h" +#endif #define CPUDEF_INIT (_type, _gen, _ec_ga, _mha_pow, _hmfai, _name, _desc) \ { \
@@ -236,6 +236,7 @@ bool s390_has_feat(S390Feat feat)return 0 ; } +#ifndef CONFIG_USER_ONLY if (s390_is_pv ()) {switch (feat) {case S390_FEAT_DIAG_318 :
@@ -259,6 +260,7 @@ bool s390_has_feat(S390Feat feat) break; } } +#endif return test_bit (feat, cpu->model->features); }
Signature · 1 line
2.38.1
Re: [PATCH v2 3/5] hw/s390x/pv: Restrict Protected Virtualization to sysemu
Quoted 7 lines · Philippe Mathieu-Daudé
Protected Virtualization is irrelevant in user emulation.
Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- target/s390x/cpu_features.c | 4 ++++ target/s390x/cpu_models.c | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-)
r~
Re: [PATCH v2 3/5] hw/s390x/pv: Restrict Protected Virtualization to sysemu
In reply to Philippe Mathieu-DaudéQuoted 7 lines · Philippe Mathieu-Daudé
Protected Virtualization is irrelevant in user emulation.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/s390x/cpu_features.c | 4 ++++ target/s390x/cpu_models.c | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-)
PATCH v2 4/5 target/s390x/tcg/misc_helper: Remove unused "memory.h" include
In reply to Philippe Mathieu-Daudé--- target/s390x/tcg/misc_helper.c | 1 - 1 file changed, 1 deletion(-)
target/s390x/tcg/misc_helper.c +0 -1
@@ -23,7 +23,6 @@#include "qemu/main-loop.h" #include "cpu.h" #include "s390x-internal.h" -#include "exec/memory.h" #include "qemu/host-utils.h" #include "exec/helper-proto.h" #include "qemu/timer.h"
Signature · 1 line
2.38.1
Re: [PATCH v2 4/5] target/s390x/tcg/misc_helper: Remove unused "memory.h" include
Quoted 11 lines · Philippe Mathieu-Daudé
Reviewed-by Richard Henderson <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/s390x/tcg/misc_helper.c | 1 - 1 file changed, 1 deletion(-)target/s390x/tcg/misc_helper.c +0
-0
target/s390x/tcg/misc_helper.c line 28
Quoted 7 lines
target/s390x/tcg/misc_helper.c +0
-1@@ -23,7 +23,6 @@#include "qemu/main-loop.h" #include "cpu.h" #include "s390x-internal.h" -#include "exec/memory.h" #include "qemu/host-utils.h" #include "exec/helper-proto.h" #include "qemu/timer.h"
PATCH v2 5/5 target/s390x/tcg/excp_helper: Restrict system headers to sysemu
In reply to Philippe Mathieu-Daudé--- target/s390x/tcg/excp_helper.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
target/s390x/tcg/excp_helper.c +4 -4
@@ -21,15 +21,15 @@#include "qemu/osdep.h" #include "qemu/log.h" #include "cpu.h" -#include "s390x-internal.h" #include "exec/helper-proto.h" -#include "qemu/timer.h" #include "exec/exec-all.h" #include "exec/cpu_ldst.h" -#include "hw/s390x/ioinst.h" -#include "exec/address-spaces.h" +#include "s390x-internal.h" #include "tcg_s390x.h" #ifndef CONFIG_USER_ONLY +#include "qemu/timer.h" +#include "exec/address-spaces.h" +#include "hw/s390x/ioinst.h" #include "hw/s390x/s390_flic.h" #include "hw/boards.h" #endif
Signature · 1 line
2.38.1
Re: [PATCH v2 5/5] target/s390x/tcg/excp_helper: Restrict system headers to sysemu
Quoted 4 lines · Philippe Mathieu-Daudé
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/s390x/tcg/excp_helper.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
r~
Quoted 25 lines
target/s390x/tcg/excp_helper.c +4
-4@@ -21,15 +21,15 @@#include "qemu/osdep.h" #include "qemu/log.h" #include "cpu.h" -#include "s390x-internal.h" #include "exec/helper-proto.h" -#include "qemu/timer.h" #include "exec/exec-all.h" #include "exec/cpu_ldst.h" -#include "hw/s390x/ioinst.h" -#include "exec/address-spaces.h" +#include "s390x-internal.h" #include "tcg_s390x.h" #ifndef CONFIG_USER_ONLY +#include "qemu/timer.h" +#include "exec/address-spaces.h" +#include "hw/s390x/ioinst.h" #include "hw/s390x/s390_flic.h" #include "hw/boards.h" #endif
Re: [PATCH v2 5/5] target/s390x/tcg/excp_helper: Restrict system headers to sysemu
In reply to Philippe Mathieu-DaudéQuoted 19 lines · Philippe Mathieu-Daudé
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/s390x/tcg/excp_helper.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)target/s390x/tcg/excp_helper.c +0
-3@@ -21,15 +21,15 @@#include "qemu/osdep.h" #include "qemu/log.h" #include "cpu.h" -#include "s390x-internal.h" #include "exec/helper-proto.h" -#include "qemu/timer.h" #include "exec/exec-all.h" #include "exec/cpu_ldst.h" -#include "hw/s390x/ioinst.h"
target/s390x/tcg/excp_helper.c line 35
Quoted 10 lines
target/s390x/tcg/excp_helper.c +4
-1-#include "exec/address-spaces.h" +#include "s390x-internal.h" #include "tcg_s390x.h" #ifndef CONFIG_USER_ONLY +#include "qemu/timer.h" +#include "exec/address-spaces.h" +#include "hw/s390x/ioinst.h" #include "hw/s390x/s390_flic.h" #include "hw/boards.h" #endif