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=-11.4 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham 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 9A01BC4363D for ; Tue, 22 Sep 2020 17:54:17 +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 3010D2376F for ; Tue, 22 Sep 2020 17:54:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=xen.org header.i=@xen.org header.b="QO9fsf2w" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3010D2376F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org 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.92) (envelope-from ) id 1kKmUD-0004vD-1O; Tue, 22 Sep 2020 17:53:53 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kKmUB-0004v3-J0 for xen-devel@lists.xenproject.org; Tue, 22 Sep 2020 17:53:51 +0000 X-Inumbo-ID: 6592c694-0972-44d6-9430-f54c34c62f71 Received: from mail.xenproject.org (unknown [104.130.215.37]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 6592c694-0972-44d6-9430-f54c34c62f71; Tue, 22 Sep 2020 17:53:50 +0000 (UTC) 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: MIME-Version:Date:Message-ID:From:References:Cc:To:Subject; bh=IVLxWPcWbQZyI71ViTcgQRMO0JlDsa1VVDmwU519uUA=; b=QO9fsf2w829iJGORngMe6dXx9H LZTI4aJRZ5Jst/O8w/Ag2JuVR9HAYBifpxyFOoAxu795TXCLSVUcYn/khT+R4xbKFaoYzqKP7sja6 3y2FtvHt9lxCv4UUkyhZY9b+Ly9o5Ta8HEMHJAtpFovHW075VYlZ8D8vD3NZVBTU7aOo=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kKmU5-0004jS-Ut; Tue, 22 Sep 2020 17:53:45 +0000 Received: from [54.239.6.185] (helo=a483e7b01a66.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kKmU5-0003AI-Mx; Tue, 22 Sep 2020 17:53:45 +0000 Subject: Re: [PATCH v4 1/4] xen: XENMEM_exchange should only be used/compiled for arch supporting PV guest To: Andrew Cooper , xen-devel@lists.xenproject.org Cc: Julien Grall , George Dunlap , Ian Jackson , Jan Beulich , Stefano Stabellini , Wei Liu References: <20200921180214.4842-1-julien@xen.org> <20200921180214.4842-2-julien@xen.org> <6e22ec07-d489-33dc-62e7-415e760bb3ea@citrix.com> From: Julien Grall Message-ID: <19b0a5af-a4f1-0058-1e36-e4ceaf18216a@xen.org> Date: Tue, 22 Sep 2020 18:53:43 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <6e22ec07-d489-33dc-62e7-415e760bb3ea@citrix.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Hi Andrew, On 21/09/2020 20:46, Andrew Cooper wrote: > On 21/09/2020 19:02, Julien Grall wrote: >> From: Julien Grall >> >> XENMEM_exchange can only be used by PV guest but the check is well >> hidden in steal_page(). This is because paging_model_external() will >> return false only for PV domain. >> >> To make clearer this is PV only, add a check at the beginning of the >> implementation. Take the opportunity to compile out the code if >> CONFIG_PV is not set. >> >> This change will also help a follow-up patch where the gmfn_mfn() will >> be completely removed on arch not supporting the M2P. >> >> Signed-off-by: Julien Grall >> >> --- >> >> Jan suggested to #ifdef anything after the check to is_pv_domain(). >> However, it means to have two block of #ifdef as we can't mix >> declaration and code. >> >> I am actually thinking to move the implementation outside of mm.c in >> possibly arch/x86 or a pv specific directory under common. Any opinion? > > arch/x86/pv/mm.c, with the case XENMEM_exchange: moving into > arch_memory_op(). > > However, making this happen is incredibly tangled, and we're years > overdue a fix here. > > Lets go with this for now, and tidying up can come later. > > Acked-by: Andrew Cooper , however... Thanks! > >> >> Changes in v4: >> - Patch added >> --- >> xen/common/memory.c | 7 +++++++ >> 1 file changed, 7 insertions(+) >> >> diff --git a/xen/common/memory.c b/xen/common/memory.c >> index 714077c1e597..9300104943b0 100644 >> --- a/xen/common/memory.c >> +++ b/xen/common/memory.c >> @@ -504,6 +504,7 @@ static bool propagate_node(unsigned int xmf, unsigned int *memflags) >> >> static long memory_exchange(XEN_GUEST_HANDLE_PARAM(xen_memory_exchange_t) arg) >> { >> +#ifdef CONFIG_PV >> struct xen_memory_exchange exch; >> PAGE_LIST_HEAD(in_chunk_list); >> PAGE_LIST_HEAD(out_chunk_list); >> @@ -516,6 +517,9 @@ static long memory_exchange(XEN_GUEST_HANDLE_PARAM(xen_memory_exchange_t) arg) >> struct domain *d; >> struct page_info *page; >> >> + if ( !is_pv_domain(d) ) >> + return -EOPNOTSUPP; >> + >> if ( copy_from_guest(&exch, arg, 1) ) >> return -EFAULT; >> >> @@ -797,6 +801,9 @@ static long memory_exchange(XEN_GUEST_HANDLE_PARAM(xen_memory_exchange_t) arg) > > ... there are now a load of #ifdef CONFIG_X86 between these two hunks > which can be dropped. I didn't drop them because I wasn't sure whether we wanted to cater future arch. Anyway, I am happy to do the cleanup :). Cheers, -- Julien Grall