From patchwork Thu Aug 8 12:56:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 18849 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f198.google.com (mail-qc0-f198.google.com [209.85.216.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D3B98248D3 for ; Thu, 8 Aug 2013 12:57:03 +0000 (UTC) Received: by mail-qc0-f198.google.com with SMTP id a11sf312455qcx.1 for ; Thu, 08 Aug 2013 05:57:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe:content-type :content-transfer-encoding; bh=p0jzzMXoW24mquGba2vdUKNn9Go19BfXhEPZeFBOweY=; b=iQgbntc2XxPlmOqhF3ymGAccZqv6mZ54s2jvHGnGwzM0jVcNjVF/COxmVRSPfYPStZ 0IuEj66xCMBTvZ29a21vuOaYYVwIamSESXzdgMmnOL270bUbR9+SgTnQnPDFeBtIc749 WU8LX6SYoBD+tyMlV7i02SNMhtoJnNG/T4EeXAtFN0938Yb/Q4otXBWABL5GZZ2BpkbE hIbOh2SynoGigvzqH4W6b4Lrn+Vsk4z7CyIytKEgi761An8CrupETweFVycC/vUZ/84u ObKHI3PaQQr+3ktnzu/eNMvYJU7VIxSbc/UiaOTHEmJx7Qfa++ipO6wsvnnrwwbreU0E OtYA== X-Received: by 10.224.171.72 with SMTP id g8mr6109695qaz.7.1375966623629; Thu, 08 Aug 2013 05:57:03 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.71.49 with SMTP id r17ls948949qeu.51.gmail; Thu, 08 Aug 2013 05:57:03 -0700 (PDT) X-Received: by 10.58.80.38 with SMTP id o6mr3003015vex.69.1375966623510; Thu, 08 Aug 2013 05:57:03 -0700 (PDT) Received: from mail-ve0-f174.google.com (mail-ve0-f174.google.com [209.85.128.174]) by mx.google.com with ESMTPS id fa1si3025714ved.89.2013.08.08.05.57.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 08 Aug 2013 05:57:03 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.174; Received: by mail-ve0-f174.google.com with SMTP id d10so3002543vea.5 for ; Thu, 08 Aug 2013 05:57:03 -0700 (PDT) X-Gm-Message-State: ALoCoQl0G1Qm0lKppWl4nl4uCIt0usgQmJQ3RMNRy+WmZrunWffAPozhGTLWhbTqdMacAyiTj0lZ X-Received: by 10.52.180.229 with SMTP id dr5mr2548434vdc.20.1375966623407; Thu, 08 Aug 2013 05:57:03 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp13949vcz; Thu, 8 Aug 2013 05:57:02 -0700 (PDT) X-Received: by 10.14.183.2 with SMTP id p2mr8181583eem.44.1375966622451; Thu, 08 Aug 2013 05:57:02 -0700 (PDT) Received: from mail-ee0-f41.google.com (mail-ee0-f41.google.com [74.125.83.41]) by mx.google.com with ESMTPS id o41si10631449eew.359.2013.08.08.05.57.01 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 08 Aug 2013 05:57:02 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.83.41 is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=74.125.83.41; Received: by mail-ee0-f41.google.com with SMTP id d17so1524215eek.28 for ; Thu, 08 Aug 2013 05:57:01 -0700 (PDT) X-Received: by 10.15.86.65 with SMTP id h41mr7933444eez.147.1375966621740; Thu, 08 Aug 2013 05:57:01 -0700 (PDT) Received: from belegaer.uk.xensource.com. (firewall.ctxuk.citrix.com. [46.33.159.2]) by mx.google.com with ESMTPSA id p5sm18995284eeg.5.2013.08.08.05.57.00 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 08 Aug 2013 05:57:01 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Cc: stefano.stabellini@eu.citrix.com, ian.campbell@citrix.com, patches@linaro.org, tim@xen.org, Julien Grall Subject: [PATCH v5 2/2] xen/arm: erratum 766422: decode thumb store during data abort Date: Thu, 8 Aug 2013 13:56:51 +0100 Message-Id: <1375966611-16942-3-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1375966611-16942-1-git-send-email-julien.grall@linaro.org> References: <1375966611-16942-1-git-send-email-julien.grall@linaro.org> MIME-Version: 1.0 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , >From the errata document: When a non-secure non-hypervisor memory operation instruction generates a stage2 page table translation fault, a trap to the hypervisor will be triggered. For an architecturally defined subset of instructions, the Hypervisor Syndrome Register (HSR) will have the Instruction Syndrome Valid (ISV) bit set to 1’b1, and the Rt field should reflect the source register (for stores) or destination register for loads. On Cortex-A15, for Thumb and ThumbEE stores, the Rt value may be incorrect and should not be used, even if the ISV bit is set. All loads, and all ARM instruction set loads and stores, will have the correct Rt value if the ISV bit is set. To avoid this issue, Xen needs to decode thumb store instruction and update the transfer register. Signed-off-by: Julien Grall Acked-by: Ian Campbell --- Changes in v5: - Add gdprintk when the instruction decoding fails - s/errata/erratum in patch and commit message Changes in v3: - Use unlikely to check if the processor is affected by the errata - Move the decoder in another patch and use it Changes in v2: - Only decode the instruction on affected processor - Handle ARM 32-bit instruction in read_instruction --- xen/arch/arm/traps.c | 15 +++++++++++++++ xen/include/asm-arm/arm32/processor.h | 4 ++++ xen/include/asm-arm/arm64/processor.h | 2 ++ 3 files changed, 21 insertions(+) diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 6b5fa51..a30797c 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -36,6 +36,7 @@ #include #include +#include "decode.h" #include "io.h" #include "vtimer.h" #include @@ -1336,6 +1337,20 @@ static void do_trap_data_abort_guest(struct cpu_user_regs *regs, if ( !dabt.valid ) goto bad_data_abort; + /* + * Erratum 766422: Thumb store translation fault to Hypervisor may + * not have correct HSR Rt value. + */ + if ( cpu_has_erratum_766422() && (regs->cpsr & PSR_THUMB) && dabt.write ) + { + rc = decode_instruction(regs, &info.dabt); + if ( rc ) + { + gdprintk(XENLOG_ERR, "Unable to decode instruction\n"); + goto bad_data_abort; + } + } + if (handle_mmio(&info)) { advance_pc(regs, hsr); diff --git a/xen/include/asm-arm/arm32/processor.h b/xen/include/asm-arm/arm32/processor.h index b266252..d1b89d0 100644 --- a/xen/include/asm-arm/arm32/processor.h +++ b/xen/include/asm-arm/arm32/processor.h @@ -111,6 +111,10 @@ struct cpu_user_regs #define READ_SYSREG(R...) READ_SYSREG32(R) #define WRITE_SYSREG(V, R...) WRITE_SYSREG32(V, R) +/* Erratum 766422: only Cortex A15 r0p4 is affected */ +#define cpu_has_erratum_766422() \ + (unlikely(current_cpu_data.midr.bits == 0x410fc0f4)) + #endif /* __ASSEMBLY__ */ #endif /* __ASM_ARM_ARM32_PROCESSOR_H */ diff --git a/xen/include/asm-arm/arm64/processor.h b/xen/include/asm-arm/arm64/processor.h index c8d4609..5bf0867 100644 --- a/xen/include/asm-arm/arm64/processor.h +++ b/xen/include/asm-arm/arm64/processor.h @@ -104,6 +104,8 @@ struct cpu_user_regs #define READ_SYSREG(name) READ_SYSREG64(name) #define WRITE_SYSREG(v, name) WRITE_SYSREG64(v, name) +#define cpu_has_erratum_766422() 0 + #endif /* __ASSEMBLY__ */ #endif /* __ASM_ARM_ARM64_PROCESSOR_H */