From patchwork Tue Dec 3 02:29:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 180680 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp950026ile; Mon, 2 Dec 2019 18:49:29 -0800 (PST) X-Google-Smtp-Source: APXvYqwvzsQPaInQnIFcPz5a11B3u6ukka3OFnfpbE2i9hYYP+gdfR/VN9v4TKardwocYaBHuRTr X-Received: by 2002:a50:f704:: with SMTP id g4mr570059edn.123.1575341369247; Mon, 02 Dec 2019 18:49:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575341369; cv=none; d=google.com; s=arc-20160816; b=YOAuV6qoqnthtc65SIaIkLujpMz4Kw0eAY8ZQgrdzXchOPfzmQemL05OlF34sPft7a ILWG5oFZvpi4iVOrRFFQk2ogLbGjDCXQvsdzlxtlZSviRzcgbGWVfoEjgJHyFmsklKo5 s/XJoVfzkCxoBl2nvTGM9qXKV0r1KhmTDe2CYCeD3IQtu+4PuiJ2yg1fW508rJ3ir/lD oTD5E6aoiM5Iv3OtGHUZm1cB7tX58Qo/ZidEcp2sSXgtNMc7FIiFH77UsoDSrX8dUI1h 2SUCAMEh9QlRFige9TxDv8XZS88XvPbQpM4zLXGxE1XkJ7CRBJ4gXni98no72yglGl3L mMgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=bOBBih3JRg5ecnanCNy6UVzBnae0IWceZ3dWmja0LB0=; b=WL2F87wsQbGJt/KXZiQ2L8L5Fi6j7cYzMMAm5znSgi/7KwD8Mj8VddDLZwBZCQm64t EhIGgvayU3q10ABhRY3UxJ6M5CEpbHaTzXn5xOZABfoZhPt12x+/5+8XzFQX5l4k3rRU cWJYrtQl91ovBPiCGIljnlGdmqpd1cK6AnFZs1n2X6vbSmrRIaeagot3jslVpX/zSlIv iGh2rWD+bHXsI2nWVcLniZKykrZ5aU5AXE0XZBt+7d7Zzx9SnXcEe9m7ULq9LLNOqcy4 Yf4xOogfn5ptboy/0bcXr+1tWOr7Kt/e8Xnx7pZc0ed9dQMxCRM83hdzjl81/2AIUMms ha5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=edKy5gsq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 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. [209.51.188.17]) by mx.google.com with ESMTPS id x18si584493ejb.1.2019.12.02.18.49.29 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Dec 2019 18:49:29 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=edKy5gsq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 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]:47446 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ibyFj-0001CD-GH for patch@linaro.org; Mon, 02 Dec 2019 21:49:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60920) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ibxxF-0003Ke-OW for qemu-devel@nongnu.org; Mon, 02 Dec 2019 21:30:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ibxxB-0008St-Au for qemu-devel@nongnu.org; Mon, 02 Dec 2019 21:30:19 -0500 Received: from mail-pj1-x1041.google.com ([2607:f8b0:4864:20::1041]:38834) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ibxxA-0008JL-Sq for qemu-devel@nongnu.org; Mon, 02 Dec 2019 21:30:17 -0500 Received: by mail-pj1-x1041.google.com with SMTP id l4so820902pjt.5 for ; Mon, 02 Dec 2019 18:30:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bOBBih3JRg5ecnanCNy6UVzBnae0IWceZ3dWmja0LB0=; b=edKy5gsqSGsIb/Aqrmu0qeeKI61BFr9bt/o0qqxYEGF+lQDctNPGEMbqsFq0/bmaO6 MZwR1OemnaTSNANgBoK8dgxPg3WQocTHMMN9r8mMURq4Qv4nrA9HDKPM0ctAOWOG55w9 XcocPm3qRE1j1j3sNN+yyTc97TKQ4+MuPJDdPuIacCbDL6roV/cyNdFH7GbIow3L0M3g C/UVgElaX9sTrAA1fzuBPhM47s4MoEStcVIj6hsVfRz+qE38ztDRG3sx5Xh8C1CMNc6r MlPsgTfBZXQik8+HyG6niii47+zRiPE++DHnKoPz8nguZCGyXeAmX2PcS/YT0mN0fAlP 2Cpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bOBBih3JRg5ecnanCNy6UVzBnae0IWceZ3dWmja0LB0=; b=SUo7kjESgMLE+10BqS8enmdr3bhnupWRcaY+9vHYuthzQ89qNWTLwrGdu0MdRE6yls C2OPJaGQkM6XsnAwEUGusF3cvhO3xAYGBgkiszU88AlOwbe54ySYf009rXVnGj3pjqVs IxGJoHC6a2SK2iEbQUCHbclt7t4De8kEkhRsdkDzsiwy7oDrwMs3unuzO3Ga0JGxH4bB EAh6hzGt4HENtG7BK20rw5g6om4hZaetZ9zFxNiNE+v0zs51RxuAwtwQKlrvTEjUTr8D 90FsJDNBrUgF8gLqSoPIoR89fTuPPGRhzq0vNwFn18KgWEH+G2St3JvrXPQCJJChvOx3 ll+w== X-Gm-Message-State: APjAAAU1IAa0HXx1jNJmpxM/lJbW4NHc/NGGokSryey8KNjsiN3Zi8wp VRt5WbEf0ZhV7eSdEA5Vchi5PlJernw= X-Received: by 2002:a17:902:b188:: with SMTP id s8mr2570088plr.206.1575340209136; Mon, 02 Dec 2019 18:30:09 -0800 (PST) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q22sm873695pfg.170.2019.12.02.18.30.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2019 18:30:08 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 23/40] target/arm: Update ctr_el0_access for EL2 Date: Mon, 2 Dec 2019 18:29:20 -0800 Message-Id: <20191203022937.1474-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191203022937.1474-1-richard.henderson@linaro.org> References: <20191203022937.1474-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::1041 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Update to include checks against HCR_EL2.TID2. Signed-off-by: Richard Henderson --- target/arm/helper.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) -- 2.17.1 Reviewed-by: Alex Bennée diff --git a/target/arm/helper.c b/target/arm/helper.c index ffa82b5509..9ad5015d5c 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -5212,11 +5212,27 @@ static const ARMCPRegInfo el3_cp_reginfo[] = { static CPAccessResult ctr_el0_access(CPUARMState *env, const ARMCPRegInfo *ri, bool isread) { - /* Only accessible in EL0 if SCTLR.UCT is set (and only in AArch64, - * but the AArch32 CTR has its own reginfo struct) - */ - if (arm_current_el(env) == 0 && !(env->cp15.sctlr_el[1] & SCTLR_UCT)) { - return CP_ACCESS_TRAP; + int cur_el = arm_current_el(env); + + if (cur_el < 2) { + uint64_t hcr = arm_hcr_el2_eff(env); + + if (cur_el == 0) { + if ((hcr & (HCR_E2H | HCR_TGE)) == (HCR_E2H | HCR_TGE)) { + if (!(env->cp15.sctlr_el[2] & SCTLR_UCT)) { + return CP_ACCESS_TRAP_EL2; + } + } else { + if (!(env->cp15.sctlr_el[1] & SCTLR_UCT)) { + return CP_ACCESS_TRAP; + } + if (hcr & HCR_TID2) { + return CP_ACCESS_TRAP_EL2; + } + } + } else if (hcr & HCR_TID2) { + return CP_ACCESS_TRAP_EL2; + } } return CP_ACCESS_OK; }