[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [for-4.22][PATCH v2] xen/arm: Fail domain construction if a secondary vCPU cannot be created
- To: Michal Orzel <michal.orzel@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: "Halder, Ayan Kumar" <ayankuma@xxxxxxx>
- Date: Thu, 9 Jul 2026 10:32:41 +0100
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ylED/Exol/IBw523L6L6OHOZUTVW6ahlDtVbvIGmfgY=; b=JtZWcWeQ9GX0lAqrE2UdfQO+g7w358OI20+Hx+DfuLLvtR65iDc3WWdMRZAicPWbKThmiRcT21pzcZuf5hzvEb8ysFocIfWoe6AFtHvRWbw0P66yU+YMo4eVw6cjgRNHSQickYv/x3MdE+N9fMtXQcfb6QWjgBPUKjqEL1y4HWgY8QYCGu3U30YYw3crOa5nWbxe9084M5G8AgogEO8spkLlmqSCVPcBIvT+xy0YMG7KZblchhnAzgKmZC1HfG63E9FRFTxl99coMV7hjaGparFoVysg7kM1r1jU/hCUfdtQTHI/n47L5pcG/m/Evy34AooIR8KEkLw7lBMRqzUn6A==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KnZOiM5R5ePUymWNzTDfuJoigw+Uyijl0aQ8kBh0gwHnqBzfRoD80Bybg6Ykl8d5Qodow07ob1ASHZDz8iQBkVkNzlqWGn32HZLekgE2bey+cP2x0xYCSECxHAHbw728A/IbGYkbvEU5AHu8NB26Ate738N33jO+QIHUPnah5JGRSNZ6T8sAb+LrZQlILFdQrxhq0ocypUHHsVOJmSvFn0wCv1IHEMGGW3bpDxxchRSNJSVOwUHUZEMe87iLTrs+r/PNPkgUnTB8Anb3+T9Z+EsUgdWpv90dny6OjWsnH4KyR16vc+XDPDhjYzJ4b78KYqyik+L1L2lGBi+0aspNhQ==
- Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=amd.com header.i="@amd.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
- Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, "Volodymyr Babchuk" <Volodymyr_Babchuk@xxxxxxxx>, <ayan.kumar.halder@xxxxxxx>, "Oleksii Kurochko" <oleksii.kurochko@xxxxxxxxx>
- Delivery-date: Thu, 09 Jul 2026 09:33:02 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 09/07/2026 07:36, Michal Orzel wrote:
construct_domain() creates the secondary vCPUs in a loop, but on a
vcpu_create() failure it only prints a message and breaks out of the
loop returning success. As a result the domain can be partially
constructed with fewer vCPUs than d->max_vcpus. This causes two contract
violations:
- Xen-Guest: domain's FDT is generated before vCPU creation - Xen exposes
incorrect information (e.g. two vCPUs listed in a device tree while only
one is actually created),
- User-Xen: unlike x86, on Arm port we try to bail out as soon as
possible on unsatisfied user requests (e.g. user requested two vCPUs
for a domain but it was created with only one).
Unrelated, but just to add my 2 cents wearing a safety hat.
The user-xen contract comes from a system integrator. Xen should try to
follow the contract and if not panic or bail out.
The Xen-guest contract can be used to enforce the rule that guest should
read the contract before doing any safety critical task.
The most important thing is anything errors that are internal to Xen,
should be propagated to the external world (either as panic or return an
error to the guest or abort the guest). If there is a degradation is
functionality (eg Xen creating a guest with lesser number of vCPUS that
what the system integrator provided), then this is safety issue unless
we put an assumption on guest to read its device tree and know the final
configuration (which may not be always ok).
Return an error instead of breaking out of the loop. Both callers
(construct_domU() and construct_hwdom()) already propagate a negative
return value and fail domain construction.
Fixes: 6b0e8e43348a ("xen/arm: allocate secondaries dom0 vcpus")
Signed-off-by: Michal Orzel <michal.orzel@xxxxxxx>
Reviewed-by: Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>
---
Changes in v2:
- return ENOMEM as allocation failure is most frequent cause of failure
- update commit msg to focus on unmet contracts
---
xen/arch/arm/domain_build.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 550617f152bb..72d531618045 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1847,7 +1847,7 @@ int __init construct_domain(struct domain *d, struct
kernel_info *kinfo)
if ( vcpu_create(d, i) == NULL )
{
printk("Failed to allocate d%dv%d\n", d->domain_id, i);
- break;
+ return -ENOMEM;
}
if ( is_64bit_domain(d) )
|