summary refs log tree commit diff stats
path: root/results/classifier/zero-shot/105/vnc/1906516
blob: 6318e0892056447caf4484b2a98da7659ddc3bdf (plain) (blame)
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
vnc: 0.799
assembly: 0.675
instruction: 0.668
KVM: 0.667
graphic: 0.629
socket: 0.577
other: 0.567
mistranslation: 0.563
network: 0.530
device: 0.529
semantic: 0.492
boot: 0.455

[RISCV] sfence.vma need to end the translation block

QEMU emulator version 5.0.0

sfence.vma will flush the tlb, so after this instruction, the translation block should be end. The following code will only work in single step mode:
```
relocate:
	li a0, OFFSET

	la t0, 1f
	add t0, t0, a0
	csrw stvec, t0

        la t0, early_pgtbl
	srl t0, t0, PAGE_SHIFT
	li t1, SATP_SV39
	or t0, t1, t0

        csrw satp, t0
1:
	sfence.vma
	la t0, trap_s
	csrw stvec, t0
	ret
```

In this code, I want to relocate pc to virtual address with the OFFSET prefix, before writing to satp, pc run at physic address, stvec has been set a label 1 with a virtual prefix and virtual address has been mapping in early_pgtbl, after writing satp, there will throw a page fault, and pc will set to virtual address of label 1.

The problem is that, in this situation, the translation block will not end after sfence.vma, and stvec will be set to trap_s,

```
----------------
IN:
Priv: 1; Virt: 0
0x00000000800000dc:  00a080b3          add             ra,ra,a0
0x00000000800000e0:  00007297          auipc           t0,28672        # 0x800070e0
0x00000000800000e4:  f2028293          addi            t0,t0,-224
0x00000000800000e8:  00c2d293          srli            t0,t0,12
0x00000000800000ec:  fff0031b          addiw           t1,zero,-1
0x00000000800000f0:  03f31313          slli            t1,t1,63
0x00000000800000f4:  005362b3          or              t0,t1,t0
0x00000000800000f8:  18029073          csrrw           zero,satp,t0

----------------
IN:
Priv: 1; Virt: 0
0x00000000800000fc:  12000073          sfence.vma      zero,zero
0x0000000080000100:  00000297          auipc           t0,0            # 0x80000100
0x0000000080000104:  1c828293          addi            t0,t0,456
0x0000000080000108:  10529073          csrrw           zero,stvec,t0

riscv_raise_exception: 12
riscv_raise_exception: 12
riscv_raise_exception: 12
riscv_raise_exception: 12
...
```

So, the program will crash, and the program will work in single step mode:
```
----------------
IN:
Priv: 1; Virt: 0
0x00000000800000f8:  18029073          csrrw           zero,satp,t0

----------------
IN:
Priv: 1; Virt: 0
0x00000000800000fc:  12000073          sfence.vma      zero,zero

riscv_raise_exception: 12
----------------
IN:
Priv: 1; Virt: 0
0xffffffff800000fc:  12000073          sfence.vma      zero,zero

----------------
IN:
Priv: 1; Virt: 0
0xffffffff80000100:  00000297          auipc           t0,0            # 0xffffffff80000100

```
The pc will set to label 1, instead of trap_s.

I try to patch the code in fence.i in trans_rvi.inc.c to sfence.vma:
```
    tcg_gen_movi_tl(cpu_pc, ctx->pc_succ_insn);
    exit_tb(ctx);
    ctx->base.is_jmp = DISAS_NORETURN;
```
This codes can help to end the tranlate block, since I'm not a qemu guy, I'm not sure if this is a corret method.

The QEMU project is currently moving its bug tracking to another system.
For this we need to know which bugs are still valid and which could be
closed already. Thus we are setting the bug state to "Incomplete" now.

If the bug has already been fixed in the latest upstream version of QEMU,
then please close this ticket as "Fix released".

If it is not fixed yet and you think that this bug report here is still
valid, then you have two options:

1) If you already have an account on gitlab.com, please open a new ticket
for this problem in our new tracker here:

    https://gitlab.com/qemu-project/qemu/-/issues

and then close this ticket here on Launchpad (or let it expire auto-
matically after 60 days). Please mention the URL of this bug ticket on
Launchpad in the new ticket on GitLab.

2) If you don't have an account on gitlab.com and don't intend to get
one, but still would like to keep this ticket opened, then please switch
the state back to "New" or "Confirmed" within the next 60 days (other-
wise it will get closed as "Expired"). We will then eventually migrate
the ticket automatically to the new system (but you won't be the reporter
of the bug in the new system and thus you won't get notified on changes
anymore).

Thank you and sorry for the inconvenience.


[Expired for QEMU because there has been no activity for 60 days.]