Skip to contentSkip to conversation

x86/mem_sharing: add missing m2p entry when mapping shared_info page

PATCH In review Tamas K Lengyel 3 participants 5 messages Oct 19, 2023 – Oct 20, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/mem_sharing: add missing m2p entry when mapping shared_info page

When mapping in the shared_info page to a fork the m2p entry wasn't set resulting in the shared_info being reset even when the fork reset was called with only reset_state and not reset_memory. This results in an extra unnecessary TLB flush.

Fixes 1a0000ac775 ("mem_sharing: map shared_info page to same gfn during fork")
---
 xen/arch/x86/mm/mem_sharing.c | 2 ++
 1 file changed, 2 insertions(+)
xen/arch/x86/mm/mem_sharing.c +2 -0
index 94b6b782ef..142258f16a 100644
@@ -1847,6 +1847,8 @@ static int copy_special_pages(struct domain *cd, struct domain *d)
                                 p2m_ram_rw, p2m->default_access, -1);
             if ( rc )
                 return rc;
+
+            set_gpfn_from_mfn(mfn_x(new_mfn), gfn_x(old_gfn));
         }
     }
 
Signature · 1 line
2.34.1
Acked-by on v1 1/1
#1 lore raw
Quoted 16 lines · Tamas K Lengyel

When mapping in the shared_info page to a fork the m2p entry wasn't set resulting in the shared_info being reset even when the fork reset was called with only reset_state and not reset_memory. This results in an extra unnecessary TLB flush.

Fixes 1a0000ac775 ("mem_sharing: map shared_info page to same gfn during fork")
---
 xen/arch/x86/mm/mem_sharing.c | 2 ++
 1 file changed, 2 insertions(+)
xen/arch/x86/mm/mem_sharing.c +0 -0
index 94b6b782ef..142258f16a 100644

xen/arch/x86/mm/mem_sharing.c static int copy_special_pages(struct domain *cd, struct domain *d) · line 1854

Quoted 8 lines
xen/arch/x86/mm/mem_sharing.c +2 -0
@@ -1847,6 +1847,8 @@ static int copy_special_pages(struct domain *cd, struct domain *d)
                                 p2m_ram_rw, p2m->default_access, -1);
             if ( rc )
                 return rc;
+
+            set_gpfn_from_mfn(mfn_x(new_mfn), gfn_x(old_gfn));
         }
     }
 

CC Henry.  This needs a view about a release ack.

Cons: it's been broken since Xen 4.14 and we're very deep into the 4.18 code freeze.

Pros: it's a bug and would clearly qualify for backport, and is in a niche feature so isn't plausibly going to adversely affect other users.

~Andrew

#2 lore raw

Hi all,

Quoted 30 lines · Andrew Cooper
Quoted 16 lines · Tamas K Lengyel

When mapping in the shared_info page to a fork the m2p entry wasn't set resulting in the shared_info being reset even when the fork reset was called with only reset_state and not reset_memory. This results in an extra unnecessary TLB flush.

Fixes 1a0000ac775 ("mem_sharing: map shared_info page to same gfn during fork")

---
xen/arch/x86/mm/mem_sharing.c | 2 ++

1 file changed, 2 insertions(+)
xen/arch/x86/mm/mem_sharing.c +0 -0
index 94b6b782ef..142258f16a 100644

xen/arch/x86/mm/mem_sharing.c static int copy_special_pages(struct domain *cd, struct domain *d) · line 1854

Quoted 8 lines
xen/arch/x86/mm/mem_sharing.c +2 -0
@@ -1847,6 +1847,8 @@ static int copy_special_pages(struct domain *cd, struct domain *d)
                                p2m_ram_rw, p2m->default_access, -1);
            if ( rc )
                return rc;
+
+            set_gpfn_from_mfn(mfn_x(new_mfn), gfn_x(old_gfn));
        }
    }
 
Quoted 7 lines

CC Henry. This needs a view about a release ack.

Cons: it's been broken since Xen 4.14 and we're very deep into the 4.18 code freeze.

Pros: it's a bug and would clearly qualify for backport, and is in a niche feature so isn't plausibly going to adversely affect other users.

Given the fact that it will be backported anyway, I had the same discussion with Juergen in his thread [1]. So if we can bear the risk of delaying merging this patch for a week, would it be ok to wait for the release and backport this patch to the stable tree? Thanks!

[1] https://lore.kernel.org/xen-devel/[email protected]/

Kind regards,
Henry

Quoted 2 lines

~Andrew

#3 lore raw
Quoted 38 lines · Henry Wang

Hi all,

Quoted 29 lines · Andrew Cooper
Quoted 16 lines · Tamas K Lengyel

When mapping in the shared_info page to a fork the m2p entry wasn't set resulting in the shared_info being reset even when the fork reset was called with only reset_state and not reset_memory. This results in an extra unnecessary TLB flush.

Fixes 1a0000ac775 ("mem_sharing: map shared_info page to same gfn during fork")

---
xen/arch/x86/mm/mem_sharing.c | 2 ++

1 file changed, 2 insertions(+)
xen/arch/x86/mm/mem_sharing.c +0 -0
index 94b6b782ef..142258f16a 100644

xen/arch/x86/mm/mem_sharing.c static int copy_special_pages(struct domain *cd, struct domain *d) · line 1854

Quoted 8 lines
xen/arch/x86/mm/mem_sharing.c +2 -0
@@ -1847,6 +1847,8 @@ static int copy_special_pages(struct domain *cd, struct domain *d)
                                p2m_ram_rw, p2m->default_access, -1);
            if ( rc )
                return rc;
+
+            set_gpfn_from_mfn(mfn_x(new_mfn), gfn_x(old_gfn));
        }
    }
 
Quoted 7 lines

CC Henry. This needs a view about a release ack.

Cons: it's been broken since Xen 4.14 and we're very deep into the 4.18 code freeze.

Pros: it's a bug and would clearly qualify for backport, and is in a niche feature so isn't plausibly going to adversely affect other users.

Quoted 8 lines

Given the fact that it will be backported anyway, I had the same discussion with Juergen in his thread [1]. So if we can bear the risk of delaying merging this patch for a week, would it be ok to wait for the release and backport this patch to the stable tree? Thanks!

[1] https://lore.kernel.org/xen-devel/[email protected]/

Kind regards,
Henry

That's fine.  I'll pull this into my next branch for when the 4.19 tree opens.

~Andrew

#4 lore raw
Quoted 44 lines · Andrew Cooper
Quoted 42 lines · Henry Wang

Hi all,

Quoted 29 lines · Andrew Cooper
Quoted 16 lines · Tamas K Lengyel

When mapping in the shared_info page to a fork the m2p entry wasn't set resulting in the shared_info being reset even when the fork reset was called with only reset_state and not reset_memory. This results in an extra unnecessary TLB flush.

Fixes 1a0000ac775 ("mem_sharing: map shared_info page to same gfn during fork")

---
xen/arch/x86/mm/mem_sharing.c | 2 ++

1 file changed, 2 insertions(+)
xen/arch/x86/mm/mem_sharing.c +0 -0
index 94b6b782ef..142258f16a 100644

xen/arch/x86/mm/mem_sharing.c static int copy_special_pages(struct domain *cd, struct domain *d) · line 1854

Quoted 8 lines
xen/arch/x86/mm/mem_sharing.c +2 -0
@@ -1847,6 +1847,8 @@ static int copy_special_pages(struct domain *cd, struct domain *d)
                                p2m_ram_rw, p2m->default_access, -1);
            if ( rc )
                return rc;
+
+            set_gpfn_from_mfn(mfn_x(new_mfn), gfn_x(old_gfn));
        }
    }
 
Quoted 7 lines

CC Henry. This needs a view about a release ack.

Cons: it's been broken since Xen 4.14 and we're very deep into the 4.18 code freeze.

Pros: it's a bug and would clearly qualify for backport, and is in a niche feature so isn't plausibly going to adversely affect other users.

Given the fact that it will be backported anyway, I had the same discussion with Juergen in his thread [1]. So if we can bear the risk of delaying merging this patch for a week, would it be ok to wait for the release and backport this patch to the stable tree? Thanks!

Quoted 7 lines
Quoted 4 lines

[1] https://lore.kernel.org/xen-devel/[email protected]/

Kind regards,
Henry

That's fine. I'll pull this into my next branch for when the 4.19 tree opens.

Thanks, I agree that backporting is perfectly fine for this one.

Tamas