From patchwork Wed Jul 31 14:49:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 18708 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f71.google.com (mail-qa0-f71.google.com [209.85.216.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 277E6248E6 for ; Wed, 31 Jul 2013 14:50:07 +0000 (UTC) Received: by mail-qa0-f71.google.com with SMTP id bq6sf1115460qab.2 for ; Wed, 31 Jul 2013 07:50:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-beenthere:x-forwarded-to:x-forwarded-for:delivered-to:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :mime-version:x-gm-message-state:x-removed-original-auth :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:x-google-group-id:list-post:list-help :list-archive:list-unsubscribe:content-type :content-transfer-encoding; bh=FQJGOxJwIEpI3Fpbzszs6jl8X3tz5cTUZzE1krxJWmM=; b=aZE5YFNkWp9/oYGGrlFLChpzGulXt1QjutEiAd1qy7ZsJ2GXwLlAUSyD5UaWib6XQJ juPICEqf38/PDKfPYEdAf9WlHZAPOcpg5URm8JhcyOaLvyVEfhoJ0qdUqaxN4lyH6/Nu BLQoQfkLVee3pjZjCUjZut5Vut8CIx3D727WD1F0LM+Zr56actwRXOBNV1BkhjaO00dW 0q6WTmdAAgNtYwhT++LHVxdmgIdrkJAhDwlIDO6aViY5Oq3WNZ9qqRd2RiXD8AHJK38s QxrPMtZycZYPrjAtQXaC8aKEGiLWN5O04OG1JObTfP2yDdKIIcSICZz+/orjTXwgvqWM EpbA== X-Received: by 10.236.125.200 with SMTP id z48mr35035643yhh.55.1375282206841; Wed, 31 Jul 2013 07:50:06 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.0.236 with SMTP id 12ls681253qeh.36.gmail; Wed, 31 Jul 2013 07:50:06 -0700 (PDT) X-Received: by 10.52.170.111 with SMTP id al15mr328238vdc.43.1375282206639; Wed, 31 Jul 2013 07:50:06 -0700 (PDT) Received: from mail-ve0-f180.google.com (mail-ve0-f180.google.com [209.85.128.180]) by mx.google.com with ESMTPS id ix2si372705vdb.46.2013.07.31.07.50.06 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 31 Jul 2013 07:50:06 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.180 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.180; Received: by mail-ve0-f180.google.com with SMTP id pb11so877082veb.11 for ; Wed, 31 Jul 2013 07:50:06 -0700 (PDT) X-Received: by 10.220.164.202 with SMTP id f10mr11502687vcy.25.1375282206493; Wed, 31 Jul 2013 07:50:06 -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.221.11.8 with SMTP id pc8csp240833vcb; Wed, 31 Jul 2013 07:50:05 -0700 (PDT) X-Received: by 10.194.104.74 with SMTP id gc10mr36572940wjb.48.1375282203318; Wed, 31 Jul 2013 07:50:03 -0700 (PDT) Received: from mail-wg0-f43.google.com (mail-wg0-f43.google.com [74.125.82.43]) by mx.google.com with ESMTPS id s20si13441842wij.16.2013.07.31.07.50.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 31 Jul 2013 07:50:03 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.43 is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=74.125.82.43; Received: by mail-wg0-f43.google.com with SMTP id z12so674422wgg.34 for ; Wed, 31 Jul 2013 07:50:02 -0700 (PDT) X-Received: by 10.180.21.229 with SMTP id y5mr4570006wie.17.1375282202604; Wed, 31 Jul 2013 07:50:02 -0700 (PDT) Received: from belegaer.uk.xensource.com. (firewall.ctxuk.citrix.com. [46.33.159.2]) by mx.google.com with ESMTPSA id b13sm15773911wic.9.2013.07.31.07.50.01 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 31 Jul 2013 07:50:01 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org, ian.campbell@citrix.com Cc: stefano.stabellini@eu.citrix.com, patches@linaro.org, tim@xen.org, Julien Grall Subject: [PATCH v3 2/2] xen/arm: errata 766422: decode thumb store during data abort Date: Wed, 31 Jul 2013 15:49:55 +0100 Message-Id: <1375282195-21653-3-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1375282195-21653-1-git-send-email-julien.grall@linaro.org> References: <1375282195-21653-1-git-send-email-julien.grall@linaro.org> MIME-Version: 1.0 X-Gm-Message-State: ALoCoQmXEpn417coqH+YFcnnarpT7agWCzr4vTorGDLiN34aJ2t+Bekv+JS7so/7T/1UumBML/mY 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.180 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 --- 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 | 12 ++++++++++++ xen/include/asm-arm/arm32/processor.h | 4 ++++ xen/include/asm-arm/arm64/processor.h | 2 ++ 3 files changed, 18 insertions(+) diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 1b9209d..83ce414 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 @@ -1229,6 +1230,17 @@ static void do_trap_data_abort_guest(struct cpu_user_regs *regs, if ( !dabt.valid ) goto bad_data_abort; + /* + * Errata 766422: Thumb store translation fault to Hypervisor may + * not have correct HSR Rt value. + */ + if ( cpu_has_errata_766422() && (regs->cpsr & PSR_THUMB) && dabt.write ) + { + rc = decode_instruction(regs, &info.dabt); + if ( rc ) + goto bad_data_abort; + } + if (handle_mmio(&info)) { regs->pc += dabt.len ? 4 : 2; diff --git a/xen/include/asm-arm/arm32/processor.h b/xen/include/asm-arm/arm32/processor.h index b266252..a21d104 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) +/* Errata 766422: only Cortex A15 r0p4 is affected */ +#define cpu_has_errata_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..5d9b952 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_errata_766422() 0 + #endif /* __ASSEMBLY__ */ #endif /* __ASM_ARM_ARM64_PROCESSOR_H */