[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Arm: tighten translate_get_page()


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: "Orzel, Michal" <michal.orzel@xxxxxxx>
  • Date: Wed, 18 Feb 2026 09:36:45 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=suse.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=GDhqwGjgmTtz/7TbZy83bZITtVkDy+KvULq8YDdE1pg=; b=KIbIn7/hl98q+8Ybj0r0Y8n4FmuRCRplKvo47UmZDK/haVOrGKYUYPty6pLvRMEFDKecA/EWUuyqY99UgxX2LR0SIMQEUyxOLBr1Jrn5zvL9mqlwV6+BAi5G+a+zXSbQXeguISouwsT4PBfwujlvS2c+2/3GtbfoxJy0bdCRyIVViIY+Kc5lXkV6pn8hpvgAWgBQu0P4/DxtrobmjIbtTcl8bL7ecsatSLW33Re3ykGlXv9rMuYoOJkdCDqA3b8gsxOFImi2vro+o8AfHlONm+N+jXPqPebJavL71+rVKrIJe0BgQA5bj4IHc5hobkhjmc0Yzhl1VWeRqT1R+NV54Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ikxP/czm00Q+XewO3o/1YNG6mfvGcIxW7MeVdNgKIM1vw2/wTqCuXFqHEG4tHrqyZWea+/Om0D96XOcqqc1D4xjOrfErZnES/U5RUjGINhMsCFuD/DlCxoyikZ/YY5CAZkuoLviI/7AIW/7azFvivdDhjWTDDxjA0h2lFhmRg7SeoPVlDBz1fHYhKSvFnzFQnT1kjtxhYwVcz0lzPonrL/HfUc2+s/gudUQ9Tgq9nvHjXBuuRiAbnsxMWbcLZxkZTqMu/ba3LcBxyMrKmM76V1sQIC28qZUOE43EqXvxBiKK0mkCzCUf+7qrb1MuntmQspAOcp8KhxkFPyja+RhPcQ==
  • Cc: Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Volodymyr Babchuk <volodymyr_babchuk@xxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Wed, 18 Feb 2026 08:37:12 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>


On 17/02/2026 16:54, Jan Beulich wrote:
> On 17.02.2026 16:28, Orzel, Michal wrote:
>>
>>
>> On 16/02/2026 16:20, Jan Beulich wrote:
>>> Permitting writes when the P2M type says "read-only" can't be correct.
>>>
>>> Fixes: 1661158723a ("xen/arm: Extend copy_to_guest to support copying 
>>> from/to guest physical address")
>>> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
>> Reviewed-by: Michal Orzel <michal.orzel@xxxxxxx>
> 
> Thanks.
> 
>>> ---
>>> What exactly p2m_ram_ro means on Arm is unclear: The comment next to its
>>> definition says one thing, its use in get_page_from_gfn() says another.
>>> (I remember raising this point before, i.e. it feels a little odd that the
>>> ambiguity still exists.) The patch here assumes the comment is what is
>>> wrong.
>>>
>>> --- a/xen/arch/arm/guestcopy.c
>>> +++ b/xen/arch/arm/guestcopy.c
>>> @@ -44,7 +44,7 @@ static struct page_info *translate_get_p
>>>      if ( !page )
>>>          return NULL;
>>>  
>>> -    if ( !p2m_is_ram(p2mt) )
>>> +    if ( write ? p2mt != p2m_ram_rw : !p2m_is_ram(p2mt) )
>>>      {
>>>          put_page(page);
>>>          return NULL;
>>
>> The ambiguity you mention is indeed problematic. This mixes page type with 
>> p2m
>> type. The comment "The p2m_type is based on the type of the page" admits this
>> conflation for DOMID_XEN.
>>
>> AFAICT, p2m_ram_ro is not used on Arm for normal domains. The only use is in
>> get_page_from_gfn() for DOMID_XEN. Maybe we could change get_page_from_gfn() 
>> to
>> always return p2m_ram_rw since DOMID_XEN has direct 1:1 access anyway?
> 
> But that's not correct for cases where share_xen_page_with_privileged_guest()
> is passed SHARE_ro. XENMAPSPACE_gmfn_foreign requests have to result in r/o
> mappings in that case.
Yes. Therefore, on Arm:
- p2m_ram_ro is never stored in P2M tables for normal domains
- it's only used by get_page_from_gfn() for DOMID_XEN pages
- it's used as a signal to install p2m_map_foreign_ro mappings

The code should stay as is then and we could modify the comment to say:
/* Read-only RAM; only used for DOMID_XEN */

~Michal




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.