All of lore.kernel.org
 help / color / mirror / Atom feed
From: "SU Hang" <darcy.sh@antgroup.com>
To: <kvm@vger.kernel.org>, <pbonzini@redhat.com>, <thuth@redhat.com>,
	<drjones@redhat.com>, "SU Hang" <darcy.sh@antgroup.com>
Subject: [kvm-unit-tests PATCH 1/2] x86: replace `push` `pop` with callee-clobbered list
Date: Sun, 24 Apr 2022 15:09:50 +0800	[thread overview]
Message-ID: <20220424070951.106990-1-darcy.sh@antgroup.com> (raw)

Stopping mess up asm callee-clobbered list with `push` `pop`,
clean up code to make it more readable.

Signed-off-by: SU Hang <darcy.sh@antgroup.com>
---
 lib/x86/usermode.c | 22 +---------------------
 1 file changed, 1 insertion(+), 21 deletions(-)

diff --git a/lib/x86/usermode.c b/lib/x86/usermode.c
index e22fb8f..477cb9f 100644
--- a/lib/x86/usermode.c
+++ b/lib/x86/usermode.c
@@ -66,32 +66,12 @@ uint64_t run_in_user(usermode_func func, unsigned int fault_vector,
 			"iretq\n"
 
 			"user_mode:\n\t"
-			/* Back up registers before invoking func */
-			"push %%rbx\n\t"
-			"push %%rcx\n\t"
-			"push %%rdx\n\t"
-			"push %%r8\n\t"
-			"push %%r9\n\t"
-			"push %%r10\n\t"
-			"push %%r11\n\t"
-			"push %%rdi\n\t"
-			"push %%rsi\n\t"
 			/* Call user mode function */
 			"mov %[arg1], %%rdi\n\t"
 			"mov %[arg2], %%rsi\n\t"
 			"mov %[arg3], %%rdx\n\t"
 			"mov %[arg4], %%rcx\n\t"
 			"call *%[func]\n\t"
-			/* Restore registers */
-			"pop %%rsi\n\t"
-			"pop %%rdi\n\t"
-			"pop %%r11\n\t"
-			"pop %%r10\n\t"
-			"pop %%r9\n\t"
-			"pop %%r8\n\t"
-			"pop %%rdx\n\t"
-			"pop %%rcx\n\t"
-			"pop %%rbx\n\t"
 			/* Return to kernel via system call */
 			"int %[kernel_entry_vector]\n\t"
 			/* Kernel Mode */
@@ -112,7 +92,7 @@ uint64_t run_in_user(usermode_func func, unsigned int fault_vector,
 					sizeof(user_stack)),
 			[kernel_entry_vector]"i"(RET_TO_KERNEL_IRQ)
 			:
-			"rsi", "rdi", "rcx", "rdx");
+			"rsi", "rdi", "rbx", "rcx", "rdx", "r8", "r9", "r10", "r11");
 
 	return rax;
 }
-- 
2.32.0.3.g01195cf9f


             reply	other threads:[~2022-04-24  7:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-24  7:09 SU Hang [this message]
2022-04-24  7:09 ` [kvm-unit-tests PATCH 2/2] x86: replace `int 0x20` with `syscall` SU Hang
2022-04-25 15:58   ` Sean Christopherson
2022-04-27  1:07     ` Sean Christopherson
2022-04-27  9:27     ` SU Hang
2022-04-28 15:58       ` Sean Christopherson

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=20220424070951.106990-1-darcy.sh@antgroup.com \
    --to=darcy.sh@antgroup.com \
    --cc=drjones@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=thuth@redhat.com \
    /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.