From patchwork Fri Jun 7 23:03:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Daney X-Patchwork-Id: 2691211 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 5A2B1DFB78 for ; Fri, 7 Jun 2013 23:08:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932104Ab3FGXIH (ORCPT ); Fri, 7 Jun 2013 19:08:07 -0400 Received: from mail-ie0-f169.google.com ([209.85.223.169]:49729 "EHLO mail-ie0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755813Ab3FGXDx (ORCPT ); Fri, 7 Jun 2013 19:03:53 -0400 Received: by mail-ie0-f169.google.com with SMTP id 10so12396075ied.28 for ; Fri, 07 Jun 2013 16:03:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=mx23w+vrmCLgT0cbXWmdHcohMpXBQwMGGsJZJhaJqqA=; b=tG7KjEZtFrc6IaG5N61Pv45002tSzUhuNG19sqLJUFxG1D+eI0smNSQ8cEU6SYJuaj yJmMNuRvmKxdtGpWVSWT7g+evPk0cPYv3HEjgC9IwXxaqKg23FihdsU/dFnwBVz93yJI iaqKnPJorEPJPOx3Ln9nFWJ9oA7He+WFaquNzZGjEGvN0oHdTmA0z0TL6mFTCHPSvkru xy3naoH8bTjM3f4nQIslV0Fuw7q+zOccK8GdOBJ2yKLrorrNMofzpMb5FgrNGTSZGPs7 6bucm7ZuCT7Fda1snDhsY9q+F0YawuMK+gPA5bA9qJ+PMuqHX3N107fa0HpOMU522pwA EFbA== X-Received: by 10.50.25.194 with SMTP id e2mr360226igg.111.1370646232911; Fri, 07 Jun 2013 16:03:52 -0700 (PDT) Received: from dl.caveonetworks.com (64.2.3.195.ptr.us.xo.net. [64.2.3.195]) by mx.google.com with ESMTPSA id vc15sm163475igb.7.2013.06.07.16.03.51 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 07 Jun 2013 16:03:52 -0700 (PDT) Received: from dl.caveonetworks.com (localhost.localdomain [127.0.0.1]) by dl.caveonetworks.com (8.14.5/8.14.5) with ESMTP id r57N3nqt006690; Fri, 7 Jun 2013 16:03:49 -0700 Received: (from ddaney@localhost) by dl.caveonetworks.com (8.14.5/8.14.5/Submit) id r57N3nDA006689; Fri, 7 Jun 2013 16:03:49 -0700 From: David Daney To: linux-mips@linux-mips.org, ralf@linux-mips.org, kvm@vger.kernel.org, Sanjay Lal Cc: linux-kernel@vger.kernel.org, David Daney Subject: [PATCH 20/31] mips/kvm: Hook into TLB fault handlers. Date: Fri, 7 Jun 2013 16:03:24 -0700 Message-Id: <1370646215-6543-21-git-send-email-ddaney.cavm@gmail.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1370646215-6543-1-git-send-email-ddaney.cavm@gmail.com> References: <1370646215-6543-1-git-send-email-ddaney.cavm@gmail.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: David Daney 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 Acked-by: Ralf Baechle --- 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 #include /* For VMALLOC_END */ #include +#include /* * 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 MFC0 a2, CP0_BADVADDR +#ifdef CONFIG_KVM_MIPSVZ + mfc0 v0, CP0_BADINSTR + mfc0 v1, CP0_BADINSTRP + sw v0, PT_BADINSTR(sp) + sw v1, PT_BADINSTRP(sp) +#endif KMODE move a0, sp REG_S a2, PT_BVADDR(sp)