-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathMakefile.qemu.patch
More file actions
2059 lines (1894 loc) · 75 KB
/
Makefile.qemu.patch
File metadata and controls
2059 lines (1894 loc) · 75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
From 4f24758b0efdc4b7800b8904e6cd217d578404bf Mon Sep 17 00:00:00 2001
From: Qiang Liu <[email protected]>
Date: Wed, 7 May 2025 09:30:54 +0200
Subject: [PATCH] Patch QEMU for HyperARM
---
accel/hvf/hvf-accel-ops.c | 2 +-
accel/kvm/kvm-all.c | 2 +-
accel/kvm/kvm-cpus.h | 2 +-
accel/tcg/atomic_common.c.inc | 4 +-
accel/tcg/atomic_template.h | 16 ++--
accel/tcg/cpu-exec.c | 34 +++++++-
accel/tcg/cputlb.c | 10 +++
accel/tcg/internal-target.h | 3 +
accel/tcg/ldst_common.c.inc | 45 +++++------
accel/tcg/plugin-gen.c | 16 ++--
accel/tcg/plugin-helpers.h | 2 +-
accel/tcg/tcg-accel-ops-mttcg.c | 2 +-
accel/tcg/tcg-accel-ops.c | 4 +-
accel/tcg/tcg-runtime.c | 25 ++++++
accel/tcg/tcg-runtime.h | 6 +-
accel/tcg/translator.c | 4 +
contrib/plugins/cache.c | 2 +-
contrib/plugins/execlog.c | 2 +-
contrib/plugins/hotpages.c | 2 +-
contrib/plugins/hwprofile.c | 2 +-
cpu-common.c | 3 +-
gdbstub/gdbstub.c | 2 +-
gdbstub/internals.h | 2 +-
gdbstub/system.c | 4 +-
gdbstub/user.c | 4 +-
hmp-commands.hx | 32 ++++++++
hw/block/pflash_cfi01.c | 2 +-
include/exec/memory.h | 14 ----
include/exec/memory_ldst_cached.h.inc | 3 -
include/exec/plugin-gen.h | 4 +-
include/exec/translation-block.h | 5 ++
include/hw/core/cpu.h | 7 +-
include/migration/snapshot.h | 3 +
include/monitor/hmp.h | 2 +
include/qemu/plugin.h | 6 +-
include/qemu/qemu-plugin.h | 11 ++-
include/sysemu/accel-ops.h | 2 +-
include/sysemu/replay.h | 2 +-
linux-user/main.c | 2 +-
memory_ldst.c.inc | 4 -
migration/migration-hmp-cmds.c | 18 +++++
migration/savevm.c | 89 +++++++++++++++++++--
plugins/api.c | 2 +-
plugins/core.c | 18 ++++-
qemuafl/cpu-translate.h | 58 ++++++++++++++
replay/replay-audio.c | 2 +-
replay/stubs-system.c | 2 +-
system/memory.c | 12 ---
system/physmem.c | 2 -
system/runstate.c | 1 +
system/vl.c | 2 +-
target/arm/cpu.c | 1 +
target/arm/debug_helper.c | 2 +-
target/arm/helper.c | 13 ++++
target/arm/ptw.c | 4 +
target/arm/tcg/translate-a64.c | 16 +++-
target/arm/tcg/translate.c | 42 +++++++++-
target/i386/tcg/sysemu/bpt_helper.c | 2 +-
target/ppc/cpu.c | 2 +-
target/riscv/debug.c | 4 +-
tcg/tcg-op-ldst.c | 22 +++---
tcg/tcg-op.c | 2 +-
tests/plugin/mem.c | 2 +-
tests/qtest/fuzz/generic_fuzz.c | 108 --------------------------
64 files changed, 480 insertions(+), 245 deletions(-)
create mode 100644 qemuafl/cpu-translate.h
diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
index abe7adf..35a0436 100644
--- a/accel/hvf/hvf-accel-ops.c
+++ b/accel/hvf/hvf-accel-ops.c
@@ -474,7 +474,7 @@ static void hvf_start_vcpu_thread(CPUState *cpu)
cpu, QEMU_THREAD_JOINABLE);
}
-static int hvf_insert_breakpoint(CPUState *cpu, int type, vaddr addr, vaddr len)
+static int hvf_insert_breakpoint(CPUState *cpu, int type, vaddr addr, vaddr len, int (*h)(void))
{
struct hvf_sw_breakpoint *bp;
int err;
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index e39a810..5552132 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -3216,7 +3216,7 @@ bool kvm_supports_guest_debug(void)
return kvm_has_guest_debug;
}
-int kvm_insert_breakpoint(CPUState *cpu, int type, vaddr addr, vaddr len)
+int kvm_insert_breakpoint(CPUState *cpu, int type, vaddr addr, vaddr len, void (*h)())
{
struct kvm_sw_breakpoint *bp;
int err;
diff --git a/accel/kvm/kvm-cpus.h b/accel/kvm/kvm-cpus.h
index ca40add..41adbb0 100644
--- a/accel/kvm/kvm-cpus.h
+++ b/accel/kvm/kvm-cpus.h
@@ -19,7 +19,7 @@ void kvm_cpu_synchronize_post_reset(CPUState *cpu);
void kvm_cpu_synchronize_post_init(CPUState *cpu);
void kvm_cpu_synchronize_pre_loadvm(CPUState *cpu);
bool kvm_supports_guest_debug(void);
-int kvm_insert_breakpoint(CPUState *cpu, int type, vaddr addr, vaddr len);
+int kvm_insert_breakpoint(CPUState *cpu, int type, vaddr addr, vaddr len, void (*)() h);
int kvm_remove_breakpoint(CPUState *cpu, int type, vaddr addr, vaddr len);
void kvm_remove_all_breakpoints(CPUState *cpu);
diff --git a/accel/tcg/atomic_common.c.inc b/accel/tcg/atomic_common.c.inc
index 95a5c5f..70c223b 100644
--- a/accel/tcg/atomic_common.c.inc
+++ b/accel/tcg/atomic_common.c.inc
@@ -14,9 +14,9 @@
*/
static void atomic_trace_rmw_post(CPUArchState *env, uint64_t addr,
- MemOpIdx oi)
+ MemOpIdx oi, enum qemu_plugin_pos pos, uint32_t size)
{
- qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, oi, QEMU_PLUGIN_MEM_RW);
+ qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, oi, QEMU_PLUGIN_MEM_RW, pos, size);
}
/*
diff --git a/accel/tcg/atomic_template.h b/accel/tcg/atomic_template.h
index 1dc2151..4a8d5b3 100644
--- a/accel/tcg/atomic_template.h
+++ b/accel/tcg/atomic_template.h
@@ -83,7 +83,7 @@ ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, abi_ptr addr,
ret = qatomic_cmpxchg__nocheck(haddr, cmpv, newv);
#endif
ATOMIC_MMU_CLEANUP;
- atomic_trace_rmw_post(env, addr, oi);
+ atomic_trace_rmw_post(env, addr, oi, QEMU_PLUGIN_AFTER, -1);
return ret;
}
@@ -97,7 +97,7 @@ ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, abi_ptr addr, ABI_TYPE val,
ret = qatomic_xchg__nocheck(haddr, val);
ATOMIC_MMU_CLEANUP;
- atomic_trace_rmw_post(env, addr, oi);
+ atomic_trace_rmw_post(env, addr, oi, QEMU_PLUGIN_AFTER, -1);
return ret;
}
@@ -109,7 +109,7 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, abi_ptr addr, \
haddr = atomic_mmu_lookup(env_cpu(env), addr, oi, DATA_SIZE, retaddr); \
ret = qatomic_##X(haddr, val); \
ATOMIC_MMU_CLEANUP; \
- atomic_trace_rmw_post(env, addr, oi); \
+ atomic_trace_rmw_post(env, addr, oi, QEMU_PLUGIN_AFTER, -1); \
return ret; \
}
@@ -145,7 +145,7 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, abi_ptr addr, \
cmp = qatomic_cmpxchg__nocheck(haddr, old, new); \
} while (cmp != old); \
ATOMIC_MMU_CLEANUP; \
- atomic_trace_rmw_post(env, addr, oi); \
+ atomic_trace_rmw_post(env, addr, oi, QEMU_PLUGIN_AFTER, -1); \
return RET; \
}
@@ -188,7 +188,7 @@ ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, abi_ptr addr,
ret = qatomic_cmpxchg__nocheck(haddr, BSWAP(cmpv), BSWAP(newv));
#endif
ATOMIC_MMU_CLEANUP;
- atomic_trace_rmw_post(env, addr, oi);
+ atomic_trace_rmw_post(env, addr, oi, QEMU_PLUGIN_AFTER, -1);
return BSWAP(ret);
}
@@ -202,7 +202,7 @@ ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, abi_ptr addr, ABI_TYPE val,
ret = qatomic_xchg__nocheck(haddr, BSWAP(val));
ATOMIC_MMU_CLEANUP;
- atomic_trace_rmw_post(env, addr, oi);
+ atomic_trace_rmw_post(env, addr, oi, QEMU_PLUGIN_AFTER, -1);
return BSWAP(ret);
}
@@ -214,7 +214,7 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, abi_ptr addr, \
haddr = atomic_mmu_lookup(env_cpu(env), addr, oi, DATA_SIZE, retaddr); \
ret = qatomic_##X(haddr, BSWAP(val)); \
ATOMIC_MMU_CLEANUP; \
- atomic_trace_rmw_post(env, addr, oi); \
+ atomic_trace_rmw_post(env, addr, oi, QEMU_PLUGIN_AFTER, -1); \
return BSWAP(ret); \
}
@@ -247,7 +247,7 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, abi_ptr addr, \
ldn = qatomic_cmpxchg__nocheck(haddr, ldo, BSWAP(new)); \
} while (ldo != ldn); \
ATOMIC_MMU_CLEANUP; \
- atomic_trace_rmw_post(env, addr, oi); \
+ atomic_trace_rmw_post(env, addr, oi, QEMU_PLUGIN_AFTER, -1); \
return RET; \
}
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index 6a4af14..96e0905 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -45,6 +45,15 @@
#include "internal-common.h"
#include "internal-target.h"
+/* Callback for an executed TB */
+exec_tb_cb_t before_exec_tb_cb;
+exec_tb_cb_t after_exec_tb_cb;
+
+void register_exec_tb_cb(exec_tb_cb_t cb0, exec_tb_cb_t cb1) {
+ before_exec_tb_cb = cb0;
+ after_exec_tb_cb = cb1;
+}
+
/* -icount align implementation. */
typedef struct SyncClocks {
@@ -364,7 +373,16 @@ static bool check_for_breakpoints_slow(CPUState *cpu, vaddr pc,
}
if (match_bp) {
- cpu->exception_index = EXCP_DEBUG;
+ if (bp->h) {
+ int ret = bp->h();
+ if (ret == 0) {
+ return false;
+ } else {
+ cpu->exception_index = ret;
+ }
+ } else {
+ cpu->exception_index = EXCP_DEBUG;
+ }
return true;
}
} else if (((pc ^ bp->pc) & TARGET_PAGE_MASK) == 0) {
@@ -916,8 +934,22 @@ static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock *tb,
{
int32_t insns_left;
+ TranslationBlock *old_tb = tb;
trace_exec_tb(tb, pc);
+ before_exec_tb_cb(cpu->cpu_index, tb);
+ if (cpu->fuzztrace) {
+ target_disas(stdout, cpu, tb->pc, tb->size);
+ }
tb = cpu_tb_exec(cpu, tb, tb_exit);
+
+ /* notify that the tb has been executed */
+ /* we now only need a pc, so */
+ if (tb == NULL) {
+ after_exec_tb_cb(cpu->cpu_index, old_tb);
+ } else {
+ after_exec_tb_cb(cpu->cpu_index, tb);
+ }
+
if (*tb_exit != TB_EXIT_REQUESTED) {
*last_tb = tb;
return;
diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
index db3f93f..dee1248 100644
--- a/accel/tcg/cputlb.c
+++ b/accel/tcg/cputlb.c
@@ -44,6 +44,11 @@
#include "tcg/tcg-ldst.h"
#include "tcg/oversized-guest.h"
+static void plugin_load_cb(CPUState *cpu, abi_ptr addr, MemOpIdx oi, enum qemu_plugin_pos pos, uint32_t size)
+{
+ qemu_plugin_vcpu_mem_cb_forced(cpu, addr, oi, QEMU_PLUGIN_MEM_R, pos, size | 0xf0);
+}
+
/* DEBUG defines, enable DEBUG_TLB_LOG to log to the CPU_LOG_MMU target */
/* #define DEBUG_TLB */
/* #define DEBUG_TLB_LOG */
@@ -2377,6 +2382,7 @@ static uint8_t do_ld1_mmu(CPUState *cpu, vaddr addr, MemOpIdx oi,
crosspage = mmu_lookup(cpu, addr, oi, ra, access_type, &l);
tcg_debug_assert(!crosspage);
+ plugin_load_cb(cpu, addr, oi, QEMU_PLUGIN_BEFORE, 0);
return do_ld_1(cpu, &l.page[0], l.mmu_idx, access_type, ra);
}
@@ -2390,6 +2396,7 @@ static uint16_t do_ld2_mmu(CPUState *cpu, vaddr addr, MemOpIdx oi,
cpu_req_mo(TCG_MO_LD_LD | TCG_MO_ST_LD);
crosspage = mmu_lookup(cpu, addr, oi, ra, access_type, &l);
+ plugin_load_cb(cpu, addr, oi, QEMU_PLUGIN_BEFORE, 1);
if (likely(!crosspage)) {
return do_ld_2(cpu, &l.page[0], l.mmu_idx, access_type, l.memop, ra);
}
@@ -2414,6 +2421,7 @@ static uint32_t do_ld4_mmu(CPUState *cpu, vaddr addr, MemOpIdx oi,
cpu_req_mo(TCG_MO_LD_LD | TCG_MO_ST_LD);
crosspage = mmu_lookup(cpu, addr, oi, ra, access_type, &l);
+ plugin_load_cb(cpu, addr, oi, QEMU_PLUGIN_BEFORE, 2);
if (likely(!crosspage)) {
return do_ld_4(cpu, &l.page[0], l.mmu_idx, access_type, l.memop, ra);
}
@@ -2435,6 +2443,7 @@ static uint64_t do_ld8_mmu(CPUState *cpu, vaddr addr, MemOpIdx oi,
cpu_req_mo(TCG_MO_LD_LD | TCG_MO_ST_LD);
crosspage = mmu_lookup(cpu, addr, oi, ra, access_type, &l);
+ plugin_load_cb(cpu, addr, oi, QEMU_PLUGIN_BEFORE, 3);
if (likely(!crosspage)) {
return do_ld_8(cpu, &l.page[0], l.mmu_idx, access_type, l.memop, ra);
}
@@ -2458,6 +2467,7 @@ static Int128 do_ld16_mmu(CPUState *cpu, vaddr addr,
cpu_req_mo(TCG_MO_LD_LD | TCG_MO_ST_LD);
crosspage = mmu_lookup(cpu, addr, oi, ra, MMU_DATA_LOAD, &l);
+ plugin_load_cb(cpu, addr, oi, QEMU_PLUGIN_BEFORE, 4);
if (likely(!crosspage)) {
if (unlikely(l.page[0].flags & TLB_MMIO)) {
ret = do_ld16_mmio_beN(cpu, l.page[0].full, 0, addr, 16,
diff --git a/accel/tcg/internal-target.h b/accel/tcg/internal-target.h
index 4e36cf8..512c20d 100644
--- a/accel/tcg/internal-target.h
+++ b/accel/tcg/internal-target.h
@@ -12,6 +12,9 @@
#include "exec/exec-all.h"
#include "exec/translate-all.h"
+typedef void (*exec_tb_cb_t)(int cpu_index, TranslationBlock *tb);
+void register_exec_tb_cb(exec_tb_cb_t cb0, exec_tb_cb_t cb1);
+
/*
* Access to the various translations structures need to be serialised
* via locks for consistency. In user-mode emulation access to the
diff --git a/accel/tcg/ldst_common.c.inc b/accel/tcg/ldst_common.c.inc
index 4483351..bdad102 100644
--- a/accel/tcg/ldst_common.c.inc
+++ b/accel/tcg/ldst_common.c.inc
@@ -12,32 +12,45 @@
* Load helpers for tcg-ldst.h
*/
+
tcg_target_ulong helper_ldub_mmu(CPUArchState *env, uint64_t addr,
MemOpIdx oi, uintptr_t retaddr)
{
+ tcg_target_ulong ret;
+
tcg_debug_assert((get_memop(oi) & MO_SIZE) == MO_8);
- return do_ld1_mmu(env_cpu(env), addr, oi, retaddr, MMU_DATA_LOAD);
+ ret = do_ld1_mmu(env_cpu(env), addr, oi, retaddr, MMU_DATA_LOAD);
+ return ret;
}
tcg_target_ulong helper_lduw_mmu(CPUArchState *env, uint64_t addr,
MemOpIdx oi, uintptr_t retaddr)
{
+ tcg_target_ulong ret;
+
tcg_debug_assert((get_memop(oi) & MO_SIZE) == MO_16);
- return do_ld2_mmu(env_cpu(env), addr, oi, retaddr, MMU_DATA_LOAD);
+ ret = do_ld2_mmu(env_cpu(env), addr, oi, retaddr, MMU_DATA_LOAD);
+ return ret;
}
tcg_target_ulong helper_ldul_mmu(CPUArchState *env, uint64_t addr,
MemOpIdx oi, uintptr_t retaddr)
{
+ tcg_target_ulong ret;
+
tcg_debug_assert((get_memop(oi) & MO_SIZE) == MO_32);
- return do_ld4_mmu(env_cpu(env), addr, oi, retaddr, MMU_DATA_LOAD);
+ ret = do_ld4_mmu(env_cpu(env), addr, oi, retaddr, MMU_DATA_LOAD);
+ return ret;
}
uint64_t helper_ldq_mmu(CPUArchState *env, uint64_t addr,
MemOpIdx oi, uintptr_t retaddr)
{
+ uint64_t ret;
+
tcg_debug_assert((get_memop(oi) & MO_SIZE) == MO_64);
- return do_ld8_mmu(env_cpu(env), addr, oi, retaddr, MMU_DATA_LOAD);
+ ret = do_ld8_mmu(env_cpu(env), addr, oi, retaddr, MMU_DATA_LOAD);
+ return ret;
}
/*
@@ -66,8 +79,10 @@ tcg_target_ulong helper_ldsl_mmu(CPUArchState *env, uint64_t addr,
Int128 helper_ld16_mmu(CPUArchState *env, uint64_t addr,
MemOpIdx oi, uintptr_t retaddr)
{
+ Int128 ret;
tcg_debug_assert((get_memop(oi) & MO_SIZE) == MO_128);
- return do_ld16_mmu(env_cpu(env), addr, oi, retaddr);
+ ret = do_ld16_mmu(env_cpu(env), addr, oi, retaddr);
+ return ret;
}
Int128 helper_ld_i128(CPUArchState *env, uint64_t addr, uint32_t oi)
@@ -123,18 +138,12 @@ void helper_st_i128(CPUArchState *env, uint64_t addr, Int128 val, MemOpIdx oi)
* Load helpers for cpu_ldst.h
*/
-static void plugin_load_cb(CPUArchState *env, abi_ptr addr, MemOpIdx oi)
-{
- qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, oi, QEMU_PLUGIN_MEM_R);
-}
-
uint8_t cpu_ldb_mmu(CPUArchState *env, abi_ptr addr, MemOpIdx oi, uintptr_t ra)
{
uint8_t ret;
tcg_debug_assert((get_memop(oi) & MO_SIZE) == MO_UB);
ret = do_ld1_mmu(env_cpu(env), addr, oi, ra, MMU_DATA_LOAD);
- plugin_load_cb(env, addr, oi);
return ret;
}
@@ -145,7 +154,6 @@ uint16_t cpu_ldw_mmu(CPUArchState *env, abi_ptr addr,
tcg_debug_assert((get_memop(oi) & MO_SIZE) == MO_16);
ret = do_ld2_mmu(env_cpu(env), addr, oi, ra, MMU_DATA_LOAD);
- plugin_load_cb(env, addr, oi);
return ret;
}
@@ -156,7 +164,6 @@ uint32_t cpu_ldl_mmu(CPUArchState *env, abi_ptr addr,
tcg_debug_assert((get_memop(oi) & MO_SIZE) == MO_32);
ret = do_ld4_mmu(env_cpu(env), addr, oi, ra, MMU_DATA_LOAD);
- plugin_load_cb(env, addr, oi);
return ret;
}
@@ -167,7 +174,6 @@ uint64_t cpu_ldq_mmu(CPUArchState *env, abi_ptr addr,
tcg_debug_assert((get_memop(oi) & MO_SIZE) == MO_64);
ret = do_ld8_mmu(env_cpu(env), addr, oi, ra, MMU_DATA_LOAD);
- plugin_load_cb(env, addr, oi);
return ret;
}
@@ -178,7 +184,6 @@ Int128 cpu_ld16_mmu(CPUArchState *env, abi_ptr addr,
tcg_debug_assert((get_memop(oi) & MO_SIZE) == MO_128);
ret = do_ld16_mmu(env_cpu(env), addr, oi, ra);
- plugin_load_cb(env, addr, oi);
return ret;
}
@@ -186,16 +191,10 @@ Int128 cpu_ld16_mmu(CPUArchState *env, abi_ptr addr,
* Store helpers for cpu_ldst.h
*/
-static void plugin_store_cb(CPUArchState *env, abi_ptr addr, MemOpIdx oi)
-{
- qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, oi, QEMU_PLUGIN_MEM_W);
-}
-
void cpu_stb_mmu(CPUArchState *env, abi_ptr addr, uint8_t val,
MemOpIdx oi, uintptr_t retaddr)
{
helper_stb_mmu(env, addr, val, oi, retaddr);
- plugin_store_cb(env, addr, oi);
}
void cpu_stw_mmu(CPUArchState *env, abi_ptr addr, uint16_t val,
@@ -203,7 +202,6 @@ void cpu_stw_mmu(CPUArchState *env, abi_ptr addr, uint16_t val,
{
tcg_debug_assert((get_memop(oi) & MO_SIZE) == MO_16);
do_st2_mmu(env_cpu(env), addr, val, oi, retaddr);
- plugin_store_cb(env, addr, oi);
}
void cpu_stl_mmu(CPUArchState *env, abi_ptr addr, uint32_t val,
@@ -211,7 +209,6 @@ void cpu_stl_mmu(CPUArchState *env, abi_ptr addr, uint32_t val,
{
tcg_debug_assert((get_memop(oi) & MO_SIZE) == MO_32);
do_st4_mmu(env_cpu(env), addr, val, oi, retaddr);
- plugin_store_cb(env, addr, oi);
}
void cpu_stq_mmu(CPUArchState *env, abi_ptr addr, uint64_t val,
@@ -219,7 +216,6 @@ void cpu_stq_mmu(CPUArchState *env, abi_ptr addr, uint64_t val,
{
tcg_debug_assert((get_memop(oi) & MO_SIZE) == MO_64);
do_st8_mmu(env_cpu(env), addr, val, oi, retaddr);
- plugin_store_cb(env, addr, oi);
}
void cpu_st16_mmu(CPUArchState *env, abi_ptr addr, Int128 val,
@@ -227,7 +223,6 @@ void cpu_st16_mmu(CPUArchState *env, abi_ptr addr, Int128 val,
{
tcg_debug_assert((get_memop(oi) & MO_SIZE) == MO_128);
do_st16_mmu(env_cpu(env), addr, val, oi, retaddr);
- plugin_store_cb(env, addr, oi);
}
/*
diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c
index 78b331b..2d80b81 100644
--- a/accel/tcg/plugin-gen.c
+++ b/accel/tcg/plugin-gen.c
@@ -95,7 +95,7 @@ void HELPER(plugin_vcpu_udata_cb)(uint32_t cpu_index, void *udata)
void HELPER(plugin_vcpu_mem_cb)(unsigned int vcpu_index,
qemu_plugin_meminfo_t info, uint64_t vaddr,
- void *userdata)
+ void *userdata, enum qemu_plugin_pos pos, uint32_t size)
{ }
static void gen_empty_udata_cb(void)
@@ -130,22 +130,28 @@ static void gen_empty_inline_cb(void)
tcg_temp_free_i64(val);
}
-static void gen_empty_mem_cb(TCGv_i64 addr, uint32_t info)
+static void gen_empty_mem_cb(TCGv_i64 addr, uint32_t info, uint32_t pos, uint32_t size)
{
TCGv_i32 cpu_index = tcg_temp_ebb_new_i32();
TCGv_i32 meminfo = tcg_temp_ebb_new_i32();
TCGv_ptr udata = tcg_temp_ebb_new_ptr();
+ TCGv_i32 __pos = tcg_temp_ebb_new_i32();
+ TCGv_i32 __size = tcg_temp_ebb_new_i32();
tcg_gen_movi_i32(meminfo, info);
tcg_gen_movi_ptr(udata, 0);
tcg_gen_ld_i32(cpu_index, tcg_env,
-offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index));
+ tcg_gen_movi_i32(__pos, pos);
+ tcg_gen_movi_i32(__size, size);
- gen_helper_plugin_vcpu_mem_cb(cpu_index, meminfo, addr, udata);
+ gen_helper_plugin_vcpu_mem_cb(cpu_index, meminfo, addr, udata, __pos, __size);
tcg_temp_free_ptr(udata);
tcg_temp_free_i32(meminfo);
tcg_temp_free_i32(cpu_index);
+ tcg_temp_free_i32(__pos);
+ tcg_temp_free_i32(__size);
}
/*
@@ -200,12 +206,12 @@ static void plugin_gen_empty_callback(enum plugin_gen_from from)
}
}
-void plugin_gen_empty_mem_callback(TCGv_i64 addr, uint32_t info)
+void plugin_gen_empty_mem_callback(TCGv_i64 addr, uint32_t info, enum qemu_plugin_pos pos, uint32_t size)
{
enum qemu_plugin_mem_rw rw = get_plugin_meminfo_rw(info);
gen_plugin_cb_start(PLUGIN_GEN_FROM_MEM, PLUGIN_GEN_CB_MEM, rw);
- gen_empty_mem_cb(addr, info);
+ gen_empty_mem_cb(addr, info, pos, size);
tcg_gen_plugin_cb_end();
gen_plugin_cb_start(PLUGIN_GEN_FROM_MEM, PLUGIN_GEN_CB_INLINE, rw);
diff --git a/accel/tcg/plugin-helpers.h b/accel/tcg/plugin-helpers.h
index 8e685e0..0c60f96 100644
--- a/accel/tcg/plugin-helpers.h
+++ b/accel/tcg/plugin-helpers.h
@@ -1,4 +1,4 @@
#ifdef CONFIG_PLUGIN
DEF_HELPER_FLAGS_2(plugin_vcpu_udata_cb, TCG_CALL_NO_RWG | TCG_CALL_PLUGIN, void, i32, ptr)
-DEF_HELPER_FLAGS_4(plugin_vcpu_mem_cb, TCG_CALL_NO_RWG | TCG_CALL_PLUGIN, void, i32, i32, i64, ptr)
+DEF_HELPER_FLAGS_6(plugin_vcpu_mem_cb, TCG_CALL_NO_RWG | TCG_CALL_PLUGIN, void, i32, i32, i64, ptr, i32, i32)
#endif
diff --git a/accel/tcg/tcg-accel-ops-mttcg.c b/accel/tcg/tcg-accel-ops-mttcg.c
index fac8009..4a2a461 100644
--- a/accel/tcg/tcg-accel-ops-mttcg.c
+++ b/accel/tcg/tcg-accel-ops-mttcg.c
@@ -89,7 +89,7 @@ static void *mttcg_cpu_thread_fn(void *arg)
cpu->exit_request = 1;
do {
- if (cpu_can_run(cpu)) {
+ if (cpu->fuzz_executing_input && cpu_can_run(cpu)) {
int r;
qemu_mutex_unlock_iothread();
r = tcg_cpus_exec(cpu);
diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c
index 1b57290..286cb11 100644
--- a/accel/tcg/tcg-accel-ops.c
+++ b/accel/tcg/tcg-accel-ops.c
@@ -126,7 +126,7 @@ static inline int xlat_gdb_type(CPUState *cpu, int gdbtype)
return cputype;
}
-static int tcg_insert_breakpoint(CPUState *cs, int type, vaddr addr, vaddr len)
+static int tcg_insert_breakpoint(CPUState *cs, int type, vaddr addr, vaddr len, int (*h)(void))
{
CPUState *cpu;
int err = 0;
@@ -135,7 +135,7 @@ static int tcg_insert_breakpoint(CPUState *cs, int type, vaddr addr, vaddr len)
case GDB_BREAKPOINT_SW:
case GDB_BREAKPOINT_HW:
CPU_FOREACH(cpu) {
- err = cpu_breakpoint_insert(cpu, addr, BP_GDB, NULL);
+ err = cpu_breakpoint_insert(cpu, addr, BP_GDB, h, NULL);
if (err) {
break;
}
diff --git a/accel/tcg/tcg-runtime.c b/accel/tcg/tcg-runtime.c
index 9fa539a..0751b5b 100644
--- a/accel/tcg/tcg-runtime.c
+++ b/accel/tcg/tcg-runtime.c
@@ -35,6 +35,31 @@
#include "exec/helper-info.c.inc"
#undef HELPER_H
+void fuzz_hook_cmp(uint64_t op1, uint64_t op2, size_t size);
+
+__attribute__((weak))
+void fuzz_hook_cmp(uint64_t op1, uint64_t op2, size_t size) {}
+
+void HELPER(afl_cmplog_8)(target_ulong arg1, target_ulong arg2)
+{
+ fuzz_hook_cmp(arg1, arg2, 1);
+}
+
+void HELPER(afl_cmplog_16)(target_ulong arg1, target_ulong arg2)
+{
+ fuzz_hook_cmp(arg1, arg2, 2);
+}
+
+void HELPER(afl_cmplog_32)(target_ulong arg1, target_ulong arg2)
+{
+ fuzz_hook_cmp(arg1, arg2, 4);
+}
+
+void HELPER(afl_cmplog_64)(target_ulong arg1, target_ulong arg2)
+{
+ fuzz_hook_cmp(arg1, arg2, 8);
+}
+
/* 32-bit helpers */
int32_t HELPER(div_i32)(int32_t arg1, int32_t arg2)
diff --git a/accel/tcg/tcg-runtime.h b/accel/tcg/tcg-runtime.h
index c23b5e6..9dac528 100644
--- a/accel/tcg/tcg-runtime.h
+++ b/accel/tcg/tcg-runtime.h
@@ -321,5 +321,9 @@ DEF_HELPER_FLAGS_4(gvec_leus8, TCG_CALL_NO_RWG, void, ptr, ptr, i64, i32)
DEF_HELPER_FLAGS_4(gvec_leus16, TCG_CALL_NO_RWG, void, ptr, ptr, i64, i32)
DEF_HELPER_FLAGS_4(gvec_leus32, TCG_CALL_NO_RWG, void, ptr, ptr, i64, i32)
DEF_HELPER_FLAGS_4(gvec_leus64, TCG_CALL_NO_RWG, void, ptr, ptr, i64, i32)
-
DEF_HELPER_FLAGS_5(gvec_bitsel, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32)
+
+DEF_HELPER_FLAGS_2(afl_cmplog_8, TCG_CALL_NO_RWG, void, i64, i64)
+DEF_HELPER_FLAGS_2(afl_cmplog_16, TCG_CALL_NO_RWG, void, i64, i64)
+DEF_HELPER_FLAGS_2(afl_cmplog_32, TCG_CALL_NO_RWG, void, i64, i64)
+DEF_HELPER_FLAGS_2(afl_cmplog_64, TCG_CALL_NO_RWG, void, i64, i64)
diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c
index 38c3400..cebd986 100644
--- a/accel/tcg/translator.c
+++ b/accel/tcg/translator.c
@@ -15,6 +15,7 @@
#include "exec/plugin-gen.h"
#include "tcg/tcg-op-common.h"
#include "internal-target.h"
+#include "target/arm/tcg/translate.h"
static void set_can_do_io(DisasContextBase *db, bool val)
{
@@ -213,6 +214,9 @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int *max_insns,
tb->size = db->pc_next - db->pc_first;
tb->icount = db->num_insns;
+ DisasContext *dc = container_of(db, DisasContext, base);
+ tb->pc_last = dc->pc_curr;
+
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
&& qemu_log_in_addr_range(db->pc_first)) {
FILE *logfile = qemu_log_trylock();
diff --git a/contrib/plugins/cache.c b/contrib/plugins/cache.c
index 9e7ade3..2729830 100644
--- a/contrib/plugins/cache.c
+++ b/contrib/plugins/cache.c
@@ -386,7 +386,7 @@ static bool access_cache(Cache *cache, uint64_t addr)
}
static void vcpu_mem_access(unsigned int vcpu_index, qemu_plugin_meminfo_t info,
- uint64_t vaddr, void *userdata)
+ uint64_t vaddr, void *userdata, enum qemu_plugin_pos pos, uint32_t size)
{
uint64_t effective_addr;
struct qemu_plugin_hwaddr *hwaddr;
diff --git a/contrib/plugins/execlog.c b/contrib/plugins/execlog.c
index 82dc2f5..19ecbee 100644
--- a/contrib/plugins/execlog.c
+++ b/contrib/plugins/execlog.c
@@ -44,7 +44,7 @@ static void expand_last_exec(int cpu_index)
* Add memory read or write information to current instruction log
*/
static void vcpu_mem(unsigned int cpu_index, qemu_plugin_meminfo_t info,
- uint64_t vaddr, void *udata)
+ uint64_t vaddr, void *udata, enum qemu_plugin_pos pos, uint32_t size)
{
GString *s;
diff --git a/contrib/plugins/hotpages.c b/contrib/plugins/hotpages.c
index 8316ae5..bf861bd 100644
--- a/contrib/plugins/hotpages.c
+++ b/contrib/plugins/hotpages.c
@@ -107,7 +107,7 @@ static void plugin_init(void)
}
static void vcpu_haddr(unsigned int cpu_index, qemu_plugin_meminfo_t meminfo,
- uint64_t vaddr, void *udata)
+ uint64_t vaddr, void *udata, enum qemu_plugin_pos pos, uint32_t size)
{
struct qemu_plugin_hwaddr *hwaddr = qemu_plugin_get_hwaddr(meminfo, vaddr);
uint64_t page;
diff --git a/contrib/plugins/hwprofile.c b/contrib/plugins/hwprofile.c
index 739ac0c..6f3c107 100644
--- a/contrib/plugins/hwprofile.c
+++ b/contrib/plugins/hwprofile.c
@@ -193,7 +193,7 @@ static void inc_count(IOCounts *count, bool is_write, unsigned int cpu_index)
}
static void vcpu_haddr(unsigned int cpu_index, qemu_plugin_meminfo_t meminfo,
- uint64_t vaddr, void *udata)
+ uint64_t vaddr, void *udata, enum qemu_plugin_pos pos, uint32_t size)
{
struct qemu_plugin_hwaddr *hwaddr = qemu_plugin_get_hwaddr(meminfo, vaddr);
diff --git a/cpu-common.c b/cpu-common.c
index c81fd72..cb9e08f 100644
--- a/cpu-common.c
+++ b/cpu-common.c
@@ -371,7 +371,7 @@ void process_queued_cpu_work(CPUState *cpu)
}
/* Add a breakpoint. */
-int cpu_breakpoint_insert(CPUState *cpu, vaddr pc, int flags,
+int cpu_breakpoint_insert(CPUState *cpu, vaddr pc, int flags, int (*h)(void),
CPUBreakpoint **breakpoint)
{
CPUClass *cc = CPU_GET_CLASS(cpu);
@@ -385,6 +385,7 @@ int cpu_breakpoint_insert(CPUState *cpu, vaddr pc, int flags,
bp->pc = pc;
bp->flags = flags;
+ bp->h = h;
/* keep all GDB-injected breakpoints in front */
if (flags & BP_GDB) {
diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c
index 46d752b..73c40bb 100644
--- a/gdbstub/gdbstub.c
+++ b/gdbstub/gdbstub.c
@@ -1121,7 +1121,7 @@ static void handle_insert_bp(GArray *params, void *user_ctx)
res = gdb_breakpoint_insert(gdbserver_state.c_cpu,
get_param(params, 0)->val_ul,
get_param(params, 1)->val_ull,
- get_param(params, 2)->val_ull);
+ get_param(params, 2)->val_ull, NULL);
if (res >= 0) {
gdb_put_packet("OK");
return;
diff --git a/gdbstub/internals.h b/gdbstub/internals.h
index 5c0c725..fe63591 100644
--- a/gdbstub/internals.h
+++ b/gdbstub/internals.h
@@ -215,7 +215,7 @@ void gdb_syscall_handling(const char *syscall_packet);
* and user mode.
*/
bool gdb_supports_guest_debug(void);
-int gdb_breakpoint_insert(CPUState *cs, int type, vaddr addr, vaddr len);
+int gdb_breakpoint_insert(CPUState *cs, int type, vaddr addr, vaddr len, int (*h)(void));
int gdb_breakpoint_remove(CPUState *cs, int type, vaddr addr, vaddr len);
void gdb_breakpoint_remove_all(CPUState *cs);
diff --git a/gdbstub/system.c b/gdbstub/system.c
index 83fd452..8c69934 100644
--- a/gdbstub/system.c
+++ b/gdbstub/system.c
@@ -637,11 +637,11 @@ bool gdb_supports_guest_debug(void)
return false;
}
-int gdb_breakpoint_insert(CPUState *cs, int type, vaddr addr, vaddr len)
+int gdb_breakpoint_insert(CPUState *cs, int type, vaddr addr, vaddr len, int (*h)(void))
{
const AccelOpsClass *ops = cpus_get_accel();
if (ops->insert_breakpoint) {
- return ops->insert_breakpoint(cs, type, addr, len);
+ return ops->insert_breakpoint(cs, type, addr, len, h);
}
return -ENOSYS;
}
diff --git a/gdbstub/user.c b/gdbstub/user.c
index dbe1d9b..942ff75 100644
--- a/gdbstub/user.c
+++ b/gdbstub/user.c
@@ -439,7 +439,7 @@ bool gdb_supports_guest_debug(void)
return true;
}
-int gdb_breakpoint_insert(CPUState *cs, int type, vaddr addr, vaddr len)
+int gdb_breakpoint_insert(CPUState *cs, int type, vaddr addr, vaddr len, int (*h)(void))
{
CPUState *cpu;
int err = 0;
@@ -448,7 +448,7 @@ int gdb_breakpoint_insert(CPUState *cs, int type, vaddr addr, vaddr len)
case GDB_BREAKPOINT_SW:
case GDB_BREAKPOINT_HW:
CPU_FOREACH(cpu) {
- err = cpu_breakpoint_insert(cpu, addr, BP_GDB, NULL);
+ err = cpu_breakpoint_insert(cpu, addr, BP_GDB, h, NULL);
if (err) {
break;
}
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 765349e..07f8967 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -325,6 +325,38 @@ ERST
SRST
``log`` *item1*\ [,...]
Activate logging of the specified items.
+ERST
+
+ {
+ .name = "hp-save-devices-state",
+ .args_type = "filename:F",
+ .params = "filename",
+ .help = "save devices state into file 'filename'.\n\t\n\t",
+ .cmd = hmp_hp_save_devices_state,
+ },
+
+SRST
+``hp-save-devices-state`` *filename*
+
+ *filename*
+ the file to save the state of the devices to as binary data.
+
+ERST
+
+ {
+ .name = "hp-load-devices-state",
+ .args_type = "filename:F",
+ .params = "filename",
+ .help = "load devices state from file 'filename'.\n\t\n\t",
+ .cmd = hmp_hp_load_devices_state,
+ },
+
+SRST
+``hp-load-devices-state`` *filename*
+
+ *filename*
+ the file to load the state of the devices to as binary data.
+
ERST
{
diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c
index 5e848a9..424e817 100644
--- a/hw/block/pflash_cfi01.c
+++ b/hw/block/pflash_cfi01.c
@@ -1045,7 +1045,7 @@ static int pflash_post_load(void *opaque, int version_id)
{
PFlashCFI01 *pfl = opaque;
- if (!pfl->ro) {
+ if (!pfl->ro && !pfl->vmstate) {
pfl->vmstate = qemu_add_vm_change_state_handler(postload_update_cb,
pfl);
}
diff --git a/include/exec/memory.h b/include/exec/memory.h
index 831f7c9..0e73fe0 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -49,19 +49,6 @@ typedef struct RamDiscardManager RamDiscardManager;
DECLARE_OBJ_CHECKERS(RamDiscardManager, RamDiscardManagerClass,
RAM_DISCARD_MANAGER, TYPE_RAM_DISCARD_MANAGER);
-#ifdef CONFIG_FUZZ
-void fuzz_dma_read_cb(size_t addr,
- size_t len,
- MemoryRegion *mr);
-#else
-static inline void fuzz_dma_read_cb(size_t addr,
- size_t len,
- MemoryRegion *mr)
-{
- /* Do Nothing */
-}
-#endif
-
/* Possible bits for global_dirty_log_{start|stop} */
/* Dirty tracking enabled because migration is running */
@@ -3021,7 +3008,6 @@ address_space_read_cached(MemoryRegionCache *cache, hwaddr addr,
void *buf, hwaddr len)
{
assert(addr < cache->len && len <= cache->len - addr);
- fuzz_dma_read_cb(cache->xlat + addr, len, cache->mrs.mr);
if (likely(cache->ptr)) {
memcpy(buf, cache->ptr + addr, len);
return MEMTX_OK;
diff --git a/include/exec/memory_ldst_cached.h.inc b/include/exec/memory_ldst_cached.h.inc
index d7834f8..4e09bb8 100644
--- a/include/exec/memory_ldst_cached.h.inc
+++ b/include/exec/memory_ldst_cached.h.inc
@@ -28,7 +28,6 @@ static inline uint16_t ADDRESS_SPACE_LD_CACHED(uw)(MemoryRegionCache *cache,
hwaddr addr, MemTxAttrs attrs, MemTxResult *result)
{
assert(addr < cache->len && 2 <= cache->len - addr);
- fuzz_dma_read_cb(cache->xlat + addr, 2, cache->mrs.mr);
if (likely(cache->ptr)) {
return LD_P(uw)(cache->ptr + addr);
} else {
@@ -40,7 +39,6 @@ static inline uint32_t ADDRESS_SPACE_LD_CACHED(l)(MemoryRegionCache *cache,
hwaddr addr, MemTxAttrs attrs, MemTxResult *result)
{
assert(addr < cache->len && 4 <= cache->len - addr);
- fuzz_dma_read_cb(cache->xlat + addr, 4, cache->mrs.mr);
if (likely(cache->ptr)) {
return LD_P(l)(cache->ptr + addr);
} else {
@@ -52,7 +50,6 @@ static inline uint64_t ADDRESS_SPACE_LD_CACHED(q)(MemoryRegionCache *cache,
hwaddr addr, MemTxAttrs attrs, MemTxResult *result)
{
assert(addr < cache->len && 8 <= cache->len - addr);
- fuzz_dma_read_cb(cache->xlat + addr, 8, cache->mrs.mr);
if (likely(cache->ptr)) {
return LD_P(q)(cache->ptr + addr);
} else {
diff --git a/include/exec/plugin-gen.h b/include/exec/plugin-gen.h
index c4552b5..33868dd 100644
--- a/include/exec/plugin-gen.h
+++ b/include/exec/plugin-gen.h
@@ -25,7 +25,7 @@ void plugin_gen_insn_start(CPUState *cpu, const struct DisasContextBase *db);
void plugin_gen_insn_end(void);
void plugin_gen_disable_mem_helpers(void);
-void plugin_gen_empty_mem_callback(TCGv_i64 addr, uint32_t info);
+void plugin_gen_empty_mem_callback(TCGv_i64 addr, uint32_t info, uint32_t pos, uint32_t size);
#else /* !CONFIG_PLUGIN */
@@ -48,7 +48,7 @@ static inline void plugin_gen_tb_end(CPUState *cpu, size_t num_insns)
static inline void plugin_gen_disable_mem_helpers(void)
{ }
-static inline void plugin_gen_empty_mem_callback(TCGv_i64 addr, uint32_t info)
+static inline void plugin_gen_empty_mem_callback(TCGv_i64 addr, uint32_t info, uint32_t pos, uint32_t size)
{ }
#endif /* CONFIG_PLUGIN */
diff --git a/include/exec/translation-block.h b/include/exec/translation-block.h
index e2b26e1..54c18c4 100644
--- a/include/exec/translation-block.h
+++ b/include/exec/translation-block.h
@@ -54,6 +54,11 @@ struct TranslationBlock {
*/
vaddr pc;
+ /*
+ * Guest PC of the last guest instruction in this TB
+ */
+ vaddr pc_last;
+
/*
* Target-specific data associated with the TranslationBlock, e.g.:
* x86: the original user, the Code Segment virtual base,
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index c0c8320..ad8bf2c 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -357,6 +357,7 @@ typedef struct CPUNegativeOffsetState {
typedef struct CPUBreakpoint {
vaddr pc;
int flags; /* BP_* */
+ int (*h)(void);
QTAILQ_ENTRY(CPUBreakpoint) entry;
} CPUBreakpoint;
@@ -568,6 +569,10 @@ struct CPUState {
/* track IOMMUs whose translations we've cached in the TCG TLB */
GArray *iommu_notifiers;
+ bool fuzztrace;
+ bool fuzzdebug_gdb;
+ bool fuzz_executing_input;
+
/*
* MUST BE LAST in order to minimize the displacement to CPUArchState.
*/
@@ -1068,7 +1073,7 @@ void cpu_single_step(CPUState *cpu, int enabled);
#define BP_WATCHPOINT_HIT_WRITE (BP_MEM_WRITE << BP_HIT_SHIFT)
#define BP_WATCHPOINT_HIT (BP_MEM_ACCESS << BP_HIT_SHIFT)
-int cpu_breakpoint_insert(CPUState *cpu, vaddr pc, int flags,
+int cpu_breakpoint_insert(CPUState *cpu, vaddr pc, int flags, int (*h)(void),