Received: from eggs.gnu.org ([140.186.70.92]:59831) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R7MDu-0002YT-57 for qemu-devel@nongnu.org; Sat, 24 Sep 2011 03:00:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R7MDs-000161-QT for qemu-devel@nongnu.org; Sat, 24 Sep 2011 03:00:30 -0400 Received: from csmailer.cs.nctu.edu.tw ([140.113.235.130]:56483) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R7MDs-00015Y-35 for qemu-devel@nongnu.org; Sat, 24 Sep 2011 03:00:28 -0400 Date: Sat, 24 Sep 2011 15:00:21 +0800 From: =?utf-8?B?6Zmz6Z+L5Lu7?= Message-ID: <20110924070021.GA18146@cs.nctu.edu.tw> References: <20110818063338.GA69924@cs.nctu.edu.tw> <20110818093907.GA92265@cs.nctu.edu.tw> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] The reason behind block linking constraint? List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Filippov Cc: qemu-devel@nongnu.org, =?utf-8?B?6Zmz6Z+L5Lu7?= Hi, Max > I meant TLB change by e.g. tlb_set_page. If you change single page > mapping then all TBs in that page will be gone. > This may be the result of e.g. a page swapping, or a task switch. You said "all TBs in that page will be gone". Does it mean QEMU will invalidate those TBs by for example, tb_invalidate_phys_page_range? Or it just leave those TBs there (without executing them)? Because I don't see functions like tb_invalidate_phys_page_range are called after tlb_set_page, I am not sure what "gone" actually means. =20 > If there's no direct link between TBs then softmmu will be used during > the target TB search and softmmu will generate an appropriate guest > exception. See cpu_exec -> tb_find_fast -> tb_find_slow -> > get_page_addr_code. >=20 > But if there is a direct link, then softmmu has no chance to do it. Let me try to describe the flow. Correct me if I am wrong. Assume tb1 and tb2 belong to different guest pages. If there's NO direct link between tb1 and tb2. After executing tb1, the control is transfered back to QEMU (cpu_exec), QEMU then call tb_find_fast to find the next TB, i.e., tb2. I assume that "all TBs in that page will be gone" means QEMU will invalidate those TBs. If not, I think tb_find_fast will return tb2 which should not be executed. So, tb_find_fast calls tb_find_slow, then tb_find_slow calls get_page_addr_code. get_page_addr_code return the guest physical address which corresponds to the pc (tb2). It looks up TLB (env1->tlb_table), and get a TLB miss since tlb_set_page has changed the mapping.=20 if (unlikely(env1->tlb_table[mmu_idx][page_index].addr_code !=3D (addr & TARGET_PAGE_MASK))) { ldub_code(addr); } But I am not sure what happen after the TLB miss. You said the softmmu will generate a guest exception. Take x86 as an example, do you mean the raise_exception_err in tlb_fill? void tlb_fill(target_ulong addr, ...) { ret =3D cpu_x86_handle_mmu_fault(env, addr, is_write, mmu_idx, 1); if (ret) { if (retaddr) { } } raise_exception_err(env->exception_index, env->error_code); } Thanks! Regards, chenwj --=20 Wei-Ren Chen (=E9=99=B3=E9=9F=8B=E4=BB=BB) Computer Systems Lab, Institute of Information Science, Academia Sinica, Taiwan (R.O.C.) Tel:886-2-2788-3799 #1667