From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
"Jan Beulich" <JBeulich@suse.com>,
"Roger Pau Monné" <roger.pau@citrix.com>, "Wei Liu" <wl@xen.org>
Subject: [PATCH 1/2] x86/svm: Remove regs param from asm-called functions
Date: Thu, 11 Aug 2022 20:59:04 +0100 [thread overview]
Message-ID: <20220811195905.7780-2-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <20220811195905.7780-1-andrew.cooper3@citrix.com>
A optimisation is going to want to conditionally have extra data on the stack
around VMExit.
We could alternative between `mov %rsp, %rdi` and `lea 8(%rsp), %rdi`, but it
is easier just to make the functions void and let the compiler do the (not
very) hard work.
Passing regs is a bit weird for HVM guests anyway, because the resulting
pointer is invariant (this isn't native exception handling where the regs
pointers *are* important), and all functions calculate `current` themselves
which is another invariant.
Finally, the compiler can merge the get_cpu_info() calculation which is common
to both `current` and guest_cpu_user_regs(), meaning the delta in C really is
just one `lea`, and not any more expensive than `mov`'s in ASM anyway.
No functional change.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Wei Liu <wl@xen.org>
---
xen/arch/x86/hvm/svm/entry.S | 3 ---
xen/arch/x86/hvm/svm/nestedsvm.c | 3 ++-
xen/arch/x86/hvm/svm/svm.c | 6 ++++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/xen/arch/x86/hvm/svm/entry.S b/xen/arch/x86/hvm/svm/entry.S
index a60d759f7108..be4ce52bd81d 100644
--- a/xen/arch/x86/hvm/svm/entry.S
+++ b/xen/arch/x86/hvm/svm/entry.S
@@ -26,7 +26,6 @@ ENTRY(svm_asm_do_resume)
GET_CURRENT(bx)
.Lsvm_do_resume:
call svm_intr_assist
- mov %rsp,%rdi
call nsvm_vcpu_switch
ASSERT_NOT_IN_ATOMIC
@@ -52,7 +51,6 @@ UNLIKELY_START(ne, nsvm_hap)
jmp .Lsvm_do_resume
__UNLIKELY_END(nsvm_hap)
- mov %rsp, %rdi
call svm_vmenter_helper
clgi
@@ -132,7 +130,6 @@ __UNLIKELY_END(nsvm_hap)
*/
stgi
GLOBAL(svm_stgi_label)
- mov %rsp,%rdi
call svm_vmexit_handler
jmp .Lsvm_do_resume
diff --git a/xen/arch/x86/hvm/svm/nestedsvm.c b/xen/arch/x86/hvm/svm/nestedsvm.c
index 9f5f35f16aff..77f754736023 100644
--- a/xen/arch/x86/hvm/svm/nestedsvm.c
+++ b/xen/arch/x86/hvm/svm/nestedsvm.c
@@ -1460,8 +1460,9 @@ nestedsvm_vcpu_vmexit(struct vcpu *v, struct cpu_user_regs *regs,
}
/* VCPU switch */
-void nsvm_vcpu_switch(struct cpu_user_regs *regs)
+void nsvm_vcpu_switch(void)
{
+ struct cpu_user_regs *regs = guest_cpu_user_regs();
struct vcpu *v = current;
struct nestedvcpu *nv;
struct nestedsvm *svm;
diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c
index 0849a9dc5f41..81f0cf55676b 100644
--- a/xen/arch/x86/hvm/svm/svm.c
+++ b/xen/arch/x86/hvm/svm/svm.c
@@ -1040,8 +1040,9 @@ static void noreturn cf_check svm_do_resume(void)
reset_stack_and_jump(svm_asm_do_resume);
}
-void svm_vmenter_helper(const struct cpu_user_regs *regs)
+void svm_vmenter_helper(void)
{
+ const struct cpu_user_regs *regs = guest_cpu_user_regs();
struct vcpu *curr = current;
struct vmcb_struct *vmcb = curr->arch.hvm.svm.vmcb;
@@ -2570,8 +2571,9 @@ static struct hvm_function_table __initdata_cf_clobber svm_function_table = {
},
};
-void svm_vmexit_handler(struct cpu_user_regs *regs)
+void svm_vmexit_handler(void)
{
+ struct cpu_user_regs *regs = guest_cpu_user_regs();
uint64_t exit_reason;
struct vcpu *v = current;
struct vmcb_struct *vmcb = v->arch.hvm.svm.vmcb;
--
2.11.0
next prev parent reply other threads:[~2022-08-11 19:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-11 19:59 [PATCH 0/2] x86/spec-ctrl: Reduce HVM RAS overhead Andrew Cooper
2022-08-11 19:59 ` Andrew Cooper [this message]
2022-08-12 7:06 ` [PATCH 1/2] x86/svm: Remove regs param from asm-called functions Jan Beulich
2022-08-11 19:59 ` [PATCH 2/2] x86/svm: Keep the RAS balanced for guests Andrew Cooper
2022-08-12 7:29 ` Jan Beulich
2022-08-12 10:04 ` Andrew Cooper
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=20220811195905.7780-2-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=roger.pau@citrix.com \
--cc=wl@xen.org \
--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.