Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 43597C433F5 for ; Tue, 26 Apr 2022 08:33:57 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.313520.531075 (Exim 4.92) (envelope-from ) id 1njGdg-0007Dx-1b; Tue, 26 Apr 2022 08:33:40 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 313520.531075; Tue, 26 Apr 2022 08:33:40 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1njGdf-0007Dq-UJ; Tue, 26 Apr 2022 08:33:39 +0000 Received: by outflank-mailman (input) for mailman id 313520; Tue, 26 Apr 2022 08:33:39 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1njGdf-0007Dk-Fm for xen-devel@lists.xenproject.org; Tue, 26 Apr 2022 08:33:39 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1njGda-00088S-Li; Tue, 26 Apr 2022 08:33:34 +0000 Received: from 54-240-197-231.amazon.com ([54.240.197.231] helo=[192.168.15.135]) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1njGda-00025K-FA; Tue, 26 Apr 2022 08:33:34 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:Cc:To:Subject:MIME-Version:Date:Message-ID; bh=h4YX8rqQzCmA8T91YPdPLIYmjjKLa55vnhuZa5+Iirg=; b=cfFaZv3CcrxfCT0ZTQqGLjUV9j Q/orSv6HDRRSF+lFkS3HqZn8H43tfQ2lfzSrhDyGvx7qsfzR1oFuGeZDz2l9SNl94TeTjx8kEoehP OLVV8AGHHK3pF6xmF08UKQK0H6VOIoESg8yk6ANIc3a9ApBl2EYX+/atsoq2xX4LcDHk=; Message-ID: Date: Tue, 26 Apr 2022 09:33:31 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH v4 1/2] x86/mem_sharing: make fork_reset more configurable To: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= , Tamas K Lengyel Cc: Tamas K Lengyel , xen-devel@lists.xenproject.org, Wei Liu , Anthony PERARD , Juergen Gross , Andrew Cooper , George Dunlap , Jan Beulich , Stefano Stabellini , Alexandru Isaila , Petre Pircalabu References: From: Julien Grall In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi, On 26/04/2022 09:17, Roger Pau Monné wrote: > On Mon, Apr 25, 2022 at 11:24:37AM -0400, Tamas K Lengyel wrote: >> On Mon, Apr 25, 2022 at 10:12 AM Roger Pau Monné wrote: >>>> diff --git a/xen/common/vm_event.c b/xen/common/vm_event.c >>>> index 84cf52636b..d26a6699fc 100644 >>>> --- a/xen/common/vm_event.c >>>> +++ b/xen/common/vm_event.c >>>> @@ -28,6 +28,11 @@ >>>> #include >>>> #include >>>> #include >>>> + >>>> +#ifdef CONFIG_MEM_SHARING >>>> +#include >>>> +#endif >>>> + >>>> #include >>>> #include >>>> >>>> @@ -394,6 +399,16 @@ static int vm_event_resume(struct domain *d, struct vm_event_domain *ved) >>>> if ( rsp.reason == VM_EVENT_REASON_MEM_PAGING ) >>>> p2m_mem_paging_resume(d, &rsp); >>>> #endif >>>> +#ifdef CONFIG_MEM_SHARING >>>> + if ( mem_sharing_is_fork(d) ) >>>> + { >>>> + bool reset_state = rsp.flags & VM_EVENT_FLAG_RESET_FORK_STATE; >>>> + bool reset_mem = rsp.flags & VM_EVENT_FLAG_RESET_FORK_MEMORY; >>>> + >>>> + if ( reset_state || reset_mem ) >>>> + ASSERT(!mem_sharing_fork_reset(d, reset_state, reset_mem)); >>> >>> Might be appropriate to destroy the domain in case fork reset fails? >>> ASSERT will only help in debug builds. >> >> No, I would prefer not destroying the domain here. If it ever becomes >> necessary the right way would be to introduce a new monitor event to >> signal an error and let the listener decide what to do. At the moment >> I don't see that being necessary as there are no known scenarios where >> we would be able to setup a fork but fail to reset is. > > My concern for raising this was what would happen on non-debug > builds if mem_sharing_fork_reset() failed, and hence my request to > crash the domain. I would have used something like: > > if ( (reset_state || reset_mem) && > mem_sharing_fork_reset(d, reset_state, reset_mem) ) > { > ASSERT_UNREACHABLE(); > domain_crash(d); > break; > } > > But if you and other vm_event maintainers are fine with the current > approach and don't think it's a problem that's OK with me. The current approach is actually not correct. On production build, ASSERT() will turn to NOP. IOW mem_sharing_fork_reset() *will* not be called. So the call needs to move outside of the ASSERT() and use a construct similar to what you suggested: if ( .... && mem_sharing_fork_reset(...) ) { ASSERT_UNREACHABLE(); break; } Cheers, -- Julien Grall