From nobody Fri Oct 31 03:47:35 2025 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=1749830223; cv=none; d=zohomail.com; s=zohoarc; b=hJfT4xJJ8n9zHxf3TFyMcy9ZKLxyaGXp391qM34B87oCNnpzlEAcXRCx+esH4neJ1TsoKr4k9J97EHqJp9s7XEkUHMRJLO+EtrPkfURtmvIAHdTtSynmqBLrJdGF4KVhKKm9dYrDnmsHA0WG3H+gSvGB43AYEFchc9Df6mFcy2w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1749830223; 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=nL7nARGDQ50XMu4IV0d9zQhakNWn40CT42TpoqjeEbk=; b=b8pCO7ZRwqmNGMnHlLKSMRgCTljp8xyabxPPVvUXnQyV43gJ6bc+B3BrLBR4vAPIr+V8lGkDWwlyhzeQvKNa65mni7UvlqX9Gc++lVKXrlVksi/ZWxZt3nRd6H/z5b6urfpoNllUbw3MMjROMAi+/RQkckiOiuHWv+lppek/Pqo= 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 1749830223081654.5988692585504; Fri, 13 Jun 2025 08:57:03 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1014703.1392833 (Exim 4.92) (envelope-from ) id 1uQ6ln-0005qj-R8; Fri, 13 Jun 2025 15:56:43 +0000 Received: by outflank-mailman (output) from mailman id 1014703.1392833; Fri, 13 Jun 2025 15:56:43 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uQ6ln-0005pW-KS; Fri, 13 Jun 2025 15:56:43 +0000 Received: by outflank-mailman (input) for mailman id 1014703; Fri, 13 Jun 2025 15:56:42 +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 1uQ6lm-0005oc-T8 for xen-devel@lists.xenproject.org; Fri, 13 Jun 2025 15:56:42 +0000 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [2a00:1450:4864:20::534]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id ff959bc8-486e-11f0-a309-13f23c93f187; Fri, 13 Jun 2025 17:56:42 +0200 (CEST) Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-6077dea37easo4390702a12.3 for ; Fri, 13 Jun 2025 08:56:42 -0700 (PDT) Received: from fedora.. (user-109-243-64-38.play-internet.pl. [109.243.64.38]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-608b4a93b03sm1357883a12.54.2025.06.13.08.56.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Jun 2025 08:56:40 -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: ff959bc8-486e-11f0-a309-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1749830201; x=1750435001; 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=nL7nARGDQ50XMu4IV0d9zQhakNWn40CT42TpoqjeEbk=; b=VKkf9n71rzy5QZ5/Pl5SMIC1CGvZtafJF59mRG+CRyVJPvOFzyrl3o5QxW2rUCEzWw T0e1B5DaoWFCCi0sN7E2dh3PPt02YHe8XI0i5Yqyx0DLDye3Z9K9piNVH7v5BF3pywCM vGYyvBOXOeCOhHlgA5waNlfkFHv5y0xAGHOQK4ItaoF70LuLKjNuWXsh6BXlPlP2QQcA 9Vaf+IC7fWOOpfci7VmhAirCcNqY+mFtVeBDtdR6kuBf9XrKvC+XBfYs5BhEPUk1kb7R Nftn2PIVFkQheMbnXgSZJQzz86HHT/QfzWOmNNFD9a5GtGx44HttHdkj/gp6cpXeLK+z PgGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749830201; x=1750435001; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nL7nARGDQ50XMu4IV0d9zQhakNWn40CT42TpoqjeEbk=; b=tqeTn3e4flAp8yQuz5I6M9E96vZwDDPIOdKFzaVmHvMlwaKph93gJJKqVFtfsPvnq4 8SBfsKmfPnXjDa2eID2q7AVxM3ujQxOL0ayqZDKc3M/bjpeElOHoodoiG+sC4kopYqti zgcuJwMxwBpnDFId1O+5tAZez6y3dOVy6clfjj3WL63wiSQyuD0nKHXwf/4jKf+52oEA JvUpSTHoq0Vzvk1C5chF4wQ9jHu4j+dXaPF37U1poziIwu5RkCuFjrszO1eNJGUIomSe BWF34VSy0MKCosgV/UsmWDG4UhsLskahZO0xgwz24oIq2+0gKu6p+MScY6Zc0zDwxgpy TyBw== X-Gm-Message-State: AOJu0Yz0cyiXTVlv+3pG8RIOqQEpZKqFkdtJwZYNw2aUngcyqirbAR3c 0RPv7s190qMuXSfSGQZLx5lFaueg1mzsvIQmjB4LqpD8NeLJjMmYNYtzFBXR7Q== X-Gm-Gg: ASbGncuLd0cbmVBPhiL5ZauKg4i1fmfWKB6lNfCx0jbZqNixMdse/Uol0dVw5m1y1J1 lxWI15DbdIYavao5mSV2hMBgSQdlvtgxW4F1tn1fz8wBx72BgSHsIO6cqNKA+5zpzsfNYehXUUh y79n/Ba9pQOW/DFI/ZHCJ0dHi5dbkLmcoU2fGT36zI/7MEpgn1G+0kqWCzKz+pO3sDgY0nuYIzh 3qvTac6rSQrwuKaYphIV4YL7qFWpXUshv+AILooc6m/6cx9pa2bhfj8IYJg/W+u+8jn6V9kzT2p gCkmSjaRHFVxiLSvJdgbFEDYNc9MIv9rxurtfvs+WaqTfB+Vuiezwk76Tod8m9erzUa8iVjb9v9 qzJyvFMKq33qcxsE6xe3w+1HXM6xH X-Google-Smtp-Source: AGHT+IEgsfiFu8C5E+JUWbofGE4zlzEgehEqBX2LkqAdmeSZ5GBYRlpFEgsuZe194HQ+AG85Yu9H9A== X-Received: by 2002:a05:6402:d08:b0:604:e6fb:e2e1 with SMTP id 4fb4d7f45d1cf-608b4a92b52mr3295769a12.33.1749830201206; Fri, 13 Jun 2025 08:56:41 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Oleksii Kurochko , Alistair Francis , Bob Eshleman , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v1 1/2] xen/riscv: rework asm/mm.h and asm/page.h includes to match other architectures Date: Fri, 13 Jun 2025 17:56:35 +0200 Message-ID: <42696025e262f50ee7d26b252bfe3d3c0a9c77e6.1749829230.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1749830225114116600 Content-Type: text/plain; charset="utf-8" To align with other architectures where is included from (and not the other way around), the following changes are made: - Since is no longer included in : - Move the definitions of paddr_to_pte() and pte_to_paddr() to , as paddr_to_pfn() and pte_to_paddr() are already defined there. - Move _vmap_to_mfn() to because mfn_from_pte() is defined the= re and open-code it inside macros vmap_to_mfn(). - Drop the inclusion of from to resolve a = compilation error: ./include/xen/domain_page.h:63:12: error: implicit declaration of funct= ion '__mfn_to_virt'; did you mean 'mfn_to_nid'? [-Werror=3Dimplicit-functio= n-declaration] 63 | return __mfn_to_virt(mfn_x(mfn)); This happens because __mfn_to_virt() is defined in , but due to the current include chain: static inline void *map_domain_page_global(mfn_t mfn) { return __mfn_to_virt(mfn_x(mfn)); } ... ... #define __mfn_to_virt() ... This leads to a circular dependency and the build error above. As a result, since is no longer included in , the flush_page_to_ram() definition cannot remain there. It is now moved to riscv/mm.c. Including from does not cause issues with the declaration/definition of clear_page() when is included, and also prevents build errors such as: common/domain.c: In function 'alloc_domain_struct': common/domain.c:797:5: error: implicit declaration of function 'clear_pag= e';did you mean 'steal_page'? [-Werror=3Dimplicit-function-declaration] 797 | clear_page(d); | ^~~~~~~~~~ | steal_page caused by using clear_page() in common/domain.c. Signed-off-by: Oleksii Kurochko Acked-by: Andrew Cooper --- xen/arch/riscv/include/asm/mm.h | 24 ++++++++++++++++++--- xen/arch/riscv/include/asm/page.h | 35 +------------------------------ xen/arch/riscv/mm.c | 14 +++++++++++++ 3 files changed, 36 insertions(+), 37 deletions(-) diff --git a/xen/arch/riscv/include/asm/mm.h b/xen/arch/riscv/include/asm/m= m.h index 01bbd92a06..9283616c02 100644 --- a/xen/arch/riscv/include/asm/mm.h +++ b/xen/arch/riscv/include/asm/mm.h @@ -12,6 +12,7 @@ #include #include =20 +#include #include =20 extern vaddr_t directmap_virt_start; @@ -19,11 +20,21 @@ extern vaddr_t directmap_virt_start; #define pfn_to_paddr(pfn) ((paddr_t)(pfn) << PAGE_SHIFT) #define paddr_to_pfn(pa) ((unsigned long)((pa) >> PAGE_SHIFT)) =20 +static inline pte_t paddr_to_pte(paddr_t paddr, + unsigned int permissions) +{ + return (pte_t) { .pte =3D (paddr_to_pfn(paddr) << PTE_PPN_SHIFT) | per= missions }; +} + +static inline paddr_t pte_to_paddr(pte_t pte) +{ + return pfn_to_paddr(pte.pte >> PTE_PPN_SHIFT); +} + #define gfn_to_gaddr(gfn) pfn_to_paddr(gfn_x(gfn)) #define gaddr_to_gfn(ga) _gfn(paddr_to_pfn(ga)) #define mfn_to_maddr(mfn) pfn_to_paddr(mfn_x(mfn)) #define maddr_to_mfn(ma) _mfn(paddr_to_pfn(ma)) -#define vmap_to_mfn(va) _vmap_to_mfn((vaddr_t)(va)) #define vmap_to_page(va) mfn_to_page(vmap_to_mfn(va)) =20 static inline void *maddr_to_virt(paddr_t ma) @@ -35,6 +46,15 @@ static inline void *maddr_to_virt(paddr_t ma) return (void *)va; } =20 +#define mfn_from_pte(pte) maddr_to_mfn(pte_to_paddr(pte)) + +#define vmap_to_mfn(va) \ +({ \ + pte_t __entry =3D pt_walk((vaddr_t)(va), NULL); \ + BUG_ON(!pte_is_mapping(__entry)); \ + maddr_to_mfn(pte_to_paddr(__entry)); \ +}) + /* * virt_to_maddr() is expected to work with virtual addresses from either * the directmap region or Xen's linkage (XEN_VIRT_START) region. @@ -76,8 +96,6 @@ static inline unsigned long virt_to_maddr(unsigned long v= a) #define virt_to_mfn(va) __virt_to_mfn(va) #define mfn_to_virt(mfn) __mfn_to_virt(mfn) =20 -#define mfn_from_pte(pte) maddr_to_mfn(pte_to_paddr(pte)) - struct page_info { /* Each frame can be threaded onto a doubly-linked list. */ diff --git a/xen/arch/riscv/include/asm/page.h b/xen/arch/riscv/include/asm= /page.h index 4cb0179648..0684229790 100644 --- a/xen/arch/riscv/include/asm/page.h +++ b/xen/arch/riscv/include/asm/page.h @@ -7,12 +7,10 @@ =20 #include #include -#include #include #include =20 #include -#include #include =20 #define VPN_MASK (PAGETABLE_ENTRIES - 1UL) @@ -114,17 +112,6 @@ typedef struct { #endif } pte_t; =20 -static inline pte_t paddr_to_pte(paddr_t paddr, - unsigned int permissions) -{ - return (pte_t) { .pte =3D (paddr_to_pfn(paddr) << PTE_PPN_SHIFT) | per= missions }; -} - -static inline paddr_t pte_to_paddr(pte_t pte) -{ - return pfn_to_paddr(pte.pte >> PTE_PPN_SHIFT); -} - static inline bool pte_is_valid(pte_t p) { return p.pte & PTE_VALID; @@ -198,18 +185,7 @@ static inline void invalidate_icache(void) #define clear_page(page) memset((void *)(page), 0, PAGE_SIZE) #define copy_page(dp, sp) memcpy(dp, sp, PAGE_SIZE) =20 -static inline void flush_page_to_ram(unsigned long mfn, bool sync_icache) -{ - const void *v =3D map_domain_page(_mfn(mfn)); - - if ( clean_and_invalidate_dcache_va_range(v, PAGE_SIZE) ) - BUG(); - - unmap_domain_page(v); - - if ( sync_icache ) - invalidate_icache(); -} +void flush_page_to_ram(unsigned long mfn, bool sync_icache); =20 /* Write a pagetable entry. */ static inline void write_pte(pte_t *p, pte_t pte) @@ -231,15 +207,6 @@ static inline pte_t pte_from_mfn(mfn_t mfn, pte_attr_t= flags) =20 pte_t pt_walk(vaddr_t va, unsigned int *pte_level); =20 -static inline mfn_t _vmap_to_mfn(vaddr_t va) -{ - pte_t entry =3D pt_walk(va, NULL); - - BUG_ON(!pte_is_mapping(entry)); - - return mfn_from_pte(entry); -} - #endif /* __ASSEMBLY__ */ =20 #endif /* ASM__RISCV__PAGE_H */ diff --git a/xen/arch/riscv/mm.c b/xen/arch/riscv/mm.c index 4047d67c0e..774ea42f2d 100644 --- a/xen/arch/riscv/mm.c +++ b/xen/arch/riscv/mm.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -613,3 +614,16 @@ void __iomem *ioremap(paddr_t pa, size_t len) { return ioremap_attr(pa, len, PAGE_HYPERVISOR_NOCACHE); } + +void flush_page_to_ram(unsigned long mfn, bool sync_icache) +{ + const void *v =3D map_domain_page(_mfn(mfn)); + + if ( clean_and_invalidate_dcache_va_range(v, PAGE_SIZE) ) + BUG(); + + unmap_domain_page(v); + + if ( sync_icache ) + invalidate_icache(); +} --=20 2.49.0 From nobody Fri Oct 31 03:47:35 2025 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=1749830219; cv=none; d=zohomail.com; s=zohoarc; b=oE/Q1ZqrqFAMbcZFrh+2psUUUr6s+UCytw8A1c6SnUHHUBuNHiHWGhP93hyVv49UKzJIP3ZLolnACrj9QTz1xOnZJTDJTg3vKp+n3ypyp73wPXNDB+h4PmOTQpLh/a5E6KMY+hGpoqxG8//PMKoQ6Tdeiz5B+pemYqdZvvySv18= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1749830219; h=Content-Type: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=tBkHTslrkdQm/XhjgO6ug1lELXFf148eDSnYyMvV87A=; b=JTU/zubz+i/EG5v+wwzOhqoWTEls2Ee2TLUTICgAPu0DI1rmWDwf7XzE87AS9isyUEfrAmxgtgStqnhYiQvPOhXnZwjRrIsoQ9YGL82Tx+nDwzibxFrn0eCVCYTQhyj4A7QvfSK0M4cu37lTFFAkRUWITXKSgsFSxBqJv4CP9AQ= 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 1749830219933554.3508008982316; Fri, 13 Jun 2025 08:56:59 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1014704.1392846 (Exim 4.92) (envelope-from ) id 1uQ6lr-0006IS-5f; Fri, 13 Jun 2025 15:56:47 +0000 Received: by outflank-mailman (output) from mailman id 1014704.1392846; Fri, 13 Jun 2025 15:56:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uQ6lr-0006IL-2r; Fri, 13 Jun 2025 15:56:47 +0000 Received: by outflank-mailman (input) for mailman id 1014704; Fri, 13 Jun 2025 15:56:45 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uQ6lp-0006Ge-Kq for xen-devel@lists.xenproject.org; Fri, 13 Jun 2025 15:56:45 +0000 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [2a00:1450:4864:20::532]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 008a3eab-486f-11f0-b894-0df219b8e170; Fri, 13 Jun 2025 17:56:43 +0200 (CEST) Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-607ec30df2bso4227443a12.1 for ; Fri, 13 Jun 2025 08:56:43 -0700 (PDT) Received: from fedora.. (user-109-243-64-38.play-internet.pl. [109.243.64.38]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-608b4a93b03sm1357883a12.54.2025.06.13.08.56.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Jun 2025 08:56:42 -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: 008a3eab-486f-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1749830203; x=1750435003; 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=tBkHTslrkdQm/XhjgO6ug1lELXFf148eDSnYyMvV87A=; b=XvFGKq4hQFNfH2ERKQ/n6wKCv0tI23/f39vtPWWMEvFI1oouE9o1ANFSe2zTVusGv3 eEtEKLaaRPVWxooHNECO8EORUlscIing/JDUso/WN0HR1z9yT/ycDCVeuuJZqbiqm0zq GUZn4VM1nFJLPpC3p5QvvLGnJrO/Hqm7k+ZEnrKU4pbR/Q/yxl+y1MtgrkhVQ4up+D6y oyL7JF/pMPw8Eeqk4jEhyU4hfo4J7NXZxvYSOu2ldMJL6cAevUYlhLhhAXKz1MzxRJ72 oKnW70A0yXPUcr+1y68GQm60EsaohN6iRLbVNs8R5qlURigMep6usX6XSJpP7EzOfOdi rXUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749830203; x=1750435003; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tBkHTslrkdQm/XhjgO6ug1lELXFf148eDSnYyMvV87A=; b=M9+vEbldGzvXouvA35EWiUYULjipcZvdKtEe9yymJMPenJJqKULJ4Fh++1SCA1gH9x hhxDZK0ImdOLxB3tCmDrpdrxfWdHKebW4NtruR084044esh08E/z9xDO8esh9aWyWSxv ACpyL/uYuslDCn4/H9Z9QzAJyjENGRX+Gy6cIqunqsS95HkOh3exVyr4z26RJ74kvTd7 K+Uj10pzKA9E/DHHNjF6jDoCjog9EMU1xomWV3TxzzB9LUiOgW11vw0Ak3icpXqegJtU MkY0nq4QQ9ThD1xI8p1e23ygJUMp40871ESh1sdXXeEKpxaF3gpqjyii90xnz2Ex47Nf QDXQ== X-Gm-Message-State: AOJu0YxkbvvChJCsh9kZpj90TlCLbN2UgTfATU5opcGpT9bHO8deP7Jp nvElBEzuj5DL7GxVmijtR88cGfTKyn906SOX731X/g/fQedM8nKFPl7o65F5Xw== X-Gm-Gg: ASbGncsgYsDNKysDJHLe4ACUtnfmuWGoqycafKbm8FlL/AQndEELK8p3LihRlmuUL19 9kfRC8cT31qIFMcBOIQulPNgqf1gxs7Efwlg93ywjbIvMbDGxZf8kuos+aqFhqylR0V0f/ExwdF E6QrqoWE3QBpX0gnYd2HJ5ThgL1Fy02kfddVE62y3ixWBskN7tjdMOAktkOouiKVqTRwmOVaFrS KlSaUMehTLR8llL8e2LwEgGqSP6dp/H8CRcn0d1orPRI9dgC9s0JXLnz+g2bMxeFbXu4mlAfRwt emOzE8AJUr+Hoca19saWZMk2nf2AYBsZ8wDEik9x61MMJMVMyajDrsmOfzlMTE0csoo+2LKf8sy onI0Fwhpk52MrV60hVZ9hJ2OWIcZt X-Google-Smtp-Source: AGHT+IFc/KLR1BzJIRacmaOsU4mrBKrO7Fs3Y8ikB2f0saA3ZsckBb22OGO4cGnpnPlrkqrMJxQHFw== X-Received: by 2002:a05:6402:270d:b0:607:7aed:feef with SMTP id 4fb4d7f45d1cf-608b49fc0aamr3189540a12.34.1749830202560; Fri, 13 Jun 2025 08:56:42 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Andrew Cooper , Anthony PERARD , Jan Beulich , Shawn Anastasio , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko Subject: [PATCH v1 2/2] xen/domain: introduce generic weak function for domain struct allocation Date: Fri, 13 Jun 2025 17:56:36 +0200 Message-ID: X-Mailer: git-send-email 2.49.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1749830220789116600 From: Roger Pau Monne x86 has specific requirements about the allocation of the domain structure, but that's not the case for ARM or likely other architectures. Introduce a generic weak function that can be overwritten with an architecture specific implementation if required. No functional change intended. Signed-off-by: Roger Pau Monn=C3=A9 Reviewed-by: Oleksii Kurochko --- Changes: - Add Reviewed-by: Oleksii Kurochko . - Add empty line before last return in alloc_domain_struct(). --- xen/arch/arm/domain.c | 12 ------------ xen/arch/ppc/stubs.c | 5 ----- xen/arch/riscv/stubs.c | 5 ----- xen/common/domain.c | 14 ++++++++++++++ 4 files changed, 14 insertions(+), 22 deletions(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 45aeb8bddc..29588f869c 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -479,18 +479,6 @@ void startup_cpu_idle_loop(void) reset_stack_and_jump(idle_loop); } =20 -struct domain *alloc_domain_struct(void) -{ - struct domain *d; - BUILD_BUG_ON(sizeof(*d) > PAGE_SIZE); - d =3D alloc_xenheap_pages(0, 0); - if ( d =3D=3D NULL ) - return NULL; - - clear_page(d); - return d; -} - void free_domain_struct(struct domain *d) { free_xenheap_page(d); diff --git a/xen/arch/ppc/stubs.c b/xen/arch/ppc/stubs.c index 671e71aa0a..d999d22718 100644 --- a/xen/arch/ppc/stubs.c +++ b/xen/arch/ppc/stubs.c @@ -294,11 +294,6 @@ void vcpu_kick(struct vcpu *v) BUG_ON("unimplemented"); } =20 -struct domain *alloc_domain_struct(void) -{ - BUG_ON("unimplemented"); -} - struct vcpu *alloc_vcpu_struct(const struct domain *d) { BUG_ON("unimplemented"); diff --git a/xen/arch/riscv/stubs.c b/xen/arch/riscv/stubs.c index e396b67cd3..155e5a7f58 100644 --- a/xen/arch/riscv/stubs.c +++ b/xen/arch/riscv/stubs.c @@ -268,11 +268,6 @@ void vcpu_kick(struct vcpu *v) BUG_ON("unimplemented"); } =20 -struct domain *alloc_domain_struct(void) -{ - BUG_ON("unimplemented"); -} - struct vcpu *alloc_vcpu_struct(const struct domain *d) { BUG_ON("unimplemented"); diff --git a/xen/common/domain.c b/xen/common/domain.c index e566a18747..c134868e95 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -785,6 +785,20 @@ static int sanitise_domain_config(struct xen_domctl_cr= eatedomain *config) return arch_sanitise_domain_config(config); } =20 +struct domain *__weak alloc_domain_struct(void) +{ + struct domain *d =3D alloc_xenheap_pages(0, 0); + + BUILD_BUG_ON(sizeof(*d) > PAGE_SIZE); + + if ( !d ) + return NULL; + + clear_page(d); + + return d; +} + struct domain *domain_create(domid_t domid, struct xen_domctl_createdomain *config, unsigned int flags) --=20 2.49.0