qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] general question


From: 吴晓琳
Subject: Re: [Qemu-devel] general question
Date: Thu, 31 May 2012 20:42:00 +0800 (CST)

I am wirting a little kernel by myself, but come into a problem which seems strange. I implement the system call fork, in which memory data is copied from parent's space to child's, I insert a fake page into the parent's page, and set its physical address to an empty frame, and then copy data from paraent's real page to this fake page.
Sometimes it runs normally(data copying is successful), sometimes(garbage codes inserted) fails.

To the most strange, it runs differently, when I set different breakpoints,and look up physical memory with qemu monitor at diffent breakpoints. I don't know whether it does matter to qemu itself or what is the matter with my codes?
 
I think it does something to do with the TLB????


--- 12年5月31日,周四, Peter Maydell <address@hidden> 写道:

发件人: Peter Maydell <address@hidden>
主题: Re: [Qemu-devel] general question
收件人: "陳韋任 (Wei-Ren Chen)" <address@hidden>
抄送: "Max Filippov" <address@hidden>, "吴晓琳" <address@hidden>, address@hidden
日期: 2012年5月31日,周四,下午6:07

On 31 May 2012 10:21, 陳韋任 (Wei-Ren Chen) <address@hidden> wrote:
> void tlb_flush_page(CPUArchState *env, target_ulong addr)
> {
>    if ((addr & env->tlb_flush_mask) == env->tlb_flush_addr) {
>        tlb_flush(env, 1); --- (1)
>        return;
>    }

This case (see the comments) is only for handling "large pages".
tlb_flush_addr/tlb_flush_mask track the range covered by large
pages, so that if we attempt to flush a page for an address in
that region we do a full tlb flush instead. (cf tlb_add_large_page()).
However the normal case is for standard sized pages:

>    ... snip ...
>
>    addr &= TARGET_PAGE_MASK;
>    i = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1);
>    for (mmu_idx = 0; mmu_idx < NB_MMU_MODES; mmu_idx++) {
>        tlb_flush_entry(&env->tlb_table[mmu_idx][i], addr);
>    }
>
>    tb_flush_jmp_cache(env, addr);

...which as you see is only flushing the tlb/tb entries
corresponding to the specified page address.

>  The comment of tlb_flush (1) says,
>
>    QEMU doesn't currently implement a global/not-global flag
>    for tlb entries, at the moment tlb_flush() will also flush all
>    tlb entries in the flush_global == false case.

This is something different. Most CPUs support some sort of concept
of TLB entries which are marked as specific to a particular OS
process, so that the OS can avoid having to do a full TLB flush
when it does a context switch. The "global" terminology is a
reference to the x86 specific flavour of this, and the QEMU API
currently reflects that x86ism. However we don't actually implement
the global/non-global distinction, hence this comment (it's always
safe to flush more entries than you're asked to flush).

-- PMM

reply via email to

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