From patchwork Mon May 4 01:52:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 47964 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f70.google.com (mail-wg0-f70.google.com [74.125.82.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7F89A2121F for ; Mon, 4 May 2015 01:55:34 +0000 (UTC) Received: by wgin8 with SMTP id n8sf40686763wgi.0 for ; Sun, 03 May 2015 18:55:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=Kw0OQYWFbN1MnaHRGyY0T3gYc3KXf3q7W9Tdx26w2mA=; b=lQsMVGyGCXMbn3fIqVbM9a3+LMqaHR5lBy5Y4HDSPesDUWXfpvypEk48pg/oz2Fbo9 ONFA0KiUcSoC53Vgf0t0IhlK2I8Y2Q3UVVANnd/rhfd4nuU2xlmo0MPoCHRfh43YJnSa QNz6YETNSfXR5AC5UwfufGvBEXtXvs9M7Iu5oNJd1cIx1AK5TbUqf+LDH2ZuOxees6ct TcD2AEyW9iQzJkRw2KzPKlwTH3z87IxsU38/fCulOu9dQzLcn0VlY7g1XypGcWr3Lcmy iB1ZRRMavLi+xLBEvikAI6gd7FwD+zKjPbvi7qRP3cpuO3c2YYvZ3xSAZWeLIcfQWFIX 7qzQ== X-Gm-Message-State: ALoCoQks9Zp1wPWzV0ejzr1Ag025XizscUI0ClZAdqmz0SvCObN7E0fzHPa/Vwso9XlANnjGNjVS X-Received: by 10.180.106.10 with SMTP id gq10mr6891923wib.0.1430704533734; Sun, 03 May 2015 18:55:33 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.245.43 with SMTP id xl11ls709669lac.21.gmail; Sun, 03 May 2015 18:55:33 -0700 (PDT) X-Received: by 10.112.204.6 with SMTP id ku6mr17413953lbc.73.1430704533578; Sun, 03 May 2015 18:55:33 -0700 (PDT) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com. [209.85.217.179]) by mx.google.com with ESMTPS id m3si9081357lah.93.2015.05.03.18.55.33 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 May 2015 18:55:33 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) client-ip=209.85.217.179; Received: by lbbuc2 with SMTP id uc2so95608102lbb.2 for ; Sun, 03 May 2015 18:55:33 -0700 (PDT) X-Received: by 10.112.204.72 with SMTP id kw8mr17644664lbc.88.1430704533479; Sun, 03 May 2015 18:55:33 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.67.65 with SMTP id l1csp1412963lbt; Sun, 3 May 2015 18:55:32 -0700 (PDT) X-Received: by 10.68.65.17 with SMTP id t17mr38450505pbs.74.1430704531684; Sun, 03 May 2015 18:55:31 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ix6si17838787pac.46.2015.05.03.18.55.30; Sun, 03 May 2015 18:55:31 -0700 (PDT) Received-SPF: none (google.com: stable-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751947AbbEDBza (ORCPT + 2 others); Sun, 3 May 2015 21:55:30 -0400 Received: from mail-pa0-f54.google.com ([209.85.220.54]:33324 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751938AbbEDBz3 (ORCPT ); Sun, 3 May 2015 21:55:29 -0400 Received: by pacwv17 with SMTP id wv17so147906978pac.0 for ; Sun, 03 May 2015 18:55:29 -0700 (PDT) X-Received: by 10.69.12.227 with SMTP id et3mr38271943pbd.11.1430704529201; Sun, 03 May 2015 18:55:29 -0700 (PDT) Received: from localhost ([180.150.153.1]) by mx.google.com with ESMTPSA id eo3sm11006469pbd.66.2015.05.03.18.55.26 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 03 May 2015 18:55:27 -0700 (PDT) From: shannon.zhao@linaro.org To: stable@vger.kernel.org Cc: gregkh@linuxfoundation.org, christoffer.dall@linaro.org, shannon.zhao@linaro.org, Ard Biesheuvel , Marc Zyngier Subject: [PATCH for 3.14.y stable 26/47] ARM/arm64: KVM: fix use of WnR bit in kvm_is_write_fault() Date: Mon, 4 May 2015 09:52:21 +0800 Message-Id: <1430704362-6292-27-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1430704362-6292-1-git-send-email-shannon.zhao@linaro.org> References: <1430704362-6292-1-git-send-email-shannon.zhao@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: stable@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: shannon.zhao@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Ard Biesheuvel commit a7d079cea2dffb112e26da2566dd84c0ef1fce97 upstream. The ISS encoding for an exception from a Data Abort has a WnR bit[6] that indicates whether the Data Abort was caused by a read or a write instruction. While there are several fields in the encoding that are only valid if the ISV bit[24] is set, WnR is not one of them, so we can read it unconditionally. Instead of fixing both implementations of kvm_is_write_fault() in place, reimplement it just once using kvm_vcpu_dabt_iswrite(), which already does the right thing with respect to the WnR bit. Also fix up the callers to pass 'vcpu' Acked-by: Laszlo Ersek Acked-by: Marc Zyngier Acked-by: Christoffer Dall Signed-off-by: Ard Biesheuvel Signed-off-by: Marc Zyngier Signed-off-by: Shannon Zhao --- arch/arm/include/asm/kvm_mmu.h | 11 ----------- arch/arm/kvm/mmu.c | 10 +++++++++- arch/arm64/include/asm/kvm_mmu.h | 13 ------------- 3 files changed, 9 insertions(+), 25 deletions(-) diff --git a/arch/arm/include/asm/kvm_mmu.h b/arch/arm/include/asm/kvm_mmu.h index 5cc0b0f..3f688b4 100644 --- a/arch/arm/include/asm/kvm_mmu.h +++ b/arch/arm/include/asm/kvm_mmu.h @@ -78,17 +78,6 @@ static inline void kvm_set_pte(pte_t *pte, pte_t new_pte) flush_pmd_entry(pte); } -static inline bool kvm_is_write_fault(unsigned long hsr) -{ - unsigned long hsr_ec = hsr >> HSR_EC_SHIFT; - if (hsr_ec == HSR_EC_IABT) - return false; - else if ((hsr & HSR_ISV) && !(hsr & HSR_WNR)) - return false; - else - return true; -} - static inline void kvm_clean_pgd(pgd_t *pgd) { clean_dcache_area(pgd, PTRS_PER_S2_PGD * sizeof(pgd_t)); diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c index 70ed2c1..049c56e 100644 --- a/arch/arm/kvm/mmu.c +++ b/arch/arm/kvm/mmu.c @@ -746,6 +746,14 @@ static bool transparent_hugepage_adjust(pfn_t *pfnp, phys_addr_t *ipap) return false; } +static bool kvm_is_write_fault(struct kvm_vcpu *vcpu) +{ + if (kvm_vcpu_trap_is_iabt(vcpu)) + return false; + + return kvm_vcpu_dabt_iswrite(vcpu); +} + static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, struct kvm_memory_slot *memslot, unsigned long fault_status) @@ -761,7 +769,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, pfn_t pfn; pgprot_t mem_type = PAGE_S2; - write_fault = kvm_is_write_fault(kvm_vcpu_get_hsr(vcpu)); + write_fault = kvm_is_write_fault(vcpu); if (fault_status == FSC_PERM && !write_fault) { kvm_err("Unexpected L2 read permission error\n"); return -EFAULT; diff --git a/arch/arm64/include/asm/kvm_mmu.h b/arch/arm64/include/asm/kvm_mmu.h index 8e138c7..737da74 100644 --- a/arch/arm64/include/asm/kvm_mmu.h +++ b/arch/arm64/include/asm/kvm_mmu.h @@ -93,19 +93,6 @@ void kvm_clear_hyp_idmap(void); #define kvm_set_pte(ptep, pte) set_pte(ptep, pte) #define kvm_set_pmd(pmdp, pmd) set_pmd(pmdp, pmd) -static inline bool kvm_is_write_fault(unsigned long esr) -{ - unsigned long esr_ec = esr >> ESR_EL2_EC_SHIFT; - - if (esr_ec == ESR_EL2_EC_IABT) - return false; - - if ((esr & ESR_EL2_ISV) && !(esr & ESR_EL2_WNR)) - return false; - - return true; -} - static inline void kvm_clean_pgd(pgd_t *pgd) {} static inline void kvm_clean_pmd_entry(pmd_t *pmd) {} static inline void kvm_clean_pte(pte_t *pte) {}