[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v1 05/28] x86/hvm: cleanup svm_create_vmcb()
- To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
- From: dmukhin@xxxxxxxx
- Date: Fri, 20 Nov 2026 09:58:50 -0800
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 148.163.138.245) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=ford.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=ford.com; dkim=pass (signature was verified) header.d=saarlouis.ford.com; dkim=pass (signature was verified) header.d=ford.com; 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=M8Bx0qAIMfPx5r188nLnmajJ1FudkWKkNNp7feuRJGg=; b=ZHzQGkcuwYC9A463ILuJXsOJE0v7ZBeiPhWBXK+/AggX6grPLUcEy6P4hwzp8Gu6VnrB1FpFUE3OS95hAWPnP0JJfNTc0hLrDHM274YeYODL63fEJFYKfaQ9kDmZU7HxAQ47/FMWWc55oI7oN3B9zlRiHb0FtNkRvsAtzZXf9bCLVAnhmzET2BHPPfdyABrwPP2506JX6/rHXpiu38/973iZY/wNMDtEviqWIlaSkY8b4ANYGBMJoXbijEtF+/LkEkZKoMd3c7WMwntx7kkme5YN+8yjVF7kD3h9E8g/UCCP3uVmEtPNwLI6fANwi+ChmQScMfYxyKbT9B8Cr0A23w==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZaYVGJ0mWr9z58CB2kXj1V3Uq6JhvE5b2AttozUKK/p2L2rUhKwuq2mMjyD+jQlFCwvNJAkrlSqjgLOPPbR8Qjcpqa5svn2ib0e9/2f+TAVuwq7zDtpfo+5DKUJZAKg6WI95bN9E4RgCz5NmJ+IUYdRde2VHqGi2buwJXFXUgn8scRdUac0f0Jy3r5hEGphQsay075ngyWCSagwU7Bm/21yLspyVG2Z2ar5ZSJIUHGB3SxLaHwQhOCsSPO8vdcZ94vl8XSzi+IzfZXo4QhBTfQw+Ynyg/wbn8hYHWB/XpJNm5M2fr0JraiXV2NR5q75QtJ9D9j/oSB9oxmIbC/kAMQ==
- Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=ppford header.d=ford.com header.i="@ford.com" header.h="Cc:Content-Transfer-Encoding:Content-Type:Date:From:In-Reply-To:Message-ID:MIME-Version:References:Subject:To"; dkim=fail header.s=selector2-azureford-onmicrosoft-com header.d=azureford.onmicrosoft.com header.i="@azureford.onmicrosoft.com"; dkim=pass header.s=ppserprodsaar header.d=saarlouis.ford.com header.i="@saarlouis.ford.com" header.h="Cc:Content-Transfer-Encoding:Content-Type:Date:From:In-Reply-To:Message-ID:MIME-Version:References:Subject:To"; dkim=pass header.s=ppfserpocford header.d=ford.com header.i="@ford.com" header.h="Cc:Content-Transfer-Encoding:Content-Type:Date:From:In-Reply-To:Message-ID:MIME-Version:References:Subject:To"
- Cc: dmukhin@xxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx, jason.andryuk@xxxxxxx, jbeulich@xxxxxxxx, roger@xxxxxxxxxxxxxx, teddy.astie@xxxxxxxxxx
- Delivery-date: Fri, 20 Nov 2026 17:59:04 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Pser-m365-app: SER-APP
On Fri, Nov 06, 2026 at 06:05:18PM +0000, Andrew Cooper wrote:
> On 05/11/2026 1:33 am, dmukhin@xxxxxxxx wrote:
> > From: Denis Mukhin <dmukhin@xxxxxxxx>
> >
> > svm_create_vmcb() does not need to be idempotent because in case of
> > failure caller must call svm_destroy_vmcb().
> >
> > Simplify code in svm_create_vmcb() to account for that.
>
> This is more complicated than it seems.
>
> There are two paths which need to clean up a struct vcpu:
> 1) The domain_kill hypercall (i.e. clean destruction)
> 2) A failure within vcpu_create()
>
> Nowadays, both vcpu and domain create() end up calling back into the
> relevant destroy paths. This is some work I started a long time ago and
> never managed to finish.
>
> We had a number of memory leaks because each init/create function was
> required to clean up after itself, and several did this incorrectly. It
> was also wasteful because we had duplicated cleanup code.
>
> At the moment, both vcpu_create() and hvm_vcpu_initialise() will call
> the relevant destruction path.
>
> In the future, we want to remove all the create() error handling except
> from the top-level, because that removes the duplication. However this
> is a large task and it's the common/arch boundary where it gets
> particularly hard to organise safely.
>
>
> Anyway. We can take this patch with an adjusted commit message. In
> particular, saying that the "caller must call ..." is a hope, rather
> than a clear statement that this is how the code behaves. I suggest
> something like:
>
> ---8<---
> svm_create_vmcb() does not need to do error handling itself because
> vcpu_create() handles this at the top level by calling vcpu_destroy().
> ---8<---
That sounds good to me!
Thanks!
>
> But, if someone has some copious free time, it would be nicer if we
> could do this a little bit wider and make better progress towards
> removing the create() error handling.
>
> ~Andrew
>
|