From: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
To: "Dong, Eddie" <eddie.dong-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: kvm-devel <kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Subject: Re: kernel device reset support
Date: Fri, 12 Oct 2007 08:18:33 +0200 [thread overview]
Message-ID: <470F11B9.4050501@qumranet.com> (raw)
In-Reply-To: <10EA09EFD8728347A513008B6B0DA77A02364C43-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
Dong, Eddie wrote:
>>> Current VP wake up logic thru INIT/SIPI doesn't support this when
>>> irqchip in kernel.
>>>
>>>
>>>
>> Doesn't this code imply that waiting for SIPI is supported?
>>
>
> It is supported to wake up VCPU in kernel, but can't wake up the VCPU
> in user level since irqchip_in_kernel is TRUE here. vcpu->mp_state
> doesn't export to user level.
>
>
We never sleep in user level if irqchip_in_kernel(). So the thread will
eventually go back to kernel mode.
>> You can put a goto to the top of the loop to redo the mmu reload. In
>> any case you need to do that because you don't want to execute
>> the reset
>> code with interrupts and preemption disabled.
>>
>
> A goto cross function? It is too aggresive and bad code style IMO.
> The vcpu->request check is in __vcpu_run, while entering block
> state is in its parent function kvm_vcpu_ioctl_run.
>
>
goto the label 'again' in __vcpu_run(), which has the call to
kvm_mmu_reload().
> But if you want, we can return a special value,
> say REQUEST_INTERNAL_LOOP, to
> kvm_vcpu_ioctl_run and let kvm_vcpu_ioctl_run use sepcial logic
> to do goto within function if it see the special return value
> REQUEST_INTERNAL_LOOP. But is it cleaner?
>
> Also we will add more kernel to user EXIT reason, such as RESET request
> from kernel sensored guest tripple fault etc.
>
>
There is already a triple fault exit code.
>>> The VCPU may be executing in kernel still, which may modify kernel
>>> device state. E.g. A VCPU may be doing PIO emulating.
>>>
>>>
>>>
>> In that case we will wait when taking kvm->lock.
>>
>
> Lock doesn't help. Lock can only avoid no 2+ modifcation
> in same time. But what we care if all other VCPUs can't
> do modification after BSP do device reset.
> It is different semantics.
>
> Maybe you are still arguing it is the AP who do RESET ops.
> Let us go to next discussion first.
>
>
We first halt all vcpus, then take the lock. So:
- other processors won't start after the device reset because they are
halted
- we won't do the reset concurrently with other processors because of
the lock
>>> If BSP reset the kernel devices earlier than the VCPU modify the
>>> device state, we are in trouble.
>>>
>>> No, VCPU0 (BSP) is current VCPU (though you don't have the current
>>> vcpu parameter explicitly) like mentioned in previous mail and
>>> as pre-requirement of user level change. Please refer my abswer
>>> above of this mail.
>>>
>>>
>>>
>> We can't rely on user space not to cause host kernel corruption.
>>
>
> ???
>
> Even an AP trigger RESET, it just sets a reset_request flag in user
> level.
> It is another VCPU who will execute RESET operation.
>
> It seems the argument is who should do the RESET operation,
> say RST_CPU. BSP only or AP too. For me, since after RESET
> only BSP can execute, and the thread executing
> qemu_system_reset will continously execute
> (after RESET kernel) per current Qemu code, so what we can do is:
>
> 1: RST_CPU=BSP. Then BSP does qemu_system_reset, or
> 2: RST_CPU = AP, say RAP, does qemu_system_reset, user level
> then
> need to block RAP after qemu_system_reset and wake up BSP to take over.
> A point here we can't blcok RAP in case 2 at kernel RESET time,
> since
> kernel RESET may be not the last step of qemu_system_reset. It may go
> to kernel again.
>
> If we go with #1, just 1 line change as in my previous mail.
> If we go with #2, we have to add a new ABI for the AP to enter
> kernel
> wait for INIT/SIPI/SIPI state, otherwise normal INIT/SIPI/SIPI couldn't
> wake it up.
>
> I see much complicate in #2 while #1 has same functionality but
> simple.
>
>
My view is:
- vcpu threads never sleep in userspace. they will always eventually
end up in the kernel so we can stop or restart them there
- reset is a platform API so it can't be dependent on which vcpu thread
executes it (if any; it may be executed from an unrelated thread,
remember we plan to separate the qemu signal handling code into a
separate thread)
- we already have a way to send messages to other vcpus
So it seems to me everything is in place to make it fairly simple.
I'll try writing a patch that does what I mean and post it. Either I'll
convince you that in-kernel is simpler, or I'll convince myself that it
is harder.
--
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
next prev parent reply other threads:[~2007-10-12 6:18 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-08 10:17 kernel device reset support Dong, Eddie
[not found] ` <10EA09EFD8728347A513008B6B0DA77A0231BB36-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-10-08 10:24 ` Avi Kivity
[not found] ` <470A0556.80903-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-10-09 1:58 ` Dong, Eddie
[not found] ` <10EA09EFD8728347A513008B6B0DA77A0231BD83-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-10-09 9:34 ` Avi Kivity
[not found] ` <470B4B2E.1000500-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-10-09 9:53 ` Avi Kivity
2007-10-09 10:11 ` Dong, Eddie
[not found] ` <10EA09EFD8728347A513008B6B0DA77A0231C1AA-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-10-09 10:17 ` Avi Kivity
[not found] ` <470B5528.2010605-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-10-09 10:36 ` Dong, Eddie
[not found] ` <10EA09EFD8728347A513008B6B0DA77A0231C1B2-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-10-09 10:55 ` Avi Kivity
[not found] ` <470B5E3B.4060006-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-10-10 6:17 ` Dong, Eddie
[not found] ` <10EA09EFD8728347A513008B6B0DA77A02364242-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-10-10 10:23 ` Avi Kivity
[not found] ` <470CA814.9050907-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-10-11 1:32 ` Dong, Eddie
[not found] ` <10EA09EFD8728347A513008B6B0DA77A02364638-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-10-11 7:24 ` Dong, Eddie
2007-10-11 12:11 ` Avi Kivity
[not found] ` <470E130D.6080808-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-10-12 1:07 ` Dong, Eddie
[not found] ` <10EA09EFD8728347A513008B6B0DA77A02364C43-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-10-12 6:18 ` Avi Kivity [this message]
[not found] ` <470F11B9.4050501-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-10-12 7:17 ` Dong, Eddie
[not found] ` <10EA09EFD8728347A513008B6B0DA77A02364F85-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-10-13 7:16 ` Avi Kivity
[not found] ` <471070D8.7030402-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-10-15 4:40 ` Dong, Eddie
[not found] ` <10EA09EFD8728347A513008B6B0DA77A023A6DFE-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-10-15 9:10 ` Avi Kivity
[not found] ` <47132E9D.7030500-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-10-16 8:44 ` Dong, Eddie
[not found] ` <10EA09EFD8728347A513008B6B0DA77A023A763C-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-10-16 10:25 ` Avi Kivity
[not found] ` <471491A9. 8040207@qumranet.com>
[not found] ` <471491A9.8040207-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-10-17 1:40 ` Dong, Eddie
2007-10-08 10:27 ` 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=470F11B9.4050501@qumranet.com \
--to=avi-atkuwr5tajbwk0htik3j/w@public.gmane.org \
--cc=eddie.dong-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox