From nobody Mon Mar 23 21:24:37 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=1774283500; cv=none; d=zohomail.com; s=zohoarc; b=CNo6kkjW8nDox86WuxpHgv96xKjB4DCIcQmUCEdgUdSQpQA6v5anUz4haFxTpafoN9fX7DT6be3fb30V6uexTWmA7OV7ZIZXoMHQvcK19qLEfuq1MaVDt9NmRy519iAxUFE78mlJr5ApeAJy3s+jc7E2y1sIZSONmSEsLpWydA0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1774283500; 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=OUX7GrhRziDvMmFWaLMh2GDPwrEhtXaG/vycDO8shAw=; b=Exh/MDAZt+0Uf4EFYnlrzmkhItGg+x3yT338A632FB1k8MgbqUgk9/862UHdb2O1ppyrPBDuJsp9ifdAcih5ImH+szetN5/8okVCZKu3FXxLOJoaCklwfldZJVEVhzeI/cM9WEO3cAPlOnzvy0i0RFFRaWbwooXEWxEhAX0Dzas= 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 1774283500726332.3415858344639; Mon, 23 Mar 2026 09:31:40 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1259474.1552798 (Exim 4.92) (envelope-from ) id 1w4iBa-0007bF-4M; Mon, 23 Mar 2026 16:31:26 +0000 Received: by outflank-mailman (output) from mailman id 1259474.1552798; Mon, 23 Mar 2026 16:31:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w4iBZ-0007b6-Vt; Mon, 23 Mar 2026 16:31:25 +0000 Received: by outflank-mailman (input) for mailman id 1259474; Mon, 23 Mar 2026 16:31:24 +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 1w4iBY-00079z-Pr for xen-devel@lists.xenproject.org; Mon, 23 Mar 2026 16:31:24 +0000 Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id bb69298a-26d5-11f1-b166-2bf370ae4941; Mon, 23 Mar 2026 17:31:24 +0100 (CET) Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-b98133bdc4bso522446566b.0 for ; Mon, 23 Mar 2026 09:31:24 -0700 (PDT) Received: from fedora (user-109-243-69-121.play-internet.pl. [109.243.69.121]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b9832f8be14sm536248166b.17.2026.03.23.09.31.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Mar 2026 09:31:18 -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" X-Inumbo-ID: bb69298a-26d5-11f1-b166-2bf370ae4941 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1774283483; x=1774888283; 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=OUX7GrhRziDvMmFWaLMh2GDPwrEhtXaG/vycDO8shAw=; b=dvBaEioFdDUTIS0NKusO4vriSn6gNLixUj0H7cm69Re7q8jIZRkgABDHF9Y7HrzZYH vFOjjl6h8ltr+ux3d//RuTt5lFWph0dbo585CvMmv5EOOUU0I4VZIO3H+CrJDysucJUq VFIkgz2Gor7wJ/YVIicyv3ZcQbPBJRxow8VFE3YvyApvV0p5lScwG2vuSFcTPPpPXuju mXrZwoBTV2ThJtBD+pZppgF07Z3SlN1B/TE9cDImhVOnqS2nyFm248aHxDWLp741mJEd mwKZR4pEIfjZ3YmBkQbdnbD185FaeX/8ysFRuzDzGRezadhd0RS3xhjMCMwfokZj/OHI 0VuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774283483; x=1774888283; 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=OUX7GrhRziDvMmFWaLMh2GDPwrEhtXaG/vycDO8shAw=; b=Q2vsJo8ZKxJCt6JfaSvaNXmE7KfokSHm11sbXOJnMvGf9vBDgjcSa2SqoQU9ISPRsE JGCkXXJN5UV9mfLaqAIE7O6iv4190PIV1lgQCu7NM+8roFjOHvz6LGVI8jrqjArSlE++ uXBPKLuCY5/UEQvNPo8MxSvhDQDZD3bq9vjemdDlGXmPT50/vNqj4C/6wXNJ5GT5poRt KJdYPxWkbbFJHg1dLLDHtp5JFQe9shNiTZWU/WKh2YNyq7opMLceo4CeIvF6BFYdS79q avB5zEJ37QkzLtM9qFafGVHLbJMebstuoKeX8yW5lT86omYHgv8hSc7RnNt37w7oLNMb EW3g== X-Gm-Message-State: AOJu0YyfPKFe3n5lo4efgOsXg16mKw5OWNeV9Z3Fhe14vsJsWRHMqDkS IQGpEmntJcgumg8QclgpJtfqwUi6n0jaLqMt2szpAknwFaLoLwrIscV9yA071Q== X-Gm-Gg: ATEYQzyCVB8/D19vg6PXNVtF23Fg38qGaiMh0z82pJhBDpPxsfZy5PDNlrODU/hFNP8 JyL3Ru3a5244BPV42KtiBFux+Cyr/GkPfD+TRxJew2JuQBWvobhzfCrIZFHWSuInROojJPMyDBM O0D3TApT0dKTsNvgcDZWuRpzBRq++l+CNQnT1EeItnn5Mub239fLyRxBwj0g9P8xsYoHrAJpJIR 8gDpFTHR7NSTMjbt1G8tB5HMZA7K8t/SH6tXbUe4UmouqHRyH6TzlQIQbjoSaqAsDk56BzoNPJn WItntBRE+z/UjNICcmd2wI7qwssri3+pgH8sviDPUDBy5WoA7Wrt3JmxP1gk73Mfk7aI/XHeZEl TPh12hutrV9ZmBUHUtFiHGhtvWZjHpyoIyJs8k5e2ML/cTf4yQCc4NuEVr7mrYmb6NRxZ5105rE tzHDvTbAYnXLm6ZhQLUQFagvHi/eegVlnHWUZWBJOwUqq7uX1X7lAEP4NhAOixMRe4YA== X-Received: by 2002:a17:906:5643:b0:b98:132e:ca97 with SMTP id a640c23a62f3a-b982f37d4damr665981666b.47.1774283483001; Mon, 23 Mar 2026 09:31:23 -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 v2 07/11] xen: move domain_use_host_layout() to common code Date: Mon, 23 Mar 2026 17:29:48 +0100 Message-ID: <533d01db2b36b8357cd87e99a64a6e66dbdd1db4.1774281309.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-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1774283503291154100 Content-Type: text/plain; charset="utf-8" domain_use_host_layout() is not really architecture-specific, so move it from the Arm header to the common header xen/domain.h and provide a common implementation in xen/common/domain.c. domain_use_host_layout() potentially is needed for x86 [1]. Turn the macro into a function to avoid header dependency issues. In particular, the implementation depends on paging_mode_translate(), and including xen/paging.h from xen/domain.h would introduce circular dependencies via xen/sched.h which will lead to compilation errors as implicit declaration of struct vcpu, or struct domain, or similar things declared in xen/sched.h. 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]. Also, inclusion of asm/p2m.h is dropped as xen/paging.h already includes it. [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 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/include/asm/domain.h | 14 -------------- xen/common/domain.c | 8 +++++++- xen/include/xen/domain.h | 16 ++++++++++++++++ 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/xen/arch/arm/include/asm/domain.h b/xen/arch/arm/include/asm/d= omain.h index 758ad807e461..1a04fe658c97 100644 --- a/xen/arch/arm/include/asm/domain.h +++ b/xen/arch/arm/include/asm/domain.h @@ -29,20 +29,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/common/domain.c b/xen/common/domain.c index ab910fcf9306..87a6a17575f9 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -35,7 +36,6 @@ #include #include #include -#include #include #include #include @@ -2544,6 +2544,12 @@ void thaw_domains(void) =20 #endif /* CONFIG_SYSTEM_SUSPEND */ =20 +bool domain_use_host_layout(struct domain *d) +{ + return is_domain_direct_mapped(d) || + (paging_mode_translate(d) && is_hardware_domain(d)); +} + /* * Local variables: * mode: C diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h index 93c0fd00c1d7..68fb1acd4083 100644 --- a/xen/include/xen/domain.h +++ b/xen/include/xen/domain.h @@ -62,6 +62,22 @@ void domid_free(domid_t domid); #define is_domain_direct_mapped(d) ((d)->cdf & CDF_directmap) #define is_domain_using_staticmem(d) ((d)->cdf & CDF_staticmem) =20 +/* + * Is the auto-translated 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 a specific address ranges + * for the devices. PV Dom0, like any other PV guests, has + * domain_use_host_layout() returning False. + */ +bool domain_use_host_layout(struct domain *d); + /* * Arch-specifics. */ --=20 2.53.0