qemu-riscv
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] target/riscv: support atomic instruction fetch (Ziccif)


From: Richard Henderson
Subject: Re: [PATCH] target/riscv: support atomic instruction fetch (Ziccif)
Date: Fri, 7 Jun 2024 06:39:42 -0700
User-agent: Mozilla Thunderbird

On 6/7/24 03:14, Jim Shu wrote:
Support 4-byte atomic instruction fetch when instruction is natural
aligned.

Current implementation is not atomic because it loads instruction twice
for first and last 2 bytes. We load 4 bytes at once to keep the
atomicity. This instruction preload method only applys when instruction
is 4-byte aligned. If instruction is unaligned, it could be across pages
so that preload will trigger additional page fault.

We encounter this issue when doing pressure test of enabling & disabling
Linux kernel ftrace. Ftrace with kernel preemption requires concurrent
modification and execution of instruction, so non-atomic instruction
fetch will cause the race condition. We may fetch the wrong instruction
which is the mixing of 2 instructions.

Hmm. This is insufficient, as you have no guarantee that translator_ldl itself is atomic. Indeed, it is not: it uses memcpy as the innermost read.

Let me think about this...


r~




reply via email to

[Prev in Thread] Current Thread [Next in Thread]