All of lore.kernel.org
 help / color / mirror / Atom feed
From: Blue Swirl <blauwirbel@gmail.com>
To: Paul Brook <paul@codesourcery.com>
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	qemu-devel@nongnu.org, "Alexander Graf" <agraf@suse.de>,
	"Max Filippov" <jcmvbkbc@gmail.com>,
	"Michael Walle" <michael@walle.cc>,
	qemu-ppc <qemu-ppc@nongnu.org>,
	"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
	"Guan Xuetao" <gxt@mprc.pku.edu.cn>,
	"Andreas Färber" <afaerber@suse.de>,
	"Aurelien Jarno" <aurelien@aurel32.net>,
	"Richard Henderson" <rth@twiddle.net>
Subject: Re: [Qemu-devel] [PATCH qom-next 57/59] cpu: Introduce mandatory tlb_flush callback
Date: Sat, 2 Jun 2012 19:40:45 +0000	[thread overview]
Message-ID: <CAAu8pHtC6aMfNp+vOC9PWoQ2Ja2tBGrXzAPhAPo1=_sOYdR2UQ@mail.gmail.com> (raw)
In-Reply-To: <201205311953.31459.paul@codesourcery.com>

On Thu, May 31, 2012 at 6:53 PM, Paul Brook <paul@codesourcery.com> wrote:
>> >> +void cpu_tlb_flush(CPUState *cpu, bool flush_global)
>> >> +{
>> >> +    CPUClass *cc = CPU_GET_CLASS(cpu);
>> >> +
>> >> +    g_assert(cc->tlb_flush != NULL);
>> >> +
>> >> +    cc->tlb_flush(cpu, flush_global);
>> >> +}
>> >
>> > This needs to be able to call tlb_flush() itself
>> > rather than having to have every single subclass of CPUState
>> > implement an identical tlb_flush method. You could do this
>> > if there was a CPU_GET_ENV()...
>>
>> Which is exactly the point: CPUState does not know about the
>> target-specific "env". And CPU_GET_ENV() is just plain wrong
>> conceptually because it adds yet another cpu.h dependency.
>
> Maybe so, but having every single taget implement its own copy of the exact
> same target independent wrapper seems even more wrong.
>
>> There's a separation between old code using env and new, clean code:
>> Just like Anthony doesn't want old concepts rewritten with the new type
>> (cf. object_realize() discussion) I don't want the old cpu.h #define
>> mess leaking into code that I'm redesigning specifically to get rid of
>> that target-*/cpu.h dependency in favor of a single qemu/cpu.h.
>> qom/cpu.c is by definition not compiled per target so it cannot contain
>> any target-specific code.
>
> At minimum it should be clearly documented[1] that this is a transitional
> hack, and how it should be removed.  There have already been two posts in this
> thread suggesting this is a feature, implying that this operation is somehow
> target specific.  I think the opposite is true:  This is a target agnostic
> detail of the TCG implementation, and implementing architecturally defined
> MMU/TLB behavior here is activley wrong.

The advantage of making the TLB more target specific (it already
depends on sizes of both target_ulong and target_phys_addr_t) is that
we can push some run time MMU model dependent code to translation
time.

The translator currently generates calls to qemu_ld, which generates a
TLB lookup with TCG. In the miss case, the TCG helper calls tlb_fill
and then cpu_xxx_handle_mmu_fault(). Most of those functions have
conditional code for current MMU mode, data access vs code access,
switch() based on MMU type etc.

With changes to TCG TLB handling, the translator could specify the
function to be called on TLB miss (or different TLB functions can be
generated with softmmu templates). Then the conditional code can be
pushed to translator.

In some TLB based MMU cases, we could predict or even calculate in
advance the MMU TLB index and other parameters but there's no way to
pass those to the miss/fault handler now.

Taking x86 as an example, we could have different functions for each case of:
- paging disabled
- x86_64 long mode enabled
- PAE enabled
- maybe permuted with the above, PSE enabled

PPC (or later Sparc64) MMU models do not change during execution, so
getting rid of the run time switches would be nice.

In some cases the QEMU TLB and target MMU TLBs could be combined,
provided that the target MMU is reasonable. For example UltraSPARC-IIi
I/D MMU TLBs have only 64 (though variable size) entries, whereas the
QEMU TLB can have many more, so I probably would not consider that
case.

Some MMUs have a notion of contexts (e.g. mapped to PID or thread ID),
but currently a TLB flush is needed when the context is changed which
can be suboptimal. To solve that, we'd need to change the TLB access
to target specific code to consider both context and address when
calculating the index.

In general, the interface between generated code and the TCG helper
should be more optimized.

>
> Paul
>
> [1] In the code, not the commit message.  Commit logs are not documentation.
> Commit logs are transient information valid only when the patch is applied.
> After that point they become archeological evidence, and you should not expect
> subsequent developers to be aware of them.

      parent reply	other threads:[~2012-06-02 19:41 UTC|newest]

Thread overview: 109+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-23  3:07 [PATCH qom-next 00/59] QOM CPUState, part 4: CPU_COMMON Andreas Färber
2012-05-23  3:07 ` [Qemu-devel] " Andreas Färber
2012-05-23  3:07 ` [Qemu-devel] [PATCH qom-next 01/59] qemu-thread: Let qemu_thread_is_self() return bool Andreas Färber
2012-05-23  3:07 ` [Qemu-devel] [PATCH qom-next 02/59] cpu: Move CPU_COMMON_THREAD into CPUState Andreas Färber
2012-05-23  3:07 ` [Qemu-devel] [PATCH qom-next 03/59] cpu: Move thread field " Andreas Färber
2012-05-23  3:07 ` [Qemu-devel] [PATCH qom-next 04/59] pc: Add CPU as /machine/cpu[n] Andreas Färber
2012-06-08  8:20   ` Igor Mammedov
2012-06-08  9:11     ` Andreas Färber
2012-06-08 10:21       ` Jan Kiszka
2012-06-08 10:36         ` Andreas Färber
2012-06-08 10:45           ` Andreas Färber
2012-06-08 11:36           ` Igor Mammedov
2012-06-08 12:26             ` Andreas Färber
2012-06-08 12:05       ` Igor Mammedov
2012-06-08 12:34         ` Andreas Färber
2012-06-08 12:36           ` Jan Kiszka
2012-06-08 12:47             ` Igor Mammedov
2012-06-08 12:52               ` Jan Kiszka
2012-06-08 13:00                 ` Q (Igor Mammedov)
2012-06-08 13:04                 ` Andreas Färber
2012-07-04  9:18                   ` Igor Mammedov
2012-05-23  3:07 ` [Qemu-devel] [PATCH qom-next 05/59] apic: Replace cpu_env pointer by X86CPU link Andreas Färber
2012-07-11 10:47   ` Igor Mammedov
2012-05-23  3:07 ` [PATCH qom-next 06/59] pc: Pass X86CPU to cpu_is_bsp() Andreas Färber
2012-05-23  3:07   ` [Qemu-devel] " Andreas Färber
2012-07-11 10:25   ` Igor Mammedov
2012-07-11 10:25     ` [Qemu-devel] " Igor Mammedov
2012-05-23  3:07 ` [Qemu-devel] [PATCH qom-next 07/59] cpu: Move thread_kicked to CPUState Andreas Färber
2012-05-23  3:07 ` [Qemu-devel] [PATCH qom-next 08/59] Makefile.dis: Add include/ to include path Andreas Färber
2012-05-23  3:07 ` [PATCH qom-next 09/59] cpus: Pass CPUState to qemu_cpu_is_self() Andreas Färber
2012-05-23  3:07   ` [Qemu-devel] " Andreas Färber
2012-05-23  3:07 ` [Qemu-devel] [PATCH qom-next 10/59] cpus: Pass CPUState to qemu_cpu_kick_thread() Andreas Färber
2012-05-23  3:07 ` [Qemu-devel] [PATCH qom-next 11/59] cpu: Move created field to CPUState Andreas Färber
2012-05-23  3:07 ` [Qemu-devel] [PATCH qom-next 12/59] cpu: Move stop " Andreas Färber
2012-05-23  3:07 ` [Qemu-devel] [PATCH qom-next 13/59] ppce500_spin: Store PowerPCCPU in SpinKick Andreas Färber
2012-05-23  3:07 ` [Qemu-devel] [PATCH qom-next 14/59] cpu: Move stopped field to CPUState Andreas Färber
2012-05-23  3:07 ` [PATCH qom-next 15/59] cpus: Pass CPUState to cpu_is_stopped() Andreas Färber
2012-05-23  3:07   ` [Qemu-devel] " Andreas Färber
2012-05-23  3:07 ` [Qemu-devel] [PATCH qom-next 16/59] cpus: Pass CPUState to cpu_can_run() Andreas Färber
2012-05-23  3:07 ` [Qemu-devel] [PATCH qom-next 17/59] cpu: Move halt_cond to CPUState Andreas Färber
2012-05-23  3:07 ` [Qemu-devel] [PATCH qom-next 18/59] cpus: Pass CPUState to qemu_tcg_cpu_thread_fn Andreas Färber
2012-05-23  3:07 ` [Qemu-devel] [PATCH qom-next 19/59] cpus: Pass CPUState to qemu_tcg_init_vcpu() Andreas Färber
2012-05-23  3:07 ` [Qemu-devel] [PATCH qom-next 20/59] ppc: Pass PowerPCCPU to ppc6xx_set_irq() Andreas Färber
2012-05-23  3:07 ` [Qemu-devel] [PATCH qom-next 21/59] ppc: Pass PowerPCCPU to ppc970_set_irq() Andreas Färber
2012-05-23  3:07 ` [Qemu-devel] [PATCH qom-next 22/59] ppc: Pass PowerPCCPU to power7_set_irq() Andreas Färber
2012-05-23  3:07 ` [Qemu-devel] [PATCH qom-next 23/59] ppc: Pass PowerPCCPU to ppc40x_set_irq() Andreas Färber
2012-05-23  3:07 ` [Qemu-devel] [PATCH qom-next 24/59] ppc: Pass PowerPCCPU to ppce500_set_irq() Andreas Färber
2012-05-23  3:07 ` [Qemu-devel] [PATCH qom-next 25/59] sun4m: Pass SPARCCPU to cpu_set_irq() Andreas Färber
2012-05-23  3:07 ` [Qemu-devel] [PATCH qom-next 26/59] sun4m: Pass SPARCCPU to cpu_kick_irq() Andreas Färber
2012-05-23  3:07 ` [Qemu-devel] [PATCH qom-next 27/59] sun4u: Pass SPARCCPU to {, s, hs}tick_irq() and cpu_timer_create() Andreas Färber
2012-05-23  3:07 ` [Qemu-devel] [PATCH qom-next 28/59] sun4u: Pass SPARCCPU to cpu_kick_irq() Andreas Färber
2012-05-23  3:07 ` [PATCH qom-next 29/59] target-ppc: Rename kvm_kick_{env => cpu} and pass PowerPCCPU Andreas Färber
2012-05-23  3:07   ` [Qemu-devel] " Andreas Färber
2012-05-23  3:07 ` [Qemu-devel] [PATCH qom-next 30/59] target-s390x: Let cpu_s390x_init() return S390CPU Andreas Färber
2012-05-23  3:07 ` [Qemu-devel] [PATCH qom-next 31/59] s390-virtio: Use cpu_s390x_init() to obtain S390CPU Andreas Färber
2012-05-23  3:07 ` [PATCH qom-next 32/59] s390-virtio: Let s390_cpu_addr2state() return S390CPU Andreas Färber
2012-05-23  3:07   ` [Qemu-devel] " Andreas Färber
2012-05-23  3:07 ` [PATCH qom-next 33/59] target-s390x: Pass S390CPU to s390_cpu_restart() Andreas Färber
2012-05-23  3:07   ` [Qemu-devel] " Andreas Färber
2012-05-23  3:07 ` [PATCH qom-next 34/59] cpus: Pass CPUState to qemu_cpu_kick() Andreas Färber
2012-05-23  3:07   ` [Qemu-devel] " Andreas Färber
2012-05-23  3:07 ` [Qemu-devel] [PATCH qom-next 35/59] cpu: Move queued_work_{first, last} to CPUState Andreas Färber
2012-05-23  3:07 ` [Qemu-devel] [PATCH qom-next 36/59] cpus: Pass CPUState to flush_queued_work() Andreas Färber
2012-05-23  3:08 ` [Qemu-devel] [PATCH qom-next 37/59] cpus: Pass CPUState to qemu_wait_io_event_common() Andreas Färber
2012-05-23  3:08 ` [Qemu-devel] [PATCH qom-next 38/59] target-ppc: Pass PowerPCCPU to powerpc_excp() Andreas Färber
2012-05-23  3:08 ` [Qemu-devel] [PATCH qom-next 39/59] target-ppc: Pass PowerPCCPU to cpu_ppc_hypercall Andreas Färber
2012-05-23  3:08 ` [PATCH qom-next 40/59] spapr: Pass PowerPCCPU to spapr_hypercall() Andreas Färber
2012-05-23  3:08   ` [Qemu-devel] " Andreas Färber
2012-05-23  3:08 ` [Qemu-devel] [PATCH qom-next 41/59] spapr: Pass PowerPCCPU to hypercalls Andreas Färber
2012-05-23  3:08 ` [Qemu-devel] [PATCH qom-next 42/59] xtensa_pic: Pass XtensaCPU to xtensa_ccompare_cb() Andreas Färber
2012-10-10 15:15   ` Andreas Färber
2012-10-10 15:35     ` Max Filippov
2012-10-10 16:33       ` Andreas Färber
2012-10-10 20:21         ` Max Filippov
2012-05-23  3:08 ` [Qemu-devel] [PATCH qom-next 43/59] cpus: Pass CPUState to [qemu_]cpu_has_work() Andreas Färber
2012-05-23  3:08 ` [PATCH qom-next 44/59] target-i386: Pass X86CPU to kvm_mce_inject() Andreas Färber
2012-05-23  3:08   ` [Qemu-devel] " Andreas Färber
2012-05-23  3:08 ` [PATCH qom-next 45/59] target-i386: Pass X86CPU to cpu_x86_inject_mce() Andreas Färber
2012-05-23  3:08   ` [Qemu-devel] " Andreas Färber
2012-05-23  3:08 ` [PATCH qom-next 46/59] cpus: Pass CPUState to run_on_cpu() Andreas Färber
2012-05-23  3:08   ` [Qemu-devel] " Andreas Färber
2012-05-23  3:08 ` [Qemu-devel] [PATCH qom-next 47/59] cpu: Move thread_id to CPUState Andreas Färber
2012-05-23  3:08 ` [Qemu-devel] [PATCH qom-next 48/59] target-i386: Pass X86CPU to cpu_x86_load_seg_cache_sipi() Andreas Färber
2012-05-23  3:08 ` [Qemu-devel] [PATCH qom-next 49/59] target-i386: Drop version 5 CPU VMState support Andreas Färber
2012-05-24 11:32   ` Juan Quintela
2012-05-23  3:08 ` [PATCH qom-next 50/59] target-i386: Pass X86CPU to kvm_get_mp_state() Andreas Färber
2012-05-23  3:08   ` [Qemu-devel] " Andreas Färber
2012-05-23  3:08 ` [PATCH qom-next 51/59] target-i386: Pass X86CPU to kvm_handle_halt() Andreas Färber
2012-05-23  3:08   ` [Qemu-devel] " Andreas Färber
2012-05-23  3:08 ` [Qemu-devel] [PATCH qom-next 52/59] target-mips: Pass MIPSCPU to mips_tc_wake() Andreas Färber
2012-05-23  3:08 ` [Qemu-devel] [PATCH qom-next 53/59] target-mips: Pass MIPSCPU to mips_vpe_is_wfi() Andreas Färber
2012-05-23  3:08 ` [Qemu-devel] [PATCH qom-next 54/59] target-mips: Pass MIPSCPU to mips_tc_sleep() Andreas Färber
2012-05-23  3:08 ` [Qemu-devel] [PATCH qom-next 55/59] target-mips: Pass MIPSCPU to mips_vpe_sleep() Andreas Färber
2012-05-23  3:08 ` [Qemu-devel] [PATCH qom-next 56/59] sun4u: Pass SPARCCPU to cpu_set_ivec_irq() Andreas Färber
2012-05-23  3:08 ` [Qemu-devel] [PATCH qom-next 57/59] cpu: Introduce mandatory tlb_flush callback Andreas Färber
2012-05-23  3:08 ` [Qemu-devel] [PATCH qom-next 58/59] xen_machine_pv: Use cpu_x86_init() to obtain X86CPU Andreas Färber
2012-05-23  3:08   ` Andreas Färber
2012-05-23  3:08 ` [PATCH qom-next 59/59] cpu: Move halted and interrupt_request to CPUState Andreas Färber
2012-05-23  3:08   ` Andreas Färber
2012-05-23  3:08   ` [Qemu-devel] " Andreas Färber
2012-05-23 11:27 ` [PATCH qom-next 00/59] QOM CPUState, part 4: CPU_COMMON Stefano Stabellini
2012-05-23 11:27   ` [Qemu-devel] " Stefano Stabellini
2012-05-23 15:36   ` Andreas Färber
2012-05-23 15:36     ` Andreas Färber
2012-05-23 15:16 ` [Qemu-devel] " Andreas Färber
2012-05-23 15:16   ` Andreas Färber
2012-05-23 19:36 ` Blue Swirl
2012-05-23 19:36   ` [Qemu-devel] " Blue Swirl
     [not found] ` <CAFEAcA9ga9=+iVUvtb8ApUQGh=j9sTfrWVcdOXHWTC2ZPx0-5w@mail.gmail.com>
     [not found]   ` <4FC5EF52.8010103@suse.de>
     [not found]     ` <201205311953.31459.paul@codesourcery.com>
2012-06-02 19:40       ` Blue Swirl [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAAu8pHtC6aMfNp+vOC9PWoQ2Ja2tBGrXzAPhAPo1=_sOYdR2UQ@mail.gmail.com' \
    --to=blauwirbel@gmail.com \
    --cc=afaerber@suse.de \
    --cc=agraf@suse.de \
    --cc=aurelien@aurel32.net \
    --cc=edgar.iglesias@gmail.com \
    --cc=gxt@mprc.pku.edu.cn \
    --cc=jcmvbkbc@gmail.com \
    --cc=michael@walle.cc \
    --cc=paul@codesourcery.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=rth@twiddle.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.