Re: [PATCH 20/31] mips/kvm: Hook into TLB fault handlers.

2013-06-16 Thread Ralf Baechle
Acked-by: Ralf Baechle r...@linux-mips.org

  Ralf
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 20/31] mips/kvm: Hook into TLB fault handlers.

2013-06-07 Thread David Daney
From: David Daney david.da...@cavium.com

If the CPU is operating in guest mode when a TLB related excpetion
occurs, give KVM a chance to do emulation.

Signed-off-by: David Daney david.da...@cavium.com
---
 arch/mips/mm/fault.c   | 8 
 arch/mips/mm/tlbex-fault.S | 6 ++
 2 files changed, 14 insertions(+)

diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
index 0fead53..9391da49 100644
--- a/arch/mips/mm/fault.c
+++ b/arch/mips/mm/fault.c
@@ -26,6 +26,7 @@
 #include asm/ptrace.h
 #include asm/highmem.h   /* For VMALLOC_END */
 #include linux/kdebug.h
+#include asm/kvm_mips_vz.h
 
 /*
  * This routine handles page faults.  It determines the address,
@@ -50,6 +51,13 @@ asmlinkage void __kprobes do_page_fault(struct pt_regs 
*regs, unsigned long writ
   field, regs-cp0_epc);
 #endif
 
+#ifdef CONFIG_KVM_MIPSVZ
+   if (test_tsk_thread_flag(current, TIF_GUESTMODE)) {
+   if (mipsvz_page_fault(regs, write, address))
+   return;
+   }
+#endif
+
 #ifdef CONFIG_KPROBES
/*
 * This is to notify the fault handler of the kprobes.  The
diff --git a/arch/mips/mm/tlbex-fault.S b/arch/mips/mm/tlbex-fault.S
index 318855e..df0f70b 100644
--- a/arch/mips/mm/tlbex-fault.S
+++ b/arch/mips/mm/tlbex-fault.S
@@ -14,6 +14,12 @@
NESTED(tlb_do_page_fault_\write, PT_SIZE, sp)
SAVE_ALL
MFC0a2, CP0_BADVADDR
+#ifdef CONFIG_KVM_MIPSVZ
+   mfc0v0, CP0_BADINSTR
+   mfc0v1, CP0_BADINSTRP
+   sw  v0, PT_BADINSTR(sp)
+   sw  v1, PT_BADINSTRP(sp)
+#endif
KMODE
movea0, sp
REG_S   a2, PT_BVADDR(sp)
-- 
1.7.11.7

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 20/31] mips/kvm: Hook into TLB fault handlers.

2013-06-07 Thread Sergei Shtylyov

Hello.

On 06/08/2013 03:03 AM, David Daney wrote:


From: David Daney david.da...@cavium.com

If the CPU is operating in guest mode when a TLB related excpetion
occurs, give KVM a chance to do emulation.

Signed-off-by: David Daney david.da...@cavium.com
---
  arch/mips/mm/fault.c   | 8 
  arch/mips/mm/tlbex-fault.S | 6 ++
  2 files changed, 14 insertions(+)

diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
index 0fead53..9391da49 100644
--- a/arch/mips/mm/fault.c
+++ b/arch/mips/mm/fault.c

[...]

@@ -50,6 +51,13 @@ asmlinkage void __kprobes do_page_fault(struct pt_regs 
*regs, unsigned long writ
   field, regs-cp0_epc);
  #endif
  
+#ifdef CONFIG_KVM_MIPSVZ

+   if (test_tsk_thread_flag(current, TIF_GUESTMODE)) {
+   if (mipsvz_page_fault(regs, write, address))


   Any reason not to collapse these into single *if*?


+   return;
+   }
+#endif
+



--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 20/31] mips/kvm: Hook into TLB fault handlers.

2013-06-07 Thread David Daney

On 06/07/2013 04:34 PM, Sergei Shtylyov wrote:

Hello.

On 06/08/2013 03:03 AM, David Daney wrote:


From: David Daney david.da...@cavium.com

If the CPU is operating in guest mode when a TLB related excpetion
occurs, give KVM a chance to do emulation.

Signed-off-by: David Daney david.da...@cavium.com
---
  arch/mips/mm/fault.c   | 8 
  arch/mips/mm/tlbex-fault.S | 6 ++
  2 files changed, 14 insertions(+)

diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
index 0fead53..9391da49 100644
--- a/arch/mips/mm/fault.c
+++ b/arch/mips/mm/fault.c

[...]

@@ -50,6 +51,13 @@ asmlinkage void __kprobes do_page_fault(struct
pt_regs *regs, unsigned long writ
 field, regs-cp0_epc);
  #endif
+#ifdef CONFIG_KVM_MIPSVZ
+if (test_tsk_thread_flag(current, TIF_GUESTMODE)) {
+if (mipsvz_page_fault(regs, write, address))


Any reason not to collapse these into single *if*?



It makes the conditional call to mipsvz_page_fault() less obvious.

Certainly the same semantics can be achieved several different ways.

David Daney



+return;
+}
+#endif
+







--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html