From patchwork Sat Oct 3 22:38:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Edgar E. Iglesias" X-Patchwork-Id: 526037 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 2870B140B0E for ; Sun, 4 Oct 2015 09:44:28 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=QiIxAsB/; dkim-atps=neutral Received: from localhost ([::1]:40252 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZiVXW-0005AN-6m for incoming@patchwork.ozlabs.org; Sat, 03 Oct 2015 18:44:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53454) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZiVSd-0005DG-KU for qemu-devel@nongnu.org; Sat, 03 Oct 2015 18:39:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZiVSc-0006N2-K4 for qemu-devel@nongnu.org; Sat, 03 Oct 2015 18:39:23 -0400 Received: from mail-pa0-x22f.google.com ([2607:f8b0:400e:c03::22f]:35826) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZiVSc-0006Mx-Dp for qemu-devel@nongnu.org; Sat, 03 Oct 2015 18:39:22 -0400 Received: by pacfv12 with SMTP id fv12so141704597pac.2 for ; Sat, 03 Oct 2015 15:39:22 -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:in-reply-to:references; bh=WrL8AgmiqyshouLqqwd+rvX9PKrr5iz3bHU0FctTsWU=; b=QiIxAsB/corgaOY5Somj9QaMNHq4Miem7eYgWKomFHyHHVatVKOPlO3HqNqocqOTAe UQ6pUedEjboAeyCLEajFYMAIzbo3YqK4k+OiWlplAqkA6F3/ETPT7KjcWnbK/SOf/qKs MVIbkPINL8y89L90rnaVGX6lP4bvi7yHiDIWNg0PxDJ7vi5Zdr9O4RAQKND4dJrLULmG tfbYodhjpDpx11CEIfeUXJeHf8erl4/2e3PG7ejCNJhgGRVhKJ1mpJCO6kX9eDIa/kz7 0/B5CoPqJFgh8zZ70+uDOaIhNOCqei6jhOwjqxXa6JHSuL+U1xa6+uf1by3aCEdOkTDD AwUQ== X-Received: by 10.66.140.70 with SMTP id re6mr29647920pab.31.1443911962001; Sat, 03 Oct 2015 15:39:22 -0700 (PDT) Received: from localhost (ec2-52-8-89-49.us-west-1.compute.amazonaws.com. [52.8.89.49]) by smtp.gmail.com with ESMTPSA id hq8sm19364027pad.35.2015.10.03.15.39.21 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 03 Oct 2015 15:39:21 -0700 (PDT) From: "Edgar E. Iglesias" To: qemu-devel@nongnu.org, peter.maydell@linaro.org Date: Sat, 3 Oct 2015 15:38:59 -0700 Message-Id: <1443911939-2825-10-git-send-email-edgar.iglesias@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1443911939-2825-1-git-send-email-edgar.iglesias@gmail.com> References: <1443911939-2825-1-git-send-email-edgar.iglesias@gmail.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c03::22f Cc: laurent.desnogues@gmail.com, serge.fdrv@gmail.com, edgar.iglesias@xilinx.com, alex.bennee@linaro.org, agraf@suse.de Subject: [Qemu-devel] [PATCH v3 9/9] target-arm: Add support for S1 + S2 MMU translations X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: "Edgar E. Iglesias" Signed-off-by: Edgar E. Iglesias --- target-arm/helper.c | 44 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/target-arm/helper.c b/target-arm/helper.c index c108248..0ec5909 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -7042,14 +7042,44 @@ static bool get_phys_addr(CPUARMState *env, target_ulong address, ARMMMUFaultInfo *fi) { if (mmu_idx == ARMMMUIdx_S12NSE0 || mmu_idx == ARMMMUIdx_S12NSE1) { - /* TODO: when we support EL2 we should here call ourselves recursively - * to do the stage 1 and then stage 2 translations. The arm_ld*_ptw - * functions will also need changing to perform ARMMMUIdx_S2NS loads - * rather than direct physical memory loads when appropriate. - * For non-EL2 CPUs a stage1+stage2 translation is just stage 1. + /* Call ourselves recursively to do the stage 1 and then stage 2 + * translations. */ - assert(!arm_feature(env, ARM_FEATURE_EL2)); - mmu_idx += ARMMMUIdx_S1NSE0; + if (arm_feature(env, ARM_FEATURE_EL2)) { + hwaddr ipa; + int s2_prot; + int ret; + + ret = get_phys_addr(env, address, access_type, + mmu_idx + ARMMMUIdx_S1NSE0, &ipa, attrs, + prot, page_size, fsr, fi); + + /* If S1 fails or S2 is disabled, return early. */ + if (ret || regime_translation_disabled(env, ARMMMUIdx_S2NS)) { + if (ret && fi->stage2) { + /* This is a S2 error while doing S1 PTW. */ + env->cp15.hpfar_el2 = extract64(fi->s2addr, 12, 47) << 4; + } + *phys_ptr = ipa; + return ret; + } + + /* S1 is done. Now do S2 translation. */ + ret = get_phys_addr_lpae(env, ipa, access_type, ARMMMUIdx_S2NS, + phys_ptr, attrs, &s2_prot, + page_size, fsr, fi); + if (ret) { + env->cp15.hpfar_el2 = extract64(ipa, 12, 47) << 4; + } + /* Combine the S1 and S2 perms. */ + *prot &= s2_prot; + return ret; + } else { + /* + * For non-EL2 CPUs a stage1+stage2 translation is just stage 1. + */ + mmu_idx += ARMMMUIdx_S1NSE0; + } } /* The page table entries may downgrade secure to non-secure, but