s390x: dump: Add PV dump support
cover s390x: dump: Add PV dump support
This is the qemu part of the PV dump support where we take the data that the KVM PV dump API gives us and put it into the ELF file for later processing.
The encrypted PV cpu state is added as an additional note like the other architecture registers.
The storage state and completion data however are put into their own sections. The storage state data provides one part of the puzzle needed to decrypt the memory and the completion data contains the other part as well as a key derivation seed for the encrypted cpu data.
Based on:
https://lore.kernel.org/qemu-devel/[email protected]/T/#t
https://lore.kernel.org/qemu-devel/[email protected]/T/#t
Personal notes:
I still need to improve error management which will mean that the ioctl functions in hw/s390x/pv.c will need to be changed to return the rc/rrc.
Janosch Frank (5):
linux header sync
s390x: Add protected dump cap
s390x: Introduce PV query interface
s390x: Add KVM PV dump interface
s390x: pv: Add dump support
dump/dump.c | 27 ---- hw/s390x/pv.c | 113 ++++++++++++++++ hw/s390x/s390-virtio-ccw.c | 5 + include/elf.h | 1 + include/hw/s390x/pv.h | 18 +++ include/sysemu/dump.h | 27 ++++ linux-headers/linux/kvm.h | 55 ++++++++ target/s390x/arch_dump.c | 247 ++++++++++++++++++++++++++++++----- target/s390x/kvm/kvm.c | 7 + target/s390x/kvm/kvm_s390x.h | 1 + 10 files changed, 443 insertions(+), 58 deletions(-)
Signature · 1 line
2.32.0
PATCH 1/5 linux header sync
--- linux-headers/linux/kvm.h | 55 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+)
linux-headers/linux/kvm.h +55 -0
@@ -1133,6 +1133,7 @@ struct kvm_ppc_resize_hpt {#define KVM_CAP_VM_MOVE_ENC_CONTEXT_FROM 206#define KVM_CAP_VM_GPA_BITS 207#define KVM_CAP_XSAVE2 208 +#define KVM_CAP_S390_PROTECTED_DUMP 212#ifdef KVM_CAP_IRQ_ROUTING
@@ -1637,6 +1638,55 @@ struct kvm_s390_pv_unp {__u64 tweak; }; +enum pv_cmd_info_id { +KVM_PV_INFO_VM , +KVM_PV_INFO_DUMP , +}; + +struct kvm_s390_pv_info_dump { +__u64 dump_cpu_buffer_len; +__u64 dump_config_mem_buffer_per_1m; +__u64 dump_config_finalize_len; +}; + +struct kvm_s390_pv_info_vm { +__u64 inst_calls_list[4 ]; +__u64 max_cpus; +__u64 max_guests; +__u64 max_guest_addr; +__u64 feature_indication; +}; + +struct kvm_s390_pv_info_header { +__u32 id; +__u32 len_max; +__u32 len_written; +__u32 reserved; +}; + +struct kvm_s390_pv_info { +struct kvm_s390_pv_info_header header; +union { +struct kvm_s390_pv_info_dump dump; +struct kvm_s390_pv_info_vm vm; + }; +}; + +enum pv_cmd_dmp_id { +KVM_PV_DUMP_INIT , +KVM_PV_DUMP_CONFIG_STATE , +KVM_PV_DUMP_COMPLETE , +KVM_PV_DUMP_CPU , +}; + +struct kvm_s390_pv_dmp { +__u64 subcmd; +__u64 buff_addr; +__u64 buff_len; +__u64 gaddr; +__u64 reserved[4 ]; +}; +enum pv_cmd_id {KVM_PV_ENABLE ,KVM_PV_DISABLE ,
@@ -1645,6 +1695,8 @@ enum pv_cmd_id {KVM_PV_VERIFY ,KVM_PV_PREP_RESET ,KVM_PV_UNSHARE_ALL , +KVM_PV_INFO , + KVM_PV_DUMP, }; struct kvm_pv_cmd {
@@ -1719,6 +1771,7 @@ struct kvm_xen_vcpu_attr {#define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_DATA 0x4#define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADJUST 0x5 +/* Secure Encrypted Virtualization command */ enum sev_cmd_id {/* Guest initialization commands */
@@ -2047,4 +2100,6 @@ struct kvm_stats_desc {#define KVM_GET_STATS_FD _IO(KVMIO, 0xce) +#define KVM_S390_PV_CPU_COMMAND _IOWR(KVMIO, 0xd0, struct kvm_pv_cmd) +#endif /* __LINUX_KVM_H */
Signature · 1 line
2.32.0
PATCH 2/5 s390x: Add protected dump cap
In reply to Janosch Frank--- target/s390x/kvm/kvm.c | 7 +++++++ target/s390x/kvm/kvm_s390x.h | 1 + 2 files changed, 8 insertions(+)
target/s390x/kvm/kvm.c +7 -0
@@ -157,6 +157,7 @@ static int cap_ri;static int cap_hpage_1m;static int cap_vcpu_resets;static int cap_protected; +static int cap_protected_dump;static int active_cmma;
@@ -358,6 +359,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s) cap_s390_irq =kvm_check_extension (s,KVM_CAP_S390_INJECT_IRQ ); cap_vcpu_resets =kvm_check_extension (s,KVM_CAP_S390_VCPU_RESETS ); cap_protected =kvm_check_extension (s,KVM_CAP_S390_PROTECTED ); + cap_protected_dump =kvm_check_extension (s,KVM_CAP_S390_PROTECTED_DUMP );kvm_vm_enable_cap (s,KVM_CAP_S390_USER_SIGP ,0 );kvm_vm_enable_cap (s,KVM_CAP_S390_VECTOR_REGISTERS ,0 );
@@ -2035,6 +2037,11 @@ int kvm_s390_assign_subch_ioeventfd(EventNotifier *notifier, uint32_t sch,return kvm_vm_ioctl (kvm_state,KVM_IOEVENTFD , &kick); } +int kvm_s390_get_protected_dump (void ) +{ +return cap_protected_dump; +} +int kvm_s390_get_ri (void ) {return cap_ri;
target/s390x/kvm/kvm_s390x.h +1 -0
@@ -26,6 +26,7 @@ int kvm_s390_set_cpu_state(S390CPU *cpu, uint8_t cpu_state);void kvm_s390_vcpu_interrupt_pre_save (S390CPU *cpu);int kvm_s390_vcpu_interrupt_post_load (S390CPU *cpu);int kvm_s390_get_hpage_1m (void ); +int kvm_s390_get_protected_dump (void );int kvm_s390_get_ri (void );int kvm_s390_get_clock (uint8_t *tod_high,uint64_t *tod_clock);int kvm_s390_get_clock_ext (uint8_t *tod_high,uint64_t *tod_clock);
Signature · 1 line
2.32.0
PATCH 3/5 s390x: Introduce PV query interface
In reply to Janosch FrankIntroduce an interface over which we can get information about UV data.
--- hw/s390x/pv.c | 61 ++++++++++++++++++++++++++++++++++++++ hw/s390x/s390-virtio-ccw.c | 5 ++++ include/hw/s390x/pv.h | 10 +++++++ 3 files changed, 76 insertions(+)
hw/s390x/pv.c +61 -0
@@ -20,6 +20,11 @@#include "exec/confidential-guest-support.h" #include "hw/s390x/ipl.h" #include "hw/s390x/pv.h" +#include "target/s390x/kvm/kvm_s390x.h" + +static bool info_valid; +static struct kvm_s390_pv_info_vm info_vm; +static struct kvm_s390_pv_info_dump info_dump;static int __s390_pv_cmd (uint32_t cmd,const char *cmdname,void *data) {
@@ -56,6 +61,42 @@ static int __s390_pv_cmd(uint32_t cmd, const char *cmdname, void *data) } \ } +int s390_pv_query_info (void ) +{ +struct kvm_s390_pv_info info = { + .header.id =KVM_PV_INFO_VM , + .header.len_max =sizeof (info.header) +sizeof (info.vm), + }; +int rc; + +/* Info API's first user is dump so they are bundled */ +if (!kvm_s390_get_protected_dump ()) { +return 0 ; + } + + rc =s390_pv_cmd (KVM_PV_INFO , &info); +if (rc) { +error_report ("KVM PV INFO cmd %x failed: %s" , + info.header.id,strerror (rc)); +return rc; + } +memcpy (&info_vm, &info.vm,sizeof (info.vm)); + + info.header.id =KVM_PV_INFO_DUMP ; + info.header.len_max =sizeof (info.header) +sizeof (info.dump); + rc =s390_pv_cmd (KVM_PV_INFO , &info); +if (rc) { +error_report ("KVM PV INFO cmd %x failed: %s" , + info.header.id,strerror (rc)); +return rc; + } + +memcpy (&info_dump, &info.dump,sizeof (info.dump)); + info_valid = true; + +return rc; +} +int s390_pv_vm_enable (void ) {return s390_pv_cmd (KVM_PV_ENABLE ,NULL );
@@ -114,6 +155,26 @@ void s390_pv_inject_reset_error(CPUState *cs) env->regs[r1 +1 ] =DIAG_308_RC_INVAL_FOR_PV ; } +uint64_t kvm_s390_pv_dmp_get_size_cpu (void ) +{ +return info_dump.dump_cpu_buffer_len; +} + +uint64_t kvm_s390_pv_dmp_get_size_complete (void ) +{ +return info_dump.dump_config_finalize_len; +} + +uint64_t kvm_s390_pv_dmp_get_size_mem (void ) +{ +return info_dump.dump_config_mem_buffer_per_1m; +} + +bool kvm_s390_pv_info_basic_valid (void ) +{ +return info_valid; +} +#define TYPE_S390_PV_GUEST "s390-pv-guest"OBJECT_DECLARE_SIMPLE_TYPE (S390PVGuest,S390_PV_GUEST )
hw/s390x/s390-virtio-ccw.c +5 -0
@@ -365,6 +365,11 @@ static int s390_machine_protect(S390CcwMachineState *ms) ms->pv = true; + rc =s390_pv_query_info (); +if (rc) { + goto out_err; + } +/* Set SE header and unpack */ rc =s390_ipl_prepare_pv_header ();if (rc) {
include/hw/s390x/pv.h +10 -0
@@ -38,6 +38,7 @@ static inline bool s390_is_pv(void)return ccw->pv; } +int s390_pv_query_info (void );int s390_pv_vm_enable (void );void s390_pv_vm_disable (void );int s390_pv_set_sec_parms (uint64_t origin,uint64_t length);
@@ -46,8 +47,13 @@ void s390_pv_prep_reset(void);int s390_pv_verify (void );void s390_pv_unshare (void );void s390_pv_inject_reset_error (CPUState *cs); +uint64_t kvm_s390_pv_dmp_get_size_cpu (void ); +uint64_t kvm_s390_pv_dmp_get_size_mem (void ); +uint64_t kvm_s390_pv_dmp_get_size_complete (void ); +bool kvm_s390_pv_info_basic_valid (void );#else /* CONFIG_KVM */ static inline bool s390_is_pv (void ) {return false; } +static inline int s390_pv_query_info (void ) {return 0 ; }static inline int s390_pv_vm_enable (void ) {return 0 ; }static inline void s390_pv_vm_disable (void ) {}static inline int s390_pv_set_sec_parms (uint64_t origin,uint64_t length) {return 0 ; }
@@ -56,6 +62,10 @@ static inline void s390_pv_prep_reset(void) {}static inline int s390_pv_verify (void ) {return 0 ; }static inline void s390_pv_unshare (void ) {}static inline void s390_pv_inject_reset_error (CPUState *cs) {}; +static inline uint64_t kvm_s390_pv_dmp_get_size_cpu (void ) {return 0 ; } +static inline uint64_t kvm_s390_pv_dmp_get_size_mem (void ) {return 0 ; } +static inline uint64_t kvm_s390_pv_dmp_get_size_complete (void ) {return 0 ; } +static inline bool kvm_s390_pv_info_basic_valid (void ) {return false; }#endif /* CONFIG_KVM */ int s390_pv_kvm_init (ConfidentialGuestSupport *cgs,Error **errp);
Signature · 1 line
2.32.0
PATCH 4/5 s390x: Add KVM PV dump interface
In reply to Janosch FrankLet's add a few bits of code which hide the new KVM PV dump API from us via new functions.
--- hw/s390x/pv.c | 52 +++++++++++++++++++++++++++++++++++++++++++ include/hw/s390x/pv.h | 8 +++++++ 2 files changed, 60 insertions(+)
hw/s390x/pv.c +52 -0
@@ -175,6 +175,58 @@ bool kvm_s390_pv_info_basic_valid(void)return info_valid; } +static int s390_pv_dump_cmd (uint64_t subcmd,uint64_t uaddr,uint64_t gaddr, +uint64_t len) +{ +struct kvm_s390_pv_dmp dmp = { + .subcmd = subcmd, + .buff_addr = uaddr, + .buff_len = len, + .gaddr = gaddr, + }; +int ret; + + ret =s390_pv_cmd (KVM_PV_DUMP , (void *)&dmp); +if (ret) { +error_report ("KVM DUMP command %ld failed" , subcmd); + + } +return ret; +} + +int kvm_s390_dump_cpu (S390CPU *cpu,void *buff) +{ +struct kvm_s390_pv_dmp dmp = { + .subcmd =KVM_PV_DUMP_CPU , + .buff_addr = (uint64_t )buff, + .gaddr =0 , + .buff_len = info_dump.dump_cpu_buffer_len, + }; +struct kvm_pv_cmd pv = { + .cmd =KVM_PV_DUMP , + .data = (uint64_t )&dmp, + }; + +return kvm_vcpu_ioctl (CPU (cpu),KVM_S390_PV_CPU_COMMAND , &pv); +} + +int kvm_s390_dump_init (void ) +{ +return s390_pv_dump_cmd (KVM_PV_DUMP_INIT ,0 ,0 ,0 ); +} + +int kvm_s390_dump_mem (uint64_t gaddr,size_t len,void *dest) +{ +return s390_pv_dump_cmd (KVM_PV_DUMP_CONFIG_STATE , (uint64_t )dest, + gaddr, len); +} + +int kvm_s390_dump_finish (void *buff) +{ +return s390_pv_dump_cmd (KVM_PV_DUMP_COMPLETE , (uint64_t )buff,0 , + info_dump.dump_config_finalize_len); +} +#define TYPE_S390_PV_GUEST "s390-pv-guest"OBJECT_DECLARE_SIMPLE_TYPE (S390PVGuest,S390_PV_GUEST )
include/hw/s390x/pv.h +8 -0
@@ -51,6 +51,10 @@ uint64_t kvm_s390_pv_dmp_get_size_cpu(void);uint64_t kvm_s390_pv_dmp_get_size_mem (void );uint64_t kvm_s390_pv_dmp_get_size_complete (void );bool kvm_s390_pv_info_basic_valid (void ); +int kvm_s390_dump_init (void ); +int kvm_s390_dump_cpu (S390CPU *cpu,void *buff); +int kvm_s390_dump_mem (uint64_t addr,size_t len,void *dest); +int kvm_s390_dump_finish (void *buff);#else /* CONFIG_KVM */ static inline bool s390_is_pv (void ) {return false; }static inline int s390_pv_query_info (void ) {return 0 ; }
@@ -66,6 +70,10 @@ static inline uint64_t kvm_s390_pv_dmp_get_size_cpu(void) { return 0; }static inline uint64_t kvm_s390_pv_dmp_get_size_mem (void ) {return 0 ; }static inline uint64_t kvm_s390_pv_dmp_get_size_complete (void ) {return 0 ; }static inline bool kvm_s390_pv_info_basic_valid (void ) {return false; } +static inline int kvm_s390_dump_init (void ) {return 0 ; } +static inline int kvm_s390_dump_cpu (S390CPU *cpu,void *buff,size_t len) {return 0 ; } +static inline int kvm_s390_dump_mem (uint64_t addr,size_t len,void *dest) {return 0 ; } +static inline int kvm_s390_dump_finish (void *buff) {return 0 ; }#endif /* CONFIG_KVM */ int s390_pv_kvm_init (ConfidentialGuestSupport *cgs,Error **errp);
Signature · 1 line
2.32.0
Re: [PATCH 4/5] s390x: Add KVM PV dump interface
Quoted 22 lines · Janosch Frank
Let's add a few bits of code which hide the new KVM PV dump API from us via new functions.
Signed-off-by Janosch Frank <[email protected]>--- hw/s390x/pv.c | 52 +++++++++++++++++++++++++++++++++++++++++++ include/hw/s390x/pv.h | 8 +++++++ 2 files changed, 60 insertions(+)hw/s390x/pv.c +5
-0@@ -175,6 +175,58 @@ bool kvm_s390_pv_info_basic_valid(void)return info_valid; } +static int s390_pv_dump_cmd (uint64_t subcmd,uint64_t uaddr,uint64_t gaddr, +uint64_t len) +{ +struct kvm_s390_pv_dmp dmp = { + .subcmd = subcmd,
hw/s390x/pv.c bool kvm_s390_pv_info_basic_valid(void) · line 192
Quoted 10 lines
hw/s390x/pv.c +10
-0+ .buff_addr = uaddr, + .buff_len = len, + .gaddr = gaddr, + }; +int ret; + + ret =s390_pv_cmd (KVM_PV_DUMP , (void *)&dmp); +if (ret) { +error_report ("KVM DUMP command %ld failed" , subcmd); +
Please remove the empty line.
hw/s390x/pv.c bool kvm_s390_pv_info_basic_valid(void) · line 195
Quoted 3 lines
hw/s390x/pv.c +3
-0+ } +return ret; +}
Thomas
PATCH 5/5 s390x: pv: Add dump support
In reply to Janosch FrankSometimes dumping a guest from the outside is the only way to get the data that is needed. This can be the case if a dumping mechanism like KDUMP hasn't been configured or data needs to be fetched at a specific point. Dumping a protected guest from the outside without help from fw/hw doesn't yield sufficient data to be useful. Hence we now introduce PV dump support.
The PV dump support works by integrating the firmware into the dump process. New Ultravisor calls are used to initiate the dump process, dump cpu data, dump memory state and lastly complete the dump process. The UV calls are exposed by KVM via the new KVM_PV_DUMP command and its subcommands. The guest's data is fully encrypted and can only be decrypted by the entity that owns the customer communication key for the dumped guest. Also dumping needs to be allowed via a flag in the SE header.
On the QEMU side of things we store the PV dump data in the newly introduced architecture ELF sections (storage state and completion data) and the cpu notes (for cpu dump data).
Users can use a tool to convert the encrypted QEMU dump to an unencrypted one.
--- dump/dump.c | 27 ----- include/elf.h | 1 + include/sysemu/dump.h | 27 +++++ target/s390x/arch_dump.c | 247 ++++++++++++++++++++++++++++++++++----- 4 files changed, 244 insertions(+), 58 deletions(-)
dump/dump.c +0 -27
@@ -708,33 +708,6 @@ static void dump_begin(DumpState *s, Error **errp)write_elf_notes (s, errp); } -static int get_next_block (DumpState *s,GuestPhysBlock *block) -{ -while (1 ) { - block =QTAILQ_NEXT (block, next); -if (!block) { -/* no more block */ -return 1 ; - } - - s->start =0 ; - s->next_block = block; -if (s->has_filter) { -if (block->target_start >= s->begin + s->length || - block->target_end <= s->begin) { -/* This block is out of the range */ -continue ; - } - -if (s->begin > block->target_start) { - s->start = s->begin - block->target_start; - } - } - -return 0 ; - } -} -/* write all memory to vmcore */ static void dump_iterate (DumpState *s,Error **errp) {
include/elf.h +1 -0
@@ -1649,6 +1649,7 @@ typedef struct elf64_shdr {#define NT_TASKSTRUCT 4#define NT_AUXV 6#define NT_PRXFPREG 0x46e62b7f/* copied from gdb5.1/include/elf/common.h */ +#define NT_S390_PV_DATA 0x30e/* s390 protvirt cpu dump data */ #define NT_S390_GS_CB 0x30b/* s390 guarded storage registers */ #define NT_S390_VXRS_HIGH 0x30a/* s390 vector registers 16-31 */ #define NT_S390_VXRS_LOW 0x309/* s390 vector registers 0-15 (lower half) */
include/sysemu/dump.h +27 -0
@@ -213,4 +213,31 @@ typedef struct DumpState {uint16_t cpu_to_dump16 (DumpState *s,uint16_t val);uint32_t cpu_to_dump32 (DumpState *s,uint32_t val);uint64_t cpu_to_dump64 (DumpState *s,uint64_t val); + +static inline int get_next_block (DumpState *s,GuestPhysBlock *block) +{ +while (1 ) { + block =QTAILQ_NEXT (block, next); +if (!block) { +/* no more block */ +return 1 ; + } + + s->start =0 ; + s->next_block = block; +if (s->has_filter) { +if (block->target_start >= s->begin + s->length || + block->target_end <= s->begin) { +/* This block is out of the range */ +continue ; + } + +if (s->begin > block->target_start) { + s->start = s->begin - block->target_start; + } + } + +return 0 ; + } +}#endif
target/s390x/arch_dump.c +216 -31
322 lines not on this page · raw message
Signature · 1 line
2.32.0
Re: [PATCH 5/5] s390x: pv: Add dump support
Quoted 55 lines · Janosch Frank
Sometimes dumping a guest from the outside is the only way to get the data that is needed. This can be the case if a dumping mechanism like KDUMP hasn't been configured or data needs to be fetched at a specific point. Dumping a protected guest from the outside without help from fw/hw doesn't yield sufficient data to be useful. Hence we now introduce PV dump support.
The PV dump support works by integrating the firmware into the dump process. New Ultravisor calls are used to initiate the dump process, dump cpu data, dump memory state and lastly complete the dump process. The UV calls are exposed by KVM via the new
KVM_PV_DUMPcommand and its subcommands. The guest's data is fully encrypted and can only be decrypted by the entity that owns the customer communication key for the dumped guest. Also dumping needs to be allowed via a flag in the SE header.On the QEMU side of things we store the PV dump data in the newly introduced architecture ELF sections (storage state and completion data) and the cpu notes (for cpu dump data).
Users can use a tool to convert the encrypted QEMU dump to an unencrypted one.
Signed-off-by Janosch Frank <[email protected]>--- dump/dump.c | 27 ----- include/elf.h | 1 + include/sysemu/dump.h | 27 +++++ target/s390x/arch_dump.c | 247 ++++++++++++++++++++++++++++++++++----- 4 files changed, 244 insertions(+), 58 deletions(-)dump/dump.c +0
-16@@ -708,33 +708,6 @@ static void dump_begin(DumpState *s, Error **errp)write_elf_notes (s, errp); } -static int get_next_block (DumpState *s,GuestPhysBlock *block) -{ -while (1 ) { - block =QTAILQ_NEXT (block, next); -if (!block) { -/* no more block */ -return 1 ; - } - - s->start =0 ; - s->next_block = block; -if (s->has_filter) { -if (block->target_start >= s->begin + s->length || - block->target_end <= s->begin) { -/* This block is out of the range */ -continue ;
dump/dump.c static void dump_begin(DumpState *s, Error **errp) · line 736
Quoted 10 lines
dump/dump.c +0
-10- } - -if (s->begin > block->target_start) { - s->start = s->begin - block->target_start; - } - } - -return 0 ; - } -}
No reason to make this inline, surely. Just export it. Anyway, this should be it's own patch.
dump/dump.c typedef struct noteStruct { · line 80
Quoted 5 lines
dump/dump.c +1
-0@@ -76,9 +77,12 @@ typedef struct noteStruct {uint64_t todcmp;uint32_t todpreg;uint64_t ctrs[16 ]; +uint8_t dynamic;/* Real size comes from PV info interface */
This needs a better comment. Possibly
uint8_t dynamic[1]; /* Would be a flexible array member, if that was legal inside a
union. Real size comes from PV info interface. */
Alternately, rewrite everything to work with
typedef struct noteStruct {
Elf64_Nhdr hdr;
char name[8];
uint8_t contents[];
} QEMU_PACKED Note;which is a better description of what's going on in this file anyway.
r~
Re: [PATCH 5/5] s390x: pv: Add dump support
Quoted 61 lines · Richard Henderson
Quoted 60 lines · Janosch Frank
Sometimes dumping a guest from the outside is the only way to get the data that is needed. This can be the case if a dumping mechanism like KDUMP hasn't been configured or data needs to be fetched at a specific point. Dumping a protected guest from the outside without help from fw/hw doesn't yield sufficient data to be useful. Hence we now introduce PV dump support.
The PV dump support works by integrating the firmware into the dump process. New Ultravisor calls are used to initiate the dump process, dump cpu data, dump memory state and lastly complete the dump process. The UV calls are exposed by KVM via the new
KVM_PV_DUMPcommand and its subcommands. The guest's data is fully encrypted and can only be decrypted by the entity that owns the customer communication key for the dumped guest. Also dumping needs to be allowed via a flag in the SE header.On the QEMU side of things we store the PV dump data in the newly introduced architecture ELF sections (storage state and completion data) and the cpu notes (for cpu dump data).
Users can use a tool to convert the encrypted QEMU dump to an unencrypted one.
Signed-off-by Janosch Frank <[email protected]>--- dump/dump.c | 27 ----- include/elf.h | 1 + include/sysemu/dump.h | 27 +++++ target/s390x/arch_dump.c | 247 ++++++++++++++++++++++++++++++++++----- 4 files changed, 244 insertions(+), 58 deletions(-)dump/dump.c +0
-21@@ -708,33 +708,6 @@ static void dump_begin(DumpState *s, Error **errp)write_elf_notes (s, errp); } -static int get_next_block (DumpState *s,GuestPhysBlock *block) -{ -while (1 ) { - block =QTAILQ_NEXT (block, next); -if (!block) { -/* no more block */ -return 1 ; - } - - s->start =0 ; - s->next_block = block; -if (s->has_filter) { -if (block->target_start >= s->begin + s->length || - block->target_end <= s->begin) { -/* This block is out of the range */ -continue ; - } - -if (s->begin > block->target_start) { - s->start = s->begin - block->target_start; - }
Quoted 8 lines
dump/dump.c static void dump_begin(DumpState *s, Error **errp) · line 736
Quoted 5 lines
dump/dump.c +0
-5- } - -return 0 ; - } -}No reason to make this inline, surely. Just export it. Anyway, this should be it's own patch.
Yeah, will do.
Quoted 14 lines
dump/dump.c typedef struct noteStruct { · line 80
Quoted 6 lines
dump/dump.c +1
-0@@ -76,9 +77,12 @@ typedef struct noteStruct {uint64_t todcmp;uint32_t todpreg;uint64_t ctrs[16 ]; +uint8_t dynamic;/* Real size comes from PV info interface */ This needs a better comment. Possibly
uint8_tdynamic[1]; /* Would be a flexible array member, if that was legal inside a
union. Real size comes from PV info interface. */Alternately, rewrite everything to work with
Quoted 7 lines
typedef struct noteStruct { Elf64_Nhdr hdr; char name[8]; uint8_t contents[]; } QEMU_PACKED Note;which is a better description of what's going on in this file anyway.
I'll have a look at that
Quoted 3 lines
r~