From nobody Mon Apr 13 00:06:08 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1775836545; cv=none; d=zohomail.com; s=zohoarc; b=Pg3LEpwicHo+0gehK52MYQDH2mPkkUaWMS59H6UOOLdm5XKbbvbYjYLOibacdqR+i+9afsM9h4fZ5kQoVyKYTPrsaR0Lrcm0szcdK9F3niJMvho4m1zMcITiAdXvE1se52oxvWgUACET1XsukkrW1RJL+lSE1U6IryZFwdG2gic= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775836545; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/4qhZ+8GYYcp7jmfiAyFTdQWpQtMp/eabTrs/ZmAwow=; b=gJtYWyudvf/Ci8oVpaKpPIq/adaIrPGRZ+k1F/Kvyn7OalOZHI05nNw818NDSgUPaaymX3Xwh+JjYMZvtHWoDgg6HFBFLob1YIecUGsm/M6bZ7Agx4n7ZNNHyVZLsxlrE1/sSerokOQ07jJNnYx0vuRGRDcpu06xLfyojDvOtI8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1775836545164206.19289330489357; Fri, 10 Apr 2026 08:55:45 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1279422.1563896 (Exim 4.92) (envelope-from ) id 1wBECX-0008Sj-1Z; Fri, 10 Apr 2026 15:55:21 +0000 Received: by outflank-mailman (output) from mailman id 1279422.1563896; Fri, 10 Apr 2026 15:55:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wBECW-0008SG-Qh; Fri, 10 Apr 2026 15:55:20 +0000 Received: by outflank-mailman (input) for mailman id 1279422; Fri, 10 Apr 2026 15:55:19 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wBECV-0007xm-6l for xen-devel@lists.xenproject.org; Fri, 10 Apr 2026 15:55:19 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wBECU-00DRfX-Io for xen-devel@lists.xenproject.org; Fri, 10 Apr 2026 17:55:18 +0200 Received: from [10.42.69.1] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 69d91d5e-5cb7-0a2a0a5109dd-0a2a450183fa-18 for ; Fri, 10 Apr 2026 17:55:18 +0200 Received: from [209.85.128.48] (helo=mail-wm1-f48.google.com) by tlsNG-d62444.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0) (envelope-from ) id 69d91d66-6fc9-0a2a45010019-d1558030c4d2-3 for ; Fri, 10 Apr 2026 17:55:18 +0200 Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-488c2690057so21734005e9.0 for ; Fri, 10 Apr 2026 08:55:18 -0700 (PDT) Received: from fedora (user-109-243-69-121.play-internet.pl. [109.243.69.121]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-488d5b3c597sm78285605e9.12.2026.04.10.08.55.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Apr 2026 08:55:17 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version 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" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775836518; x=1776441318; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/4qhZ+8GYYcp7jmfiAyFTdQWpQtMp/eabTrs/ZmAwow=; b=pjSsxaFKtWTHxQ/sRV6fUzOTfKcWByj49lHDgoRo7NJx7KJHtcSDnUX5SOdTjhK5Uj UpMOgELMNUBUjiELa09Mc625OeqglUYEJJoTo0nzSKtrbzvv/KLeqU78PtJ80Cxl6U4q y4uMDM7JEhl45B/sMrHt+nPUtJop1Vf9D9idOP4zeeLLTWSbJiwzOxvCM5MvelGKGohr Jek5RQNDjgzkHDy4zZDJ8z15DdrKhkVOV2zf38PupwO2Q92cvlf0vJ74daNqMVwilEXT 4rjE58cwlpwi/rw8n1eqAcnnwm+19AbFRx3qxDBwQXZK+NOukSulCYqrN5syGakQADLD FD3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775836518; x=1776441318; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=/4qhZ+8GYYcp7jmfiAyFTdQWpQtMp/eabTrs/ZmAwow=; b=Qhe+/wDInL3gDiYnSPOQ360OoRAxT8rwdGf0KJVE4E+5He1v09pOnzJTQ48HHFqCHl ljagoaJ+ggnelIT7ItbDiJT6EKqdq8TIoHygCeA3Lq+53UGQ2qLO87FlgUhjxPxYFJRg vEQn/LoFHUBl7huQTE23AKwT6f6c5/zH6REQWFqvaiyyoqIuDsaktNUnPkR4ZPpAITMR jEwRBYkaCYwc6oH+Wukgy460p3ykKy2Dzs7fA7sI9fZ6PE+Kshc/tVTYHwr8f2iPDs29 MQ7ECrUJ/DSXY0tr8EQSU1vE4mt7NMYkNLehsEOQ4+utGVSjPecAf1HAGASbqV0yRC77 Qm/Q== X-Gm-Message-State: AOJu0YzQMeEqe+q2h6ft032AIj0a8TUfViJ5uDmV090kOszlxp0xpVwT euPXpA/ivRoYpS4ybkYk0vZCVxnvHBeV3U2uyasNnFyyNgXq6CWZRdh7c/9m0g== X-Gm-Gg: AeBDievIVYZHwTP2Xv3NqZgs92eaN9wYNODsa2+L2V86LiKjwjudOJP1MIUeeFxDg35 pHViMzp8PjwCdCJiRI41OiGLagehV2AAbEvkDr/QjoqL+A9LKrx2e6u0PFSwHRAq0fJ2b2JW02X CMnuo19Bx1EOyyqCiLUPHV1FlDt+iq7Ubr0NVoG75S/audCFdStYMrRbmzS/avTrvSpRTeCYbfe JPME+JmdNqEiryIQAslKapPYN8CQ8+3j6e4trOJgsiB+RDlyiUgaFgJQdhxWqBQ4T3kQZf4nMbY 0qdCpcXHyFDoNA1y1ri0ZLi1F1kDlHjqWdGB7H20qLvKDG3kH3G+/b8ZP4sXXOM0GzHkJ27bEoF XVbD4NseqXWdFOj+7/9C7mBGAz3c9kXISU2T1yfMjAAEaPYEM2bDLAbhFEJd716plZnnANFTGCd JR5uGe+o3MQtw3l9LgeZGtfFqnVYIidGAhge957/RdpFR8wl0J7NpWaonvdiJhFkPBAQ== X-Received: by 2002:a05:600c:4e4d:b0:485:3193:6ddb with SMTP id 5b1f17b1804b1-488d6808507mr49943295e9.3.1775836517625; Fri, 10 Apr 2026 08:55:17 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Oleksii Kurochko , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Andrew Cooper , Anthony PERARD , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v3 07/12] xen: introduce domain-layout.h with common domain_use_host_layout() Date: Fri, 10 Apr 2026 17:54:53 +0200 Message-ID: <2057380b431df202adedf852ad492dd0f156f863.1775836193.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-d62444/1775836518-154EE185-F1932820/10/73395122804 X-purgate-type: spam X-purgate-size: 5440 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1775836546990154100 Content-Type: text/plain; charset="utf-8" domain_use_host_layout() is not architecture-specific and may be needed on x86 [1]. Replace the ARM-specific macro in asm/domain.h with a common static inline in a new dedicated header, xen/domain-layout.h. xen/domain.h would be the natural home, but placing it there would require including xen/paging.h (for paging_mode_translate()) and xen/sched.h (for is_hardware_domain()), which would introduce circular dependencies. A separate header that callers opt into avoids this. Adjust the implementation to take paging_mode_translate() into account so it works correctly for all architectures, including x86. Some extra details about implementation [2] and [3]. [1] https://lore.kernel.org/xen-devel/alpine.DEB.2.22.394.2602161038120.359= 097@ubuntu-linux-20-04-desktop/ [2] https://lore.kernel.org/xen-devel/alpine.DEB.2.22.394.2602271742400.314= 8344@ubuntu-linux-20-04-desktop/ [3] https://lore.kernel.org/xen-devel/alpine.DEB.2.22.394.2602271750190.314= 8344@ubuntu-linux-20-04-desktop/ Suggested-by: Stefano Stabellini Signed-off-by: Oleksii Kurochko --- Changes in v3: - Make argument of domain_use_host_layout() const. - Create a separate header to avoid circular heder dependecy and making domain_use_host_layour() as static inline. - Rework domain_use_host_layout() to be protected by paging_mode_translate= (). - Update the commit message. --- Changes in v2: - Drop ifdef around defintion of domain_use_host_layout() as it was suggested generic version. It could be returned back when the real use case for it will appear. - Add Suggested-by: and update the commit message. - Make domain_use_host_layout() function instead of macros to avoid ciclular header dependecies. Look at more details in the commit message. --- xen/arch/arm/domain_build.c | 1 + xen/arch/arm/include/asm/domain.h | 14 -------------- xen/arch/arm/vgic-v3.c | 1 + xen/common/device-tree/domain-build.c | 1 + xen/include/xen/domain-layout.h | 28 +++++++++++++++++++++++++++ 5 files changed, 31 insertions(+), 14 deletions(-) create mode 100644 xen/include/xen/domain-layout.h diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 6c17a84b2633..60a7cbf915a5 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include diff --git a/xen/arch/arm/include/asm/domain.h b/xen/arch/arm/include/asm/d= omain.h index ffe5d0d9f0a6..f95ad1285e6e 100644 --- a/xen/arch/arm/include/asm/domain.h +++ b/xen/arch/arm/include/asm/domain.h @@ -30,20 +30,6 @@ enum domain_type { #define is_64bit_domain(d) (0) #endif =20 -/* - * Is the domain using the host memory layout? - * - * Direct-mapped domain will always have the RAM mapped with GFN =3D=3D MF= N. - * To avoid any trouble finding space, it is easier to force using the - * host memory layout. - * - * The hardware domain will use the host layout regardless of - * direct-mapped because some OS may rely on a specific address ranges - * for the devices. - */ -#define domain_use_host_layout(d) (is_domain_direct_mapped(d) || \ - is_hardware_domain(d)) - struct vtimer { struct vcpu *v; int irq; diff --git a/xen/arch/arm/vgic-v3.c b/xen/arch/arm/vgic-v3.c index 77aab5c3c293..77517c303061 100644 --- a/xen/arch/arm/vgic-v3.c +++ b/xen/arch/arm/vgic-v3.c @@ -10,6 +10,7 @@ */ =20 #include +#include #include #include #include diff --git a/xen/common/device-tree/domain-build.c b/xen/common/device-tree= /domain-build.c index 540627b74e96..e706a6173ba6 100644 --- a/xen/common/device-tree/domain-build.c +++ b/xen/common/device-tree/domain-build.c @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ =20 #include +#include #include #include #include diff --git a/xen/include/xen/domain-layout.h b/xen/include/xen/domain-layou= t.h new file mode 100644 index 000000000000..15cbb1813c8a --- /dev/null +++ b/xen/include/xen/domain-layout.h @@ -0,0 +1,28 @@ +#ifndef __XEN_DOMAIN_LAYOUT_H__ +#define __XEN_DOMAIN_LAYOUT_H__ + +#include +#include +#include + +/* + * Is a domain using the host memory layout? + * + * domain_use_host_layout() is always False for PV guests. + * + * Direct-mapped domains (autotranslated domains with memory allocated + * contiguously and mapped 1:1 so that GFN =3D=3D MFN) are always using the + * host memory layout to avoid address clashes. + * + * The hardware domain will use the host layout (regardless of + * direct-mapped) because some OS may rely on specific address ranges + * for the devices. PV Dom0, like any other PV guests, has + * domain_use_host_layout() returning False. + */ +static inline bool domain_use_host_layout(const struct domain *d) +{ + return paging_mode_translate(d) && + (is_domain_direct_mapped(d) || is_hardware_domain(d)); +} + +#endif /* __XEN_DOMAIN_LAYOUT_H__ */ --=20 2.53.0