[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 1/7] xen/evtchn: Make sure all buckets below d->valid_evtchns are allocated
- To: Michal Orzel <michal.orzel@xxxxxxx>
- From: Rahul Singh <Rahul.Singh@xxxxxxx>
- Date: Thu, 1 Sep 2022 12:52:10 +0000
- Accept-language: en-US
- Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
- Arc-message-signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=TgIZLiaji23oAiTU/MzMChTmwY+es3GPxmRbrVWMRGA=; b=I1PZXbmcO34zjkdLvMqno2wnvhx5EqzP5p+quqTFGlHHtIO3Sn0fccm1C2ciQkPQquPAbwcJz/TIkgd380YuG56xMpwbJm3ZmMrQzrbIM7XmLcl7XrI8TpFnLzw3oZUWUNXAgm9+pJtkVbE5qoIiWpWqVgu26T4MkPg2UG3+l4ZeVpTzPtZ2ZloZePZtfIXaN7AgQbpN2xe0G8difJequD2vGnVQHtDDol6nZT6dCc1qDm2BuVUnnN5O75tbnduD5/JNA1RlgzaCCPuzHnxXDrGOxTq7qHOIvARUEhnUq3SIM/71RVxotLHUEKrbLtAYRjUIfQcRGhrODUgMaGva0Q==
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=TgIZLiaji23oAiTU/MzMChTmwY+es3GPxmRbrVWMRGA=; b=ATiC9u8DEiFB66dGOGTvtVnlnEea9u97lZOEbQmjetHF5cHgNiTNIPMOud2RE8pHXGotXVtXfcYr/nXUhTJQnUdXiJYkmbibBZBJP098nOcdqNIUrQCSCgzfzd74/Y2Vf6tG27QwfmiEYffcSZrJea/RneJ8zsXhJzqTVWMF1uZfCO2CGiwWkV7+PDIhoBVjIbWqFG68nypjxl3kMcnnl1rTv7nN627MV5aGXjgMfHQAh8RsBn8ztZ7/Nx531I7Xzk7kwchUKtZpxvXJ3nMbqaiswXZnp/sVMw7X9MDxUYWxv+ZFu1tVytEL3w4OFSKQ1l7wnXAWUUCFyBJ1HEz7rw==
- Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=R5TGgyoy2Snlg7lfUASIiL8nTgVM6J2Q/5rdCgl+3kZCsJl/Pb0MCQvcHxIh0XA3Zubpj2NDRZWQe2QNz4ABzo/39PXQM0fm+4ogP7Si+mGuJwuRxjbLOuQnIx3NpKspW3anpKu0jbFF5LiBKMjh3qxHSwvk6+o+Gvdo6nwypKDnDk9HVCOLP5EwhIaMCMAd0jq2AqPU/oKuUARCuWG74iwN5UQJ29wKHeOLiFcK/ub9JxIR84ZVgo8TCdULGgeZOohYASQlbm/ifNG6qXzq6CFsII+dOFBg1IPabCsQTfwxAQi6KoG7CLupycJitcZnszgHVmztHl/qAhjGMiwRcQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OpC5eV9oUHpjj3HvibRgS3IEIOr+bi4tPVZtr5uSodnlyAh2QQXc66KO77Fmn188DLgG4helMut53vrEflb0CRy2YsnpgJHnIhkY3SDLD6QPztpQw1ec1bxEK5Q6qbLHuHYZL5yMeQZqW/F4JJ4+EP3sswfyr1XmgzTGLjiJwqnI+P0Dw/rE9rjq/MLA2YjHLQty/p6xbipmEtsrpdXgy0fFuHgCEtLhLO/9RsIthGx2GzhZrPNDlzn+XCSvSczwLEIw5xy90G5kV+2p/pc53D+wG6rkq1FN6jTZcbcnF6ClPI6zk9KeeL8mIDVzjD+YduJj1IVsV3SaYUlKwwGzaQ==
- Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
- Cc: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Julien Grall <jgrall@xxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
- Delivery-date: Thu, 01 Sep 2022 12:52:30 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Nodisclaimer: true
- Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
- Thread-index: AQHYveMkt35gh2PJUU+Mzacc/fzh2K3KhkQAgAABQIA=
- Thread-topic: [PATCH v3 1/7] xen/evtchn: Make sure all buckets below d->valid_evtchns are allocated
Hi Michal,
> On 1 Sep 2022, at 1:47 pm, Michal Orzel <michal.orzel@xxxxxxx> wrote:
>
> Hi Rahul,
>
> On 01/09/2022 11:13, Rahul Singh wrote:
>>
>> From: Julien Grall <jgrall@xxxxxxxxxx>
>>
>> Since commit 01280dc19cf3 "evtchn: simplify port_is_valid()", the event
>> channels code assumes that all the buckets below d->valid_evtchns are
>> always allocated.
>>
>> This assumption hold in most of the situation because a guest is not
>> allowed to chose the port. Instead, it will be the first free from port
>> 0.
>>
>> When static event channel support will be added for dom0less domains
>> user can request to allocate the evtchn port numbers that are scattered
>> in nature.
>>
>> The existing implementation of evtchn_allocate_port() is not able to
>> deal with such situation and will end up to override bucket or/and leave
>> some bucket unallocated. The latter will result to a droplet crash if
>> the event channel belongs to an unallocated bucket.
>>
>> This can be solved by making sure that all the buckets below
>> d->valid_evtchns are allocated. There should be no impact for most of
>> the situation but LM/LU as only one bucket would be allocated. For
>> LM/LU, we may end up to allocate multiple buckets if ports in use are
>> sparse.
>>
>> A potential alternative is to check that the bucket is valid in
>> is_port_valid(). This should still possible to do it without taking
>> per-domain lock but will result a couple more of memory access.
>>
>> Signed-off-by: Julien Grall <jgrall@xxxxxxxxxx>
>> Signed-off-by: Rahul Singh <rahul.singh@xxxxxxx>
>> ---
>> Changes in v3:
>> - fix comments in commit msg.
>> - modify code related to d->valid_evtchns and {read,write}_atomic()
>> Changes in v2:
>> - new patch in this version to avoid the security issue
>> ---
>> xen/common/event_channel.c | 55 ++++++++++++++++++++++++--------------
>> 1 file changed, 35 insertions(+), 20 deletions(-)
>>
>> diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c
>> index c2c6f8c151..80b06d9743 100644
>> --- a/xen/common/event_channel.c
>> +++ b/xen/common/event_channel.c
>> @@ -193,6 +193,15 @@ static struct evtchn *alloc_evtchn_bucket(struct domain
>> *d, unsigned int port)
>> return NULL;
>> }
>>
>> +/*
>> + * Allocate a given port and ensure all the buckets up to that ports
>> + * have been allocated.
>> + *
>> + * The last part is important because the rest of the event channel code
>> + * relies on all the buckets up to d->valid_evtchns to be valid. However,
>> + * event channels may be sparsed when restoring a domain during Guest
>> + * Transparent Migration and Live Update.
> You got rid of mentioning these non-existing features from the commit msg,
> but you still mention them here.
I missed that I will fix that in next version.
Regards,
Rahul
|