* [PATCH v2] libxl: disallow PCI device assignment for HVM guest when PoD is enabled
@ 2014-01-13 11:52 Wei Liu
2014-01-14 14:50 ` Ian Campbell
0 siblings, 1 reply; 6+ messages in thread
From: Wei Liu @ 2014-01-13 11:52 UTC (permalink / raw)
To: xen-devel; +Cc: Ian Jackson, Wei Liu, Ian Campbell
This replicates a Xend behavior, see ec789523749 ("xend: Dis-allow
device assignment if PoD is enabled.").
This change is restricted to HVM guest, as only HVM is relevant in the
counterpart in Xend. We're late in release cycle so the change should
only do what's necessary. Probably we can revisit it if we need to do
the same thing for PV guest in the future.
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
---
v2: fix comment
---
tools/libxl/libxl_create.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index e03bb55..61437de 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -706,6 +706,7 @@ static void initiate_domain_create(libxl__egc *egc,
libxl_ctx *ctx = libxl__gc_owner(gc);
uint32_t domid;
int i, ret;
+ bool pod_enabled = false;
/* convenience aliases */
libxl_domain_config *const d_config = dcs->guest_config;
@@ -714,6 +715,25 @@ static void initiate_domain_create(libxl__egc *egc,
domid = 0;
+ /* If target_memkb is smaller than max_memkb, the subsequent call
+ * to libxc when building HVM domain will enable PoD mode.
+ */
+ pod_enabled = (d_config->c_info.type == LIBXL_DOMAIN_TYPE_HVM) &&
+ (d_config->b_info.target_memkb < d_config->b_info.max_memkb);
+
+ /* We cannot have PoD and PCI device assignment at the same time
+ * for HVM guest. It was reported that IOMMU cannot work with PoD
+ * enabled because it needs to populated entire page table for
+ * guest. To stay on the safe side, we disable PCI device
+ * assignment when PoD is enabled.
+ */
+ if (d_config->c_info.type == LIBXL_DOMAIN_TYPE_HVM &&
+ d_config->num_pcidevs && pod_enabled) {
+ ret = ERROR_INVAL;
+ LOG(ERROR, "PCI device assignment for HVM guest failed due to PoD enabled");
+ goto error_out;
+ }
+
ret = libxl__domain_create_info_setdefault(gc, &d_config->c_info);
if (ret) goto error_out;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH v2] libxl: disallow PCI device assignment for HVM guest when PoD is enabled
2014-01-13 11:52 [PATCH v2] libxl: disallow PCI device assignment for HVM guest when PoD is enabled Wei Liu
@ 2014-01-14 14:50 ` Ian Campbell
2014-01-14 14:54 ` Andrew Cooper
0 siblings, 1 reply; 6+ messages in thread
From: Ian Campbell @ 2014-01-14 14:50 UTC (permalink / raw)
To: Wei Liu; +Cc: George Dunlap, Ian Jackson, xen-devel
On Mon, 2014-01-13 at 11:52 +0000, Wei Liu wrote:
> This replicates a Xend behavior, see ec789523749 ("xend: Dis-allow
> device assignment if PoD is enabled.").
>
> This change is restricted to HVM guest, as only HVM is relevant in the
> counterpart in Xend. We're late in release cycle so the change should
> only do what's necessary. Probably we can revisit it if we need to do
> the same thing for PV guest in the future.
>
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Release hat: The risk here is of a false positive detecting whether PoD
would be used and therefore refusing to start a domain. However Wei
directed me earlier on to the code in setup_guest which sets
XENMEMF_populate_on_demand and I believe it is using the same logic.
The benefit of this is that it will stop people starting a domain in an
invalid configuration -- but what is the downside here? Is it an
unhandled IOMMU fault or another host-fatal error? That would make the
argument for taking this patch pretty strong. On the other hand if the
failure were simply to kill this domain, that would be a less serious
issue and I'd be in two minds, mainly due to George not being here to
confirm that the pod_enabled logic is correct (although if he were here
I wouldn't be wrestling with this question at all ;-)).
I'm leaning towards taking this fix, but I'd really like to know what
the current failure case looks like.
Ian.
> Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> ---
> v2: fix comment
> ---
> tools/libxl/libxl_create.c | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
> index e03bb55..61437de 100644
> --- a/tools/libxl/libxl_create.c
> +++ b/tools/libxl/libxl_create.c
> @@ -706,6 +706,7 @@ static void initiate_domain_create(libxl__egc *egc,
> libxl_ctx *ctx = libxl__gc_owner(gc);
> uint32_t domid;
> int i, ret;
> + bool pod_enabled = false;
>
> /* convenience aliases */
> libxl_domain_config *const d_config = dcs->guest_config;
> @@ -714,6 +715,25 @@ static void initiate_domain_create(libxl__egc *egc,
>
> domid = 0;
>
> + /* If target_memkb is smaller than max_memkb, the subsequent call
> + * to libxc when building HVM domain will enable PoD mode.
> + */
> + pod_enabled = (d_config->c_info.type == LIBXL_DOMAIN_TYPE_HVM) &&
> + (d_config->b_info.target_memkb < d_config->b_info.max_memkb);
> +
> + /* We cannot have PoD and PCI device assignment at the same time
> + * for HVM guest. It was reported that IOMMU cannot work with PoD
> + * enabled because it needs to populated entire page table for
> + * guest. To stay on the safe side, we disable PCI device
> + * assignment when PoD is enabled.
> + */
> + if (d_config->c_info.type == LIBXL_DOMAIN_TYPE_HVM &&
> + d_config->num_pcidevs && pod_enabled) {
> + ret = ERROR_INVAL;
> + LOG(ERROR, "PCI device assignment for HVM guest failed due to PoD enabled");
> + goto error_out;
> + }
> +
> ret = libxl__domain_create_info_setdefault(gc, &d_config->c_info);
> if (ret) goto error_out;
>
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH v2] libxl: disallow PCI device assignment for HVM guest when PoD is enabled
2014-01-14 14:50 ` Ian Campbell
@ 2014-01-14 14:54 ` Andrew Cooper
2014-01-15 14:12 ` Ian Campbell
2014-01-20 14:04 ` George Dunlap
0 siblings, 2 replies; 6+ messages in thread
From: Andrew Cooper @ 2014-01-14 14:54 UTC (permalink / raw)
To: Ian Campbell; +Cc: George Dunlap, Ian Jackson, Wei Liu, xen-devel
On 14/01/14 14:50, Ian Campbell wrote:
> On Mon, 2014-01-13 at 11:52 +0000, Wei Liu wrote:
>> This replicates a Xend behavior, see ec789523749 ("xend: Dis-allow
>> device assignment if PoD is enabled.").
>>
>> This change is restricted to HVM guest, as only HVM is relevant in the
>> counterpart in Xend. We're late in release cycle so the change should
>> only do what's necessary. Probably we can revisit it if we need to do
>> the same thing for PV guest in the future.
>>
>> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> Acked-by: Ian Campbell <ian.campbell@citrix.com>
>
> Release hat: The risk here is of a false positive detecting whether PoD
> would be used and therefore refusing to start a domain. However Wei
> directed me earlier on to the code in setup_guest which sets
> XENMEMF_populate_on_demand and I believe it is using the same logic.
>
> The benefit of this is that it will stop people starting a domain in an
> invalid configuration -- but what is the downside here? Is it an
> unhandled IOMMU fault or another host-fatal error? That would make the
> argument for taking this patch pretty strong. On the other hand if the
> failure were simply to kill this domain, that would be a less serious
> issue and I'd be in two minds, mainly due to George not being here to
> confirm that the pod_enabled logic is correct (although if he were here
> I wouldn't be wrestling with this question at all ;-)).
>
> I'm leaning towards taking this fix, but I'd really like to know what
> the current failure case looks like.
>
> Ian.
The answer is likely hardware specific.
An IOMMU fault (however handled by Xen) will result in a master abort on
the DMA transaction for the PCI device which has suffered the fault.
That device can then do anything from continue blindly to issuing an NMI
IOCK/SERR which will likely be fatal to the entire server.
~Andrew
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH v2] libxl: disallow PCI device assignment for HVM guest when PoD is enabled
2014-01-14 14:54 ` Andrew Cooper
@ 2014-01-15 14:12 ` Ian Campbell
2014-01-20 14:04 ` George Dunlap
1 sibling, 0 replies; 6+ messages in thread
From: Ian Campbell @ 2014-01-15 14:12 UTC (permalink / raw)
To: Andrew Cooper; +Cc: George Dunlap, Ian Jackson, Wei Liu, xen-devel
On Tue, 2014-01-14 at 14:54 +0000, Andrew Cooper wrote:
> On 14/01/14 14:50, Ian Campbell wrote:
> > On Mon, 2014-01-13 at 11:52 +0000, Wei Liu wrote:
> >> This replicates a Xend behavior, see ec789523749 ("xend: Dis-allow
> >> device assignment if PoD is enabled.").
> >>
> >> This change is restricted to HVM guest, as only HVM is relevant in the
> >> counterpart in Xend. We're late in release cycle so the change should
> >> only do what's necessary. Probably we can revisit it if we need to do
> >> the same thing for PV guest in the future.
> >>
> >> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> > Acked-by: Ian Campbell <ian.campbell@citrix.com>
> >
> > Release hat: The risk here is of a false positive detecting whether PoD
> > would be used and therefore refusing to start a domain. However Wei
> > directed me earlier on to the code in setup_guest which sets
> > XENMEMF_populate_on_demand and I believe it is using the same logic.
> >
> > The benefit of this is that it will stop people starting a domain in an
> > invalid configuration -- but what is the downside here? Is it an
> > unhandled IOMMU fault or another host-fatal error? That would make the
> > argument for taking this patch pretty strong. On the other hand if the
> > failure were simply to kill this domain, that would be a less serious
> > issue and I'd be in two minds, mainly due to George not being here to
> > confirm that the pod_enabled logic is correct (although if he were here
> > I wouldn't be wrestling with this question at all ;-)).
> >
> > I'm leaning towards taking this fix, but I'd really like to know what
> > the current failure case looks like.
> >
> > Ian.
>
> The answer is likely hardware specific.
>
> An IOMMU fault (however handled by Xen) will result in a master abort on
> the DMA transaction for the PCI device which has suffered the fault.
> That device can then do anything from continue blindly to issuing an NMI
> IOCK/SERR which will likely be fatal to the entire server.
Thanks, that tips me over into:
Release-ack: Ian Campbell
I applied, there was a reject against "libxl: Auto-assign NIC devids in
initiate_domain_create" which I fixed up.
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH v2] libxl: disallow PCI device assignment for HVM guest when PoD is enabled
2014-01-14 14:54 ` Andrew Cooper
2014-01-15 14:12 ` Ian Campbell
@ 2014-01-20 14:04 ` George Dunlap
2014-01-20 14:23 ` Andrew Cooper
1 sibling, 1 reply; 6+ messages in thread
From: George Dunlap @ 2014-01-20 14:04 UTC (permalink / raw)
To: Andrew Cooper, Ian Campbell; +Cc: Ian Jackson, Wei Liu, xen-devel
On 01/14/2014 02:54 PM, Andrew Cooper wrote:
> On 14/01/14 14:50, Ian Campbell wrote:
>> On Mon, 2014-01-13 at 11:52 +0000, Wei Liu wrote:
>>> This replicates a Xend behavior, see ec789523749 ("xend: Dis-allow
>>> device assignment if PoD is enabled.").
>>>
>>> This change is restricted to HVM guest, as only HVM is relevant in the
>>> counterpart in Xend. We're late in release cycle so the change should
>>> only do what's necessary. Probably we can revisit it if we need to do
>>> the same thing for PV guest in the future.
>>>
>>> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
>> Acked-by: Ian Campbell <ian.campbell@citrix.com>
>>
>> Release hat: The risk here is of a false positive detecting whether PoD
>> would be used and therefore refusing to start a domain. However Wei
>> directed me earlier on to the code in setup_guest which sets
>> XENMEMF_populate_on_demand and I believe it is using the same logic.
>>
>> The benefit of this is that it will stop people starting a domain in an
>> invalid configuration -- but what is the downside here? Is it an
>> unhandled IOMMU fault or another host-fatal error? That would make the
>> argument for taking this patch pretty strong. On the other hand if the
>> failure were simply to kill this domain, that would be a less serious
>> issue and I'd be in two minds, mainly due to George not being here to
>> confirm that the pod_enabled logic is correct (although if he were here
>> I wouldn't be wrestling with this question at all ;-)).
>>
>> I'm leaning towards taking this fix, but I'd really like to know what
>> the current failure case looks like.
>>
>> Ian.
> The answer is likely hardware specific.
>
> An IOMMU fault (however handled by Xen) will result in a master abort on
> the DMA transaction for the PCI device which has suffered the fault.
> That device can then do anything from continue blindly to issuing an NMI
> IOCK/SERR which will likely be fatal to the entire server.
I thought we changed the behavior of Xen not to crash on SERR? Or was I
confused about that?
Since a VM should be able to craft a DMA pointing to invalid p2m space
fairly easily, it seems like having the host crash in that scenario
would basically remove half of the reason for having am IOMMU in the
first place.
-George
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH v2] libxl: disallow PCI device assignment for HVM guest when PoD is enabled
2014-01-20 14:04 ` George Dunlap
@ 2014-01-20 14:23 ` Andrew Cooper
0 siblings, 0 replies; 6+ messages in thread
From: Andrew Cooper @ 2014-01-20 14:23 UTC (permalink / raw)
To: George Dunlap; +Cc: Ian Jackson, Wei Liu, Ian Campbell, xen-devel
On 20/01/14 14:04, George Dunlap wrote:
> On 01/14/2014 02:54 PM, Andrew Cooper wrote:
>> On 14/01/14 14:50, Ian Campbell wrote:
>>> On Mon, 2014-01-13 at 11:52 +0000, Wei Liu wrote:
>>>> This replicates a Xend behavior, see ec789523749 ("xend: Dis-allow
>>>> device assignment if PoD is enabled.").
>>>>
>>>> This change is restricted to HVM guest, as only HVM is relevant in the
>>>> counterpart in Xend. We're late in release cycle so the change should
>>>> only do what's necessary. Probably we can revisit it if we need to do
>>>> the same thing for PV guest in the future.
>>>>
>>>> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
>>> Acked-by: Ian Campbell <ian.campbell@citrix.com>
>>>
>>> Release hat: The risk here is of a false positive detecting whether PoD
>>> would be used and therefore refusing to start a domain. However Wei
>>> directed me earlier on to the code in setup_guest which sets
>>> XENMEMF_populate_on_demand and I believe it is using the same logic.
>>>
>>> The benefit of this is that it will stop people starting a domain in an
>>> invalid configuration -- but what is the downside here? Is it an
>>> unhandled IOMMU fault or another host-fatal error? That would make the
>>> argument for taking this patch pretty strong. On the other hand if the
>>> failure were simply to kill this domain, that would be a less serious
>>> issue and I'd be in two minds, mainly due to George not being here to
>>> confirm that the pod_enabled logic is correct (although if he were here
>>> I wouldn't be wrestling with this question at all ;-)).
>>>
>>> I'm leaning towards taking this fix, but I'd really like to know what
>>> the current failure case looks like.
>>>
>>> Ian.
>> The answer is likely hardware specific.
>>
>> An IOMMU fault (however handled by Xen) will result in a master abort on
>> the DMA transaction for the PCI device which has suffered the fault.
>> That device can then do anything from continue blindly to issuing an NMI
>> IOCK/SERR which will likely be fatal to the entire server.
>
> I thought we changed the behavior of Xen not to crash on SERR? Or was
> I confused about that?
>
> Since a VM should be able to craft a DMA pointing to invalid p2m space
> fairly easily, it seems like having the host crash in that scenario
> would basically remove half of the reason for having am IOMMU in the
> first place.
>
> -George
The behaviour of IOCK/SERR NMIs depends on the "nmi=" command line
option, which for a non-debug build is "redirect to dom0", and in a
debug build is fatal. Dom0's behaviour is normally to say "huh - my
virtual environment looks fine", which makes it the option quite useless.
IOCK/SERR NMIs can be out-of-band, possibly via the BMC on a server
class motherboard, and per XSA-59, possibly not caught by the IOMMU.
~Andrew
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-01-20 14:23 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-13 11:52 [PATCH v2] libxl: disallow PCI device assignment for HVM guest when PoD is enabled Wei Liu
2014-01-14 14:50 ` Ian Campbell
2014-01-14 14:54 ` Andrew Cooper
2014-01-15 14:12 ` Ian Campbell
2014-01-20 14:04 ` George Dunlap
2014-01-20 14:23 ` Andrew Cooper
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.