[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] arm: fix TB alignment check
From: |
Laurent Desnogues |
Subject: |
Re: [Qemu-devel] [PATCH] arm: fix TB alignment check |
Date: |
Thu, 23 Oct 2014 15:42:10 +0200 |
Hello,
On Tue, Oct 21, 2014 at 2:14 PM, Pavel Dovgalyuk
<address@hidden> wrote:
> Sometimes page faults happen during the translation of the target
> instructions.
> To avoid the faults in the middle of the TB we have to stop translation at
> the end of the page. Current implementation of ARM translation assumes that
> instructions are aligned to their own size (4 or 2 bytes). But in thumb2 mode
> 4-byte instruction can be aligned to 2 bytes. In some cases such an alignment
> leads to page fault.
> This patch adds check that allows translation of such instructions only in
> the beginning of the TB.
>
> Signed-off-by: Pavel Dovgalyuk <address@hidden>
> ---
> target-arm/translate.c | 3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/target-arm/translate.c b/target-arm/translate.c
> index 2c0b1de..bc3a16b 100644
> --- a/target-arm/translate.c
> +++ b/target-arm/translate.c
> @@ -11124,7 +11124,8 @@ static inline void
> gen_intermediate_code_internal(ARMCPU *cpu,
> !cs->singlestep_enabled &&
> !singlestep &&
> !dc->ss_active &&
> - dc->pc < next_page_start &&
> + /* +3 is for unaligned Thumb2 instructions */
> + dc->pc + 3 < next_page_start &&
Won't this end prematurely a (4KB) block which last instruction
is a Thumb 16-bit one?
Thanks,
Laurent
> num_insns < max_insns);
>
> if (tb->cflags & CF_LAST_IO) {
>
>