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 6D557E68169 for ; Tue, 17 Feb 2026 10:40:32 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.1234786.1537902 (Exim 4.92) (envelope-from ) id 1vsIV6-0007q3-13; Tue, 17 Feb 2026 10:40:16 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1234786.1537902; Tue, 17 Feb 2026 10:40:16 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vsIV5-0007pw-UV; Tue, 17 Feb 2026 10:40:15 +0000 Received: by outflank-mailman (input) for mailman id 1234786; Tue, 17 Feb 2026 10:40:14 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vsIV4-0006sb-RW for xen-devel@lists.xenproject.org; Tue, 17 Feb 2026 10:40:14 +0000 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [2a00:1450:4864:20::42c]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 0a84cf2a-0bed-11f1-b164-2bf370ae4941; Tue, 17 Feb 2026 11:40:13 +0100 (CET) Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-4359a302794so2879091f8f.1 for ; Tue, 17 Feb 2026 02:40:13 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48370a78c89sm326708785e9.5.2026.02.17.02.40.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 17 Feb 2026 02:40:12 -0800 (PST) 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: 0a84cf2a-0bed-11f1-b164-2bf370ae4941 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1771324813; x=1771929613; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=jhRM5XYO45exmyR3bTfVssls7DqrhYBlqXmOgp9F1Iw=; b=VWlrIDaaez3w0ddOdEXOqAh6EbVaUNjoGGz8f7PqiK2lbO3bzN/xpvsyS4UvsEzutx L0zsMriegCMaab7F3BBLO0Kz2aYUfniS/LSFVN/SdYK6i+11Nrrk/AWkbxXXUnVKy/iP BY46jYWBQ0SSiI0mpxrMGUh+KVqpPR5QznqBufKNI+jh60juiD+IO+2eJYSQvLG+3Uz6 kCE+OpSut1dXTTv9iq2SnMp+NX2h3ugQIdbwDhkFYaUFKuDsDVOU2GE3DPZWzQVZJP5D ss55ufjpNDLZEqGtAxpmwSmqvU9aKGUTRObyFGFziURdQ5WJpXtoNlzOpAVLXCGhqnW9 I4lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771324813; x=1771929613; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=jhRM5XYO45exmyR3bTfVssls7DqrhYBlqXmOgp9F1Iw=; b=LTpyvixP4SMroKfcHMmfdAqIE/htdyBb5dKQHE7SfYGcKKko2JTKPGX9kpIIIdHQbw eA4lMHwCWCjk1g+T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Received: by 2002:a05:600c:8b30:b0:480:1c69:9d36 with SMTP id 5b1f17b1804b1-48379bd7462mr189936365e9.17.1771324813089; Tue, 17 Feb 2026 02:40:13 -0800 (PST) Message-ID: Date: Tue, 17 Feb 2026 11:40:10 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 1/6] xen/riscv: implement get_page_from_gfn() To: Oleksii Kurochko Cc: Romain Caritey , Alistair Francis , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Julien Grall , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= , Stefano Stabellini , xen-devel@lists.xenproject.org References: <04eee3ae5e8aadf8c7f0b873ba24ce38220e8fa2.1770821989.git.oleksii.kurochko@gmail.com> <349ad398-8a18-46cc-a34b-576edfb544c0@suse.com> <5146fc56-9fa7-49c9-8184-954ca84eb439@gmail.com> Content-Language: en-US From: Jan Beulich Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <5146fc56-9fa7-49c9-8184-954ca84eb439@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 17.02.2026 10:58, Oleksii Kurochko wrote: > > On 2/17/26 10:10 AM, Jan Beulich wrote: >> On 17.02.2026 10:01, Oleksii Kurochko wrote: >>> On 2/16/26 1:38 PM, Jan Beulich wrote: >>>> On 12.02.2026 17:21, Oleksii Kurochko wrote: >>>>> --- a/xen/arch/riscv/p2m.c >>>>> +++ b/xen/arch/riscv/p2m.c >>>>> @@ -1557,3 +1557,31 @@ void p2m_handle_vmenter(void) >>>>> flush_tlb_guest_local(); >>>>> } >>>>> } >>>>> + >>>>> +struct page_info *get_page_from_gfn(struct domain *d, unsigned long gfn, >>>>> + p2m_type_t *t, p2m_query_t q) >>>>> +{ >>>>> + struct page_info *page; >>>>> + >>>>> + /* >>>>> + * Special case for DOMID_XEN as it is the only domain so far that is >>>>> + * not auto-translated. >>>>> + */ >>>> Once again something taken verbatim from Arm. Yes, dom_xen can in fact appear >>>> here, but it's not a real domain, has no memory truly assigned to it, has no >>>> GFN space, and hence calling it translated (or not) is simply wrong (at best: >>>> misleading). IOW ... >>>> >>>>> + if ( likely(d != dom_xen) ) >>>>> + return p2m_get_page_from_gfn(p2m_get_hostp2m(d), _gfn(gfn), t); >>>>> + >>>>> + /* Non-translated guests see 1-1 RAM / MMIO mappings everywhere */ >>>> ... this comment would also want re-wording. >>> As you mentioned in the another reply to this patch, I messed up x86 and Arm >>> implementation in a bad way, so here should be DOMID_XEN used instead of >>> "Non-translated". >>> >>> Based on your reply it seems like the first comment should be also rephrased >>> as you mentioned that DOMID_XEN can't be called also "not auto-translated". >>> I think it would be better to write the following: >>> /* >>> * Special case for DOMID_XEN as it is the only domain so far that has >>> * no GFN space. >>> */ >> Simply say that dom_xen isn't a "normal" domain? >> >>>>> + if ( t ) >>>>> + *t = p2m_invalid; >>>>> + >>>>> + page = mfn_to_page(_mfn(gfn)); >>>>> + >>>>> + if ( !mfn_valid(_mfn(gfn)) || !get_page(page, d) ) >>>>> + return NULL; >>>>> + >>>>> + if ( t ) >>>>> + *t = likely(d != dom_io) ? p2m_ram_rw : p2m_mmio_direct_io; >>>> If only dom_xen can make it here, why the check for dom_io? >>> Incorrectly copied from x86. It should be just: >>> *t = p2m_ram_rw >>> here as in RISC-V for MMIO pages owner isn't set to dom_io (and the same is >>> true for Arm I think). >> May I suggest that right away you use the construct that I suggested Arm to >> switch to (you were Cc-ed on that patch, I think)? Despite the absence of >> p2m_ram_ro on RISC-V, that'll be usable, and it will allow keeping the code >> untouched when p2m_ram_ro is introduced (sooner or later you will need it, >> I expect). > > Sure, but doesn't that patch is connected to another function (translate_get_page()) > and just fixing the handling of what get_page_from_gfn() in *t? Oh, sorry, I should have made explicit that the request was for patch 2. Here indeed ... > For get_page_from_gfn() to not miss the case when new type is introduced it make > sense to do the following: > if ( page->u.inuse.type_info & PGT_writable_page ) > *t = p2m_ram_rw; > else > BUG_ON("unimplemented"); ... this may be the best you can do right now (unless you want to introduce p2m_ram_ro). Jan