From nobody Thu Jan 8 12:40:00 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; 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=1766509371; cv=none; d=zohomail.com; s=zohoarc; b=jSj1W2OYJwgiY8kU8T/eyo3tSANCLzamdze1Gi6nbL6JmOD5pQPJoOfgklHg0eeRHc3WNLLfEJyW+/Qr1NqK2lc/6l2AouBL6c++ZFppQxyn8udxycYTTA4F4zLBTtxAu7TmkW1XoXkFIrk0fr56eWe2K266CgyyV0wGtJfBfKU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1766509371; 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=j+aOZqII5wc7BowuwzDWz84yJZJIh5yD9oqK8sJIWHU=; b=c89155QueiuFw8+dKc519F3931RZsrx0xwsyJui2gIrXRUkoWckpmoY3zcNq8wsNAZEhLdu5Dv8cRUhUDxHe3Y8XEPiOctNwu2TtoychbrBTQH9YixG02ZuXvGJW+VuTHz7TSWZD4DXiazVQ1i3glYY62N9Kw4/61HbFsddpfPA= 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 176650937183287.72264667754177; Tue, 23 Dec 2025 09:02:51 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1192706.1511836 (Exim 4.92) (envelope-from ) id 1vY5m0-0000z0-MA; Tue, 23 Dec 2025 17:02:12 +0000 Received: by outflank-mailman (output) from mailman id 1192706.1511836; Tue, 23 Dec 2025 17:02:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vY5m0-0000wu-Fy; Tue, 23 Dec 2025 17:02:12 +0000 Received: by outflank-mailman (input) for mailman id 1192706; Tue, 23 Dec 2025 17:02:11 +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 1vY5ly-0000rG-Uu for xen-devel@lists.xenproject.org; Tue, 23 Dec 2025 17:02:10 +0000 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [2a00:1450:4864:20::62a]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 1deb8b92-e021-11f0-9cce-f158ae23cfc8; Tue, 23 Dec 2025 18:02:09 +0100 (CET) Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-b7a72874af1so895079966b.3 for ; Tue, 23 Dec 2025 09:02:09 -0800 (PST) Received: from fedora (user-109-243-71-38.play-internet.pl. [109.243.71.38]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b80464e01d9sm1306260566b.42.2025.12.23.09.02.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Dec 2025 09:02:07 -0800 (PST) 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: 1deb8b92-e021-11f0-9cce-f158ae23cfc8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766509328; x=1767114128; 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=j+aOZqII5wc7BowuwzDWz84yJZJIh5yD9oqK8sJIWHU=; b=U34azGk/kIgqoN9JkWzmgzoKsBiDc7dEhAqgDq3eLJ0XGidpV0OPA/KZw4EEFpY1c2 ZJh3OPdv7NDREITZiHsPwBEuv+7RfU9+lO8QPCavWAl99wIMZXDOzjHMrj7VwTIbw2rA aCP5ynArzqbMqVH0g7SmErqfRZU8aPGuNyWVL72hyypTaOqik1w5UX+B7ukjEsyJyZbv t7HfpPemI8ZWxTE3XWwZE6RdHpNMO1PHYODBniL+ABATBE9li63Dxo2rvfLpahftRVi4 V6B0PWpHuJphxFr3LJNMOCxJxkTyjfBFM7pPLJBjghfjICCHQZsi6wR5DmUI9UxSVxF4 8RMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766509328; x=1767114128; 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=j+aOZqII5wc7BowuwzDWz84yJZJIh5yD9oqK8sJIWHU=; b=wCiuPX3+9LK+g0v7dDHAhXfhS0ecS9bZm7kuSsVQiYhIPuulkc8DaYwFTUh9M71F25 ZTBuQ8cnad092Tc2mhojs99RR4SavZPs6OslqmJSAFtzTUIHEgTgXpEMZDL2Gz6HWtxN m+NCKdU+vXj1AQG8xdDeXTWRE71z7J91eWy46DLOpTf/0yK26+cd3l9yDNP6rN6UDLsB 29I1QCjU5suH0gzhDvLrP477HeOzCDyTaMFd5UapRTChGSJZk3ZfD5ba8B4DOcYuKV7L yylWHhM+CCX63QpT8brxPcnG15bKXZa0f4uVsncKvbHGqaAizk9OFqGEmXtK0ZeKIrvX Beog== X-Gm-Message-State: AOJu0YzymtpaxbfcRT9v2EKKAKUX5VP3NuCbzLUjXD9LODGMysyEfxG0 zsMslP+6YYhPd0VwCZH4QDGqEgojp4n4LMClolxpzsKc38oldM7UoiLcJDnGBA== X-Gm-Gg: AY/fxX6tu9i0Pw6KJ32Ayq7N+qOt+Rj/ZTmSEjxD73GspyFoLA8INtID9K9zzB0NF+B UWHfeg1OW/bTzn8gw3EilCIG8TM/2UguAVIer/SR4aK/rztLXmlrNpzV/P+M9H++H6wR2PB1hoU BDxJK8i2hi0bkEGQCWbOBQvkH5WpD+p3uVFpOTKZP8R8QdU28HzxOTBLNvihu6Dcta+TGt8ntcl do+G1w00wHFY505xGBoh5GaNx+XyxNsWSPIL0E++mjtkCkFbnG8ghS1GxPDxnA0A3ATqOhzlxLT eL1omuHrMJpzBDm5koElykmpWBiwoyF1QVF/JxxXvFHsk3s21bIn3AHI3ROmDEfs0LYcJBYdoJQ 1pj6NqnLLxIvqYQsuweU8L+TPMJnf6Ce/CcVZB8ChF8hdGjiPff2vaQkt9UJd21Rl2hhiSBRPKk xDIVrMS6rHxCGK7ZLKTj8rBBfjL+/XQJvAaqpcYlRZ/SLstDbMLdde1w5unfjawnNXbA== X-Google-Smtp-Source: AGHT+IFdBau6LYw66LiszAsIrMwHExSX3yPph04NnwJrpcy0HJbAmKM1EnTblHaCRBYBx5YCL/+Qzg== X-Received: by 2002:a17:907:1b0f:b0:b76:d4d0:68da with SMTP id a640c23a62f3a-b8036ebaaf1mr1435816066b.6.1766509328037; Tue, 23 Dec 2025 09:02:08 -0800 (PST) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Oleksii Kurochko , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Andrew Cooper Subject: [PATCH v4 1/4] xen/arm: vcpu_vgic_free() updates Date: Tue, 23 Dec 2025 18:01:55 +0100 Message-ID: X-Mailer: git-send-email 2.52.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1766509372222158500 Content-Type: text/plain; charset="utf-8" Use XFREE() instead of xfree() so that vcpu_vgic_free() can be idempotent. With XFREE(), vgic_vcpu->private_irqs is set to NULL, so calling vcpu_vgic_free() a second time is not an issue. Update the prototype of vcpu_vgic_free() to return void to satisfy MISRA Rule 17.7, since the return value of vcpu_vgic_free() is not used by any callers. Suggested-by: Andrew Cooper Signed-off-by: Oleksii Kurochko Reviewed-by: Andrew Cooper Acked-by: Michal Orzel --- Change in v4: - Add Reviewed-by: Andrew Cooper . --- Change in v3: - New patch. --- xen/arch/arm/include/asm/vgic.h | 2 +- xen/arch/arm/vgic.c | 5 ++--- xen/arch/arm/vgic/vgic-init.c | 4 +--- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/xen/arch/arm/include/asm/vgic.h b/xen/arch/arm/include/asm/vgi= c.h index 31b3d3e5ec5d..6f9ab1c98c1c 100644 --- a/xen/arch/arm/include/asm/vgic.h +++ b/xen/arch/arm/include/asm/vgic.h @@ -418,7 +418,7 @@ int domain_vgic_register(struct domain *d, unsigned int= *mmio_count); int domain_vgic_init(struct domain *d, unsigned int nr_spis); void domain_vgic_free(struct domain *d); int vcpu_vgic_init(struct vcpu *v); -int vcpu_vgic_free(struct vcpu *v); +void vcpu_vgic_free(struct vcpu *v); =20 void vgic_inject_irq(struct domain *d, struct vcpu *v, unsigned int virq, bool level); diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c index 3ebdf9953f07..6647071ad4d7 100644 --- a/xen/arch/arm/vgic.c +++ b/xen/arch/arm/vgic.c @@ -390,10 +390,9 @@ int vcpu_vgic_init(struct vcpu *v) return 0; } =20 -int vcpu_vgic_free(struct vcpu *v) +void vcpu_vgic_free(struct vcpu *v) { - xfree(v->arch.vgic.private_irqs); - return 0; + XFREE(v->arch.vgic.private_irqs); } =20 struct vcpu *vgic_get_target_vcpu(struct vcpu *v, unsigned int virq) diff --git a/xen/arch/arm/vgic/vgic-init.c b/xen/arch/arm/vgic/vgic-init.c index f8d7d3a226d0..aef526f2e717 100644 --- a/xen/arch/arm/vgic/vgic-init.c +++ b/xen/arch/arm/vgic/vgic-init.c @@ -239,13 +239,11 @@ void domain_vgic_free(struct domain *d) dist->nr_spis =3D 0; } =20 -int vcpu_vgic_free(struct vcpu *v) +void vcpu_vgic_free(struct vcpu *v) { struct vgic_cpu *vgic_cpu =3D &v->arch.vgic; =20 INIT_LIST_HEAD(&vgic_cpu->ap_list_head); - - return 0; } =20 /* --=20 2.52.0 From nobody Thu Jan 8 12:40:00 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; 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=1766509362; cv=none; d=zohomail.com; s=zohoarc; b=W+PUo1ma4sGFEo/5RPqUzceDsYOQOmC9g+bN197sTZg3wZ5c2EwPtqttmKZIBUd/IBsqICeW7ti64JeY4PhmRgr948B/3AlLtHdYHBRpcikCi3CxUXgncJQyWDS040juHeAjbvp/zPL5ina96nW93iIAe5K8WY8D+7WPx/UC5/M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1766509362; 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=S95KJYi4jIB1ArhFJq9VOfQamAB3y8b+WB2+NeoNQsg=; b=iHD5VarnghgWezx5lyJghXLKGy2p3MkHvuhNiS7xMUHyD7+hXluRikHAWBoxAfdS98H6JK5kfbIDPGx1SirB8ZLo/txiOR8LM3PPmU4JmlQAjinv8X7KjvX7n4twunOCMkvSH3gq/xgBGF9QkrP5evBgWhuZ05dKYfQQOQI6bec= 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 176650936279924.418022742322478; Tue, 23 Dec 2025 09:02:42 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1192705.1511832 (Exim 4.92) (envelope-from ) id 1vY5m0-0000v0-F3; Tue, 23 Dec 2025 17:02:12 +0000 Received: by outflank-mailman (output) from mailman id 1192705.1511832; Tue, 23 Dec 2025 17:02:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vY5m0-0000ta-94; Tue, 23 Dec 2025 17:02:12 +0000 Received: by outflank-mailman (input) for mailman id 1192705; Tue, 23 Dec 2025 17:02:10 +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 1vY5ly-0000rH-NJ for xen-devel@lists.xenproject.org; Tue, 23 Dec 2025 17:02:10 +0000 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [2a00:1450:4864:20::633]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 1e775447-e021-11f0-b15b-2bf370ae4941; Tue, 23 Dec 2025 18:02:09 +0100 (CET) Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-b73a9592fb8so979261366b.1 for ; Tue, 23 Dec 2025 09:02:09 -0800 (PST) Received: from fedora (user-109-243-71-38.play-internet.pl. [109.243.71.38]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b80464e01d9sm1306260566b.42.2025.12.23.09.02.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Dec 2025 09:02:08 -0800 (PST) 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: 1e775447-e021-11f0-b15b-2bf370ae4941 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766509329; x=1767114129; 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=S95KJYi4jIB1ArhFJq9VOfQamAB3y8b+WB2+NeoNQsg=; b=D6aw+pG0j8x6elEPVh0rp33t/TZUqrCSxRj86XqkkIYlrqAdFnaMH1pUXBY0NdJbpI JrsRKDmOvnezLRUOS0rXwwMhzBgs2ZYZ4Z1RMDCmgPsCxIuAiw0pQob+q9DS6c+aEqBW patnWSGf0fCr9d1i+MigsVMKOPLilUrqQQNTJnKqm/Ti8yYhkynb/pvljcfSHXMGVfZq aX+VW3mc2XDtavEx4eA/v3aZQPW+6ftCFlK85VueuEqwCysEtnXT9G4Vu69Y7yF20r8Y 6P5oSjL3h3seDDMy8CH9ss6uyQomjhnK2HF4oAfZZ12Is0CS+EgkyxNf+AAwulFzDTwN e/5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766509329; x=1767114129; 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=S95KJYi4jIB1ArhFJq9VOfQamAB3y8b+WB2+NeoNQsg=; b=qZ0hpZkdjT0MwjGG/S0BeXRRpfNeEN+GC1Fl5PKwqkbjQzIcZQRUnBt5TWlTCzWhk5 0mJsE71TOwyGU0XCHnPRbMT/XWscvgzggeqVS76dqCCO3KIKzoEr7Hn+HTKDJYOmsGJj Jj0bmqxfxrI1qkrwehZnU6+btlHLN4lxBGooTFEES5PANeBFAk4jAPuF9AuteNe+0VvE vTCqv/uosqkcQ1fiN/4Zg91pg3M+CVT9IBAc+tjwwYrKld3S+I1TBBB9OPXs/7IRYYew 7hNtFr/D9/o+3AcQlvReAnS2XXiAfc6sxw+bxV4qu8Sulbvth2zcxlICohPstqShPxCN ss0g== X-Gm-Message-State: AOJu0YzDMvTgOfYay8YEVPaL+Zk3a88/BUQ3p6Pj/sCXyoIvnoktlZQa fkQApRPh41tDOXcmsIO1bfxoa8KT2f5J5P8KfPZoSj2zZx58K6EkHxh1DXLjRA== X-Gm-Gg: AY/fxX7fbSLpqhSP84TBON2f4viCFwcTLR2gXXhDddxUytczqVhNIsWwwA2v0SpWChc F5Bh5Qmirjplhe0HznRA9hKBp7iHyLvczEPZPagBU9YLFKxFIx4A4C7M9Fc7GCe7QY5oFiVHKZZ TKcsiZiy5Je2gVjCnFdqBcqUOqOTxpGVQ1XygSjrYrPomJKGXXB/4ZWm+HeudNMnzLYanYL2fWX aulvFQIh8YUoAu/tRc0IPA6qL/5Mi0Aqnt5ySjN4tin6npzqwtBOnq6JRCODLkrFlzNlPPn7JAf LfV+e3Or4ePDADBxSFf0+GksS6ZYD7ycVonGtw70J3ZA2WXLBBdJv1hXeAtf1Acl5XmNHmSHT0Q NX74hlVRlw81/E9ScSsqsWXxTJUv84yS/WGKWT4zsENMyoy5NbfjRhce8KRG7CYbWOHKHrykiED JOqaz2ZdVu89iuZ31oDk/6tbYWwjcUkvLM27OoWZ7QBeUaBCQw52Uk+PM= X-Google-Smtp-Source: AGHT+IGpGaRAzqQ1l6lcLkd3EgAivjDFotE6e8nL5bz+/5hixOWejp5H7cVVzYJVmdmv5kDkCCMIsw== X-Received: by 2002:a17:907:70d7:b0:b80:1403:764c with SMTP id a640c23a62f3a-b80205e6bd3mr1400852366b.24.1766509329133; Tue, 23 Dec 2025 09:02:09 -0800 (PST) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Oleksii Kurochko , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Andrew Cooper Subject: [PATCH v4 2/4] xen/arm: optimize the size of struct vcpu Date: Tue, 23 Dec 2025 18:01:56 +0100 Message-ID: <0756ee97dd47f6acdefe593694b743eb6bfefacb.1766504313.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1766509364429158500 Content-Type: text/plain; charset="utf-8" When CONFIG_NEW_VGIC=3Dy and CONFIG_ARM_64=3Dy, the size of struct vcpu exceeds one page, which requires allocating two pages and led to the introduction of MAX_PAGES_PER_VCPU. To remove the need for MAX_PAGES_PER_VCPU in a follow-up patch, the vgic member of NEW_VGIC's struct vgic_vcpu member private_irq is changed to a pointer to struct vgic_irq. As a result, the size of struct vcpu for Arm64 is reduced to 2176 bytes, compared to 3840 bytes (without these changes and with CONFIG_ARM_64=3Dy) and 4736 bytes (without these changes and with both CONFIG_ARM_64=3Dy and CONFIG_NEW_VGIC=3Dy). Since the private_irqs member is now a pointer, vcpu_vgic_init() and vcpu_vgic_free() are updated to allocate and free private_irqs instance. Suggested-by: Andrew Cooper Signed-off-by: Oleksii Kurochko Reviewed-by: Andrew Cooper Acked-by: Michal Orzel --- Change in v4: - Add Reviewed-by: Andrew Cooper . --- Changes in v3: - Make private_irqs member as pointer to vgic_irq in struct vgic_cpu of new_vgic instead of vgic member of arch_vcpu. --- Changes in v2: - New patch. --- xen/arch/arm/include/asm/new_vgic.h | 2 +- xen/arch/arm/vgic/vgic-init.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/include/asm/new_vgic.h b/xen/arch/arm/include/asm= /new_vgic.h index 1e762138939f..6f7af0e02b2b 100644 --- a/xen/arch/arm/include/asm/new_vgic.h +++ b/xen/arch/arm/include/asm/new_vgic.h @@ -155,7 +155,7 @@ struct vgic_dist { }; =20 struct vgic_cpu { - struct vgic_irq private_irqs[VGIC_NR_PRIVATE_IRQS]; + struct vgic_irq *private_irqs; =20 struct list_head ap_list_head; spinlock_t ap_list_lock; /* Protects the ap_list */ diff --git a/xen/arch/arm/vgic/vgic-init.c b/xen/arch/arm/vgic/vgic-init.c index aef526f2e717..4eb49d922492 100644 --- a/xen/arch/arm/vgic/vgic-init.c +++ b/xen/arch/arm/vgic/vgic-init.c @@ -202,6 +202,11 @@ int vcpu_vgic_init(struct vcpu *v) { int ret =3D 0; =20 + v->arch.vgic.private_irqs =3D + xzalloc_array(struct vgic_irq, VGIC_NR_PRIVATE_IRQS); + if ( !v->arch.vgic.private_irqs ) + return -ENOMEM; + vgic_vcpu_early_init(v); =20 if ( gic_hw_version() =3D=3D GIC_V2 ) @@ -244,6 +249,8 @@ void vcpu_vgic_free(struct vcpu *v) struct vgic_cpu *vgic_cpu =3D &v->arch.vgic; =20 INIT_LIST_HEAD(&vgic_cpu->ap_list_head); + + XFREE(v->arch.vgic.private_irqs); } =20 /* --=20 2.52.0 From nobody Thu Jan 8 12:40:00 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; 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=1766509364; cv=none; d=zohomail.com; s=zohoarc; b=iYuNnbGMvJjrTuO1tZPLqfNRvy9dLF7bjPTCIoKK9dzUovxtPpeEU7mIz4QSg3tTdcG6X1zzmY2PwZLi7GKm1GR7XO1TrMvTOOYJy3Tt7012jJ8wLuhfEy1G+5KJlk2CzgduK1vLJ9a63k+nYwsfT4t/J4Zviq6vw9J3/Evtne8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1766509364; 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=haLvGCsDO/JizmjiuTr97WlOBT3BtJPjB3KsDGCVV4s=; b=BERsDTr5i8AMyCXuj8pDcZ6YV9qq970QGzyhDXYwUHpfcuKFUj2JsjiXMadfDJ1JZwW584B6xRAJ/anIlqkhw505zIOIk/rYma7IMnFXcF+Hrj+dWILqBa1kLbCH7TxVcqjFIL3AcLldlrXxW13oTfMNz+jxTi5iL2DkJU8AaNs= 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 1766509364105451.54895718433795; Tue, 23 Dec 2025 09:02:44 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1192707.1511855 (Exim 4.92) (envelope-from ) id 1vY5m4-0001Xm-1X; Tue, 23 Dec 2025 17:02:16 +0000 Received: by outflank-mailman (output) from mailman id 1192707.1511855; Tue, 23 Dec 2025 17:02: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 1vY5m3-0001Xd-V3; Tue, 23 Dec 2025 17:02:15 +0000 Received: by outflank-mailman (input) for mailman id 1192707; Tue, 23 Dec 2025 17:02: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 1vY5m2-0000rH-90 for xen-devel@lists.xenproject.org; Tue, 23 Dec 2025 17:02:14 +0000 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [2a00:1450:4864:20::631]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 1fa0b5d7-e021-11f0-b15b-2bf370ae4941; Tue, 23 Dec 2025 18:02:11 +0100 (CET) Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-b7cf4a975d2so749271366b.2 for ; Tue, 23 Dec 2025 09:02:11 -0800 (PST) Received: from fedora (user-109-243-71-38.play-internet.pl. [109.243.71.38]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b80464e01d9sm1306260566b.42.2025.12.23.09.02.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Dec 2025 09:02:10 -0800 (PST) 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: 1fa0b5d7-e021-11f0-b15b-2bf370ae4941 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766509331; x=1767114131; 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=haLvGCsDO/JizmjiuTr97WlOBT3BtJPjB3KsDGCVV4s=; b=FO2NBsjeNihT1dhu26TDuagTEpIziN+/4OC1dZkaZCzwHnFZ4M1cFDrJAsVVn5y7IE mHCaYSJ+XaCrIMkjAom+ex5uzkNc+iQXzRf8I/1z2S34b0UxUaHzIwzwSUtIJPHsTpcP NmgyK3fdzhD784aUcMEHdJrOGNsVsAVGQXYvh/zPgEfCFGt7SvpM9vkiAI3vxNriGXhA NlosxsDzaJjGH1ZnvNzQ+pizp6awkx3vGQjru0hyhCyYCfoRQ+S/jUrTfNdAaIYCWkyc G7uyC9Q2rwOCZZP63e+Ve3s2Qd7BVLl4h6b/U75bEiXohXLKEgrKjWF518WF5d9OR52I vymQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766509331; x=1767114131; 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=haLvGCsDO/JizmjiuTr97WlOBT3BtJPjB3KsDGCVV4s=; b=cj4Mz+joOLN07r8bRlBGGfdOxdgTHdca7YwqvpHmqFnviYozbv0YoZqyxXNXFez6Sb +2sdUVEaDrR88FqFHl80x65tHxg06ocez4PSuavg36/x6HeKACfxzguF8nduObZL9e4G KtGCLcBuYrOGzdjfrPyZ5e5EJvN+5/7ziJp+UDMNBAdzJqBSQqB75mYUJTLuAxkZEMDB Lvpv9/xDseSSSqsIXiliKBwRIDRERiFcnGmN2TPxVcRg9F93X1Y/4iX+d0VPccXgiPOR 0FZ/yYJoYujGISo06DTH/x99k795f+9GQ6R6/+WXW+UEITxfAto97x6iRUTPdoPmIkSP t8ZA== X-Gm-Message-State: AOJu0Yyb4cPqqioo0pAXsJjOmC0gpNDJ/+Du4O+CukdSRCq6PfURNMs8 RdIf3y4yKhE2OqJlPmXnAdkEKjXuruBAUCXtc46czYKUZna9o2vE76MIheqHXA== X-Gm-Gg: AY/fxX6WVzD+U2uCoIR3Ps9GPHTAlI0A/UeFCOrgSHu4dyyaTSlTnp4/Px5xS0uIVbh gWO199ZkRrZTrSn4G7XueXAC6hAe7AjhKAjPZCNUOfc4hVFXSXsR+3YOKC1rFjt04C6G+eRko57 weWuLIh6Sa1P/baHdsb1uyX1yIQSTPzhxTVcEpBxBcOScJ8WiPZQO5EAbdKp8itL0Z9+OKrbzXf iyPMIX+0eDPjGiiTqe4ApFGxDLPYqw+LzFWA7sy0hDZrG5CAME//V6c6lZ/zkBKSjKzJ7ZNbXjL fOvFKz2FBlEOQ2R3w402CGnGLMH432UB5awpisihtM9IdKwzwbkxD6iKsQMaKTsYIZqh7JcgMHL vO2P+Cv0ba81lo7ZxmHmo1U8NwnBlzU3VWeTQwzx4L8ASLN7HgCkhFjz1fPB2Fmm+rhz3PkDrNp DUp7WQrT756QDzjev3orAmxQwvHZL8faM84GRTNoXNuau3qJNZx5z9GtiZX4AOuKtDyg== X-Google-Smtp-Source: AGHT+IHL7MJPWU9DeYNFy7laCsarytKMy+DXZKU8ixnYu6eCQsucB2E5Eov/WdAD7DcVr/WjYTdlKw== X-Received: by 2002:a17:907:948d:b0:b7a:1bde:1224 with SMTP id a640c23a62f3a-b80371e921fmr1543243666b.65.1766509330514; Tue, 23 Dec 2025 09:02:10 -0800 (PST) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: 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?= , Timothy Pearson , Alistair Francis , Bob Eshleman , Connor Davis Subject: [PATCH v4 3/4] xen: move alloc/free_vcpu_struct() to common code Date: Tue, 23 Dec 2025 18:01:57 +0100 Message-ID: <6041657e2309fbc8466050860bcf60d3c3c4d4bc.1766504313.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1766509366301158500 Content-Type: text/plain; charset="utf-8" alloc_vcpu_struct() and free_vcpu_struct() contain little architecture-specific logic and are suitable for sharing across architectures. Move both helpers to common code. To support the remaining architectural differences, introduce arch_vcpu_struct_memflags(), allowing architectures to override the memory flags passed to alloc_xenheap_pages(). This is currently needed by x86, which may require MEMF_bits(32) for HVM guests using shadow paging. The ARM implementation of alloc/free_vcpu_struct() is removed and replaced by the common version. Stub implementations are also dropped from PPC and RISC-V. Now that the size of struct vcpu for Arm64 is smaller than PAGE_SIZE, MAX_PAGES_PER_VCPU is no longer needed and is removed. Finally, make alloc_vcpu_struct() and free_vcpu_struct() static to common/domain.c, as they are no longer used outside common code. No functional changes. Signed-off-by: Oleksii Kurochko Acked-by: Jan Beulich Reviewed-by: Andrew Cooper --- Changes in v4: - Move implementation of alloc_vcpu_struct() and free_vcpu_struct() ahead of vmtrace_free_buffer(). - Add Reviewed-by: Andrew Cooper . - Add Acked-by: Jan Beulich . --- Changes in v3: - Make from function arch_vcpu_struct_memflags() a macros in asm/domain.h. - Drop forward declaration of arch_vcpu_struct_memflags() in asm/domain.h. - Update defintion of arch_vcpu_stuct_memflags() in alloc_vcpu_struct(). --- Changes in v2: - Rework alloc/free_vcpu_struct() to work with only one page. - Return back the comment about the restriction inside x86's arch_vcpu_struct_memflags(). - Drop MAX_PAGES_PER_VCPU. --- xen/arch/arm/domain.c | 32 ------------------------------- xen/arch/ppc/stubs.c | 10 ---------- xen/arch/riscv/stubs.c | 10 ---------- xen/arch/x86/domain.c | 24 ----------------------- xen/arch/x86/include/asm/domain.h | 12 ++++++++++++ xen/common/domain.c | 20 +++++++++++++++++++ xen/include/xen/domain.h | 4 ---- 7 files changed, 32 insertions(+), 80 deletions(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 47973f99d935..507df807edb8 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -473,38 +473,6 @@ void dump_pageframe_info(struct domain *d) =20 } =20 -/* - * The new VGIC has a bigger per-IRQ structure, so we need more than one - * page on ARM64. Cowardly increase the limit in this case. - */ -#if defined(CONFIG_NEW_VGIC) && defined(CONFIG_ARM_64) -#define MAX_PAGES_PER_VCPU 2 -#else -#define MAX_PAGES_PER_VCPU 1 -#endif - -struct vcpu *alloc_vcpu_struct(const struct domain *d) -{ - struct vcpu *v; - - BUILD_BUG_ON(sizeof(*v) > MAX_PAGES_PER_VCPU * PAGE_SIZE); - v =3D alloc_xenheap_pages(get_order_from_bytes(sizeof(*v)), 0); - if ( v !=3D NULL ) - { - unsigned int i; - - for ( i =3D 0; i < DIV_ROUND_UP(sizeof(*v), PAGE_SIZE); i++ ) - clear_page((void *)v + i * PAGE_SIZE); - } - - return v; -} - -void free_vcpu_struct(struct vcpu *v) -{ - free_xenheap_pages(v, get_order_from_bytes(sizeof(*v))); -} - int arch_vcpu_create(struct vcpu *v) { int rc =3D 0; diff --git a/xen/arch/ppc/stubs.c b/xen/arch/ppc/stubs.c index 9953ea1c6c08..f7f6e7ed97af 100644 --- a/xen/arch/ppc/stubs.c +++ b/xen/arch/ppc/stubs.c @@ -152,11 +152,6 @@ void dump_pageframe_info(struct domain *d) BUG_ON("unimplemented"); } =20 -void free_vcpu_struct(struct vcpu *v) -{ - BUG_ON("unimplemented"); -} - int arch_vcpu_create(struct vcpu *v) { BUG_ON("unimplemented"); @@ -264,11 +259,6 @@ void vcpu_kick(struct vcpu *v) BUG_ON("unimplemented"); } =20 -struct vcpu *alloc_vcpu_struct(const struct domain *d) -{ - BUG_ON("unimplemented"); -} - unsigned long hypercall_create_continuation(unsigned int op, const char *format, ...) { diff --git a/xen/arch/riscv/stubs.c b/xen/arch/riscv/stubs.c index 164fc091b28a..29bdb65afbdf 100644 --- a/xen/arch/riscv/stubs.c +++ b/xen/arch/riscv/stubs.c @@ -121,11 +121,6 @@ void dump_pageframe_info(struct domain *d) BUG_ON("unimplemented"); } =20 -void free_vcpu_struct(struct vcpu *v) -{ - BUG_ON("unimplemented"); -} - int arch_vcpu_create(struct vcpu *v) { BUG_ON("unimplemented"); @@ -233,11 +228,6 @@ void vcpu_kick(struct vcpu *v) BUG_ON("unimplemented"); } =20 -struct vcpu *alloc_vcpu_struct(const struct domain *d) -{ - BUG_ON("unimplemented"); -} - unsigned long hypercall_create_continuation(unsigned int op, const char *format, ...) { diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 7632d5e2d62d..c29a6b0decee 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -493,30 +493,6 @@ unsigned int arch_domain_struct_memflags(void) return MEMF_bits(bits); } =20 -struct vcpu *alloc_vcpu_struct(const struct domain *d) -{ - struct vcpu *v; - /* - * This structure contains embedded PAE PDPTEs, used when an HVM guest - * runs on shadow pagetables outside of 64-bit mode. In this case the = CPU - * may require that the shadow CR3 points below 4GB, and hence the who= le - * structure must satisfy this restriction. Thus we specify MEMF_bits(= 32). - */ - unsigned int memflags =3D - (is_hvm_domain(d) && paging_mode_shadow(d)) ? MEMF_bits(32) : 0; - - BUILD_BUG_ON(sizeof(*v) > PAGE_SIZE); - v =3D alloc_xenheap_pages(0, memflags); - if ( v !=3D NULL ) - clear_page(v); - return v; -} - -void free_vcpu_struct(struct vcpu *v) -{ - free_xenheap_page(v); -} - /* Initialise various registers to their architectural INIT/RESET state. */ void arch_vcpu_regs_init(struct vcpu *v) { diff --git a/xen/arch/x86/include/asm/domain.h b/xen/arch/x86/include/asm/d= omain.h index 16cd45cc32c0..effb23a23416 100644 --- a/xen/arch/x86/include/asm/domain.h +++ b/xen/arch/x86/include/asm/domain.h @@ -15,6 +15,18 @@ unsigned int arch_domain_struct_memflags(void); #define arch_domain_struct_memflags arch_domain_struct_memflags =20 +/* + * This structure contains embedded PAE PDPTEs, used when an HVM guest + * runs on shadow pagetables outside of 64-bit mode. In this case the CPU + * may require that the shadow CR3 points below 4GB, and hence the whole + * structure must satisfy this restriction. Thus we specify MEMF_bits(32). + */ +#define arch_vcpu_struct_memflags(d) ({ \ + const struct domain *d_ =3D (d); \ + \ + (is_hvm_domain(d_) && paging_mode_shadow(d_) ? MEMF_bits(32) : 0); \ +}) + #define has_32bit_shinfo(d) ((d)->arch.has_32bit_shinfo) =20 /* diff --git a/xen/common/domain.c b/xen/common/domain.c index 93c71bc766b0..655d9590f846 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -316,6 +316,26 @@ static void vcpu_info_reset(struct vcpu *v) : &dummy_vcpu_info); } =20 +static struct vcpu *alloc_vcpu_struct(const struct domain *d) +{ +#ifndef arch_vcpu_struct_memflags +# define arch_vcpu_struct_memflags(d) ((void)(d), 0) +#endif + struct vcpu *v; + + BUILD_BUG_ON(sizeof(*v) > PAGE_SIZE); + v =3D alloc_xenheap_pages(0, arch_vcpu_struct_memflags(d)); + if ( v ) + clear_page(v); + + return v; +} + +static void free_vcpu_struct(struct vcpu *v) +{ + free_xenheap_page(v); +} + static void vmtrace_free_buffer(struct vcpu *v) { const struct domain *d =3D v->domain; diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h index 8aab05ae93c8..644f5ac3f293 100644 --- a/xen/include/xen/domain.h +++ b/xen/include/xen/domain.h @@ -70,10 +70,6 @@ void domid_free(domid_t domid); struct domain *alloc_domain_struct(void); void free_domain_struct(struct domain *d); =20 -/* Allocate/free a VCPU structure. */ -struct vcpu *alloc_vcpu_struct(const struct domain *d); -void free_vcpu_struct(struct vcpu *v); - /* Allocate/free a PIRQ structure. */ #ifndef alloc_pirq_struct struct pirq *alloc_pirq_struct(struct domain *d); --=20 2.52.0 From nobody Thu Jan 8 12:40:00 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; 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=1766509362; cv=none; d=zohomail.com; s=zohoarc; b=l0AHwOT2VeYsx/vCIt9ofnw6EDOXVhOcy9M5+j6HOUB8Wb110i0Jst2BYWFphhv+vICrDgcggvWErHiQby8qK1hkUVK4srHU8yjR8mvvyF+M+Jf9CmpOh6KscaAPHFlgD/VcFxM/E5EovBdKWpSRBwDbq+93+SsrNWvdOiz929o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1766509362; 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=53lxFHrWyKrVGe7Q7DFq09Waedw2HF5xUPeWdO/aDjY=; b=mGcGSBAt+ZIYufJIWqmYnhns0yHjvcjGR6C1K9v2U2nsthSp5pxjAl0+CgLWSmiggTSdTAHYS7JEEruhhItb8QkPQdVltTTJK/2fZx2hcYNqa6J89t4UaaD1fxQrhAfPRQHE16TLl5Y3GbOTTUdkcjHpVLObIGHd5IyWLbdZWNw= 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 1766509362795547.5508493834875; Tue, 23 Dec 2025 09:02:42 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1192708.1511866 (Exim 4.92) (envelope-from ) id 1vY5m5-0001md-CX; Tue, 23 Dec 2025 17:02:17 +0000 Received: by outflank-mailman (output) from mailman id 1192708.1511866; Tue, 23 Dec 2025 17:02:17 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vY5m5-0001mC-6j; Tue, 23 Dec 2025 17:02:17 +0000 Received: by outflank-mailman (input) for mailman id 1192708; Tue, 23 Dec 2025 17:02:15 +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 1vY5m3-0000rG-Ft for xen-devel@lists.xenproject.org; Tue, 23 Dec 2025 17:02:15 +0000 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [2a00:1450:4864:20::62e]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 1fde30af-e021-11f0-9cce-f158ae23cfc8; Tue, 23 Dec 2025 18:02:12 +0100 (CET) Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-b8052725de4so379259766b.0 for ; Tue, 23 Dec 2025 09:02:12 -0800 (PST) Received: from fedora (user-109-243-71-38.play-internet.pl. [109.243.71.38]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b80464e01d9sm1306260566b.42.2025.12.23.09.02.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Dec 2025 09:02:11 -0800 (PST) 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: 1fde30af-e021-11f0-9cce-f158ae23cfc8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766509331; x=1767114131; 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=53lxFHrWyKrVGe7Q7DFq09Waedw2HF5xUPeWdO/aDjY=; b=enWmrLDOtXjYcL0F596u3QHl1z8R2XD6oVzDdO23g+H4dMT03pwCznKVqJPtn9RjNe gEC3KRIag2oJvgbk9dXilfEmtT5Qio+yITG63C8hcf8aduEODQNmWpx5sun9axlCHg5f SRIKQQXs4IHM48z1F1nO6raYnTsg0NsQdbfg8SQeH7q2WjJNEsyZTKtKinT4FOd8gXrd rWqeAosJPGZAabt9MxUs7PGMHwqcz5xw/751StZQXC7BPxQCGLPd282URA46pHQ5S8hr x/vproxHex4o+/zyudKKZ6tqAF8br62YO9MyFjCSIKlXx9RwHCFuMooRuJVe+WXb/ttW 4fVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766509331; x=1767114131; 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=53lxFHrWyKrVGe7Q7DFq09Waedw2HF5xUPeWdO/aDjY=; b=JeALDNqCA8rTgDkTPGZxrfGfRxGzWRfUKQT3sNQbDeZC7DTFE4BqY50Ij5jlvywB5Y VmBgfL2cihyhy6vbDG9Z0QC+DWvRox1cTfDTG7P2R31bxkDq10lebL9BvOVLLiMTUPSQ wg23ZykBKpPwg8bI/semg7UMPo50NABYw26fAJy6OOsavOM8hxJKCwakcLQYH2D3rADf JQ+O71u6R71oDao3g8ZyguZfHqCMBPR5E+BzAkQmdx8Bpkg39OcaEWFZIDv18UZPJcfd 0ev6pCqKO2FiqLPgJ64I1Mj92HDzADP516EPMt182LPkwDWmKhEkeGsBsbkDN+6DS1KQ XEKA== X-Gm-Message-State: AOJu0Yzo4T1jRZanen1cX4ENX9simTflLbOtW+tiL7LNPNe+muUa6IMy bqSzj+cjDHykKejylHA6bSiCsj1Rmihe/3oyZ5JcboSL6/mw2AyAWqFuZBWygg== X-Gm-Gg: AY/fxX6KOclqJC+NYf5nMbt45gC6onUTln60ffjgGSAhLW4g/BrK8oiV6wLbT6JWjtC tEOZHmrBMu4g+08YkMCmZWiLHkdX0areLnMnIaPK/+hHGyUsnaBuVtaO2l4XQ8tF023NkcGFlT2 DtImL4ZnFRSxhqWU0GjRy2hpWbyUwBO85O52vgrdZOawlfOz4Q2b3v8ouvUF+/9Tdal0l5Zorma m90fx++VsO5PSt1QAulL+apj913lNSjr7TsGaajKwHwCOLQR7APaIjnaNAYbdA25RnX/cUaVl1O g9np5ycx2HL//nGd2cUYBD6xbXj61RFZ+F7495IkNQ8FR2wc1xXeAkYMzLyszAvseDFab8YaZ+G KYTNhGSY4sv6KPRQNKbb5ODXrKHTLjQpYjk4szmspI/k2fDXnTuy+1I2skjxnDwVWIIidQEYrm5 LJXtqgYeEmeN9W09bnygRing5s5okbTmopwU8GqUj1N5Umb78LXC+r+50= X-Google-Smtp-Source: AGHT+IHXnaNp4fKXvrKrxjOgAN7KGFkLq1lGkwU6OoXQPf/mSnwxKFE0bLIQUQV9NuMYq7RGZQkAFA== X-Received: by 2002:a17:907:e106:b0:b80:4103:537e with SMTP id a640c23a62f3a-b80410355bcmr1001770366b.53.1766509331372; Tue, 23 Dec 2025 09:02:11 -0800 (PST) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Oleksii Kurochko , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v4 4/4] xen/common: make {alloc,free}_domain_struct() static Date: Tue, 23 Dec 2025 18:01:58 +0100 Message-ID: <8f1c95499cddf63310b72c7a0913b2b37ca3c24b.1766504313.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1766509364506158500 Content-Type: text/plain; charset="utf-8" As {alloc,free}_domain_struct() are used only within domain.c, they can be declared static and their declarations removed from xen/domain.h. Signed-off-by: Oleksii Kurochko Acked-by: Andrew Cooper --- Changes in v4: - Move implementation of alloc_domain_struct() and free_domain_struct() ahead of alloc_vcpu_struct(). --- Changes in v3: - Move alloc_domain_struct() and free_domain_struct() to not have forward declaration. - Add Acked-by: Andrew Cooper . --- Changes in v2: - New patch. --- xen/common/domain.c | 42 ++++++++++++++++++++-------------------- xen/include/xen/domain.h | 4 ---- 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/xen/common/domain.c b/xen/common/domain.c index 655d9590f846..ed4b6175de0b 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -316,6 +316,27 @@ static void vcpu_info_reset(struct vcpu *v) : &dummy_vcpu_info); } =20 +static struct domain *alloc_domain_struct(void) +{ +#ifndef arch_domain_struct_memflags +# define arch_domain_struct_memflags() 0 +#endif + + struct domain *d =3D alloc_xenheap_pages(0, arch_domain_struct_memflag= s()); + + BUILD_BUG_ON(sizeof(*d) > PAGE_SIZE); + + if ( d ) + clear_page(d); + + return d; +} + +static void free_domain_struct(struct domain *d) +{ + free_xenheap_page(d); +} + static struct vcpu *alloc_vcpu_struct(const struct domain *d) { #ifndef arch_vcpu_struct_memflags @@ -819,27 +840,6 @@ static int sanitise_domain_config(struct xen_domctl_cr= eatedomain *config) return arch_sanitise_domain_config(config); } =20 -struct domain *alloc_domain_struct(void) -{ -#ifndef arch_domain_struct_memflags -# define arch_domain_struct_memflags() 0 -#endif - - struct domain *d =3D alloc_xenheap_pages(0, arch_domain_struct_memflag= s()); - - BUILD_BUG_ON(sizeof(*d) > PAGE_SIZE); - - if ( d ) - clear_page(d); - - return d; -} - -void free_domain_struct(struct domain *d) -{ - free_xenheap_page(d); -} - struct domain *domain_create(domid_t domid, struct xen_domctl_createdomain *config, unsigned int flags) diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h index 644f5ac3f293..273717c31b3f 100644 --- a/xen/include/xen/domain.h +++ b/xen/include/xen/domain.h @@ -66,10 +66,6 @@ void domid_free(domid_t domid); * Arch-specifics. */ =20 -/* Allocate/free a domain structure. */ -struct domain *alloc_domain_struct(void); -void free_domain_struct(struct domain *d); - /* Allocate/free a PIRQ structure. */ #ifndef alloc_pirq_struct struct pirq *alloc_pirq_struct(struct domain *d); --=20 2.52.0