ppc: record-replay fixes and enablement
cover ppc: record-replay fixes and enablement
Here is a series that gets ppc pseries and powernv machines into better shape for record-replay, maybe for 8.2. It's likely got a few deficiencies but it does run test cases and helped find bugs in migration already. It requires previous decrementer fixes to work well.
I think we can get away without patch 1 for 8.1, because we inadvertently fixed regular (non-rr) migration of reservation with commit 392d328abe753. But opinions welcome.
For record/replay and avocado test reviewers, I would mainly be interested in opinions about patch 6. I tried not to affect existing archs much.
Thanks,
Nick
Nicholas Piggin (7):
target/ppc: Fix CPU reservation migration for record-replay target/ppc: Fix timebase reset with record-replay
spapr: Fix machine reset deadlock from replay-record
spapr: Fix record-replay machine reset consuming too many events tests/avocado: boot ppc64 pseries replay-record test to Linux VFS
mount
tests/avocado: reverse-debugging cope with re-executing breakpoints tests/avocado: ppc64 reverse debugging tests for pseries and powernv
hw/ppc/ppc.c | 11 ++++-- hw/ppc/spapr.c | 32 +++++++++++++++--- include/hw/ppc/spapr.h | 2 ++ target/ppc/compat.c | 19 +++++++++++ target/ppc/cpu.h | 3 ++ target/ppc/machine.c | 26 ++++++++++++-- target/ppc/translate.c | 4 +++ tests/avocado/replay_kernel.py | 3 +- tests/avocado/reverse_debugging.py | 54 +++++++++++++++++++++++++++--- 9 files changed, 139 insertions(+), 15 deletions(-)
Signature · 1 line
2.40.1
PATCH 1/7 target/ppc: Fix CPU reservation migration for record-replay
ppc only migrates reserve_addr, so the destination machine can get a valid reservation with an incorrect reservation value of 0. Prior to commit 392d328abe753 ("target/ppc: Ensure stcx size matches larx"), this could permit a stcx. to incorrectly succeed. That commit inadvertently fixed that bug because the target machine starts with an impossible reservation size of 0, so any stcx. will fail.
This behaviour is permitted by the ISA because reservation loss may have implementation-dependent cause. What's more, with KVM machines it is impossible save or reasonably restore reservation state. However if the vmstate is being used for record-replay, the reservation must be saved and restored exactly in order for execution from snapshot to match the record.
This patch deprecates the existing incomplete reserve_addr vmstate, and adds a new vmstate subsection with complete reservation state. The new vmstate is needed only when record-replay mode is active.
--- target/ppc/cpu.h | 2 ++ target/ppc/machine.c | 26 ++++++++++++++++++++++++-- target/ppc/translate.c | 4 ++++ 3 files changed, 30 insertions(+), 2 deletions(-)
target/ppc/cpu.h +2 -0
@@ -1121,7 +1121,9 @@ struct CPUArchState {target_ulong reserve_addr;/* Reservation address */ target_ulong reserve_length;/* Reservation larx op size (bytes) */ target_ulong reserve_val;/* Reservation value */ +#if defined(TARGET_PPC64 )target_ulong reserve_val2; +#endif /* These are used in supervisor mode only */ target_ulong msr;/* machine state register */
target/ppc/machine.c +24 -2
@@ -10,6 +10,7 @@#include "qemu/main-loop.h" #include "kvm_ppc.h" #include "power8-pmu.h" +#include "sysemu/replay.h" static void post_load_update_msr (CPUPPCState *env) {
@@ -685,6 +686,27 @@ static const VMStateDescription vmstate_compat = { } }; +static bool reservation_needed (void *opaque) +{ +return (replay_mode !=REPLAY_MODE_NONE ); +} + +static const VMStateDescription vmstate_reservation = { + .name ="cpu/reservation" , + .version_id =1 , + .minimum_version_id =1 , + .needed = reservation_needed, + .fields = (VMStateField []) { +VMSTATE_UINTTL (env.reserve_addr, PowerPCCPU), +VMSTATE_UINTTL (env.reserve_length, PowerPCCPU), +VMSTATE_UINTTL (env.reserve_val, PowerPCCPU), +#if defined(TARGET_PPC64) +VMSTATE_UINTTL (env.reserve_val2, PowerPCCPU), +#endif +VMSTATE_END_OF_LIST () + } +}; +const VMStateDescription vmstate_ppc_cpu = { .name ="cpu" , .version_id =5 ,
@@ -706,8 +728,7 @@ const VMStateDescription vmstate_ppc_cpu = {VMSTATE_UINTTL_ARRAY (env.spr, PowerPCCPU,1024 ),VMSTATE_UINT64 (env.spe_acc, PowerPCCPU), -/* Reservation */ -VMSTATE_UINTTL (env.reserve_addr, PowerPCCPU), +VMSTATE_UNUSED (sizeof (target_ulong)),/* was env.reserve_addr */ /* Supervisor mode architected state */ VMSTATE_UINTTL(env.msr, PowerPCCPU),
@@ -736,6 +757,7 @@ const VMStateDescription vmstate_ppc_cpu = { &vmstate_tlbemb, &vmstate_tlbmas, &vmstate_compat, + &vmstate_reservation, NULL } };
target/ppc/translate.c +4 -0
@@ -77,7 +77,9 @@ static TCGv cpu_xer, cpu_so, cpu_ov, cpu_ca, cpu_ov32, cpu_ca32;static TCGv cpu_reserve;static TCGv cpu_reserve_length;static TCGv cpu_reserve_val; +#if defined(TARGET_PPC64 )static TCGv cpu_reserve_val2; +#endif static TCGv cpu_fpscr;static TCGv_i32 cpu_access_type;
@@ -151,9 +153,11 @@ void ppc_translate_init(void) cpu_reserve_val =tcg_global_mem_new (cpu_env, offsetof(CPUPPCState , reserve_val),"reserve_val" ); +#if defined(TARGET_PPC64 ) cpu_reserve_val2 =tcg_global_mem_new (cpu_env, offsetof(CPUPPCState , reserve_val2),"reserve_val2" ); +#endif cpu_fpscr =tcg_global_mem_new (cpu_env, offsetof(CPUPPCState , fpscr),"fpscr" );
Signature · 1 line
2.40.1
PATCH 2/7 target/ppc: Fix timebase reset with record-replay
In reply to Nicholas PigginTimebase save uses a random number for a legacy vmstate field, which makes rr snapshot loading unbalanced. The easiest way to deal with this is just to skip the rng if record-replay is active.
--- hw/ppc/ppc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
hw/ppc/ppc.c +9 -2
@@ -32,6 +32,7 @@#include "qemu/main-loop.h" #include "qemu/error-report.h" #include "sysemu/kvm.h" +#include "sysemu/replay.h" #include "sysemu/runstate.h" #include "kvm_ppc.h" #include "migration/vmstate.h"
@@ -937,8 +938,14 @@ static void timebase_save(PPCTimebase *tb)return ; } -/* not used anymore, we keep it for compatibility */ - tb->time_of_the_day_ns =qemu_clock_get_ns (QEMU_CLOCK_HOST ); +if (replay_mode ==REPLAY_MODE_NONE ) { +/* not used anymore, we keep it for compatibility */ + tb->time_of_the_day_ns =qemu_clock_get_ns (QEMU_CLOCK_HOST ); + }else { +/* simpler for record-replay to avoid this event, compat not needed */ + tb->time_of_the_day_ns =0 ; + } +/* * tb_offset is only expected to be changed by QEMU so * there is no need to update it from KVM here
Signature · 1 line
2.40.1
PATCH 3/7 spapr: Fix machine reset deadlock from replay-record
In reply to Nicholas PigginWhen the machine is reset to load a new snapshot while being debugged with replay-record, it is done from another thread, so the CPU does not run the register setting operations. Set CPU registers directly in machine reset.
--- hw/ppc/spapr.c | 20 ++++++++++++++++++-- include/hw/ppc/spapr.h | 1 + target/ppc/compat.c | 19 +++++++++++++++++++ target/ppc/cpu.h | 1 + 4 files changed, 39 insertions(+), 2 deletions(-)
hw/ppc/spapr.c +18 -2
@@ -1322,6 +1322,22 @@ void spapr_set_all_lpcrs(target_ulong value, target_ulong mask) } } +/* May be used when the machine is not running */ +void spapr_init_all_lpcrs (target_ulong value,target_ulong mask) +{ +CPUState *cs; +CPU_FOREACH (cs) { +PowerPCCPU *cpu =POWERPC_CPU (cs); +CPUPPCState *env = &cpu->env; +target_ulong lpcr; + + lpcr = env->spr[SPR_LPCR ]; + lpcr &= ~(LPCR_HR |LPCR_UPRT ); +ppc_store_lpcr (cpu, lpcr); + } +} + +static bool spapr_get_pate (PPCVirtualHypervisor *vhyp,PowerPCCPU *cpu,target_ulong lpid,ppc_v3_pate_t *entry) {
@@ -1583,7 +1599,7 @@ int spapr_reallocate_hpt(SpaprMachineState *spapr, int shift, Error **errp) }/* We're setting up a hash table, so that means we're not radix */ spapr->patb_entry =0 ; -spapr_set_all_lpcrs (0 ,LPCR_HR |LPCR_UPRT ); +spapr_init_all_lpcrs (0 ,LPCR_HR |LPCR_UPRT );return 0 ; }
@@ -1661,7 +1677,7 @@ static void spapr_machine_reset(MachineState *machine, ShutdownCause reason)spapr_ovec_cleanup (spapr->ov5_cas); spapr->ov5_cas =spapr_ovec_new (); -ppc_set_compat_all (spapr->max_compat_pvr, &error_fatal); +ppc_init_compat_all (spapr->max_compat_pvr, &error_fatal);/* * This is fixing some of the default configuration of the XIVE
include/hw/ppc/spapr.h +1 -0
@@ -1012,6 +1012,7 @@ bool spapr_check_pagesize(SpaprMachineState *spapr, hwaddr pagesize,#define SPAPR_OV5_XIVE_BOTH 0x80/* Only to advertise on the platform */ void spapr_set_all_lpcrs (target_ulong value,target_ulong mask); +void spapr_init_all_lpcrs (target_ulong value,target_ulong mask);hwaddr spapr_get_rtas_addr (void );bool spapr_memory_hot_unplug_supported (SpaprMachineState *spapr);
target/ppc/compat.c +19 -0
@@ -229,6 +229,25 @@ int ppc_set_compat_all(uint32_t compat_pvr, Error **errp)return 0 ; } +/* To be used when the machine is not running */ +int ppc_init_compat_all (uint32_t compat_pvr,Error **errp) +{ +CPUState *cs; + +CPU_FOREACH (cs) { +PowerPCCPU *cpu =POWERPC_CPU (cs); +int ret; + + ret =ppc_set_compat (cpu, compat_pvr, errp); + +if (ret <0 ) { +return ret; + } + } + +return 0 ; +} +int ppc_compat_max_vthreads (PowerPCCPU *cpu) {const CompatInfo *compat =compat_by_pvr (cpu->compat_pvr);
target/ppc/cpu.h +1 -0
@@ -1497,6 +1497,7 @@ int ppc_set_compat(PowerPCCPU *cpu, uint32_t compat_pvr, Error **errp);#if !defined(CONFIG_USER_ONLY )int ppc_set_compat_all (uint32_t compat_pvr,Error **errp); +int ppc_init_compat_all (uint32_t compat_pvr,Error **errp);#endif int ppc_compat_max_vthreads (PowerPCCPU *cpu); void ppc_compat_add_property(Object *obj, const char *name,
Signature · 1 line
2.40.1
PATCH 4/7 spapr: Fix record-replay machine reset consuming too many events
In reply to Nicholas Pigginspapr_machine_reset gets a random number to populate the device-tree rng seed with. When loading a snapshot for record-replay, the machine is reset again, and that tries to consume the random event record again, crashing due to inconsistent record
Fix this by saving the seed to populate the device tree with, and skipping the rng on snapshot load.
--- hw/ppc/spapr.c | 12 +++++++++--- include/hw/ppc/spapr.h | 1 + 2 files changed, 10 insertions(+), 3 deletions(-)
hw/ppc/spapr.c +9 -3
@@ -1022,7 +1022,6 @@ static void spapr_dt_chosen(SpaprMachineState *spapr, void *fdt, bool reset) {MachineState *machine =MACHINE (spapr);SpaprMachineClass *smc =SPAPR_MACHINE_GET_CLASS (machine); -uint8_t rng_seed[32 ];int chosen;_FDT (chosen =fdt_add_subnode (fdt,0 ,"chosen" ));
@@ -1100,8 +1099,7 @@ static void spapr_dt_chosen(SpaprMachineState *spapr, void *fdt, bool reset)spapr_dt_ov5_platform_support (spapr, fdt, chosen); } -qemu_guest_getrandom_nofail (rng_seed,sizeof (rng_seed)); -_FDT (fdt_setprop (fdt, chosen,"rng-seed" , rng_seed,sizeof (rng_seed))); +_FDT (fdt_setprop (fdt, chosen,"rng-seed" , spapr->fdt_rng_seed,32 ));_FDT (spapr_dt_ovec (fdt, chosen, spapr->ov5_cas,"ibm,architecture-vec-5" )); }
@@ -1654,6 +1652,14 @@ static void spapr_machine_reset(MachineState *machine, ShutdownCause reason)void *fdt;int rc; +if (reason !=SHUTDOWN_CAUSE_SNAPSHOT_LOAD ) { +/* +* Record-replay snapshot load must not consume random, this was +* already replayed from initial machine reset. +*/ +qemu_guest_getrandom_nofail (spapr->fdt_rng_seed,32 ); + } +pef_kvm_reset (machine->cgs, &error_fatal);spapr_caps_apply (spapr);
include/hw/ppc/spapr.h +1 -0
@@ -204,6 +204,7 @@ struct SpaprMachineState {uint32_t fdt_size;uint32_t fdt_initial_size;void *fdt_blob; +uint8_t fdt_rng_seed[32 ];long kernel_size;bool kernel_le;uint64_t kernel_addr;
Signature · 1 line
2.40.1
Re: [PATCH 4/7] spapr: Fix record-replay machine reset consuming too many events
Quoted 64 lines · Nicholas Piggin
spapr_machine_resetgets a random number to populate the device-tree rng seed with. When loading a snapshot for record-replay, the machine is reset again, and that tries to consume the random event record again, crashing due to inconsistent recordFix this by saving the seed to populate the device tree with, and skipping the rng on snapshot load.
Cc Pavel Dovgalyuk <[email protected]>Signed-off-by Nicholas Piggin <[email protected]>--- hw/ppc/spapr.c | 12 +++++++++--- include/hw/ppc/spapr.h | 1 + 2 files changed, 10 insertions(+), 3 deletions(-)hw/ppc/spapr.c +9
-3@@ -1022,7 +1022,6 @@ static void spapr_dt_chosen(SpaprMachineState *spapr, void *fdt, bool reset) {MachineState *machine =MACHINE (spapr);SpaprMachineClass *smc =SPAPR_MACHINE_GET_CLASS (machine); -uint8_t rng_seed[32 ];int chosen;_FDT (chosen =fdt_add_subnode (fdt,0 ,"chosen" ));@@ -1100,8 +1099,7 @@ static void spapr_dt_chosen(SpaprMachineState *spapr, void *fdt, bool reset)spapr_dt_ov5_platform_support (spapr, fdt, chosen); } -qemu_guest_getrandom_nofail (rng_seed,sizeof (rng_seed)); -_FDT (fdt_setprop (fdt, chosen,"rng-seed" , rng_seed,sizeof (rng_seed))); +_FDT (fdt_setprop (fdt, chosen,"rng-seed" , spapr->fdt_rng_seed,32 ));_FDT (spapr_dt_ovec (fdt, chosen, spapr->ov5_cas,"ibm,architecture-vec-5" )); }@@ -1654,6 +1652,14 @@ static void spapr_machine_reset(MachineState *machine, ShutdownCause reason)void *fdt;int rc; +if (reason !=SHUTDOWN_CAUSE_SNAPSHOT_LOAD ) { +/* +* Record-replay snapshot load must not consume random, this was +* already replayed from initial machine reset. +*/ +qemu_guest_getrandom_nofail (spapr->fdt_rng_seed,32 ); + } +pef_kvm_reset (machine->cgs, &error_fatal);spapr_caps_apply (spapr);include/hw/ppc/spapr.h +1
-0@@ -204,6 +204,7 @@ struct SpaprMachineState {uint32_t fdt_size;uint32_t fdt_initial_size;void *fdt_blob; +uint8_t fdt_rng_seed[32 ];long kernel_size;bool kernel_le;uint64_t kernel_addr;
Re: [PATCH 4/7] spapr: Fix record-replay machine reset consuming too many events
In reply to Nicholas PigginBTW, there is a function qemu_register_reset_nosnapshotload that can be used in similar cases. Can you just use it without changing the code of the reset handler?
Quoted 64 lines · Nicholas Piggin
spapr_machine_resetgets a random number to populate the device-tree rng seed with. When loading a snapshot for record-replay, the machine is reset again, and that tries to consume the random event record again, crashing due to inconsistent recordFix this by saving the seed to populate the device tree with, and skipping the rng on snapshot load.
Cc Pavel Dovgalyuk <[email protected]>Signed-off-by Nicholas Piggin <[email protected]>--- hw/ppc/spapr.c | 12 +++++++++--- include/hw/ppc/spapr.h | 1 + 2 files changed, 10 insertions(+), 3 deletions(-)hw/ppc/spapr.c +9
-3@@ -1022,7 +1022,6 @@ static void spapr_dt_chosen(SpaprMachineState *spapr, void *fdt, bool reset) {MachineState *machine =MACHINE (spapr);SpaprMachineClass *smc =SPAPR_MACHINE_GET_CLASS (machine); -uint8_t rng_seed[32 ];int chosen;_FDT (chosen =fdt_add_subnode (fdt,0 ,"chosen" ));@@ -1100,8 +1099,7 @@ static void spapr_dt_chosen(SpaprMachineState *spapr, void *fdt, bool reset)spapr_dt_ov5_platform_support (spapr, fdt, chosen); } -qemu_guest_getrandom_nofail (rng_seed,sizeof (rng_seed)); -_FDT (fdt_setprop (fdt, chosen,"rng-seed" , rng_seed,sizeof (rng_seed))); +_FDT (fdt_setprop (fdt, chosen,"rng-seed" , spapr->fdt_rng_seed,32 ));_FDT (spapr_dt_ovec (fdt, chosen, spapr->ov5_cas,"ibm,architecture-vec-5" )); }@@ -1654,6 +1652,14 @@ static void spapr_machine_reset(MachineState *machine, ShutdownCause reason)void *fdt;int rc; +if (reason !=SHUTDOWN_CAUSE_SNAPSHOT_LOAD ) { +/* +* Record-replay snapshot load must not consume random, this was +* already replayed from initial machine reset. +*/ +qemu_guest_getrandom_nofail (spapr->fdt_rng_seed,32 ); + } +pef_kvm_reset (machine->cgs, &error_fatal);spapr_caps_apply (spapr);include/hw/ppc/spapr.h +1
-0@@ -204,6 +204,7 @@ struct SpaprMachineState {uint32_t fdt_size;uint32_t fdt_initial_size;void *fdt_blob; +uint8_t fdt_rng_seed[32 ];long kernel_size;bool kernel_le;uint64_t kernel_addr;
Re: [PATCH 4/7] spapr: Fix record-replay machine reset consuming too many events
Quoted 3 lines · Pavel Dovgalyuk
BTW, there is a function
qemu_register_reset_nosnapshotloadthat can be used in similar cases.
Can you just use it without changing the code of the reset handler?
I didn't know that, thanks for pointing it out. I'll take a closer look at it before reposting.
Thanks,
Nick
Quoted 66 lines · Nicholas Piggin
Quoted 64 lines
spapr_machine_resetgets a random number to populate the device-tree rng seed with. When loading a snapshot for record-replay, the machine is reset again, and that tries to consume the random event record again, crashing due to inconsistent recordFix this by saving the seed to populate the device tree with, and skipping the rng on snapshot load.
Cc Pavel Dovgalyuk <[email protected]>Signed-off-by Nicholas Piggin <[email protected]>--- hw/ppc/spapr.c | 12 +++++++++--- include/hw/ppc/spapr.h | 1 + 2 files changed, 10 insertions(+), 3 deletions(-)hw/ppc/spapr.c +9
-3@@ -1022,7 +1022,6 @@ static void spapr_dt_chosen(SpaprMachineState *spapr, void *fdt, bool reset) {MachineState *machine =MACHINE (spapr);SpaprMachineClass *smc =SPAPR_MACHINE_GET_CLASS (machine); -uint8_t rng_seed[32 ];int chosen;_FDT (chosen =fdt_add_subnode (fdt,0 ,"chosen" ));@@ -1100,8 +1099,7 @@ static void spapr_dt_chosen(SpaprMachineState *spapr, void *fdt, bool reset)spapr_dt_ov5_platform_support (spapr, fdt, chosen); } -qemu_guest_getrandom_nofail (rng_seed,sizeof (rng_seed)); -_FDT (fdt_setprop (fdt, chosen,"rng-seed" , rng_seed,sizeof (rng_seed))); +_FDT (fdt_setprop (fdt, chosen,"rng-seed" , spapr->fdt_rng_seed,32 ));_FDT (spapr_dt_ovec (fdt, chosen, spapr->ov5_cas,"ibm,architecture-vec-5" )); }@@ -1654,6 +1652,14 @@ static void spapr_machine_reset(MachineState *machine, ShutdownCause reason)void *fdt;int rc; +if (reason !=SHUTDOWN_CAUSE_SNAPSHOT_LOAD ) { +/* +* Record-replay snapshot load must not consume random, this was +* already replayed from initial machine reset. +*/ +qemu_guest_getrandom_nofail (spapr->fdt_rng_seed,32 ); + } +pef_kvm_reset (machine->cgs, &error_fatal);spapr_caps_apply (spapr);include/hw/ppc/spapr.h +1
-0@@ -204,6 +204,7 @@ struct SpaprMachineState {uint32_t fdt_size;uint32_t fdt_initial_size;void *fdt_blob; +uint8_t fdt_rng_seed[32 ];long kernel_size;bool kernel_le;uint64_t kernel_addr;
Re: [PATCH 4/7] spapr: Fix record-replay machine reset consuming too many events
Quoted 7 lines · Nicholas Piggin
Quoted 3 lines · Pavel Dovgalyuk
BTW, there is a function
qemu_register_reset_nosnapshotloadthat can be used in similar cases.
Can you just use it without changing the code of the reset handler?I didn't know that, thanks for pointing it out. I'll take a closer look at it before reposting.
Seems a bit tricky because the device tree has to be rebuilt at reset time (including snapshot load), but it uses the random number. So having a second nosnapshotload reset function might not be called in the correct order, I think? For now I will keep it as is.
Thanks,
Nick
Re: [PATCH 4/7] spapr: Fix record-replay machine reset consuming too many events
Quoted 11 lines · Nicholas Piggin
Quoted 7 lines · Nicholas Piggin
Quoted 3 lines · Pavel Dovgalyuk
BTW, there is a function
qemu_register_reset_nosnapshotloadthat can be used in similar cases.
Can you just use it without changing the code of the reset handler?I didn't know that, thanks for pointing it out. I'll take a closer look at it before reposting.
Seems a bit tricky because the device tree has to be rebuilt at reset time (including snapshot load), but it uses the random number. So
It seems strange to me, that loading the existing configuration has to randomize the device tree.
Quoted 2 lines
having a second nosnapshotload reset function might not be called in the correct order, I think? For now I will keep it as is.
Ok, let's wait for other reviewers.
Pavel Dovgalyuk
Re: [PATCH 4/7] spapr: Fix record-replay machine reset consuming too many events
Quoted 7 lines · Pavel Dovgalyuk
Quoted 6 lines · Nicholas Piggin
Quoted 5 lines · Nicholas Piggin
Quoted 3 lines · Pavel Dovgalyuk
BTW, there is a function
qemu_register_reset_nosnapshotloadthat can be used in similar cases.
Can you just use it without changing the code of the reset handler?
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
I didn't know that, thanks for pointing it out. I'll take a closer look at it before reposting.
Seems a bit tricky because the device tree has to be rebuilt at reset time (including snapshot load), but it uses the random number. So
It seems strange to me, that loading the existing configuration has to randomize the device tree.
Building the device tree requires a random number for one of the properties.
Other architectures that don't have this "cas" firmware call that changes the device tree and so requires it is rebuilt at machine reset time just build the device tree once at machine creation time I believe.
So spapr is already weird in that way. We could go the way that other archs have and just save that random number once at creation and then reuse it for each reset. I thought that was not so good because for a normal reset I think it is better to get a new random number each time, no?
So I think it's natural enough to take a new random number for a regular reset, but keep the existing one for a snapshot reset. I could be misunderstanding something though.
Thanks,
Nick
Quoted 8 lines
Quoted 3 lines
having a second nosnapshotload reset function might not be called in the correct order, I think? For now I will keep it as is.
Ok, let's wait for other reviewers.
Pavel Dovgalyuk
PATCH 5/7 tests/avocado: boot ppc64 pseries replay-record test to Linux VFS mount
In reply to Nicholas PigginThis the ppc64 record-replay test is able to replay the full kernel boot so try enabling it.
--- tests/avocado/replay_kernel.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
tests/avocado/replay_kernel.py +1 -2
@@ -255,8 +255,7 @@ def test_ppc64_pseries(self): kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=hvc0' - # icount is not good enough for PPC64 for complete boot yet - console_pattern = 'Kernel command line: %s' % kernel_command_line + console_pattern = 'VFS: Cannot open root device' self.run_rr(kernel_path, kernel_command_line, console_pattern) def test_ppc64_powernv(self):
Signature · 1 line
2.40.1
Re: [PATCH 5/7] tests/avocado: boot ppc64 pseries replay-record test to Linux VFS mount
Quoted 23 lines · Nicholas Piggin
This the ppc64 record-replay test is able to replay the full kernel boot so try enabling it.
Cc Pavel Dovgalyuk <[email protected]>Signed-off-by Nicholas Piggin <[email protected]>--- tests/avocado/replay_kernel.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)tests/avocado/replay_kernel.py +1
-2@@ -255,8 +255,7 @@ def test_ppc64_pseries(self): kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=hvc0' - # icount is not good enough for PPC64 for complete boot yet - console_pattern = 'Kernel command line: %s' % kernel_command_line + console_pattern = 'VFS: Cannot open root device' self.run_rr(kernel_path, kernel_command_line, console_pattern) def test_ppc64_powernv(self):
PATCH 6/7 tests/avocado: reverse-debugging cope with re-executing breakpoints
In reply to Nicholas PigginThe reverse-debugging test creates a trace, then replays it and:
1. Steps the first 10 instructions and records their addresses.
2. Steps backward and verifies their addresses match.
3. Runs to (near) the end of the trace.
4. Sets breakpoints on the first 10 instructions.
5. Continues backward and verifies execution stops at the last breakpoint.
Step 5 breaks if any of the other 9 breakpoints are re-executed in the trace after the 10th instruction is run, because those will be unexpectedly hit when reverse continuing. This situation does arise with the ppc pseries machine, the SLOF bios branches to its own entry point.
Permit this breakpoint re-execution by switching steps 4 and 5, so that the trace will be run to the end *or* the next breakpoint hit. Reversing from there to the 10th intsruction will not hit another breakpoint, by definition.
Another step is added between steps 2 and 3, which steps forward over the first 10 instructions and verifies their addresses, to support this.
--- tests/avocado/reverse_debugging.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-)
tests/avocado/reverse_debugging.py +21 -4
@@ -150,16 +150,33 @@ def reverse_debugging(self, shift=7, args=None): self.check_pc(g, addr) logger.info('found position %x' % addr) - logger.info('seeking to the end (icount %s)' % (last_icount - 1)) - vm.qmp('replay-break', icount=last_icount - 1) - # continue - will return after pausing - g.cmd(b'c', b'T02thread:01;') + # visit the recorded instruction in forward order + logger.info('stepping forward') + for addr in steps: + self.check_pc(g, addr) + self.gdb_step(g) + logger.info('found position %x' % addr) + # set breakpoints for the instructions just stepped over logger.info('setting breakpoints') for addr in steps: # hardware breakpoint at addr with len=1 g.cmd(b'Z1,%x,1' % addr, b'OK') + # this may hit a breakpoint if first instructions are executed + # again + logger.info('continuing execution') + vm.qmp('replay-break', icount=last_icount - 1) + # continue - will return after pausing + # This could stop at the end and get a T02 return, or by + # re-executing one of the breakpoints and get a T05 return. + g.cmd(b'c') + if self.vm_get_icount(vm) == last_icount - 1: + logger.info('reached the end (icount %s)' % (last_icount - 1)) + else: + logger.info('hit a breakpoint again at %x (icount %s)' % + (self.get_pc(g), self.vm_get_icount(vm))) + logger.info('running reverse continue to reach %x' % steps[-1]) # reverse continue - will return after stopping at the breakpoint g.cmd(b'bc', b'T05thread:01;')
Signature · 1 line
2.40.1
Re: [PATCH 6/7] tests/avocado: reverse-debugging cope with re-executing breakpoints
Quoted 71 lines · Nicholas Piggin
The reverse-debugging test creates a trace, then replays it and:
1. Steps the first 10 instructions and records their addresses.
2. Steps backward and verifies their addresses match.
3. Runs to (near) the end of the trace.
4. Sets breakpoints on the first 10 instructions.
5. Continues backward and verifies execution stops at the last breakpoint.Step 5 breaks if any of the other 9 breakpoints are re-executed in the trace after the 10th instruction is run, because those will be unexpectedly hit when reverse continuing. This situation does arise with the ppc pseries machine, the SLOF bios branches to its own entry point.
Permit this breakpoint re-execution by switching steps 4 and 5, so that the trace will be run to the end *or* the next breakpoint hit. Reversing from there to the 10th intsruction will not hit another breakpoint, by definition.
Another step is added between steps 2 and 3, which steps forward over the first 10 instructions and verifies their addresses, to support this.
Cc Pavel Dovgalyuk <[email protected]>Signed-off-by Nicholas Piggin <[email protected]>--- tests/avocado/reverse_debugging.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-)tests/avocado/reverse_debugging.py +21
-4@@ -150,16 +150,33 @@ def reverse_debugging(self, shift=7, args=None): self.check_pc(g, addr) logger.info('found position %x' % addr) - logger.info('seeking to the end (icount %s)' % (last_icount - 1)) - vm.qmp('replay-break', icount=last_icount - 1) - # continue - will return after pausing - g.cmd(b'c', b'T02thread:01;') + # visit the recorded instruction in forward order + logger.info('stepping forward') + for addr in steps: + self.check_pc(g, addr) + self.gdb_step(g) + logger.info('found position %x' % addr) + # set breakpoints for the instructions just stepped over logger.info('setting breakpoints') for addr in steps: # hardware breakpoint at addr with len=1 g.cmd(b'Z1,%x,1' % addr, b'OK') + # this may hit a breakpoint if first instructions are executed + # again + logger.info('continuing execution') + vm.qmp('replay-break', icount=last_icount - 1) + # continue - will return after pausing + # This could stop at the end and get a T02 return, or by + # re-executing one of the breakpoints and get a T05 return. + g.cmd(b'c') + if self.vm_get_icount(vm) == last_icount - 1: + logger.info('reached the end (icount %s)' % (last_icount - 1)) + else: + logger.info('hit a breakpoint again at %x (icount %s)' % + (self.get_pc(g), self.vm_get_icount(vm))) + logger.info('running reverse continue to reach %x' % steps[-1]) # reverse continue - will return after stopping at the breakpoint g.cmd(b'bc', b'T05thread:01;')
PATCH 7/7 tests/avocado: ppc64 reverse debugging tests for pseries and powernv
In reply to Nicholas PigginThese machines run reverse-debugging well enough to pass basic tests. Wire them up.
--- tests/avocado/reverse_debugging.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
tests/avocado/reverse_debugging.py +29 -0
@@ -233,3 +233,32 @@ def test_aarch64_virt(self): self.reverse_debugging( args=('-kernel', kernel_path)) + +class ReverseDebugging_ppc64(ReverseDebugging): + """ + :avocado: tags=accel:tcg + """ + + REG_PC = 0x40 + + # unidentified gitlab timeout problem + @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab') + def test_ppc64_pseries(self): + """ + :avocado: tags=arch:ppc64 + :avocado: tags=machine:pseries + """ + # SLOF branches back to its entry point, which causes this test + # to take the 'hit a breakpoint again' path. That's not a problem, + # just slightly different than the other machines. + self.endian_is_le = False + self.reverse_debugging() + + @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab') + def test_ppc64_powernv(self): + """ + :avocado: tags=arch:ppc64 + :avocado: tags=machine:powernv + """ + self.endian_is_le = False + self.reverse_debugging()
Signature · 1 line
2.40.1
Re: [PATCH 7/7] tests/avocado: ppc64 reverse debugging tests for pseries and powernv
Quoted 46 lines · Nicholas Piggin
These machines run reverse-debugging well enough to pass basic tests. Wire them up.
Cc Pavel Dovgalyuk <[email protected]>Signed-off-by Nicholas Piggin <[email protected]>--- tests/avocado/reverse_debugging.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)tests/avocado/reverse_debugging.py +29
-0@@ -233,3 +233,32 @@ def test_aarch64_virt(self): self.reverse_debugging( args=('-kernel', kernel_path)) + +class ReverseDebugging_ppc64(ReverseDebugging): + """ + :avocado: tags=accel:tcg + """ + + REG_PC = 0x40 + + # unidentified gitlab timeout problem + @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab') + def test_ppc64_pseries(self): + """ + :avocado: tags=arch:ppc64 + :avocado: tags=machine:pseries + """ + # SLOF branches back to its entry point, which causes this test + # to take the 'hit a breakpoint again' path. That's not a problem, + # just slightly different than the other machines. + self.endian_is_le = False + self.reverse_debugging() + + @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab') + def test_ppc64_powernv(self): + """ + :avocado: tags=arch:ppc64 + :avocado: tags=machine:powernv + """ + self.endian_is_le = False + self.reverse_debugging()