From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60025) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YxIkE-0005b7-Ut for qemu-devel@nongnu.org; Tue, 26 May 2015 13:34:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YxIkA-0003FC-Ob for qemu-devel@nongnu.org; Tue, 26 May 2015 13:34:26 -0400 Received: from mail-qk0-f181.google.com ([209.85.220.181]:33743) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YxIkA-0003F8-Kj for qemu-devel@nongnu.org; Tue, 26 May 2015 13:34:22 -0400 Received: by qkhg32 with SMTP id g32so11302392qkh.0 for ; Tue, 26 May 2015 10:33:36 -0700 (PDT) Sender: Richard Henderson Message-ID: <5564AE6B.4070406@twiddle.net> Date: Tue, 26 May 2015 10:33:31 -0700 From: Richard Henderson MIME-Version: 1.0 References: <1432658961-48553-1-git-send-email-yongbok.kim@imgtec.com> <1432658961-48553-3-git-send-email-yongbok.kim@imgtec.com> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v5 2/3] softmmu: Add probe_write() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell , Yongbok Kim Cc: Leon Alrae , QEMU Developers , =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= On 05/26/2015 09:53 AM, Peter Maydell wrote: > On 26 May 2015 at 17:49, Yongbok Kim wrote: >> Add probe_write() forces a tlb_fill if the specified guest virtual >> index isn't in the TCG softmmu TLB. > > Surely the point is not to fill the TLB but to raise an > exception if the address is not writable? > >> +#if DATA_SIZE == 1 >> +/* >> + * Force a tlb_fill if the specified guest virtual index isn't in the TCG >> + * softmmu TLB. >> + */ >> +void probe_write(CPUArchState *env, target_ulong addr, int mmu_idx, >> + uintptr_t retaddr) >> +{ >> + int index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); >> + target_ulong tlb_addr = env->tlb_table[mmu_idx][index].addr_write; >> + >> + if ((addr & TARGET_PAGE_MASK) >> + != (tlb_addr & (TARGET_PAGE_MASK | TLB_INVALID_MASK))) { >> + /* TLB entry is for a different page */ >> + if (!VICTIM_TLB_HIT(addr_write)) { >> + tlb_fill(ENV_GET_CPU(env), addr, MMU_DATA_STORE, mmu_idx, retaddr); >> + } >> + } >> +} >> +#endif >> #endif /* !defined(SOFTMMU_CODE_ACCESS) */ > > I think this code does what you want, but the comments are > rather misleading... Indeed. The fact that the TLB gets loaded is merely a happy side-effect. r~