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=-4.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 8EC12C4338F for ; Sat, 7 Aug 2021 17:04:14 +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 305B160462 for ; Sat, 7 Aug 2021 17:04:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 305B160462 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.164860.301276 (Exim 4.92) (envelope-from ) id 1mCPji-00011Q-9F; Sat, 07 Aug 2021 17:03:50 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 164860.301276; Sat, 07 Aug 2021 17:03:50 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mCPji-00011J-5I; Sat, 07 Aug 2021 17:03:50 +0000 Received: by outflank-mailman (input) for mailman id 164860; Sat, 07 Aug 2021 17:03:49 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mCPjh-00011D-CF for xen-devel@lists.xenproject.org; Sat, 07 Aug 2021 17:03:49 +0000 Received: from mail-lf1-x134.google.com (unknown [2a00:1450:4864:20::134]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 7e604098-58f9-41d5-a617-b16981a3ba08; Sat, 07 Aug 2021 17:03:47 +0000 (UTC) Received: by mail-lf1-x134.google.com with SMTP id u3so24724703lff.9 for ; Sat, 07 Aug 2021 10:03:47 -0700 (PDT) Received: from [192.168.1.7] ([212.22.223.21]) by smtp.gmail.com with ESMTPSA id e17sm988469ljg.61.2021.08.07.10.03.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 07 Aug 2021 10:03:46 -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: 7e604098-58f9-41d5-a617-b16981a3ba08 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=O5zwWnT/42l8E5X7sQOIY0zNo0b+w3uVHD2pGQ7GRfU=; b=ARXrOkx8lxk4LKsVt9lrYGFbqJtbR58VPnX/J+Recn4Vow5GzVsyAJ3ta2oGDNgTuC NDfKM6sbS1/FvXJkUayhbEG1vhlTuIQbSTbkaBgIYdv9mpNBTdGLPpnN+hn//mmvW4ut LK4EWQcMwYeaVAUnY++j8Kr22EXgm+ZT1+EhxVcJxkSQQox0+of6bkEFBE8Pz6cmN7tl W3/NdtOR0I3vA1DjAt8/qLFhR9Pb4HyUGr5dMwZNr2ZPgaI+WOpJ7GQNCKsVENIHLn7M 5kn+EH0cuMhEO2Pjx1YRrsopA2UIRzTSOilsoR3eT8nGTruqJe/RZ9LB1hrlqKo7ZQx0 e3dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=O5zwWnT/42l8E5X7sQOIY0zNo0b+w3uVHD2pGQ7GRfU=; b=OSCVrmQStM6VJcCw7odwo+g7RKIM4HPSnfBTYQOoIdc3IIENCYz5R/PWAHgbckj4HR gnRw0UPCnjNDLOC4Cf1z1ISvZUdBT7xS1j8S9kgBXuzozRzGM/LeTYmm+vHWv8v3b+QH NURagSK8rf8dJLEiwFTXlSIpt8TP/YjcOx+XUSChKj+xkJ6FMi+YmBq9UbjdoXrSkzcb 8PKjbvIyGNzNYhR7LngI0yw8APIzqMjNTkeXMd8MQ2hjw1uCxD0cNajGZSTjg6HfXIJc GNbbQ8CFN6Syfl8i8RD77IdsIPiL/t489p+goPs8IyvXQMGcyMWJc38gczcWp18JMJO1 JwUw== X-Gm-Message-State: AOAM5339lxMeH/48fgOocgBsCClUczj2whMx4hKDn7YIRq6X1Q0PX1CL DndEQ5gNYUISXnkeVRmLyC4= X-Google-Smtp-Source: ABdhPJxj0tf5JxthyCbht1aOFQzi+x/yt8+xQX2ldcl5v1Qf8llt/0rR/hNl2BPyrJqQl98phSVB3A== X-Received: by 2002:ac2:4119:: with SMTP id b25mr12246256lfi.284.1628355826642; Sat, 07 Aug 2021 10:03:46 -0700 (PDT) Subject: Re: [RFC PATCH] xen/memory: Introduce a hypercall to provide unallocated space To: Stefano Stabellini Cc: Julien Grall , Andrew Cooper , xen-devel@lists.xenproject.org, Oleksandr Tyshchenko , Daniel De Graaf , "Daniel P. Smith" , Ian Jackson , Wei Liu , George Dunlap , Jan Beulich , Volodymyr Babchuk , =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= , Bertrand Marquis , Wei Chen References: <1627489110-25633-1-git-send-email-olekstysh@gmail.com> <80fafc01-f063-d6e5-1c08-7ad64550310c@citrix.com> <4de5ed21-379e-b618-44c8-924d88b1a519@citrix.com> <6a633f4e-13e0-4a2b-cf6e-35ef90ae977c@gmail.com> <5643d414-0b76-74a4-2c37-c7a99338d547@gmail.com> From: Oleksandr Message-ID: <6596ad08-8398-64dd-ef62-cd7bc6f7333e@gmail.com> Date: Sat, 7 Aug 2021 20:03:44 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US On 06.08.21 03:30, Stefano Stabellini wrote: Hi Stefano > On Wed, 4 Aug 2021, Julien Grall wrote: >>> +#define GUEST_SAFE_RANGE_BASE   xen_mk_ullong(0xDE00000000) /* 128GB */ >>> +#define GUEST_SAFE_RANGE_SIZE   xen_mk_ullong(0x0200000000) >>> >>> While the possible new DT bindings has not been agreed yet, I re-used >>> existing "reg" property under the hypervisor node to pass safe range as a >>> second region, >>> https://elixir.bootlin.com/linux/v5.14-rc4/source/Documentation/devicetree/bindings/arm/xen.txt#L10: >> So a single region works for a guest today, but for dom0 we will need multiple >> regions because it is may be difficult to find enough contiguous space for a >> single region. >> >> That said, as dom0 is mapped 1:1 (including some guest mapping), there is also >> the question where to allocate the safe region. For grant table, we so far >> re-use the Xen address space because it is assumed it will space will always >> be bigger than the grant table. >> >> I am not sure yet where we could allocate the safe regions. Stefano, do you >> have any ideas? > The safest choice would be the address range corresponding to memory > (/memory) not already allocated to Dom0. > > For instance from my last boot logs: > (XEN) Allocating 1:1 mappings totalling 1600MB for dom0: > (XEN) BANK[0] 0x00000010000000-0x00000070000000 (1536MB) > (XEN) BANK[1] 0x00000078000000-0x0000007c000000 (64MB) > > All the other ranges could be given as unallocated space: > > - 0x0 - 0x10000000 > - 0x70000000 - 0x78000000 > - 0x8_0000_0000 - 0x8_8000_0000 Thank you for the ideas. If I got the idea correctly, yes, as these ranges represent the real RAM, so no I/O would be in conflict with them and as the result - no overlaps would be expected. But, I wonder, would this work if we have IOMMU enabled for Dom0 and need to establish 1:1 mapping for the DMA devices to work with grant mappings... In arm_iommu_map_page() we call guest_physmap_add_entry() with gfn = mfn, so the question is could we end up with this new gfn replacing the valid mapping (with gfn allocated from the safe region)? > > > > The second best choice would be an hole: an address range not used by > anybody else (no reg property) and also not even mappable by a bus (not > covered by a ranges property). This is not the best choice because there > can cases where physical resources appear afterwards. Unfortunately, yes. -- Regards, Oleksandr Tyshchenko