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=-12.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,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 80DBBC4338F for ; Thu, 5 Aug 2021 16:38:05 +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 30CC361050 for ; Thu, 5 Aug 2021 16:38:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 30CC361050 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=apertussolutions.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.164494.300805 (Exim 4.92) (envelope-from ) id 1mBgNI-000553-45; Thu, 05 Aug 2021 16:37:40 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 164494.300805; Thu, 05 Aug 2021 16:37: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 1mBgNI-00054w-06; Thu, 05 Aug 2021 16:37:40 +0000 Received: by outflank-mailman (input) for mailman id 164494; Thu, 05 Aug 2021 16:37:39 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mBgNH-00054q-Fg for xen-devel@lists.xenproject.org; Thu, 05 Aug 2021 16:37:39 +0000 Received: from sender4-of-o51.zoho.com (unknown [136.143.188.51]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 3e1a6901-367a-4edf-85c3-08b534a4ed47; Thu, 05 Aug 2021 16:37:38 +0000 (UTC) Received: from [10.10.1.24] (static-72-81-132-2.bltmmd.fios.verizon.net [72.81.132.2]) by mx.zohomail.com with SMTPS id 1628181447491448.4037791473961; Thu, 5 Aug 2021 09:37:27 -0700 (PDT) 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" X-Inumbo-ID: 3e1a6901-367a-4edf-85c3-08b534a4ed47 ARC-Seal: i=1; a=rsa-sha256; t=1628181452; cv=none; d=zohomail.com; s=zohoarc; b=b9FNzdBERyOS/rb+yqbsYaY/XNLw4z2jaJLE8dLGxFtSC5HpXBZdyDhGXyRVgdhG12LUH0HZOZvGBeChKi29aPlpyKHgm4H6GyGpYqfJTN1vTGa5yboVKFIeiSQQF8R46r/hWux6SU/jMmW10ZVGCs1Sl4qOwo/W8nBjEPVU+Dc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628181452; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=Qa4584XltKHjJ1wQAT6FGYfNLVVWGTyVkOKd1H6WQs4=; b=EHdYQQxWa54PWxV6FDST0DKiHjq0a4QCThPBqaVf7dLQzW8bAZrOYRcRiQ/H9wISVUWIzlX/Z+5eeNVGorG1EFbazhSGWlvM89x3Uc6GgM6SwgtSoK/ZgmwTMMLY1IEi0s1xlfsupaVGnUwpR8OkXvtAnEyc6ACr0CrDf/Qx4qc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1628181452; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=To:Cc:References:From:Subject:Message-ID:Date:MIME-Version:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=Qa4584XltKHjJ1wQAT6FGYfNLVVWGTyVkOKd1H6WQs4=; b=qSeBcreSxo1ZUr1SUXXSpBGPYPeBCQG6iu6Im/O9oLrML1784vjX5IsUTA4hfFes EaEK1Hsa+c35jpCvFtEole/ft8ONdA5drsGEYLvCenOOEjUEmT+fAXcBSP0LuPi7e3t Jlkos1B6XTUjrb4KzZqWVGv7ZeeAYx5t5CVOIakc= To: Oleksandr Cc: xen-devel@lists.xenproject.org, Oleksandr Tyshchenko , Daniel De Graaf , Ian Jackson , Wei Liu , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Volodymyr Babchuk , =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= , Bertrand Marquis , Wei Chen References: <1627489110-25633-1-git-send-email-olekstysh@gmail.com> <6e573489-ceb7-03f4-3511-e6c166b318a6@apertussolutions.com> From: "Daniel P. Smith" Subject: Re: [RFC PATCH] xen/memory: Introduce a hypercall to provide unallocated space Message-ID: Date: Thu, 5 Aug 2021 12:37:25 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-ZohoMailClient: External Hey Oleksandr! On 8/5/21 11:59 AM, Oleksandr wrote: > > On 05.08.21 18:03, Daniel P. Smith wrote: > > Hi Daniel. > >> On 7/28/21 12:18 PM, Oleksandr Tyshchenko wrote: >>> From: Oleksandr Tyshchenko >> ... >> >>> diff --git a/xen/common/memory.c b/xen/common/memory.c >>> index e07bd9a..3f9b816 100644 >>> --- a/xen/common/memory.c >>> +++ b/xen/common/memory.c >>> @@ -1811,6 +1811,62 @@ long do_memory_op(unsigned long cmd, >>> XEN_GUEST_HANDLE_PARAM(void) arg) >>>               start_extent); >>>           break; >>>   +    case XENMEM_get_unallocated_space: >>> +    { >>> +        struct xen_get_unallocated_space xgus; >>> +        struct xen_unallocated_region *regions; >>> + >>> +        if ( unlikely(start_extent) ) >>> +            return -EINVAL; >>> + >>> +        if ( copy_from_guest(&xgus, arg, 1) || >>> +             !guest_handle_okay(xgus.buffer, xgus.nr_regions) ) >>> +            return -EFAULT; >>> + >>> +        d = rcu_lock_domain_by_any_id(xgus.domid); >>> +        if ( d == NULL ) >>> +            return -ESRCH; >>> + >>> +        rc = xsm_get_unallocated_space(XSM_HOOK, d); >> Not sure if you are aware but XSM_HOOK is a no-op check, meaning that >> you are allowing any domain to do this operation on any other domain. In >> most cases there is an XSM check at the beginning of the hypercall >> processing to do an initial clamp down but I am pretty sure there is no >> prior XSM check on this path. Based on my understanding of how this is >> intended, which may be incorrect, but I think you would actually want >> XSM_TARGET.the > Thank you for pointing this out. > I am aware what the XSM_HOOK is, but I was thinking what the default > action would be better suited for that hypercall, and failed to think of > a better alternative. > I was going to choose XSM_TARGET, but the description "/* Can perform on > self or your target domain */" confused me a bit, as there was no target > domain involved as I thought, XSM_PRIV > sounded too strictly to me, etc. So, I decided to leave a "hook" for the > RFC version. But, now I see that XSM_TARGET might be indeed better > choice across all possible variants. If you unravel the craftiness that is xsm_default_action, there is actually a bit of hierarchy there. If you set the default_action to XSM_TARGET, it will first check if calling domain(src) is the target, then falls into the XSM_DM_PRIV check which is if src->target == target, and then finally checks if is_control_domain(src). That will constrict the operation so that a domain can call it on itself, a device model domain (stubdom) can call it on the domain it is backing, and the control domain can make the call. I am not a 100% sure on this but I do not believe a hardware domain would be able to make the call with it set to XSM_TARGET and not employing Flask. Hope this helps.