From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62481C2D0E5 for ; Wed, 25 Mar 2020 17:49:39 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 39534206F6 for ; Wed, 25 Mar 2020 17:49:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=tklengyel-com.20150623.gappssmtp.com header.i=@tklengyel-com.20150623.gappssmtp.com header.b="pwMH/ryi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 39534206F6 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=tklengyel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jHA8A-0001FL-8z; Wed, 25 Mar 2020 17:47:54 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jHA89-0001FG-4s for xen-devel@lists.xenproject.org; Wed, 25 Mar 2020 17:47:53 +0000 X-Inumbo-ID: bfdef046-6ec0-11ea-bec1-bc764e2007e4 Received: from mail-ed1-x542.google.com (unknown [2a00:1450:4864:20::542]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id bfdef046-6ec0-11ea-bec1-bc764e2007e4; Wed, 25 Mar 2020 17:47:52 +0000 (UTC) Received: by mail-ed1-x542.google.com with SMTP id i16so2660027edy.11 for ; Wed, 25 Mar 2020 10:47:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tklengyel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=Jlq3aSn1LLbtOLq22RUHlgaTqBIHopNWtX0qsj2oJIA=; b=pwMH/ryi8VM3ctGyqDLVHwNNgntGmhrSBRJZkm6LNEqbq/7gDHU8uRDBqAKcwX2Y5C 0qW/KgwLTvWDXi2DASaZ84LfB5AJygHBW+0DsNd7na+qKNNeC4Oi90XR6nKy4AK0XQiL j2FY3H8zyczOVO0fdJzhp3gYqP9LSr0kOxoPFArc09x59G1Ui1r6EC0pq7+UrOfG4h+9 AQD8tP1AbYs0/bXaB3vM+NOwG8OivlyZ6j0YLayA2xjzGyN6X4x3H79ZnDn+8NQ0vDw+ sGVv4HDGZkZ7lJdgzfYc+akhlu3/eYc8pDgk41tNAv80qtoL/a7DUEIOhO/B9C1xgbXh Sy1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=Jlq3aSn1LLbtOLq22RUHlgaTqBIHopNWtX0qsj2oJIA=; b=nLn/qShipHZv+1Vaf8GOFulDwD+aRlENMavETnkf/32vFsYJ1K+rzI16KCvrmaYcPf PkpzJh2p9gP+Y/+vuNDW44S6KWiSzVHCcFXr5mYszndU3MtRyjwDeKHGiCp0Tj30mEKJ iahAme+awj9maXCbp977SzlBvRsbH2CKxEkGapSmtp++5b5QHt3RaV9MOADqD/M4JROC uwD/2ewoBfoOOl6tzzoZpMugRYo2P6ySkdg0hNvHDOBcIRLoO4Z138S1uhcCgOuDFxXO MkNpv0qhCkaqq2dqBs/5mC7oR/zyGyjMwwXpcJzEAKWn8gqdrTkpEf9vyolrvB+fRDa1 q07g== X-Gm-Message-State: ANhLgQ2NCXHBvpdggEvEEeB0VoBqmp+lpqutC6+Y6lqG2UFT4XAI682u xUwHtNVHIFs5iinMc73yxtjMCIYxg3o= X-Google-Smtp-Source: ADFU+vsewS/Ab3L3A+x1Xg1rh6V00vYijah275SvYhF0yenLw1WUkbMkJKIw5L3zCZF3uGct9Iwt6g== X-Received: by 2002:a17:906:ccdd:: with SMTP id ot29mr1471924ejb.144.1585158471191; Wed, 25 Mar 2020 10:47:51 -0700 (PDT) Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com. [209.85.221.47]) by smtp.gmail.com with ESMTPSA id t24sm1637945edy.94.2020.03.25.10.47.48 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 25 Mar 2020 10:47:49 -0700 (PDT) Received: by mail-wr1-f47.google.com with SMTP id 65so4340808wrl.1 for ; Wed, 25 Mar 2020 10:47:48 -0700 (PDT) X-Received: by 2002:a5d:640a:: with SMTP id z10mr4893863wru.301.1585158468376; Wed, 25 Mar 2020 10:47:48 -0700 (PDT) MIME-Version: 1.0 References: <20200325154702.GD28601@Air-de-Roger> <95a7c1bf-9b2f-f0e8-1463-3cf8afb74041@xen.org> <20200325171627.GG28601@Air-de-Roger> In-Reply-To: <20200325171627.GG28601@Air-de-Roger> From: Tamas K Lengyel Date: Wed, 25 Mar 2020 11:47:11 -0600 X-Gmail-Original-Message-ID: Message-ID: To: =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [Xen-devel] [PATCH v12 1/3] xen/mem_sharing: VM forking X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Tamas K Lengyel , Wei Liu , Andrew Cooper , Ian Jackson , George Dunlap , Jan Beulich , Xen-devel , Julien Grall Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" On Wed, Mar 25, 2020 at 11:16 AM Roger Pau Monn=C3=A9 wrote: > > On Wed, Mar 25, 2020 at 11:00:05AM -0600, Tamas K Lengyel wrote: > > On Wed, Mar 25, 2020 at 10:52 AM Julien Grall wrote: > > > > > > > > > > > > On 25/03/2020 16:47, Tamas K Lengyel wrote: > > > > On Wed, Mar 25, 2020 at 10:42 AM Julien Grall wrot= e: > > > >> > > > >> Hi, > > > >> > > > >> On 25/03/2020 16:34, Tamas K Lengyel wrote: > > > >>>>> diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c > > > >>>>> index 9f51370327..1ed7d13084 100644 > > > >>>>> --- a/xen/arch/x86/mm/p2m.c > > > >>>>> +++ b/xen/arch/x86/mm/p2m.c > > > >>>>> @@ -509,6 +509,12 @@ mfn_t __get_gfn_type_access(struct p2m_dom= ain *p2m, unsigned long gfn_l, > > > >>>>> > > > >>>>> mfn =3D p2m->get_entry(p2m, gfn, t, a, q, page_order, NU= LL); > > > >>>>> > > > >>>>> + /* Check if we need to fork the page */ > > > >>>>> + if ( (q & P2M_ALLOC) && p2m_is_hole(*t) && > > > >>>>> + !mem_sharing_fork_page(p2m->domain, gfn, q & P2M_UNSH= ARE) ) > > > >>>>> + mfn =3D p2m->get_entry(p2m, gfn, t, a, q, page_order, = NULL); > > > >>>>> + > > > >>>>> + /* Check if we need to unshare the page */ > > > >>>>> if ( (q & P2M_UNSHARE) && p2m_is_shared(*t) ) > > > >>>>> { > > > >>>>> ASSERT(p2m_is_hostp2m(p2m)); > > > >>>>> @@ -588,7 +594,8 @@ struct page_info *p2m_get_page_from_gfn( > > > >>>>> return page; > > > >>>>> > > > >>>>> /* Error path: not a suitable GFN at all */ > > > >>>>> - if ( !p2m_is_ram(*t) && !p2m_is_paging(*t) && !p2m_is_= pod(*t) ) > > > >>>>> + if ( !p2m_is_ram(*t) && !p2m_is_paging(*t) && !p2m_is_= pod(*t) && > > > >>>>> + !mem_sharing_is_fork(p2m->domain) ) > > > >>>>> return NULL; > > > >>>>> } > > > >>>>> > > > >>>>> diff --git a/xen/common/domain.c b/xen/common/domain.c > > > >>>>> index b4eb476a9c..62aed53a16 100644 > > > >>>>> --- a/xen/common/domain.c > > > >>>>> +++ b/xen/common/domain.c > > > >>>>> @@ -1270,6 +1270,9 @@ int map_vcpu_info(struct vcpu *v, unsigne= d long gfn, unsigned offset) > > > >>>>> > > > >>>>> v->vcpu_info =3D new_info; > > > >>>>> v->vcpu_info_mfn =3D page_to_mfn(page); > > > >>>>> +#ifdef CONFIG_MEM_SHARING > > > >>>>> + v->vcpu_info_offset =3D offset; > > > >>>> > > > >>>> There's no need to introduce this field, you can just use v->vcp= u_info > > > >>>> & ~PAGE_MASK AFAICT. > > > >>> > > > >>> Just doing what you suggest above results in: > > > >>> > > > >>> mem_sharing.c:1603:55: error: invalid operands to binary & (have > > > >>> =E2=80=98vcpu_info_t * const=E2=80=99 {aka =E2=80=98union * const=E2=80=99} and =E2=80=98long > > > >>> int=E2=80=99) > > > >>> d_vcpu->vcpu_info & ~PAGE_= MASK); > > > >>> > > > >>> I can of course cast the vcpu_info pointer to (long int), it's ju= st a > > > >>> bit ugly. Thoughts? > > > >> > > > >> FWIW, I will also need the offset for liveupdate. I have used (uns= igned > > > >> long)v->vcpu_info & ~PAGE_MASK so far but this is not really prett= y. > > > >> > > > >> So I am all for either a new field or a macro hiding this uglyness= . > > > > > > > > A macro sounds like a good way to go, no need for an extra field if= we > > > > can calculate it based on the currently existing one. How about > > > > > > > > #define VCPU_INFO_OFFSET(v) (((unsigned long)v->vcpu_info) & ~PAGE_= MASK) > > > > > > I was more thinking a generic macro to find the offset in a page. > > > > > > PAGE_OFFSET(ptr) ((unsigned long)(ptr) & ~PAGE_MASK) > > > > LGTM. Should we stuff this into xen/sched.h or asm/page.h? > > page.h would be better, albeit you will have to duplicate it for x86 > and Arm. There's xen/pfn.h which is not arch specific, but feels a bit > weird to place it there. > I'll go with page.h, that allows us to use vaddr_t for the ARM macro. Tamas