From patchwork Mon Jan 9 06:24:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jintack Lim X-Patchwork-Id: 9503905 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DA4916075F for ; Mon, 9 Jan 2017 06:31:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BFB2728335 for ; Mon, 9 Jan 2017 06:31:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B4206280D0; Mon, 9 Jan 2017 06:31:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7924B280D0 for ; Mon, 9 Jan 2017 06:31:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162814AbdAIGax (ORCPT ); Mon, 9 Jan 2017 01:30:53 -0500 Received: from outprodmail01.cc.columbia.edu ([128.59.72.39]:38597 "EHLO outprodmail01.cc.columbia.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S939808AbdAIG0l (ORCPT ); Mon, 9 Jan 2017 01:26:41 -0500 Received: from hazelnut (hazelnut.cc.columbia.edu [128.59.213.250]) by outprodmail01.cc.columbia.edu (8.14.4/8.14.4) with ESMTP id v096Q51N017978 for ; Mon, 9 Jan 2017 01:26:29 -0500 Received: from hazelnut (localhost.localdomain [127.0.0.1]) by hazelnut (Postfix) with ESMTP id 0FBC781 for ; Mon, 9 Jan 2017 01:26:29 -0500 (EST) Received: from sendprodmail01.cc.columbia.edu (sendprodmail01.cc.columbia.edu [128.59.72.13]) by hazelnut (Postfix) with ESMTP id DF76482 for ; Mon, 9 Jan 2017 01:26:28 -0500 (EST) Received: from mail-qt0-f198.google.com (mail-qt0-f198.google.com [209.85.216.198]) by sendprodmail01.cc.columbia.edu (8.14.4/8.14.4) with ESMTP id v096QS89041642 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 9 Jan 2017 01:26:28 -0500 Received: by mail-qt0-f198.google.com with SMTP id t56so77868563qte.3 for ; Sun, 08 Jan 2017 22:26:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mPuURSuqMcG09Yi5RmOYfHMhwUHpgEoeW+Ah1Qv19C8=; b=XDKYjwZ7P0iRlq5N4mCsRBEjlqdYsZgr4rnda5RZvt0dwfOxE5FMU+OpmQtSIi1HJa 5T5NYGv0W0bX4E8bsrwSD7UlaxQkszbQF7gmDf3V+h/FdtdVP7OD8BzZJmUNnGCDMKh5 jFtxmrLOVX3fxLPWdqfCw3uYROnDFS55fvxAIDG9+Z3wD0VmitNRTqoexHomPKolbPBW PbMk2u415CAKt+ws4lfVCJj121gWFs3jZ5ZZpldkPncJivy9SSsGELExnRlE+L+9mPpl EwwsgqbtyevAU/4/PaX+nWYKrm4I1tfOTKztJXVyOffwBNQk9+KsHAt2wWzDBHQ8hS5V un5g== X-Gm-Message-State: AIkVDXJRCUawWXfJKKlPc+Pegw2gk+tkgJdonjLhkWOiam+MtgKF6vXb8zQYHtviRcT4GImpQ9fo2JvndDOqhEI1/ja9fjwCBBee4AGWH0bQgSt5P7DJAbUcEStWpEVft6RXRa9sN1NKhyY= X-Received: by 10.55.142.194 with SMTP id q185mr82356966qkd.82.1483943188541; Sun, 08 Jan 2017 22:26:28 -0800 (PST) X-Received: by 10.55.142.194 with SMTP id q185mr82356953qkd.82.1483943188380; Sun, 08 Jan 2017 22:26:28 -0800 (PST) Received: from jintack.cs.columbia.edu ([2001:18d8:ffff:16:21a:4aff:feaa:f900]) by smtp.gmail.com with ESMTPSA id h3sm8623257qtc.6.2017.01.08.22.26.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 08 Jan 2017 22:26:27 -0800 (PST) From: Jintack Lim To: christoffer.dall@linaro.org, marc.zyngier@arm.com, pbonzini@redhat.com, rkrcmar@redhat.com, linux@armlinux.org.uk, catalin.marinas@arm.com, will.deacon@arm.com, vladimir.murzin@arm.com, suzuki.poulose@arm.com, mark.rutland@arm.com, james.morse@arm.com, lorenzo.pieralisi@arm.com, kevin.brodsky@arm.com, wcohen@redhat.com, shankerd@codeaurora.org, geoff@infradead.org, andre.przywara@arm.com, eric.auger@redhat.com, anna-maria@linutronix.de, shihwei@cs.columbia.edu, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: jintack@cs.columbia.edu Subject: [RFC 45/55] KVM: arm64: KVM: Inject stage-2 page faults Date: Mon, 9 Jan 2017 01:24:41 -0500 Message-Id: <1483943091-1364-46-git-send-email-jintack@cs.columbia.edu> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1483943091-1364-1-git-send-email-jintack@cs.columbia.edu> References: <1483943091-1364-1-git-send-email-jintack@cs.columbia.edu> X-No-Spam-Score: Local X-Scanned-By: MIMEDefang 2.78 on 128.59.72.13 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Christoffer Dall Inject stage-2 page faults to the guest hypervisor. Signed-off-by: Christoffer Dall Signed-off-by: Jintack Lim --- arch/arm64/include/asm/esr.h | 1 + arch/arm64/kvm/mmu-nested.c | 30 ++++++++++++++++++++++++------ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/arch/arm64/include/asm/esr.h b/arch/arm64/include/asm/esr.h index f32e3a7..6104e31 100644 --- a/arch/arm64/include/asm/esr.h +++ b/arch/arm64/include/asm/esr.h @@ -107,6 +107,7 @@ #define ESR_ELx_CM (UL(1) << 8) /* ISS field definitions for exceptions taken in to Hyp */ +#define ESR_ELx_FSC_ADDRSZ (0x00) #define ESR_ELx_CV (UL(1) << 24) #define ESR_ELx_COND_SHIFT (20) #define ESR_ELx_COND_MASK (UL(0xF) << ESR_ELx_COND_SHIFT) diff --git a/arch/arm64/kvm/mmu-nested.c b/arch/arm64/kvm/mmu-nested.c index a2fab41..b161b55 100644 --- a/arch/arm64/kvm/mmu-nested.c +++ b/arch/arm64/kvm/mmu-nested.c @@ -55,22 +55,40 @@ static unsigned int pa_max(void) static int vcpu_inject_s2_trans_fault(struct kvm_vcpu *vcpu, gpa_t ipa, int level) { - /* TODO: Implement */ - return -EFAULT; + u32 esr; + + vcpu->arch.ctxt.el2_regs[FAR_EL2] = vcpu->arch.fault.far_el2; + vcpu->arch.ctxt.el2_regs[HPFAR_EL2] = vcpu->arch.fault.hpfar_el2; + esr = kvm_vcpu_get_hsr(vcpu) & ~ESR_ELx_FSC; + esr |= ESR_ELx_FSC_FAULT; + esr |= level & 0x3; + return kvm_inject_nested_sync(vcpu, esr); } static int vcpu_inject_s2_addr_sz_fault(struct kvm_vcpu *vcpu, gpa_t ipa, int level) { - /* TODO: Implement */ - return -EFAULT; + u32 esr; + + vcpu->arch.ctxt.el2_regs[FAR_EL2] = vcpu->arch.fault.far_el2; + vcpu->arch.ctxt.el2_regs[HPFAR_EL2] = vcpu->arch.fault.hpfar_el2; + esr = kvm_vcpu_get_hsr(vcpu) & ~ESR_ELx_FSC; + esr |= ESR_ELx_FSC_ADDRSZ; + esr |= level & 0x3; + return kvm_inject_nested_sync(vcpu, esr); } static int vcpu_inject_s2_access_flag_fault(struct kvm_vcpu *vcpu, gpa_t ipa, int level) { - /* TODO: Implement */ - return -EFAULT; + u32 esr; + + vcpu->arch.ctxt.el2_regs[FAR_EL2] = vcpu->arch.fault.far_el2; + vcpu->arch.ctxt.el2_regs[HPFAR_EL2] = vcpu->arch.fault.hpfar_el2; + esr = kvm_vcpu_get_hsr(vcpu) & ~ESR_ELx_FSC; + esr |= ESR_ELx_FSC_ACCESS; + esr |= level & 0x3; + return kvm_inject_nested_sync(vcpu, esr); } static int check_base_s2_limits(struct kvm_vcpu *vcpu, struct s2_walk_info *wi,