From nobody Fri Oct 31 09:40:16 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=1749560772; cv=none; d=zohomail.com; s=zohoarc; b=mhha6Gpc51OgwLMPf3rKaSk6aq9yp+S6hiJbWxVV5UHCaJbtBhnCqT1qSYYm6C4D8wjIunCXVFC37ReywdjTorn79BJJZNmEJC4gejaK4if9xrB/r+ehSffXCw18RO+yHT0JypWDFf5XxCRzO2Bd2hZ36CEalNZM9Znysr3Oyxc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1749560772; 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=wljNhX5Z+KEFF48phAFs/NmPQwz56AjKrfG07RWLiVw=; b=LeqkNtpoeD/nR2abisgu7xFeYWRq3+Nvy5uRurXON5XORwm2juxYpSIUBCM/fLKmiB35PkWGAXC94RTuftREJEPmJTAauNwLhz1C1XmmiiBE9RaDSTxIeAFJnEAWR7ZqjpiCq1SyNaHkRIkNZxYwSx/lr9qB3CzV0jfAg4/aM/Y= 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 1749560772982293.7164443056946; Tue, 10 Jun 2025 06:06:12 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1010790.1389054 (Exim 4.92) (envelope-from ) id 1uOyfp-0006mg-T8; Tue, 10 Jun 2025 13:05:53 +0000 Received: by outflank-mailman (output) from mailman id 1010790.1389054; Tue, 10 Jun 2025 13:05:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uOyfp-0006l6-JQ; Tue, 10 Jun 2025 13:05:53 +0000 Received: by outflank-mailman (input) for mailman id 1010790; Tue, 10 Jun 2025 13:05:52 +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 1uOyfo-0004Sm-2h for xen-devel@lists.xenproject.org; Tue, 10 Jun 2025 13:05:52 +0000 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [2a00:1450:4864:20::630]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id a1d624fb-45fb-11f0-b894-0df219b8e170; Tue, 10 Jun 2025 15:05:50 +0200 (CEST) Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-acae7e7587dso823661566b.2 for ; Tue, 10 Jun 2025 06:05:50 -0700 (PDT) Received: from fedora.. (user-109-243-64-38.play-internet.pl. [109.243.64.38]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ade32c42770sm626465466b.41.2025.06.10.06.05.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 06:05:49 -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: a1d624fb-45fb-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1749560750; x=1750165550; 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=wljNhX5Z+KEFF48phAFs/NmPQwz56AjKrfG07RWLiVw=; b=Vn1/yWEBMYmo+Z/CrH+R8PICecpmbyqJHEGPrtvN8I723o0L0qIy09wOgkD0/r/d9E Xie3LqYjqr4appOhIUE4mm2ZGmxvCejmPH+HU3CzQIz2ZXFdpc+bIEvrz3V4Y6DxweuU Z3rPY074N/0bnv9w1/QsxGgCMjRbJL4B2iS5DsBQHa9lAFH0XYSoSoxZGOUiZOFynKRZ BnCwEiTIYI5dOY4mBfK3tBZqc573w6SZ1aEsnu1QsQSsazPGanpdtiQr/ShttTZrPeXF qNUBzfwewKawX+4B77odSYNQTFtddAFK9gGypPVROLDboS2G/MuhJ/r09It7ffqoM3RH h87A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749560750; x=1750165550; 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=wljNhX5Z+KEFF48phAFs/NmPQwz56AjKrfG07RWLiVw=; b=lWSfSGnAahX1OmFtX80pzh2pVkGzrE26R11qitcn/AQ1O45gH6ZAMILp7tM2nPuRXB 4rAKn0AbTQUmFre42DBNFNgXUVFQYcUYijWSX8bz0kAReEZZCfe2lViR96mltNTot3WV rxELeQmm/8NZnewrzFtXtyiWWG4tvA+zZAHHFD1Ji6io1GyiPDbQVT3UNN072Pohjk4m zHdxMZ1QwIn0XR/+58Fdxw0PzcD0mkIE5pl0xkaeXp2RnkFgKxQb7EsLgPMHkd0G9BLp 4lAx5JLcHwQw6MzfBZqe7c1auNDX0XcOAOfv5PNZOn75TEBZbuM4i3qs8Z+1twC0afme jPMA== X-Gm-Message-State: AOJu0YzAIYwNlISlFRaNFMBmP2S1Sp2x0wRUiPRIwpHs5bQY0sw77VKh dIVIa7bgOREzIIkdqlj3BKGQ3q1QH1Brw3tdztTFPdRpujyzXZZhOAKd7u/SZQ== X-Gm-Gg: ASbGncudktniiDyI763MF8i6scDwyVU9KpnangAYNlDdG3MZ0pzFBl68dHV8UkyXzWy 2DyLYBZFUINDAMj8mi2tBKQp/sz99Z8xOq13TNrjKbW2AHM+7asViHqzMcSLIh2uCIZj0TewhDm 2UWFD95YmbWR9HpdoN9SN9bpfb0jOqM/am21HE7sVVPBPvc9DV5c6I96yD5lTqJWty8YvB+c27C /28gOFXXofMorwiXQD5omosRlcgnRtkSi8LWoAjVOPtMZpMm3mEAtEUTZtp/lHXVtNHi3qowlae BhRyOXlQf/dlWI6vMsB2XyukukIQxCEJdsknRFTIef+XVPEmNw8JQG4dP2PxZ/VxcOniG0o8DMR jU5Wgx4aIhZY01Dre1iPbIWlYPXC5 X-Google-Smtp-Source: AGHT+IGFjTXdFlS6sZvD06fXM72cWhnM/gD4j/C7i7+WrXUDNN4lIYkxwD7jGkhRmCOFEo4b6nz+FA== X-Received: by 2002:a17:907:6ea8:b0:ade:450a:695a with SMTP id a640c23a62f3a-ade450a70e9mr993218466b.61.1749560749329; Tue, 10 Jun 2025 06:05:49 -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 v2 08/17] xen/riscv: add new p2m types and helper macros for type classification Date: Tue, 10 Jun 2025 15:05:23 +0200 Message-ID: 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: 1749560774786124100 Content-Type: text/plain; charset="utf-8" - Extended p2m_type_t with additional types: p2m_ram_ro, p2m_mmio_direct_de= v, p2m_grant_map_{rw,ro}. - Added macros to classify memory types: P2M_RAM_TYPES, P2M_GRANT_TYPES. - Introduced helper predicates: p2m_is_ram(), p2m_is_any_ram(). Signed-off-by: Oleksii Kurochko --- Changes in V2: - Drop stuff connected to foreign mapping as it isn't necessary for RISC-V right now. --- xen/arch/riscv/include/asm/p2m.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/xen/arch/riscv/include/asm/p2m.h b/xen/arch/riscv/include/asm/= p2m.h index a31b05bd50..0c05b58992 100644 --- a/xen/arch/riscv/include/asm/p2m.h +++ b/xen/arch/riscv/include/asm/p2m.h @@ -61,8 +61,28 @@ struct p2m_domain { typedef enum { p2m_invalid =3D 0, /* Nothing mapped here */ p2m_ram_rw, /* Normal read/write domain RAM */ + p2m_ram_ro, /* Read-only; writes are silently dropped */ + p2m_mmio_direct_dev,/* Read/write mapping of genuine Device MMIO area = */ + p2m_grant_map_rw, /* Read/write grant mapping */ + p2m_grant_map_ro, /* Read-only grant mapping */ } p2m_type_t; =20 +/* We use bitmaps and mask to handle groups of types */ +#define p2m_to_mask(t_) BIT(t_, UL) + +/* RAM types, which map to real machine frames */ +#define P2M_RAM_TYPES (p2m_to_mask(p2m_ram_rw) | \ + p2m_to_mask(p2m_ram_ro)) + +/* Grant mapping types, which map to a real frame in another VM */ +#define P2M_GRANT_TYPES (p2m_to_mask(p2m_grant_map_rw) | \ + p2m_to_mask(p2m_grant_map_ro)) + +/* Useful predicates */ +#define p2m_is_ram(t_) (p2m_to_mask(t_) & P2M_RAM_TYPES) +#define p2m_is_any_ram(t_) (p2m_to_mask(t_) & \ + (P2M_RAM_TYPES | P2M_GRANT_TYPES)) + #include =20 static inline int get_page_and_type(struct page_info *page, --=20 2.49.0