From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mukesh Rathor Subject: [V11 PATCH 10/21] PVH xen: support invalid op emulation for PVH Date: Thu, 22 Aug 2013 18:18:59 -0700 Message-ID: <1377220750-19514-11-git-send-email-mukesh.rathor@oracle.com> References: <1377220750-19514-1-git-send-email-mukesh.rathor@oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1377220750-19514-1-git-send-email-mukesh.rathor@oracle.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org This patch supports invalid op emulation for PVH by calling appropriate copy macros and and HVM function to inject PF. Changes in V11: - Break propagate_page_fault to create pv_inject_page_fault. Signed-off-by: Mukesh Rathor Reviewed-by: Jan Beulich Acked-by: Keir Fraser Reviewed-by: Andrew Cooper Reviewed-by: Tim Deegan PV-HVM-Regression-Tested-by: Andrew Cooper --- xen/arch/x86/traps.c | 21 ++++++++++++++++++--- 1 files changed, 18 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index 0519836..2e92a0e 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -460,6 +460,11 @@ static void instruction_done( struct cpu_user_regs *regs, unsigned long eip, unsigned int bpmatch) { regs->eip = eip; + + /* PVH fixme: support guest io bp trap below */ + if ( is_pvh_vcpu(current) ) + return; + regs->eflags &= ~X86_EFLAGS_RF; if ( bpmatch || (regs->eflags & X86_EFLAGS_TF) ) { @@ -922,7 +927,7 @@ static int emulate_forced_invalid_op(struct cpu_user_regs *regs) eip = regs->eip; /* Check for forced emulation signature: ud2 ; .ascii "xen". */ - if ( (rc = copy_from_user(sig, (char *)eip, sizeof(sig))) != 0 ) + if ( (rc = raw_copy_from_guest(sig, (char *)eip, sizeof(sig))) != 0 ) { propagate_page_fault(eip + sizeof(sig) - rc, 0); return EXCRET_fault_fixed; @@ -932,7 +937,7 @@ static int emulate_forced_invalid_op(struct cpu_user_regs *regs) eip += sizeof(sig); /* We only emulate CPUID. */ - if ( ( rc = copy_from_user(instr, (char *)eip, sizeof(instr))) != 0 ) + if ( ( rc = raw_copy_from_guest(instr, (char *)eip, sizeof(instr))) != 0 ) { propagate_page_fault(eip + sizeof(instr) - rc, 0); return EXCRET_fault_fixed; @@ -1071,7 +1076,7 @@ static void reserved_bit_page_fault( show_execution_state(regs); } -void propagate_page_fault(unsigned long addr, u16 error_code) +static void pv_inject_page_fault(unsigned long addr, u16 error_code) { struct trap_info *ti; struct vcpu *v = current; @@ -1105,6 +1110,16 @@ void propagate_page_fault(unsigned long addr, u16 error_code) reserved_bit_page_fault(addr, guest_cpu_user_regs()); } +void propagate_page_fault(unsigned long addr, u16 error_code) +{ + if ( is_pvh_vcpu(current) ) + hvm_inject_page_fault(error_code, addr); + else if ( is_pv_vcpu(current) ) + pv_inject_page_fault(addr, error_code); + else + BUG(); +} + static int handle_gdt_ldt_mapping_fault( unsigned long offset, struct cpu_user_regs *regs) { -- 1.7.2.3