linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <levinsasha928@gmail.com>
To: Anthony Liguori <anthony@codemonkey.ws>
Cc: Wen Congyang <wency@cn.fujitsu.com>,
	kvm list <kvm@vger.kernel.org>,
	qemu-devel <qemu-devel@nongnu.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Avi Kivity <avi@redhat.com>,
	"Daniel P. Berrange" <berrange@redhat.com>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
	Jan Kiszka <jan.kiszka@siemens.com>,
	Gleb Natapov <gleb@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v7] kvm: notify host when the guest is panicked
Date: Sun, 22 Jul 2012 22:31:47 +0200	[thread overview]
Message-ID: <500C6333.6010609@gmail.com> (raw)
In-Reply-To: <500C604B.3080800@gmail.com>

On 07/22/2012 10:19 PM, Sasha Levin wrote:
> On 07/22/2012 09:22 PM, Anthony Liguori wrote:
>> Sasha Levin <levinsasha928@gmail.com> writes:
>>
>>> On 07/21/2012 09:12 AM, Wen Congyang wrote:
>>>> +#define KVM_PV_PORT	(0x505UL)
>>>> +
>>>>  #ifdef __KERNEL__
>>>>  #include <asm/processor.h>
>>>>  
>>>> @@ -221,6 +223,11 @@ static inline void kvm_disable_steal_time(void)
>>>>  }
>>>>  #endif
>>>>  
>>>> +static inline unsigned int kvm_arch_pv_features(void)
>>>> +{
>>>> +	return inl(KVM_PV_PORT);
>>>> +}
>>>> +
>>>
>>> Why is this safe?
>>>
>>> I'm not sure you can just pick any ioport you'd like and use it.
>>
>> There are three ways I/O ports get used on a PC:
>>
>> 1) Platform devices
>>  - This is well defined since the vast majority of platform devices are
>>    implemented within a single chip.  If you're emulating an i440fx
>>    chipset, the PIIX4 spec has an exhaustive list.
>>
>> 2) PCI devices
>>  - Typically, PCI only allocates ports starting at 0x0d00 to avoid
>>    conflicts with ISA devices.
>>
>> 3) ISA devices
>>  - ISA uses subtractive decoding so any ISA device can access.  In
>>    theory, an ISA device could attempt to use port 0x0505 but it's
>>    unlikely.  In a modern guest, there aren't really any ISA devices being
>>    added either.
>>
>> So yes, picking port 0x0505 is safe for something like this (as long as
>> you check to make sure that you really are under KVM).
> 
> Is there anything that actually prevents me from using PCI ports lower than 0x0d00? As you said in (3), ISA isn't really used anymore (nor is implemented by lkvm for example), so placing PCI below 0x0d00 might even make sense in that case.
> 
> Furthermore, I can place one of these brand new virtio-mmio devices which got introduced recently wherever I want right now - Having a device that uses 0x505 would cause a pretty non-obvious failure mode.
> 
> Either way, If we are going to grab an ioport, then:
> 
>  - It should be documented well somewhere in Documentation/virt/kvm
>  - It should go through request_region() to actually claim those ioports.
>  - It should fail gracefully if that port is taken for some reason, instead of not even checking it.
> 

Out of curiosity I tested that, and apparently lkvm has no problem allocating virtio-pci devices in that range:

sh-4.2# pwd
/sys/devices/pci0000:00/0000:00:01.0
sh-4.2# cat resource | head -n1
0x0000000000000500 0x00000000000005ff 0x0000000000040101

This was with the commit in question applied.

  reply	other threads:[~2012-07-22 20:31 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-21  7:12 [PATCH v7] kvm: notify host when the guest is panicked Wen Congyang
2012-07-21  7:14 ` [PATCH 1/6 v7] start vm after reseting it Wen Congyang
2012-07-21  7:14 ` [PATCH 2/6 v7] kvm: Update kernel headers Wen Congyang
2012-07-21  7:15 ` [PATCH 3/6 v7] add a new runstate: RUN_STATE_GUEST_PANICKED Wen Congyang
2012-07-21  7:16 ` [PATCH 4/6 v7] add a new qevent: QEVENT_GUEST_PANICKED Wen Congyang
2012-07-21  7:16 ` [PATCH 5/6 v7] introduce a new qom device to deal with panicked event Wen Congyang
2012-07-21  7:19 ` [PATCH 6/6 v7] allow the user to disable pv event support Wen Congyang
2012-07-21  7:19 ` [PATCH v7] kvm: notify host when the guest is panicked Jan Kiszka
2012-07-21  8:41   ` Wen Congyang
2012-07-21  8:44 ` [PATCH v7.5] " Wen Congyang
2012-07-22 11:39   ` [Qemu-devel] " Sasha Levin
2012-07-22 19:14     ` Anthony Liguori
2012-07-22 20:03       ` Sasha Levin
2012-07-22 22:36         ` Anthony Liguori
2012-07-22 23:50           ` Sasha Levin
2012-07-23  2:08             ` Wen Congyang
2012-07-23  2:07     ` Wen Congyang
2012-07-21 10:50 ` [Qemu-devel] [PATCH v7] " Sasha Levin
2012-07-22 19:22   ` Anthony Liguori
2012-07-22 20:19     ` Sasha Levin
2012-07-22 20:31       ` Sasha Levin [this message]
2012-07-22 22:29         ` Anthony Liguori
2012-07-22 23:35           ` Sasha Levin
2012-07-22 22:20       ` Anthony Liguori
2012-07-23  6:27       ` Wen Congyang

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=500C6333.6010609@gmail.com \
    --to=levinsasha928@gmail.com \
    --cc=anthony@codemonkey.ws \
    --cc=avi@redhat.com \
    --cc=berrange@redhat.com \
    --cc=gleb@redhat.com \
    --cc=jan.kiszka@siemens.com \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=qemu-devel@nongnu.org \
    --cc=wency@cn.fujitsu.com \
    /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;
as well as URLs for NNTP newsgroup(s).