From: Jan Kiszka <jan.kiszka@siemens.com>
To: Gleb Natapov <gleb@redhat.com>
Cc: Avi Kivity <avi@redhat.com>, kvm@vger.kernel.org
Subject: Re: [PATCH] Don't call cpu_synchronize_state() in apic_init_reset()
Date: Fri, 25 Sep 2009 17:03:49 +0200 [thread overview]
Message-ID: <4ABCDBD5.7040603@siemens.com> (raw)
In-Reply-To: <20090924091145.GB14258@redhat.com>
Gleb Natapov wrote:
> On Thu, Sep 24, 2009 at 10:59:46AM +0200, Jan Kiszka wrote:
>> Gleb Natapov wrote:
>>> On Thu, Sep 24, 2009 at 10:15:15AM +0200, Jan Kiszka wrote:
>>>> Gleb Natapov wrote:
>>>>> On Thu, Sep 24, 2009 at 10:53:59AM +0300, Avi Kivity wrote:
>>>>>> On 09/23/2009 06:45 PM, Jan Kiszka wrote:
>>>>>>>> Functions calling each other in the same subsystem can rely on callers
>>>>>>>> calling cpu_synchronize_state(). Across subsystems, that's another
>>>>>>>> matter, exported functions should try not to rely on implementation
>>>>>>>> details of their callers.
>>>>>>>>
>>>>>>>> (You might argue that the apic is not separate subsystem wrt an x86 cpu,
>>>>>>>> and I'm not sure I have a counterargument)
>>>>>>>>
>>>>>>> I do accept this argument. It's just that my feeling is that we are
>>>>>>> lacking proper review of the required call sites of cpu_sychronize_state
>>>>>>> and rather put it where some regression popped up (and that only in
>>>>>>> qemu-kvm...).
>>>>>> That's life...
>>>>>>
>>>>>>> The new rule is: Synchronize the states before accessing registers (or
>>>>>>> in-kernel devices) the first time after a vmexit to user space.
>>>>>> No, the rule is: synchronize state before accessing registers.
>>>>>> Extra synchronization is cheap, while missing synchronization is
>>>>>> very expensive.
>>>>>>
>>>>> So should we stick cpu_synchronize_state() before each register
>>>>> accesses? I think it is reasonable to omit it if all callers do it
>>>>> already.
>>>>>
>>>>>>> But,
>>>>>>> e.g., I do not see where we do this on CPU reset.
>>>>>> That's a bug.
>>>>>>
>>>>> Only if kvm support cpus without apic. Otherwise CPU is reset by
>>>>> apic_reset() and cpu_synchronize_state() is called there.
>>>> No, that's not enough if cpu_reset() first fiddles with some registers
>>>> that may later on be overwritten on cpu_synchronize_state() with the old
>>>> in-kernel state. At least in theory, haven't checked yet what happens in
>>> Can't happen. Call chain is apic_reset() -> cpu_reset() and apic_reset()
>>> calls cpu_synchronize_state() before calling cpu_reset().
>> And system_reset?
>>
> And system_reset calls apic_reset() if cpu has apic, cpu_reset()
> otherwise. That is why I said that the bug is only for cpus without
> apic.
Yes, I see now. Still, it's not a good reference for other archs (did
anyone already checked the situation on ppc?). Will file a patch.
Jan
--
Siemens AG, Corporate Technology, CT SE 2
Corporate Competence Center Embedded Linux
next prev parent reply other threads:[~2009-09-25 15:04 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-22 14:51 [PATCH] Update halted state from mpstate only in case of inkernel irq chip Gleb Natapov
2009-09-22 14:51 ` [PATCH] Don't call kvm_cpu_synchronize_state() if there is no irqchip events to process Gleb Natapov
2009-09-23 9:00 ` Avi Kivity
2009-09-22 14:51 ` [PATCH] Don't call cpu_synchronize_state() in apic_init_reset() Gleb Natapov
2009-09-23 9:00 ` Avi Kivity
2009-09-23 15:07 ` Jan Kiszka
2009-09-23 15:17 ` Avi Kivity
2009-09-23 15:45 ` Jan Kiszka
2009-09-24 7:53 ` Avi Kivity
2009-09-24 8:03 ` Gleb Natapov
2009-09-24 8:15 ` Jan Kiszka
2009-09-24 8:30 ` Gleb Natapov
2009-09-24 8:59 ` Jan Kiszka
2009-09-24 9:11 ` Gleb Natapov
2009-09-25 15:03 ` Jan Kiszka [this message]
2009-09-24 8:24 ` Avi Kivity
2009-09-23 9:00 ` [PATCH] Update halted state from mpstate only in case of inkernel irq chip Avi Kivity
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=4ABCDBD5.7040603@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=avi@redhat.com \
--cc=gleb@redhat.com \
--cc=kvm@vger.kernel.org \
/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.