[PATCH] x86/mem_sharing: Release domain if we are not able to enable memory sharing

Frediano Ziglio posted 1 patch 5 months, 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20231122163955.14555-1-frediano.ziglio@cloud.com
xen/arch/x86/mm/mem_sharing.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] x86/mem_sharing: Release domain if we are not able to enable memory sharing
Posted by Frediano Ziglio 5 months, 1 week ago
In case it's not possible to enable memory sharing (mem_sharing_control
fails) we just return the error code without releasing the domain
acquired some lines above by rcu_lock_live_remote_domain_by_id.

Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
--
I didn't manage to check the change, I was just looking at the code
for different purposes.
---
 xen/arch/x86/mm/mem_sharing.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c
index 9647e651f9..4f810706a3 100644
--- a/xen/arch/x86/mm/mem_sharing.c
+++ b/xen/arch/x86/mm/mem_sharing.c
@@ -2013,7 +2013,7 @@ int mem_sharing_memop(XEN_GUEST_HANDLE_PARAM(xen_mem_sharing_op_t) arg)
 
     if ( !mem_sharing_enabled(d) &&
          (rc = mem_sharing_control(d, true, 0)) )
-        return rc;
+        goto out;
 
     switch ( mso.op )
     {
-- 
2.34.1
Re: [PATCH] x86/mem_sharing: Release domain if we are not able to enable memory sharing
Posted by Andrew Cooper 5 months, 1 week ago
On 22/11/2023 4:39 pm, Frediano Ziglio wrote:
> In case it's not possible to enable memory sharing (mem_sharing_control
> fails) we just return the error code without releasing the domain
> acquired some lines above by rcu_lock_live_remote_domain_by_id.

Fixes: 72f8d45d69b8 ("x86/mem_sharing: enable mem_sharing on first memop")

> Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

That was simply a broken transformation in the patch.
Re: [PATCH] x86/mem_sharing: Release domain if we are not able to enable memory sharing
Posted by Tamas K Lengyel 5 months, 1 week ago
On Wed, Nov 22, 2023 at 2:42 PM Andrew Cooper <andrew.cooper3@citrix.com> wrote:
>
> On 22/11/2023 4:39 pm, Frediano Ziglio wrote:
> > In case it's not possible to enable memory sharing (mem_sharing_control
> > fails) we just return the error code without releasing the domain
> > acquired some lines above by rcu_lock_live_remote_domain_by_id.
>
> Fixes: 72f8d45d69b8 ("x86/mem_sharing: enable mem_sharing on first memop")
>
> > Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
>
> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

Acked-by: Tamas K Lengyel <tamas@tklengyel.com>