All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yuho Choi <oss.patchbox@gmail.com>
To: xen-devel@lists.xenproject.org
Cc: "Jan Beulich" <jbeulich@suse.com>,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Roger Pau Monné" <roger@xenproject.org>,
	"Teddy Astie" <teddy.astie@vates.tech>,
	"Yuho Choi" <oss.patchbox@gmail.com>
Subject: [PATCH] x86/platform: fix the MTRR rollback in XENPF_add_memtype
Date: Tue,  3 Nov 2026 23:50:50 -0500	[thread overview]
Message-ID: <20261104045058.1434821-1-oss.patchbox@gmail.com> (raw)

If copying the result back to the caller fails, XENPF_add_memtype
tries to undo mtrr_add_page() with mtrr_del_page(ret, 0, 0). By then
ret holds -EFAULT, so mtrr_del_page() looks up an MTRR with base and
size 0 and releases nothing. The register that was added, or whose
usage count was raised, stays in use, and the caller only gets
-EFAULT, without the register number it would need to delete it.

Pass the register number saved in op->u.add_memtype.reg instead.

Fixes: 8ee614278c2d ("[XEN] Fix memtype accessor domctls.")
Signed-off-by: Yuho Choi <oss.patchbox@gmail.com>
---
Build-tested only (x86_64 defconfig); not run.

 xen/arch/x86/platform_hypercall.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/x86/platform_hypercall.c b/xen/arch/x86/platform_hypercall.c
index 6dee4922f3..0f3c791fc2 100644
--- a/xen/arch/x86/platform_hypercall.c
+++ b/xen/arch/x86/platform_hypercall.c
@@ -295,7 +295,7 @@ ret_t do_platform_op(
             ret = __copy_field_to_guest(u_xenpf_op, op, u.add_memtype) ?
                   -EFAULT : 0;
             if ( ret != 0 )
-                mtrr_del_page(ret, 0, 0);
+                mtrr_del_page(op->u.add_memtype.reg, 0, 0);
         }
         break;
 
-- 
2.43.0



             reply	other threads:[~2026-11-04  6:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-04  4:50 Yuho Choi [this message]
2026-11-04  6:37 ` [PATCH] x86/platform: fix the MTRR rollback in XENPF_add_memtype Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261104045058.1434821-1-oss.patchbox@gmail.com \
    --to=oss.patchbox@gmail.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=roger@xenproject.org \
    --cc=teddy.astie@vates.tech \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.