Skip to content

Commit c22f352

Browse files
committed
Arm Virt board RR Support
Modified Diverge.py to sucessfully run. It had problems with setting breakpoints. Created a readfn for the virt timer ctl value Added record/replay macros to readfn for counter and virt timer ctl.
1 parent af06664 commit c22f352

File tree

4 files changed

+44
-8
lines changed

4 files changed

+44
-8
lines changed

panda/include/panda/rr/rr_log.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ static inline uint64_t rr_num_instr_before_next_interrupt(void) {
216216

217217
uint32_t rr_checksum_memory(void);
218218
uint32_t rr_checksum_regs(void);
219-
219+
uint32_t rr_checksum_timers(int);
220220
bool rr_queue_empty(void);
221221

222222
#endif

panda/scripts/diverge.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from multiprocessing.pool import ThreadPool
1515
from os.path import join
1616
from subprocess import check_call, CalledProcessError
17+
from time import sleep
1718

1819
from expect import Expect, TimeoutExpired
1920
from tempdir import TempDir
@@ -255,19 +256,19 @@ def display_commands(self):
255256
def ram_ptr(self):
256257
return self.get_value(
257258
"memory_region_find(" +
258-
"get_system_memory(), 0x2000000, 1).mr->ram_block.host")
259+
"get_system_memory(), 0x2000000, 1).mr->ram_block->host")
259260

260261
def crc32_ram(self, low, size):
261262
step = 1 << 31 if size > (1 << 31) else size
262263
crc32s = 0
263264
for start in range(low, low + size, step):
264-
crc32s ^= self.get_value("crc32(0, {} + {}, {})".format(
265-
hex(self.ram_ptr), hex(start), hex(step)))
265+
crc32s ^= self.get_value("(unsigned long) crc32(0, {} +{}, {})".format(
266+
hex(self.ram_ptr), hex(start), hex(step)))
266267
return crc32s
267268

268269
@cached_property
269270
def ram_size(self):
270-
return self.get_value('ram_size')
271+
return self.get_value('memory_region_find(get_system_memory(), 0x2000000, 1).mr->ram_block.used_length')
271272

272273
@cached_property
273274
def reg_size(self):
@@ -670,11 +671,12 @@ def cleanup_error():
670671
self.both.gdb("set pagination off")
671672

672673
check_call(['tmux', 'select-layout', 'even-horizontal'])
673-
674+
self.both.breakpoint("_start")
675+
self.both.gdb("c")
676+
sleep(1)
674677
self.both.breakpoint("rr_do_begin_record")
675678
self.both.breakpoint("rr_do_begin_replay")
676679
self.both.breakpoint("cpu_loop_exec_tb")
677-
678680
try:
679681
self.both.breakpoint("debug_counter")
680682
except RuntimeError:

panda/src/rr/rr_log.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1951,6 +1951,14 @@ uint32_t rr_checksum_regs(void) {
19511951
#endif
19521952
return crc;
19531953
}
1954+
uint32_t rr_checksum_timers(int index) {
1955+
uint32_t crc = crc32(0, Z_NULL, 0);
1956+
#if defined(TARGET_ARM)
1957+
CPUARMState *env = (CPUArchState *)first_cpu->env_ptr;
1958+
crc = crc32(crc, (unsigned char *)&env->cp15.c14_timer[index], sizeof(env->cp15.c14_timer[index]));
1959+
#endif
1960+
return crc;
1961+
}
19541962

19551963
uint8_t rr_debug_readb(target_ulong addr);
19561964
uint8_t rr_debug_readb(target_ulong addr) {

target/arm/helper.c

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
#include <zlib.h> /* For crc32 */
1616
#include "exec/semihost.h"
1717
#include "sysemu/kvm.h"
18+
#ifdef CONFIG_SOFTMMU
19+
#include "panda/rr/rr_log_all.h"
20+
#include "panda/rr/rr_log.h"
21+
#endif
1822

1923
#define ARM_CPU_FREQ 1000000000 /* FIXME: 1 GHz, should be configurable */
2024

@@ -1701,6 +1705,15 @@ static uint64_t gt_cnt_read(CPUARMState *env, const ARMCPRegInfo *ri)
17011705

17021706
static uint64_t gt_virt_cnt_read(CPUARMState *env, const ARMCPRegInfo *ri)
17031707
{
1708+
#ifdef CONFIG_SOFTMMU
1709+
uint64_t now;
1710+
RR_DO_RECORD_OR_REPLAY(
1711+
/*action*/ now = gt_get_countervalue(env) - env->cp15.cntvoff_el2,
1712+
/*record*/ rr_input_8(&now),
1713+
/*replay*/ rr_input_8(&now),
1714+
/*location*/RR_CALLSITE_READ_8);
1715+
return now;
1716+
#endif
17041717
return gt_get_countervalue(env) - env->cp15.cntvoff_el2;
17051718
}
17061719

@@ -1812,7 +1825,18 @@ static void gt_virt_ctl_write(CPUARMState *env, const ARMCPRegInfo *ri,
18121825
{
18131826
gt_ctl_write(env, ri, GTIMER_VIRT, value);
18141827
}
1815-
1828+
static uint64_t gt_virt_ctl_read(CPUARMState *env, const ARMCPRegInfo *ri)
1829+
{
1830+
uint64_t ctl;
1831+
#ifdef CONFIG_SOFTMMU
1832+
RR_DO_RECORD_OR_REPLAY(
1833+
/*action*/ ctl = env->cp15.c14_timer[GTIMER_VIRT].ctl,
1834+
/*record*/ rr_input_8(&ctl),
1835+
/*replay*/ rr_input_8(&ctl),
1836+
/*location*/RR_CALLSITE_READ_8);
1837+
#endif
1838+
return ctl;
1839+
}
18161840
static void gt_cntvoff_write(CPUARMState *env, const ARMCPRegInfo *ri,
18171841
uint64_t value)
18181842
{
@@ -1961,6 +1985,7 @@ static const ARMCPRegInfo generic_timer_cp_reginfo[] = {
19611985
.accessfn = gt_vtimer_access,
19621986
.fieldoffset = offsetoflow32(CPUARMState,
19631987
cp15.c14_timer[GTIMER_VIRT].ctl),
1988+
.readfn = gt_virt_ctl_read,
19641989
.writefn = gt_virt_ctl_write, .raw_writefn = raw_write,
19651990
},
19661991
{ .name = "CNTV_CTL_EL0", .state = ARM_CP_STATE_AA64,
@@ -1969,6 +1994,7 @@ static const ARMCPRegInfo generic_timer_cp_reginfo[] = {
19691994
.accessfn = gt_vtimer_access,
19701995
.fieldoffset = offsetof(CPUARMState, cp15.c14_timer[GTIMER_VIRT].ctl),
19711996
.resetvalue = 0,
1997+
.readfn = gt_virt_ctl_read,
19721998
.writefn = gt_virt_ctl_write, .raw_writefn = raw_write,
19731999
},
19742000
/* TimerValue views: a 32 bit downcounting view of the underlying state */

0 commit comments

Comments
 (0)