From patchwork Fri Oct 19 16:57:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 149342 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp3601559lji; Fri, 19 Oct 2018 10:50:44 -0700 (PDT) X-Google-Smtp-Source: ACcGV61pllT3lVV5FyvPdY8N0YDMld1Rd83MPWZq7B8sMC9TEq9tlnF8L99cs4o5djCry96jIQ+T X-Received: by 2002:ac8:75d8:: with SMTP id z24-v6mr33072540qtq.362.1539971444658; Fri, 19 Oct 2018 10:50:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539971444; cv=none; d=google.com; s=arc-20160816; b=bqh7p/MYSiC694WHBGQOPWkDTnNEsNf7xmYS8ztC5wtJc3SZZ97iC8/jhj8rf2WcQx 9QEx+BNtjEKwa8tn7L33g/Cs/gkEdxT5lPxtFXpyo8OGJhS1PUDfElS+FfgnNMjFIpV5 WfElESoFvUBgx5TnDDxvouzwh3njZlAD8Pbkf6imDAZGC6BCxkcpz2735pIpFTbknmLO NZPRvatXtqC6Uo+RvcQqfMx2h1tF8zWQmBC0xAsagm6Gcc5QsKNc6fNIkOopIb7Xm9Mh H+XnVMXr7LarVoy3fyqPJSGO8uCKmD9C4nTYXpyDVzM9XY3mvLBHWDYd1Jd4gfDWfuRt HtnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from; bh=SzA7hkJQ9Sl7QxPmjhykULfDT39zObB4i3g7sj+tPoA=; b=Env6627oaf5/XRkylXxFENNoBzUpkmHT6foLxrqyGS+gx3Zh8306rBXD0H24mVRvfm 2IJ17mewAfecPRXi3bZdXxFrj9Ud6uPSV/OGZkB5E2scydObKIqNDUQ3BGROsj1GzFVQ 6soAQpsptkMNvEFC2l+/UufELTXshqpxDkl/evr8h/m6A35fIRif1IkwpixRMMHQCbjl Osr/+e8PxSJANLILIuT3vd8auJgdSIzGtnKowXOLGZJnRDuM7oW/jAYqUfvm4Y9Q2ljB tgSvdUj8SdMnJvkp5nF7QUj1utAUQEon3zArproM3dWmPVqpuh0TuY7CDE55ettKNTN0 NAbg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id n62-v6si1793107qkf.126.2018.10.19.10.50.44 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 19 Oct 2018 10:50:44 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:52009 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDYv6-0001je-0G for patch@linaro.org; Fri, 19 Oct 2018 13:50:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48937) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDY8D-0003e8-Ud for qemu-devel@nongnu.org; Fri, 19 Oct 2018 13:00:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gDY8C-0005GF-VR for qemu-devel@nongnu.org; Fri, 19 Oct 2018 13:00:13 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:51982) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gDY8C-0002Jh-DU for qemu-devel@nongnu.org; Fri, 19 Oct 2018 13:00:12 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1gDY5y-0006jH-UX for qemu-devel@nongnu.org; Fri, 19 Oct 2018 17:57:54 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 19 Oct 2018 17:57:07 +0100 Message-Id: <20181019165735.22511-18-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181019165735.22511-1-peter.maydell@linaro.org> References: <20181019165735.22511-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 17/45] target/arm: Implement HCR.PTW X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" If the HCR_EL2 PTW virtualizaiton configuration register bit is set, then this means that a stage 2 Permission fault must be generated if a stage 1 translation table access is made to an address that is mapped as Device memory in stage 2. Implement this. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20181012144235.19646-8-peter.maydell@linaro.org --- target/arm/helper.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) -- 2.19.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index af2f63c31b0..1928d3fadd9 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -9141,9 +9141,20 @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx, hwaddr s2pa; int s2prot; int ret; + ARMCacheAttrs cacheattrs = {}; + ARMCacheAttrs *pcacheattrs = NULL; + + if (env->cp15.hcr_el2 & HCR_PTW) { + /* + * PTW means we must fault if this S1 walk touches S2 Device + * memory; otherwise we don't care about the attributes and can + * save the S2 translation the effort of computing them. + */ + pcacheattrs = &cacheattrs; + } ret = get_phys_addr_lpae(env, addr, 0, ARMMMUIdx_S2NS, &s2pa, - &txattrs, &s2prot, &s2size, fi, NULL); + &txattrs, &s2prot, &s2size, fi, pcacheattrs); if (ret) { assert(fi->type != ARMFault_None); fi->s2addr = addr; @@ -9151,6 +9162,14 @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx, fi->s1ptw = true; return ~0; } + if (pcacheattrs && (pcacheattrs->attrs & 0xf0) == 0) { + /* Access was to Device memory: generate Permission fault */ + fi->type = ARMFault_Permission; + fi->s2addr = addr; + fi->stage2 = true; + fi->s1ptw = true; + return ~0; + } addr = s2pa; } return addr;