[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH v6 40/43] arm/altp2m: Add altp2m_reset_altp2m routine
- To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Rose Spangler <Rose.Spangler@xxxxxxxxxxxxxx>
- Date: Mon, 20 Apr 2026 17:32:03 -0400
- Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 40.93.6.107) smtp.rcpttodomain=amd.com smtp.mailfrom=elektrobit.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=elektrobit.com; dkim=pass (signature was verified) header.d=elektrobit.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=elektrobit.com] dmarc=[1,1,header.from=elektrobit.com])
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 213.95.148.172) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=elektrobit.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=elektrobit.com; dkim=none (message not signed); arc=none (0)
- Arc-message-signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ASN5ZYxdsnJbb4wpR/egaU8I/r7OxT8I6SsLPMu6BO4=; b=BJouAqVicquqoWCYiMYD3zIxec8/3zkqhKoLe+H71Ym2JoecnfUWO+oP2Hkcm1bVYtSIlQHrvrsrnFBd0OE4Xas6a3PvOGl5vOU7ilWg0V90F2vk0sQZLEAgl1G7jYk6M2jK4t+ZqrnHARBh8qXPxDvcL9iKtB49Z9uj4i5EitL/KjB1fLziOa62aRL82KKtreNjR9z2lA1Xu3anDU7PScSE5jwJ31ChEhvRooF5yyDFanZoUr7/z7c0G+NMqFnoLcE4FfaO1h3ch8/HVb32fbVzhSD/xAc1MPYlTYF0IadBs+rpTyxuvqlqoFpZ8iyUVpYPZeatydPInZapknMthA==
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ASN5ZYxdsnJbb4wpR/egaU8I/r7OxT8I6SsLPMu6BO4=; b=xSpq/8cXq7G+xQ4UWS/Rsbi1AsgCj8wvrtNsy2nLxNIGurYSLIOK3VCoLNxRf2wXYivJPPxLBuS7kEWMXZGGpb15lDdchTbU4eeUpU5cdAzQpb/FH8u+7nVkX24t78wsz30IzO4hcLpVvziOnvU2FpVM17Iw20FcXHOLZj4BrI2X46+BP1qpenqRz3Xgg190KFBUQ3gufhZR0TSMpQtwB6V57bXBFrLl3NkJ4/n3bHpifvdavqt1v6V5w5r3rnCxBvkeNlfNIJGC21sIOSY2mJ+W25zBGGHOzXIUna5hG8darGgEIIlH9h0b7LCiZbYo9Q6+ceO13sjHlPYmFVLD8Q==
- Arc-seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=CLpCBLD1qECGrCupVE1yKbteMT4bUT66alW5ozmUBIcWoZCikY9MUOn2yN0PkZ+92pGrKlLVVQFGkrkz/O60i4/k/ogG8mz3YhDYQBSeKGqK3hToMz1ls8P68vADnkbXIftl02oQBEoDRT79KC0NHBVYJAUwy9R/TDyIxqxmqVEb77Abh/njqUeU31GMw2chpKrhd7rj36TVCNSVHO8rEIZxZthwSymZC+Z0DqzouTDsyKTlaH11UHkKfF32FnwVvqGcI1vgho9/OfotOgLwsMycxS8qpMn6nHY9qPGFvdJaR4XjQFtbm7BkKOp4lKf1TyXO93MsWUW0CNGJMnZVGA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mGGmhqDc+C13sdDWM1adpVFrCmZNecvUwEBiAe4N4mugtgQtzMKK03myi94tIA4jVr/DdaVIs0f0MrR4+nSREpjE67+i6i0IW7ehuV1fxaNPZ8EGzNAx/poLEgCEjmprvOlA47IjyBqPlJMOCMdGroJnC29rPf31F/sj1RbJK+mEWzET4I9se9yd7CA8mjaKb9SZhwPzqnz0D1Mb6rMnWIOQyC/PKDKNNKU9HgJbEYzdOKvF3I2mCgZ3zdOzDevXcZ9TzWEmf2yI9lN3Skb5Ym598sWWuVVxPmPXrZOQYrfc+05AMgWxR4JhZ57FO/im5l79Fg15xer7q35VvwV2uQ==
- Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=elektrobit.com header.i="@elektrobit.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"; dkim=pass header.s=selector1 header.d=elektrobit.com header.i="@elektrobit.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
- Cc: Rose Spangler <Rose.Spangler@xxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, "Volodymyr Babchuk" <Volodymyr_Babchuk@xxxxxxxx>
- Delivery-date: Mon, 20 Apr 2026 21:34:06 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
This commit adds the altp2m_reset_altp2m routine on ARM. This will later be
used as part of the altp2m_flush routine.
This is commit 2/2 of the altp2m_reset_altp2m phase.
Signed-off-by: Rose Spangler <Rose.Spangler@xxxxxxxxxxxxxx>
---
v6: Introduced this patch.
I'm not sure if duplicating the altp2m_reset_type enum is really the
best way to handle this. The distinction isn't even relevant on ARM
since the logdirty ranges don't need to be freed. However, the function
prototype has to be the same in order to call it on both x86 and ARM.
Ideally the altp2m_reset_type enum would be part of a header that
asm/altp2m.h includes on both architectures. The main xen/altp2m.h
header can't fill this role since it includes asm/altp2m.h, so it would
be a circular include. Introducing *another* header file to just hold
altp2m_reset_type also isn't great, so I chose to just duplicate the
enum. Any better ideas here would be appreciated.
---
xen/arch/arm/altp2m.c | 20 ++++++++++++++++++++
xen/arch/arm/include/asm/altp2m.h | 8 ++++++++
2 files changed, 28 insertions(+)
diff --git a/xen/arch/arm/altp2m.c b/xen/arch/arm/altp2m.c
index aa56b3ca79b5..bf2d9095830f 100644
--- a/xen/arch/arm/altp2m.c
+++ b/xen/arch/arm/altp2m.c
@@ -7,6 +7,7 @@
#include <xen/sched.h>
+#include <asm/altp2m.h>
#include <asm/p2m.h>
/* Check to see if vcpu should be switched to a different p2m. */
@@ -37,6 +38,25 @@ bool altp2m_view_is_visible(struct domain *d, unsigned int
idx)
return d->arch.altp2m_state[array_index_nospec(idx, d->nr_altp2m)] ==
ALTP2M_VISIBLE;
}
+void altp2m_reset_altp2m(struct domain *d, unsigned int idx,
+ enum altp2m_reset_type reset_type)
+{
+ struct p2m_domain *p2m;
+
+ ASSERT(idx < d->nr_altp2m);
+ p2m = d->altp2m_p2m[array_index_nospec(idx, d->nr_altp2m)];
+
+ p2m_write_lock(p2m);
+
+ while ( p2m_flush_table(p2m) == -ERESTART )
+ continue; /* No preemption support here */
+
+ p2m->lowest_mapped_gfn = INVALID_GFN;
+ p2m->max_mapped_gfn = _gfn(0);
+
+ p2m_write_unlock(p2m);
+}
+
int altp2m_activate_altp2m(struct domain *d, unsigned int idx,
p2m_access_t hvmmem_default_access)
{
diff --git a/xen/arch/arm/include/asm/altp2m.h
b/xen/arch/arm/include/asm/altp2m.h
index 192240f48c33..14961736a238 100644
--- a/xen/arch/arm/include/asm/altp2m.h
+++ b/xen/arch/arm/include/asm/altp2m.h
@@ -52,6 +52,14 @@ int altp2m_set_view_visibility_locked(struct domain *d,
unsigned int altp2m_idx,
int altp2m_activate_altp2m(struct domain *d, unsigned int idx,
p2m_access_t hvmmem_default_access);
+/* Reset an altp2m view */
+enum altp2m_reset_type {
+ ALTP2M_RESET,
+ ALTP2M_DEACTIVATE
+};
+void altp2m_reset_altp2m(struct domain *d, unsigned int idx,
+ enum altp2m_reset_type reset_type);
+
#else /* CONFIG_ALTP2M */
static inline bool altp2m_supported(void)
--
2.34.1
|