x86/pv: Drop int80_bounce from struct pv_vcpu

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>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
This commit is contained in:
Andrew Cooper committed 2018-03-05 17:36:31 +00:00
1 parent 344c552298
commit f75b1a5247
7 files changed
+28 -32

No files matched your search

-2
View File
@@ -892,8 +892,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;
-8
View File
@@ -371,7 +371,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;
}
@@ -393,9 +392,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() )
@@ -420,7 +416,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(curr);
return 0;
}
@@ -439,9 +434,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(curr);
guest_handle_add_offset(traps, 1);
if ( hypercall_preempt_check() )
-14
View File
@@ -142,20 +142,6 @@ bool set_guest_nmi_trapbounce(void)
return !null_trap_bounce(curr, tb);
}
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);
}
struct softirq_trap {
struct domain *domain; /* domain to inject trap */
struct vcpu *vcpu; /* vcpu to inject trap */
-1
View File
@@ -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);
+28 -4
View File
@@ -336,12 +336,36 @@ UNLIKELY_END(msi_check)
movq STACK_CPUINFO_FIELD(current_vcpu)(%rbx), %rbx
/* 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
cmpb $0, 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
mov %cl, TRAPBOUNCE_flags(%rdx)
cmpb $0, DOMAIN_is_32bit_pv(%rax)
jne compat_int80_direct_trap
-1
View File
@@ -482,7 +482,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. */
-2
View File
@@ -439,8 +439,6 @@ extern idt_entry_t *idt_tables[];
DECLARE_PER_CPU(struct tss_struct, init_tss);
DECLARE_PER_CPU(root_pgentry_t *, root_pgt);
extern void init_int80_direct_trap(struct vcpu *v);
extern void write_ptbase(struct vcpu *v);
/* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.