From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
Wei Liu <wei.liu2@citrix.com>, Jan Beulich <JBeulich@suse.com>
Subject: [PATCH 1/4] x86/pv: Drop int80_bounce from struct pv_vcpu
Date: Mon, 8 May 2017 16:48:05 +0100 [thread overview]
Message-ID: <1494258488-30714-2-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <1494258488-30714-1-git-send-email-andrew.cooper3@citrix.com>
The int80_bounce field of struct pv_vcpu is a bit of an odd special case,
because it is a simple derivation of trap_ctxt[0x80], which is also stored.
It is also the only use of {compat_,}create_bounce_frame() which isn't
referencing the plain trap_bounce field of struct pv_vcpu. (And altering this
property the purpose of this patch.)
Remove the int80_bounce field entirely, along with init_int80_direct_trap(),
which in turn requires that the int80_direct_trap() path gain logic previously
contained in init_int80_direct_trap().
This does admittedly make the int80 fastpath slightly longer, but these few
instructions are in the noise compared to the architectural context switch
overhead, and it now matches the syscall/sysenter paths (which have far less
architectural overhead already).
No behavioural change from the guests point of view.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
---
xen/arch/x86/domain.c | 2 --
xen/arch/x86/traps.c | 4 ----
xen/arch/x86/x86_64/asm-offsets.c | 1 -
xen/arch/x86/x86_64/compat/traps.c | 4 ----
xen/arch/x86/x86_64/entry.S | 32 ++++++++++++++++++++++++++++----
xen/arch/x86/x86_64/traps.c | 14 --------------
xen/include/asm-x86/domain.h | 1 -
xen/include/asm-x86/processor.h | 2 --
8 files changed, 28 insertions(+), 32 deletions(-)
diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index 2ef1c9f..7b301e3 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -833,8 +833,6 @@ int arch_set_info_guest(
goto out;
}
- init_int80_direct_trap(v);
-
/* IOPL privileges are virtualised. */
v->arch.pv_vcpu.iopl = v->arch.user_regs.eflags & X86_EFLAGS_IOPL;
v->arch.user_regs.eflags &= ~X86_EFLAGS_IOPL;
diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index 27fdf12..ece2c13 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -4013,7 +4013,6 @@ long do_set_trap_table(XEN_GUEST_HANDLE_PARAM(const_trap_info_t) traps)
if ( guest_handle_is_null(traps) )
{
memset(dst, 0, NR_VECTORS * sizeof(*dst));
- init_int80_direct_trap(curr);
return 0;
}
@@ -4035,9 +4034,6 @@ long do_set_trap_table(XEN_GUEST_HANDLE_PARAM(const_trap_info_t) traps)
memcpy(&dst[cur.vector], &cur, sizeof(cur));
- if ( cur.vector == 0x80 )
- init_int80_direct_trap(curr);
-
guest_handle_add_offset(traps, 1);
if ( hypercall_preempt_check() )
diff --git a/xen/arch/x86/x86_64/asm-offsets.c b/xen/arch/x86/x86_64/asm-offsets.c
index e136af6..adf2749 100644
--- a/xen/arch/x86/x86_64/asm-offsets.c
+++ b/xen/arch/x86/x86_64/asm-offsets.c
@@ -61,7 +61,6 @@ void __dummy__(void)
OFFSET(VCPU_domain, struct vcpu, domain);
OFFSET(VCPU_vcpu_info, struct vcpu, vcpu_info);
OFFSET(VCPU_trap_bounce, struct vcpu, arch.pv_vcpu.trap_bounce);
- OFFSET(VCPU_int80_bounce, struct vcpu, arch.pv_vcpu.int80_bounce);
OFFSET(VCPU_thread_flags, struct vcpu, arch.flags);
OFFSET(VCPU_event_addr, struct vcpu, arch.pv_vcpu.event_callback_eip);
OFFSET(VCPU_event_sel, struct vcpu, arch.pv_vcpu.event_callback_cs);
diff --git a/xen/arch/x86/x86_64/compat/traps.c b/xen/arch/x86/x86_64/compat/traps.c
index 1751ec6..0ab2c31 100644
--- a/xen/arch/x86/x86_64/compat/traps.c
+++ b/xen/arch/x86/x86_64/compat/traps.c
@@ -339,7 +339,6 @@ int compat_set_trap_table(XEN_GUEST_HANDLE(trap_info_compat_t) traps)
if ( guest_handle_is_null(traps) )
{
memset(dst, 0, NR_VECTORS * sizeof(*dst));
- init_int80_direct_trap(current);
return 0;
}
@@ -358,9 +357,6 @@ int compat_set_trap_table(XEN_GUEST_HANDLE(trap_info_compat_t) traps)
XLAT_trap_info(dst + cur.vector, &cur);
- if ( cur.vector == 0x80 )
- init_int80_direct_trap(current);
-
guest_handle_add_offset(traps, 1);
if ( hypercall_preempt_check() )
diff --git a/xen/arch/x86/x86_64/entry.S b/xen/arch/x86/x86_64/entry.S
index 65c771f..57952d0 100644
--- a/xen/arch/x86/x86_64/entry.S
+++ b/xen/arch/x86/x86_64/entry.S
@@ -233,12 +233,36 @@ UNLIKELY_END(msi_check)
GET_CURRENT(bx)
- /* Check that the callback is non-null. */
- leaq VCPU_int80_bounce(%rbx),%rdx
- cmpb $0,TRAPBOUNCE_flags(%rdx)
+ mov VCPU_trap_ctxt(%rbx), %rsi
+ mov VCPU_domain(%rbx), %rax
+
+ /*
+ * if ( null_trap_bounce(v, &v->arch.pv_vcpu.trap_ctxt[0x80]) )
+ * goto int80_slow_path;
+ */
+ mov 0x80 * TRAPINFO_sizeof + TRAPINFO_eip(%rsi), %rdi
+ movzwl 0x80 * TRAPINFO_sizeof + TRAPINFO_cs (%rsi), %ecx
+
+ mov %ecx, %edx
+ and $~3, %edx
+
+ testb $1, DOMAIN_is_32bit_pv(%rax)
+ cmove %rdi, %rdx
+
+ test %rdx, %rdx
jz int80_slow_path
- movq VCPU_domain(%rbx),%rax
+ /* Construct trap_bounce from trap_ctxt[0x80]. */
+ lea VCPU_trap_bounce(%rbx), %rdx
+ movw %cx, TRAPBOUNCE_cs(%rdx)
+ movq %rdi, TRAPBOUNCE_eip(%rdx)
+
+ /* TB_flags = TBF_EXCEPTION | (TI_GET_IF(ti) ? TBF_INTERRUPT : 0); */
+ testb $4, 0x80 * TRAPINFO_sizeof + TRAPINFO_flags(%rsi)
+ setnz %cl
+ lea TBF_EXCEPTION(, %rcx, TBF_INTERRUPT), %ecx
+ movb %cl, TRAPBOUNCE_flags(%rdx)
+
testb $1,DOMAIN_is_32bit_pv(%rax)
jnz compat_int80_direct_trap
diff --git a/xen/arch/x86/x86_64/traps.c b/xen/arch/x86/x86_64/traps.c
index 78f4105..69f1dc2 100644
--- a/xen/arch/x86/x86_64/traps.c
+++ b/xen/arch/x86/x86_64/traps.c
@@ -422,20 +422,6 @@ void subarch_percpu_traps_init(void)
wrmsrl(MSR_SYSCALL_MASK, XEN_SYSCALL_MASK);
}
-void init_int80_direct_trap(struct vcpu *v)
-{
- struct trap_info *ti = &v->arch.pv_vcpu.trap_ctxt[0x80];
- struct trap_bounce *tb = &v->arch.pv_vcpu.int80_bounce;
-
- tb->cs = ti->cs;
- tb->eip = ti->address;
-
- if ( null_trap_bounce(v, tb) )
- tb->flags = 0;
- else
- tb->flags = TBF_EXCEPTION | (TI_GET_IF(ti) ? TBF_INTERRUPT : 0);
-}
-
static long register_guest_callback(struct callback_register *reg)
{
long ret = 0;
diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h
index 6ab987f..ece016b 100644
--- a/xen/include/asm-x86/domain.h
+++ b/xen/include/asm-x86/domain.h
@@ -473,7 +473,6 @@ struct pv_vcpu
/* Bounce information for propagating an exception to guest OS. */
struct trap_bounce trap_bounce;
- struct trap_bounce int80_bounce;
/* I/O-port access bitmap. */
XEN_GUEST_HANDLE(uint8) iobmp; /* Guest kernel vaddr of the bitmap. */
diff --git a/xen/include/asm-x86/processor.h b/xen/include/asm-x86/processor.h
index 1d1a4ff..50435e3 100644
--- a/xen/include/asm-x86/processor.h
+++ b/xen/include/asm-x86/processor.h
@@ -466,8 +466,6 @@ extern idt_entry_t *idt_tables[];
DECLARE_PER_CPU(struct tss_struct, init_tss);
-extern void init_int80_direct_trap(struct vcpu *v);
-
extern void write_ptbase(struct vcpu *v);
void destroy_gdt(struct vcpu *d);
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-05-08 15:48 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-08 15:48 [PATCH RFC for-next 0/4] Reimpliement {compat_, }create_bounce_frame() in C Andrew Cooper
2017-05-08 15:48 ` Andrew Cooper [this message]
2017-05-09 14:49 ` [PATCH 1/4] x86/pv: Drop int80_bounce from struct pv_vcpu Jan Beulich
2017-05-09 15:09 ` Andrew Cooper
2017-05-08 15:48 ` [PATCH 2/4] x86/pv: Introduce pv_create_exception_frame() Andrew Cooper
2017-05-09 15:58 ` Jan Beulich
2017-05-09 17:09 ` Andrew Cooper
2017-05-10 7:43 ` Jan Beulich
2017-05-08 15:48 ` [PATCH 3/4] x86/pv: Drop {compat_, }create_bounce_frame() and use the C version instead Andrew Cooper
2017-05-09 16:16 ` Jan Beulich
2017-05-09 17:24 ` Andrew Cooper
2017-05-10 7:50 ` Jan Beulich
2017-05-08 15:48 ` [PATCH 4/4] x86/pv: Implement the failsafe callback using the general path Andrew Cooper
2017-05-09 16:22 ` 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=1494258488-30714-2-git-send-email-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).