From: Wei Liu <wei.liu2@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
Wei Liu <wei.liu2@citrix.com>, Jan Beulich <JBeulich@suse.com>
Subject: [PATCH v2 03/18] x86/traps: lift do_guest_trap to domain.h
Date: Fri, 5 May 2017 15:48:21 +0100 [thread overview]
Message-ID: <20170505144836.8612-4-wei.liu2@citrix.com> (raw)
In-Reply-To: <20170505144836.8612-1-wei.liu2@citrix.com>
Put it along side with other pv_inject functions and rename it to
pv_inject_trap.
We need this because this function is used by PV emulation code and PV
trap handling code, which will be split into different files.
No functional change.
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
xen/arch/x86/traps.c | 58 ++++++++++++++++++--------------------------
xen/include/asm-x86/domain.h | 12 +++++++++
2 files changed, 35 insertions(+), 35 deletions(-)
diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index 8023392a06..2639be7850 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -684,18 +684,6 @@ void pv_inject_event(const struct x86_event *event)
}
}
-static inline void do_guest_trap(unsigned int trapnr,
- const struct cpu_user_regs *regs)
-{
- const struct x86_event event = {
- .vector = trapnr,
- .error_code = (((trapnr < 32) && (TRAP_HAVE_EC & (1u << trapnr)))
- ? regs->error_code : X86_EVENT_NO_EC),
- };
-
- pv_inject_event(&event);
-}
-
static void instruction_done(struct cpu_user_regs *regs, unsigned long rip)
{
regs->rip = rip;
@@ -703,7 +691,7 @@ static void instruction_done(struct cpu_user_regs *regs, unsigned long rip)
if ( regs->eflags & X86_EFLAGS_TF )
{
current->arch.debugreg[6] |= DR_STEP | DR_STATUS_RESERVED_ONE;
- do_guest_trap(TRAP_debug, regs);
+ pv_inject_trap(TRAP_debug, regs);
}
}
@@ -751,7 +739,7 @@ int set_guest_machinecheck_trapbounce(void)
struct vcpu *v = current;
struct trap_bounce *tb = &v->arch.pv_vcpu.trap_bounce;
- do_guest_trap(TRAP_machine_check, guest_cpu_user_regs());
+ pv_inject_trap(TRAP_machine_check, guest_cpu_user_regs());
tb->flags &= ~TBF_EXCEPTION; /* not needed for MCE delivery path */
return !null_trap_bounce(v, tb);
}
@@ -764,7 +752,7 @@ int set_guest_nmi_trapbounce(void)
{
struct vcpu *v = current;
struct trap_bounce *tb = &v->arch.pv_vcpu.trap_bounce;
- do_guest_trap(TRAP_nmi, guest_cpu_user_regs());
+ pv_inject_trap(TRAP_nmi, guest_cpu_user_regs());
tb->flags &= ~TBF_EXCEPTION; /* not needed for NMI delivery path */
return !null_trap_bounce(v, tb);
}
@@ -794,7 +782,7 @@ void do_trap(struct cpu_user_regs *regs)
if ( guest_mode(regs) )
{
- do_guest_trap(trapnr, regs);
+ pv_inject_trap(trapnr, regs);
return;
}
@@ -1060,7 +1048,7 @@ static int emulate_forced_invalid_op(struct cpu_user_regs *regs)
if ( current->arch.cpuid_faulting && !guest_kernel_mode(current, regs) )
{
regs->rip = eip;
- do_guest_trap(TRAP_gp_fault, regs);
+ pv_inject_trap(TRAP_gp_fault, regs);
return EXCRET_fault_fixed;
}
@@ -1096,7 +1084,7 @@ void do_invalid_op(struct cpu_user_regs *regs)
{
if ( !emulate_invalid_rdtscp(regs) &&
!emulate_forced_invalid_op(regs) )
- do_guest_trap(TRAP_invalid_op, regs);
+ pv_inject_trap(TRAP_invalid_op, regs);
return;
}
@@ -1224,7 +1212,7 @@ void do_int3(struct cpu_user_regs *regs)
return;
}
- do_guest_trap(TRAP_int3, regs);
+ pv_inject_trap(TRAP_int3, regs);
}
static void reserved_bit_page_fault(
@@ -3038,7 +3026,7 @@ static int emulate_privileged_op(struct cpu_user_regs *regs)
{
curr->arch.debugreg[6] |= ctxt.bpmatch | DR_STATUS_RESERVED_ONE;
if ( !(curr->arch.pv_vcpu.trap_bounce.flags & TBF_EXCEPTION) )
- do_guest_trap(TRAP_debug, regs);
+ pv_inject_trap(TRAP_debug, regs);
}
/* fall through */
case X86EMUL_RETRY:
@@ -3153,12 +3141,12 @@ static void emulate_gate_op(struct cpu_user_regs *regs)
(((ar >> 13) & 3) < (regs->cs & 3)) ||
((ar & _SEGMENT_TYPE) != 0xc00) )
{
- do_guest_trap(TRAP_gp_fault, regs);
+ pv_inject_trap(TRAP_gp_fault, regs);
return;
}
if ( !(ar & _SEGMENT_P) )
{
- do_guest_trap(TRAP_no_segment, regs);
+ pv_inject_trap(TRAP_no_segment, regs);
return;
}
dpl = (ar >> 13) & 3;
@@ -3174,7 +3162,7 @@ static void emulate_gate_op(struct cpu_user_regs *regs)
!(ar & _SEGMENT_P) ||
!(ar & _SEGMENT_CODE) )
{
- do_guest_trap(TRAP_gp_fault, regs);
+ pv_inject_trap(TRAP_gp_fault, regs);
return;
}
@@ -3187,7 +3175,7 @@ static void emulate_gate_op(struct cpu_user_regs *regs)
if ( PTR_ERR(state) == -X86EMUL_EXCEPTION )
pv_inject_event(&ctxt.ctxt.event);
else
- do_guest_trap(TRAP_gp_fault, regs);
+ pv_inject_trap(TRAP_gp_fault, regs);
return;
}
@@ -3237,7 +3225,7 @@ static void emulate_gate_op(struct cpu_user_regs *regs)
(opnd_sel & ~3) != regs->error_code ||
dpl < (opnd_sel & 3) )
{
- do_guest_trap(TRAP_gp_fault, regs);
+ pv_inject_trap(TRAP_gp_fault, regs);
return;
}
@@ -3285,7 +3273,7 @@ static void emulate_gate_op(struct cpu_user_regs *regs)
/* Inner stack known only for kernel ring. */
if ( (sel & 3) != GUEST_KERNEL_RPL(v->domain) )
{
- do_guest_trap(TRAP_gp_fault, regs);
+ pv_inject_trap(TRAP_gp_fault, regs);
return;
}
esp = v->arch.pv_vcpu.kernel_sp;
@@ -3309,7 +3297,7 @@ static void emulate_gate_op(struct cpu_user_regs *regs)
stkp = (unsigned int *)(unsigned long)((unsigned int)base + esp);
if ( !compat_access_ok(stkp - 4 - nparm, (4 + nparm) * 4) )
{
- do_guest_trap(TRAP_gp_fault, regs);
+ pv_inject_trap(TRAP_gp_fault, regs);
return;
}
push(regs->ss);
@@ -3324,12 +3312,12 @@ static void emulate_gate_op(struct cpu_user_regs *regs)
(ar & _SEGMENT_CODE) ||
!(ar & _SEGMENT_WR) ||
!check_stack_limit(ar, limit, esp + nparm * 4, nparm * 4) )
- return do_guest_trap(TRAP_gp_fault, regs);
+ return pv_inject_trap(TRAP_gp_fault, regs);
ustkp = (unsigned int *)(unsigned long)
((unsigned int)base + regs->esp + nparm * 4);
if ( !compat_access_ok(ustkp - nparm, nparm * 4) )
{
- do_guest_trap(TRAP_gp_fault, regs);
+ pv_inject_trap(TRAP_gp_fault, regs);
return;
}
do
@@ -3355,7 +3343,7 @@ static void emulate_gate_op(struct cpu_user_regs *regs)
if ( !read_descriptor(ss, v, &base, &limit, &ar, 0) ||
((ar >> 13) & 3) != (sel & 3) )
{
- do_guest_trap(TRAP_gp_fault, regs);
+ pv_inject_trap(TRAP_gp_fault, regs);
return;
}
if ( !check_stack_limit(ar, limit, esp, 2 * 4) )
@@ -3366,7 +3354,7 @@ static void emulate_gate_op(struct cpu_user_regs *regs)
stkp = (unsigned int *)(unsigned long)((unsigned int)base + esp);
if ( !compat_access_ok(stkp - 2, 2 * 4) )
{
- do_guest_trap(TRAP_gp_fault, regs);
+ pv_inject_trap(TRAP_gp_fault, regs);
return;
}
}
@@ -3427,7 +3415,7 @@ void do_general_protection(struct cpu_user_regs *regs)
if ( permit_softint(TI_GET_DPL(ti), v, regs) )
{
regs->rip += 2;
- do_guest_trap(vector, regs);
+ pv_inject_trap(vector, regs);
return;
}
}
@@ -3446,7 +3434,7 @@ void do_general_protection(struct cpu_user_regs *regs)
}
/* Pass on GPF as is. */
- do_guest_trap(TRAP_gp_fault, regs);
+ pv_inject_trap(TRAP_gp_fault, regs);
return;
gp_in_kernel:
@@ -3666,7 +3654,7 @@ void do_device_not_available(struct cpu_user_regs *regs)
if ( curr->arch.pv_vcpu.ctrlreg[0] & X86_CR0_TS )
{
- do_guest_trap(TRAP_no_device, regs);
+ pv_inject_trap(TRAP_no_device, regs);
curr->arch.pv_vcpu.ctrlreg[0] &= ~X86_CR0_TS;
}
else
@@ -3739,7 +3727,7 @@ void do_debug(struct cpu_user_regs *regs)
v->arch.debugreg[6] = read_debugreg(6);
ler_enable();
- do_guest_trap(TRAP_debug, regs);
+ pv_inject_trap(TRAP_debug, regs);
return;
out:
diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h
index 6ab987f231..355a8afcdb 100644
--- a/xen/include/asm-x86/domain.h
+++ b/xen/include/asm-x86/domain.h
@@ -655,6 +655,18 @@ static inline void pv_inject_page_fault(int errcode, unsigned long cr2)
pv_inject_event(&event);
}
+static inline void pv_inject_trap(unsigned int trapnr,
+ const struct cpu_user_regs *regs)
+{
+ const struct x86_event event = {
+ .vector = trapnr,
+ .error_code = (((trapnr < 32) && (TRAP_HAVE_EC & (1u << trapnr)))
+ ? regs->error_code : X86_EVENT_NO_EC),
+ };
+
+ pv_inject_event(&event);
+}
+
#endif /* __ASM_DOMAIN_H__ */
/*
--
2.11.0
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-05-05 14:48 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-05 14:48 [PATCH v2 00/18] Refactor x86 trap handling code Wei Liu
2017-05-05 14:48 ` [PATCH v2 01/18] x86/traps: factor out pv_percpu_traps_init Wei Liu
2017-05-05 16:12 ` Andrew Cooper
2017-05-12 12:00 ` Wei Liu
2017-05-05 14:48 ` [PATCH v2 02/18] x86/traps: export trapstr Wei Liu
2017-05-05 14:48 ` Wei Liu [this message]
2017-05-12 18:16 ` [PATCH v2 03/18] x86/traps: lift do_guest_trap to domain.h Andrew Cooper
2017-05-12 18:26 ` Andrew Cooper
2017-05-15 7:50 ` Jan Beulich
2017-05-05 14:48 ` [PATCH v2 04/18] x86/traps: move all PV emulation code to pv/emulate_ops.h Wei Liu
2017-05-11 10:18 ` Andrew Cooper
2017-05-12 12:00 ` Wei Liu
2017-05-05 14:48 ` [PATCH v2 05/18] x86/pv: clean up emulate_ops.c Wei Liu
2017-05-11 11:22 ` Andrew Cooper
2017-05-12 12:02 ` Wei Liu
2017-05-12 12:03 ` Wei Liu
2017-05-05 14:48 ` [PATCH v2 06/18] x86/traps: move PV hypercall handlers to pv/traps.c Wei Liu
2017-05-05 14:48 ` [PATCH v2 07/18] x86/traps: move pv_inject_event " Wei Liu
2017-05-05 14:48 ` [PATCH v2 08/18] x86/traps: move set_guest_{machinecheck, nmi}_trapbounce Wei Liu
2017-05-05 14:48 ` [PATCH v2 09/18] x86/traps: move {un, }register_guest_nmi_callback Wei Liu
2017-05-05 14:48 ` [PATCH v2 10/18] x86/traps: delcare percpu softirq_trap Wei Liu
2017-05-05 14:48 ` [PATCH v2 11/18] x86/traps: move guest_has_trap_callback to pv/traps.c Wei Liu
2017-05-05 14:48 ` [PATCH v2 12/18] x86/traps: move send_guest_trap " Wei Liu
2017-05-05 14:48 ` [PATCH v2 13/18] x86/traps: move PV specific code in x86_64/traps.c Wei Liu
2017-05-05 14:48 ` [PATCH v2 14/18] x86/traps: merge x86_64/compat/traps.c into pv/traps.c Wei Liu
2017-05-05 14:48 ` [PATCH v2 15/18] x86: clean up pv/traps.c Wei Liu
2017-05-05 14:48 ` [PATCH v2 16/18] x86: guest_has_trap_callback should return bool Wei Liu
2017-05-05 14:48 ` [PATCH v2 17/18] x86: fix coding style issues in asm-x86/traps.h Wei Liu
2017-05-05 14:48 ` [PATCH v2 18/18] x86: clean up traps.c Wei Liu
2017-05-09 10:50 ` [PATCH v2 00/18] Refactor x86 trap handling code 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=20170505144836.8612-4-wei.liu2@citrix.com \
--to=wei.liu2@citrix.com \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--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 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).