From patchwork Tue Feb 18 19:09:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 183605 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp6460947ile; Tue, 18 Feb 2020 11:12:31 -0800 (PST) X-Google-Smtp-Source: APXvYqxKbhjb0xyiBkHE9uQe76Fw9PK8Zl/NZJ4SktYQbxKa+59t11ImPMhIz98Jf8apSX/43AII X-Received: by 2002:a05:6214:927:: with SMTP id dk7mr18303290qvb.200.1582053151067; Tue, 18 Feb 2020 11:12:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582053151; cv=none; d=google.com; s=arc-20160816; b=0qH3mC7Kb78TI1+lsyhVJz9MQ6qhWSxOenVo2pqQpnesSkNOoVP6N2L7y1F84XlQKt ufnZqKtKrDESB/RT5/vHaDA5UKuPwqOAUv1jl1q3aZMQNBNuieWG1IB+AxWoT7bHcAlC dcnMrLam4fIuq0LswF5oTwRGUhsR37yJecdMjLp21Q+ItRcaC9PlW0FEgHBIHuwALdFS 0U8oLwhw3W4Jz9oIDQnlkK1ubCCcn/ysIXyHXOXH8Z7PKn9vE7hkcT3F4P+83oqOZJi1 z3UyQWd6+4LSKkOtEygG3Dgx5N4IhlyFlwaHyO6qDFertMHK1uPkO8+6QbUo1YrOfOQj Zg2w== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=/9wXoDEsxSRqmYUkdBOvS37ZtLP9FiINAczvKHAmVVI=; b=1I8YSwpze9sPFqXIDX+bqFkJiY57BdRYn6baZ+t1tEZTjrwnEs7DX7neBhCekx8Pcd smWeTmnwf8kws6qZY8sKmBernrxr+EpFAONaZnCwdZqV+RGU/alDUMBIWCNymtSOqbpu 5IaDB8VlOod3n48MNQXcUkzE49m3HjaFh8svuvgxy/iP/VLji5EoLwz2tuBn5oR0kiEJ IOwhuKH5gy35MfD/mvQluGUBPLfyrunWqnoDDYfDT2DuJpw0g2aclsVTVHm3ig+qNnx0 w9bu9QTe3zbIl9TUmk74Wd82jGfDCaA2RBN3Yhj33yAu7UgXQRT/NWNf6iO/ldx7Zg0n +kzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aEHSaFma; 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=pass (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 o10si2132182qtj.260.2020.02.18.11.12.30 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 18 Feb 2020 11:12:31 -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=pass header.i=@linaro.org header.s=google header.b=aEHSaFma; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:40512 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j48II-00089x-Fa for patch@linaro.org; Tue, 18 Feb 2020 14:12:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46628) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j48Fw-0004sT-V5 for qemu-devel@nongnu.org; Tue, 18 Feb 2020 14:10:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j48Fv-0001kM-P9 for qemu-devel@nongnu.org; Tue, 18 Feb 2020 14:10:04 -0500 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:46948) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j48Fv-0001ip-Jo for qemu-devel@nongnu.org; Tue, 18 Feb 2020 14:10:03 -0500 Received: by mail-pf1-x442.google.com with SMTP id k29so11103507pfp.13 for ; Tue, 18 Feb 2020 11:10:03 -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 :mime-version:content-transfer-encoding; bh=/9wXoDEsxSRqmYUkdBOvS37ZtLP9FiINAczvKHAmVVI=; b=aEHSaFmaqt9CFosgT/kRgfwaWvMLlgf5q66LGeQpwPZ5HnyvrtsdP4PSUY/eK+UwRW P+JG2oHhdfvb2Gmcrr1BjAMmtV8STZL9o3ulG10eNKdXLq1DYg8Vklo2chMa0bGln01Z 07oT1VwpjM76KnjAy9OODZ8XpoBg2VzICDjTjVp3hzh7But+dFfk1ex/5SLhrwtSOL58 UsSWjkJnMMJB7yVmbRPP9OV/dMwbTspDbcfh1HBbo6yBEgttNDktUdqyuPgHdG9nzZLi SYuxaf/Zd96gCUeB45PeX/pBHwtDYpjdwGLpeE3eijJfEosEbx0AvuHztjX45A2l6Bwd G75g== 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:mime-version:content-transfer-encoding; bh=/9wXoDEsxSRqmYUkdBOvS37ZtLP9FiINAczvKHAmVVI=; b=exHpOPpeAzFmus7h9XF21XXoS8z8mOURGbpixWf6TcBpLSUFaICtO2BY+2Aum7VaeN ZnOTvdNEEUl2Z24wc7iubfM5fdpRC/t6X3yH3Ds3Vg48bUTVR3ukrTnnZQawx6cWI9bT D30kfplgexpIfx+/dghnZR8Lm1zwEjlOio+U9f4oTV6lNb4lCN43FAGViIc3q2x7BZGj GuGxPFbmWfleq72zjy0tK1Xo1adWZwuzI4NROD1JAHQ2Dnl/0dJ9w2KDqOhYRbrHBHGC LZGMN71ri4skA8TNt6gzDYLKaovMPtrXRpckN6X69d/RUUONaaEnt1C7j3ygbmo4/wIb eGRw== X-Gm-Message-State: APjAAAVtedhv+7RP4jBnn4DE4ehxZRd9dtrsCKnOKOyEurR4eGCIV8uE vtBrnt4C0t+/ISlOloOcQ7bQKupwfQc= X-Received: by 2002:a62:6409:: with SMTP id y9mr22994459pfb.30.1582053002266; Tue, 18 Feb 2020 11:10:02 -0800 (PST) Received: from localhost.localdomain (97-126-123-70.tukw.qwest.net. [97.126.123.70]) by smtp.gmail.com with ESMTPSA id i68sm5139399pfe.173.2020.02.18.11.10.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Feb 2020 11:10:01 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 1/7] target/arm: Set ID_MMFR4.HPDS for aarch64_max_initfn Date: Tue, 18 Feb 2020 11:09:52 -0800 Message-Id: <20200218190958.745-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200218190958.745-1-richard.henderson@linaro.org> References: <20200218190958.745-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::442 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, qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We had set this for aarch32-only in arm_max_initfn, but failed to set the same bit for aarch64. Signed-off-by: Richard Henderson --- target/arm/cpu64.c | 1 + 1 file changed, 1 insertion(+) -- 2.20.1 diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 32cf8ee98b..32c3e24a3d 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -704,6 +704,7 @@ static void aarch64_max_initfn(Object *obj) cpu->isar.id_mmfr3 = u; u = cpu->isar.id_mmfr4; + u = FIELD_DP32(u, ID_MMFR4, HPDS, 1); /* AA32HPD */ u = FIELD_DP32(u, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 implemented */ cpu->isar.id_mmfr4 = u; From patchwork Tue Feb 18 19:09:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 183608 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp6465315ile; Tue, 18 Feb 2020 11:16:49 -0800 (PST) X-Google-Smtp-Source: APXvYqxze3ZBdW1SYXwFu4iTi17uYnyYH27ISC+AnAVV1xoaUNZQqlcY07vYrC+MMgG6LRS+QHdH X-Received: by 2002:a05:620a:9d2:: with SMTP id y18mr19117338qky.98.1582053409825; Tue, 18 Feb 2020 11:16:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582053409; cv=none; d=google.com; s=arc-20160816; b=YnKMH1VQkwFRYMy14PGiVVziEPZpYIxDU2vhjSlWSa6ubw/Apa6HZIDmEIu76dXjik 2cBk/v2WOXyLsRTXBUXVP5K2a9rBqvz2u9elWl4OWRaVvOTV9kJAm77HVJR6zilgjXyO 9bEkoU5QcBgO8ODeQkPhsCyKKh4fKkqqDQYjtmnOGWQSYMC3VuvRlIxdAq3fUvrJQjng ICA2PDAAMmlv3dpz6Vv+VDE+k1VYc4ylE212RVThiaRCjjgo+bqIPLNfqXJtJmNRWAsQ I206SPsGsdk1WU+iXnu1LG6sVsbS7l3y73VzClWm2cz6WvBnKCFkkz6aR/3EfbhbWmJ3 WkWQ== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=FW5hSe916aupkvtDNQI+gZPx6BhoZSiZ4PytdS9WQ+4=; b=HPFr2S0HZYmxWwVYzeryuNaibcs+DCDL5c3WgSXuDJYaQEhoG3xfMEnmEq1oZzFuLf 8hz8dj+m9dKYHaoRBMGCz1vg1+f8TFswxAfZMBsRJ5l2UVkYBWRsGER0gObYiUJ8IG+a p58W54Gkr7b3vv67aWvXFbSeO6oHjb0vNLueEHzxLxLTTBxz4KlLcEPoe190BVNKgAuY DhcyuTgk4SdJM5KH+xBNbTzO70Oee5oKrmMPxxn+aLQOdnt98Cg5Hy3+yugVYHsXyoM0 wqgbjKRLfVU+mnYywTWbK+UzylqbWDUtZOtNC3byogYRMgsBB1fB7PdPtr2ui/yp6gGR t/sQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=quiu2gw5; 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=pass (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 g2si2264832qtm.158.2020.02.18.11.16.49 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 18 Feb 2020 11:16:49 -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=pass header.i=@linaro.org header.s=google header.b=quiu2gw5; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:40620 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j48MT-0006LE-8s for patch@linaro.org; Tue, 18 Feb 2020 14:16:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46780) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j48Fz-0004vh-D9 for qemu-devel@nongnu.org; Tue, 18 Feb 2020 14:10:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j48Fx-0001nd-D6 for qemu-devel@nongnu.org; Tue, 18 Feb 2020 14:10:07 -0500 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:46949) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j48Fx-0001m8-5f for qemu-devel@nongnu.org; Tue, 18 Feb 2020 14:10:05 -0500 Received: by mail-pf1-x443.google.com with SMTP id k29so11103541pfp.13 for ; Tue, 18 Feb 2020 11:10:05 -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 :mime-version:content-transfer-encoding; bh=FW5hSe916aupkvtDNQI+gZPx6BhoZSiZ4PytdS9WQ+4=; b=quiu2gw525H+gdDWWgK2j93Bg3hyUPi1l+l14rwpRmY7jp/fQzQ29G/+1Tw6WOCzKY 1Oo11Ph4nDZ6oconIFHQdmd6XGlWGb+r5bFXjbEfzGcO0wrhJk3KSzfA0ms6OMsUH7LV OPCcMjvUChNw4z+vZDr1zjBYux97HGcJOkYmH+9jFSDSE4/5Bf50xkoXnaD47fEQm0fp YnNdGOA6tmRHnOhogA4aKMhIPCkiKxNZJNmLGo79CKPQtazk2QUl2KYuMR0DV15BRBLT muMUWjwQ2GKfRjyb0ffNWUlIolpof1Yo5eLHalT5DGhQjTtOWI7+ri+YV05mjkICFjH9 B6gA== 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:mime-version:content-transfer-encoding; bh=FW5hSe916aupkvtDNQI+gZPx6BhoZSiZ4PytdS9WQ+4=; b=fPVuX2QFdPqxBGQdsT/65P1Cty0QpTqQqp/Q+0hv8+LMFnoKyrB6Sr4mEGEhhNQQ/c StI2ZQeegLccwmHJ7aPvHpkpQROBq695fjeHrSWc9DoRlFoPjxhiICQEsVIHeYz59EUY O4h+Hr4TLELTaQ3Ga1duqvzopp5cHj0Sq+iNHKmB/o71EadTZVc8SUuPQRKJNc9TVmpK 7WggqvZIXIndUp1Pm1tUYiv2QaN0UnXK1xQyfI1PYTPeiUvaBk6lCdFD1gznkYdHi5MX NywlV+KY+6YisSGlG1r1SB2RuQoBx/Q5cBtjk2OfgK6ZBcgrmzmv+XYyEwyxYZWbGFSM /+1w== X-Gm-Message-State: APjAAAWJhTAhcIzBX9Me+y0uwNzoGJ9Aj0caBjy7zlbEpl0oSs2JHAIC w9qBdciSwSFGdslW2hdoeg7VNGPjiMA= X-Received: by 2002:a63:ba43:: with SMTP id l3mr25364582pgu.120.1582053003565; Tue, 18 Feb 2020 11:10:03 -0800 (PST) Received: from localhost.localdomain (97-126-123-70.tukw.qwest.net. [97.126.123.70]) by smtp.gmail.com with ESMTPSA id i68sm5139399pfe.173.2020.02.18.11.10.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Feb 2020 11:10:02 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 2/7] target/arm: Honor the HCR_EL2.{TVM,TRVM} bits Date: Tue, 18 Feb 2020 11:09:53 -0800 Message-Id: <20200218190958.745-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200218190958.745-1-richard.henderson@linaro.org> References: <20200218190958.745-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::443 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, qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" These bits trap EL1 access to various virtual memory controls. Buglink: https://bugs.launchpad.net/bugs/1855072 Signed-off-by: Richard Henderson --- v2: Include TTBCR. --- target/arm/helper.c | 77 ++++++++++++++++++++++++++++++--------------- 1 file changed, 52 insertions(+), 25 deletions(-) -- 2.20.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index 513f4edbb4..8abbc4e991 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -530,6 +530,19 @@ static CPAccessResult access_tpm(CPUARMState *env, const ARMCPRegInfo *ri, return CP_ACCESS_OK; } +/* Check for traps from EL1 due to HCR_EL2.TVM and HCR_EL2.TRVM. */ +static CPAccessResult access_tvm_trvm(CPUARMState *env, const ARMCPRegInfo *ri, + bool isread) +{ + if (arm_current_el(env) == 1) { + uint64_t trap = isread ? HCR_TRVM : HCR_TVM; + if (arm_hcr_el2_eff(env) & trap) { + return CP_ACCESS_TRAP_EL2; + } + } + return CP_ACCESS_OK; +} + static void dacr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { ARMCPU *cpu = env_archcpu(env); @@ -785,7 +798,8 @@ static const ARMCPRegInfo cp_reginfo[] = { */ { .name = "CONTEXTIDR_EL1", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 13, .crm = 0, .opc2 = 1, - .access = PL1_RW, .secure = ARM_CP_SECSTATE_NS, + .access = PL1_RW, .accessfn = access_tvm_trvm, + .secure = ARM_CP_SECSTATE_NS, .fieldoffset = offsetof(CPUARMState, cp15.contextidr_el[1]), .resetvalue = 0, .writefn = contextidr_write, .raw_writefn = raw_write, }, { .name = "CONTEXTIDR_S", .state = ARM_CP_STATE_AA32, @@ -877,9 +891,11 @@ static const ARMCPRegInfo not_v7_cp_reginfo[] = { .opc1 = CP_ANY, .opc2 = 3, .access = PL1_W, .writefn = tlbimvaa_write, .type = ARM_CP_NO_RAW }, { .name = "PRRR", .cp = 15, .crn = 10, .crm = 2, - .opc1 = 0, .opc2 = 0, .access = PL1_RW, .type = ARM_CP_NOP }, + .opc1 = 0, .opc2 = 0, .access = PL1_RW, .accessfn = access_tvm_trvm, + .type = ARM_CP_NOP }, { .name = "NMRR", .cp = 15, .crn = 10, .crm = 2, - .opc1 = 0, .opc2 = 1, .access = PL1_RW, .type = ARM_CP_NOP }, + .opc1 = 0, .opc2 = 1, .access = PL1_RW, .accessfn = access_tvm_trvm, + .type = ARM_CP_NOP }, REGINFO_SENTINEL }; @@ -997,7 +1013,7 @@ static const ARMCPRegInfo v6_cp_reginfo[] = { { .name = "DMB", .cp = 15, .crn = 7, .crm = 10, .opc1 = 0, .opc2 = 5, .access = PL0_W, .type = ARM_CP_NOP }, { .name = "IFAR", .cp = 15, .crn = 6, .crm = 0, .opc1 = 0, .opc2 = 2, - .access = PL1_RW, + .access = PL1_RW, .accessfn = access_tvm_trvm, .bank_fieldoffsets = { offsetof(CPUARMState, cp15.ifar_s), offsetof(CPUARMState, cp15.ifar_ns) }, .resetvalue = 0, }, @@ -2209,16 +2225,19 @@ static const ARMCPRegInfo v7_cp_reginfo[] = { */ { .name = "AFSR0_EL1", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 5, .crm = 1, .opc2 = 0, - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, + .access = PL1_RW, .accessfn = access_tvm_trvm, + .type = ARM_CP_CONST, .resetvalue = 0 }, { .name = "AFSR1_EL1", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 5, .crm = 1, .opc2 = 1, - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, + .access = PL1_RW, .accessfn = access_tvm_trvm, + .type = ARM_CP_CONST, .resetvalue = 0 }, /* MAIR can just read-as-written because we don't implement caches * and so don't need to care about memory attributes. */ { .name = "MAIR_EL1", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 2, .opc2 = 0, - .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.mair_el[1]), + .access = PL1_RW, .accessfn = access_tvm_trvm, + .fieldoffset = offsetof(CPUARMState, cp15.mair_el[1]), .resetvalue = 0 }, { .name = "MAIR_EL3", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 6, .crn = 10, .crm = 2, .opc2 = 0, @@ -2232,12 +2251,14 @@ static const ARMCPRegInfo v7_cp_reginfo[] = { * handled in the field definitions. */ { .name = "MAIR0", .state = ARM_CP_STATE_AA32, - .cp = 15, .opc1 = 0, .crn = 10, .crm = 2, .opc2 = 0, .access = PL1_RW, + .cp = 15, .opc1 = 0, .crn = 10, .crm = 2, .opc2 = 0, + .access = PL1_RW, .accessfn = access_tvm_trvm, .bank_fieldoffsets = { offsetof(CPUARMState, cp15.mair0_s), offsetof(CPUARMState, cp15.mair0_ns) }, .resetfn = arm_cp_reset_ignore }, { .name = "MAIR1", .state = ARM_CP_STATE_AA32, - .cp = 15, .opc1 = 0, .crn = 10, .crm = 2, .opc2 = 1, .access = PL1_RW, + .cp = 15, .opc1 = 0, .crn = 10, .crm = 2, .opc2 = 1, + .access = PL1_RW, .accessfn = access_tvm_trvm, .bank_fieldoffsets = { offsetof(CPUARMState, cp15.mair1_s), offsetof(CPUARMState, cp15.mair1_ns) }, .resetfn = arm_cp_reset_ignore }, @@ -3887,20 +3908,21 @@ static void vttbr_write(CPUARMState *env, const ARMCPRegInfo *ri, static const ARMCPRegInfo vmsa_pmsa_cp_reginfo[] = { { .name = "DFSR", .cp = 15, .crn = 5, .crm = 0, .opc1 = 0, .opc2 = 0, - .access = PL1_RW, .type = ARM_CP_ALIAS, + .access = PL1_RW, .accessfn = access_tvm_trvm, .type = ARM_CP_ALIAS, .bank_fieldoffsets = { offsetoflow32(CPUARMState, cp15.dfsr_s), offsetoflow32(CPUARMState, cp15.dfsr_ns) }, }, { .name = "IFSR", .cp = 15, .crn = 5, .crm = 0, .opc1 = 0, .opc2 = 1, - .access = PL1_RW, .resetvalue = 0, + .access = PL1_RW, .accessfn = access_tvm_trvm, .resetvalue = 0, .bank_fieldoffsets = { offsetoflow32(CPUARMState, cp15.ifsr_s), offsetoflow32(CPUARMState, cp15.ifsr_ns) } }, { .name = "DFAR", .cp = 15, .opc1 = 0, .crn = 6, .crm = 0, .opc2 = 0, - .access = PL1_RW, .resetvalue = 0, + .access = PL1_RW, .accessfn = access_tvm_trvm, .resetvalue = 0, .bank_fieldoffsets = { offsetof(CPUARMState, cp15.dfar_s), offsetof(CPUARMState, cp15.dfar_ns) } }, { .name = "FAR_EL1", .state = ARM_CP_STATE_AA64, .opc0 = 3, .crn = 6, .crm = 0, .opc1 = 0, .opc2 = 0, - .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.far_el[1]), + .access = PL1_RW, .accessfn = access_tvm_trvm, + .fieldoffset = offsetof(CPUARMState, cp15.far_el[1]), .resetvalue = 0, }, REGINFO_SENTINEL }; @@ -3908,25 +3930,29 @@ static const ARMCPRegInfo vmsa_pmsa_cp_reginfo[] = { static const ARMCPRegInfo vmsa_cp_reginfo[] = { { .name = "ESR_EL1", .state = ARM_CP_STATE_AA64, .opc0 = 3, .crn = 5, .crm = 2, .opc1 = 0, .opc2 = 0, - .access = PL1_RW, + .access = PL1_RW, .accessfn = access_tvm_trvm, .fieldoffset = offsetof(CPUARMState, cp15.esr_el[1]), .resetvalue = 0, }, { .name = "TTBR0_EL1", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 0, .opc2 = 0, - .access = PL1_RW, .writefn = vmsa_ttbr_write, .resetvalue = 0, + .access = PL1_RW, .accessfn = access_tvm_trvm, + .writefn = vmsa_ttbr_write, .resetvalue = 0, .bank_fieldoffsets = { offsetof(CPUARMState, cp15.ttbr0_s), offsetof(CPUARMState, cp15.ttbr0_ns) } }, { .name = "TTBR1_EL1", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 0, .opc2 = 1, - .access = PL1_RW, .writefn = vmsa_ttbr_write, .resetvalue = 0, + .access = PL1_RW, .accessfn = access_tvm_trvm, + .writefn = vmsa_ttbr_write, .resetvalue = 0, .bank_fieldoffsets = { offsetof(CPUARMState, cp15.ttbr1_s), offsetof(CPUARMState, cp15.ttbr1_ns) } }, { .name = "TCR_EL1", .state = ARM_CP_STATE_AA64, .opc0 = 3, .crn = 2, .crm = 0, .opc1 = 0, .opc2 = 2, - .access = PL1_RW, .writefn = vmsa_tcr_el12_write, + .access = PL1_RW, .accessfn = access_tvm_trvm, + .writefn = vmsa_tcr_el12_write, .resetfn = vmsa_ttbcr_reset, .raw_writefn = raw_write, .fieldoffset = offsetof(CPUARMState, cp15.tcr_el[1]) }, { .name = "TTBCR", .cp = 15, .crn = 2, .crm = 0, .opc1 = 0, .opc2 = 2, - .access = PL1_RW, .type = ARM_CP_ALIAS, .writefn = vmsa_ttbcr_write, + .access = PL1_RW, .accessfn = access_tvm_trvm, + .type = ARM_CP_ALIAS, .writefn = vmsa_ttbcr_write, .raw_writefn = vmsa_ttbcr_raw_write, .bank_fieldoffsets = { offsetoflow32(CPUARMState, cp15.tcr_el[3]), offsetoflow32(CPUARMState, cp15.tcr_el[1])} }, @@ -3938,7 +3964,8 @@ static const ARMCPRegInfo vmsa_cp_reginfo[] = { */ static const ARMCPRegInfo ttbcr2_reginfo = { .name = "TTBCR2", .cp = 15, .opc1 = 0, .crn = 2, .crm = 0, .opc2 = 3, - .access = PL1_RW, .type = ARM_CP_ALIAS, + .access = PL1_RW, .accessfn = access_tvm_trvm, + .type = ARM_CP_ALIAS, .bank_fieldoffsets = { offsetofhigh32(CPUARMState, cp15.tcr_el[3]), offsetofhigh32(CPUARMState, cp15.tcr_el[1]) }, }; @@ -4158,12 +4185,12 @@ static const ARMCPRegInfo lpae_cp_reginfo[] = { /* NOP AMAIR0/1 */ { .name = "AMAIR0", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .crn = 10, .crm = 3, .opc1 = 0, .opc2 = 0, - .access = PL1_RW, .type = ARM_CP_CONST, - .resetvalue = 0 }, + .access = PL1_RW, .accessfn = access_tvm_trvm, + .type = ARM_CP_CONST, .resetvalue = 0 }, /* AMAIR1 is mapped to AMAIR_EL1[63:32] */ { .name = "AMAIR1", .cp = 15, .crn = 10, .crm = 3, .opc1 = 0, .opc2 = 1, - .access = PL1_RW, .type = ARM_CP_CONST, - .resetvalue = 0 }, + .access = PL1_RW, .accessfn = access_tvm_trvm, + .type = ARM_CP_CONST, .resetvalue = 0 }, { .name = "PAR", .cp = 15, .crm = 7, .opc1 = 0, .access = PL1_RW, .type = ARM_CP_64BIT, .resetvalue = 0, .bank_fieldoffsets = { offsetof(CPUARMState, cp15.par_s), @@ -4889,7 +4916,7 @@ static const ARMCPRegInfo v8_cp_reginfo[] = { .type = ARM_CP_NOP, .access = PL1_W }, /* MMU Domain access control / MPU write buffer control */ { .name = "DACR", .cp = 15, .opc1 = 0, .crn = 3, .crm = 0, .opc2 = 0, - .access = PL1_RW, .resetvalue = 0, + .access = PL1_RW, .accessfn = access_tvm_trvm, .resetvalue = 0, .writefn = dacr_write, .raw_writefn = raw_write, .bank_fieldoffsets = { offsetoflow32(CPUARMState, cp15.dacr_s), offsetoflow32(CPUARMState, cp15.dacr_ns) } }, @@ -7716,7 +7743,7 @@ void register_cp_regs_for_features(ARMCPU *cpu) ARMCPRegInfo sctlr = { .name = "SCTLR", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 1, .crm = 0, .opc2 = 0, - .access = PL1_RW, + .access = PL1_RW, .accessfn = access_tvm_trvm, .bank_fieldoffsets = { offsetof(CPUARMState, cp15.sctlr_s), offsetof(CPUARMState, cp15.sctlr_ns) }, .writefn = sctlr_write, .resetvalue = cpu->reset_sctlr, From patchwork Tue Feb 18 19:09:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 183607 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp6465051ile; Tue, 18 Feb 2020 11:16:34 -0800 (PST) X-Google-Smtp-Source: APXvYqy94KVHVa8QAoZXhfMYLuwZWEc89bXmyABA1sr9yni1qnOdVXEbWvlWvGslqVp+H34WuE4u X-Received: by 2002:a37:4b4b:: with SMTP id y72mr19931856qka.175.1582053394613; Tue, 18 Feb 2020 11:16:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582053394; cv=none; d=google.com; s=arc-20160816; b=CzvDcWnyhCK2cdUYi0QLVdstpwDZRNpFZOTMKcGH+NvvAXqolIp+dB0Z8VKeuOVF8v 3WZLLmlhaNOcam7anYrz4E3VEjdKfjdNcg8Kpf0IWR+6x1lrL9ysTLlSan/zAAi/n9QJ OhNvrGwmwFX/G9aj9lfi42Psx8tb8651L0ghkb0xVDFgejT9NOjm1nqB9ggBmG1dkld7 N6NiQsIjJ5tovcfidHQrIYSOqi9RMzCcW/izyDAssUIks/j/OJebpPOONVaUxtldfY2m WPeQkx0HrWcFwMoSVlZVMSya2kRj+7k3lkwcpOQyUKP1AOaMFuSlqz/9hTa3H/+OgIFB e7pA== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=aT+wiWpglSLXunTwVoN4RPF1V0ishR6Qd0crZF3h7bM=; b=ZrXdHxw5/ABL2Ye7vGpuQ2e/Ij2yZhVAto1dnqtX2eiSTvDtFYoD2VqHBnsfpaOZAX zCmu4Oij2J6qo+idG+kbHauU+bJWJh+R7HFhsUBUK/Vjfbd8fERjH3nLFLADyxbMsOJF 4x4KO+XDKAfKTX89k9tU2NeE0ukeDvhqBgOYgy96ZE2zNAjUjgMx5wZvs2WdszhSZRdP BGPYxtamlEHK83W73zbLMqSSu5ZJGLralLZyzraD2xF0isjCSNuiXvdNp1SIqId0Ojuk VsyJ1TgQAq40x8S1G17un0xAUHMxiH5r8yEIc+gcg+mCYLckc7nuMVLNFwX4MgwTBXIP USXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=v8QubRib; 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=pass (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 g13si2085926qtv.387.2020.02.18.11.16.34 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 18 Feb 2020 11:16:34 -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=pass header.i=@linaro.org header.s=google header.b=v8QubRib; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:40616 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j48ME-0006Dm-55 for patch@linaro.org; Tue, 18 Feb 2020 14:16:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46818) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j48Fz-0004wm-Ty for qemu-devel@nongnu.org; Tue, 18 Feb 2020 14:10:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j48Fy-0001qU-Fk for qemu-devel@nongnu.org; Tue, 18 Feb 2020 14:10:07 -0500 Received: from mail-pj1-x1041.google.com ([2607:f8b0:4864:20::1041]:50639) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j48Fy-0001oS-9m for qemu-devel@nongnu.org; Tue, 18 Feb 2020 14:10:06 -0500 Received: by mail-pj1-x1041.google.com with SMTP id r67so1447057pjb.0 for ; Tue, 18 Feb 2020 11:10:06 -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 :mime-version:content-transfer-encoding; bh=aT+wiWpglSLXunTwVoN4RPF1V0ishR6Qd0crZF3h7bM=; b=v8QubRibTLDCjL+qLjfh4h5/fAFDbGbXAy+5GhWoynru3nPS/7itzgaySkz1lo+GyN mTGRwKAbgDSCkvdEcncMXlvGPg4uyjmFTQmI6adYie4q3gPeTQnroRKNAKEFBUMZQpbV TPMawS9kxVptSWmGKWyD/n4io81KMAyehUuuOCxm6kGpgUeXN+1U0GSgIBCeixvvKYiS yisNbxm9QIqfN1KL0+WEPlLaII5qR1bGAirvYjmUllO5+rziLR+Ymuui0MwPbUZgluBp XrFejTmOqHnqQF0arcbtMI8a6LnHcL7Q1qkpIS5fCrPqfrJsvaHiRzR3uwHWkaj904r1 +Wow== 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:mime-version:content-transfer-encoding; bh=aT+wiWpglSLXunTwVoN4RPF1V0ishR6Qd0crZF3h7bM=; b=k0VC4UzoqsFa2O+ZIWNjf3yywIj2fkJoqXb8oJND+tFjYujWXHWjqrzRyr1+f988S3 50at6s3tN9HfSTGlLHkjRtTjRPxXP7Utim1u4wWXJEjm8ypwg4PSW8ht6VhpCIoZu753 3tCgVrZi7FmP7E9nVAveL7Z9xhxkOCqnm+Zq3/nEmEinQi6WeE346oz+kFe1d1YDMKGh /O9rIEtZomu4AMZJLmu/GKzS9IPFYb3PPrH6+0/mg//Dpn8n4le28IfLHPBxWgULDfmz p+8AMsP8vNzqx/srwpyBErQGdSC+GERzrozD4UTKJy/slM6afjJhcAIuheAZfYNwscMS 1DFA== X-Gm-Message-State: APjAAAULjkJunFR8+rBJC0rSdJjfOQAdcQ2X9kgk3Y2uSmgvKOO2VObg da56EkhtNW11SZtHAr7VMP4poCfrLD0= X-Received: by 2002:a17:90a:fa8d:: with SMTP id cu13mr4328683pjb.68.1582053004856; Tue, 18 Feb 2020 11:10:04 -0800 (PST) Received: from localhost.localdomain (97-126-123-70.tukw.qwest.net. [97.126.123.70]) by smtp.gmail.com with ESMTPSA id i68sm5139399pfe.173.2020.02.18.11.10.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Feb 2020 11:10:04 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 3/7] target/arm: Honor the HCR_EL2.TSW bit Date: Tue, 18 Feb 2020 11:09:54 -0800 Message-Id: <20200218190958.745-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200218190958.745-1-richard.henderson@linaro.org> References: <20200218190958.745-1-richard.henderson@linaro.org> MIME-Version: 1.0 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, qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" These bits trap EL1 access to set/way cache maintenance insns. Buglink: https://bugs.launchpad.net/bugs/1863685 Signed-off-by: Richard Henderson --- target/arm/helper.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) -- 2.20.1 Reviewed-by: Peter Maydell diff --git a/target/arm/helper.c b/target/arm/helper.c index 8abbc4e991..dc99ee5d18 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -543,6 +543,16 @@ static CPAccessResult access_tvm_trvm(CPUARMState *env, const ARMCPRegInfo *ri, return CP_ACCESS_OK; } +/* Check for traps from EL1 due to HCR_EL2.TSW. */ +static CPAccessResult access_tsw(CPUARMState *env, const ARMCPRegInfo *ri, + bool isread) +{ + if (arm_current_el(env) == 1 && (arm_hcr_el2_eff(env) & HCR_TSW)) { + return CP_ACCESS_TRAP_EL2; + } + return CP_ACCESS_OK; +} + static void dacr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { ARMCPU *cpu = env_archcpu(env); @@ -4704,14 +4714,14 @@ static const ARMCPRegInfo v8_cp_reginfo[] = { .access = PL1_W, .type = ARM_CP_NOP }, { .name = "DC_ISW", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 6, .opc2 = 2, - .access = PL1_W, .type = ARM_CP_NOP }, + .access = PL1_W, .accessfn = access_tsw, .type = ARM_CP_NOP }, { .name = "DC_CVAC", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 10, .opc2 = 1, .access = PL0_W, .type = ARM_CP_NOP, .accessfn = aa64_cacheop_access }, { .name = "DC_CSW", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 10, .opc2 = 2, - .access = PL1_W, .type = ARM_CP_NOP }, + .access = PL1_W, .accessfn = access_tsw, .type = ARM_CP_NOP }, { .name = "DC_CVAU", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 11, .opc2 = 1, .access = PL0_W, .type = ARM_CP_NOP, @@ -4722,7 +4732,7 @@ static const ARMCPRegInfo v8_cp_reginfo[] = { .accessfn = aa64_cacheop_access }, { .name = "DC_CISW", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 14, .opc2 = 2, - .access = PL1_W, .type = ARM_CP_NOP }, + .access = PL1_W, .accessfn = access_tsw, .type = ARM_CP_NOP }, /* TLBI operations */ { .name = "TLBI_VMALLE1IS", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 0, @@ -4903,17 +4913,17 @@ static const ARMCPRegInfo v8_cp_reginfo[] = { { .name = "DCIMVAC", .cp = 15, .opc1 = 0, .crn = 7, .crm = 6, .opc2 = 1, .type = ARM_CP_NOP, .access = PL1_W }, { .name = "DCISW", .cp = 15, .opc1 = 0, .crn = 7, .crm = 6, .opc2 = 2, - .type = ARM_CP_NOP, .access = PL1_W }, + .type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tsw }, { .name = "DCCMVAC", .cp = 15, .opc1 = 0, .crn = 7, .crm = 10, .opc2 = 1, .type = ARM_CP_NOP, .access = PL1_W }, { .name = "DCCSW", .cp = 15, .opc1 = 0, .crn = 7, .crm = 10, .opc2 = 2, - .type = ARM_CP_NOP, .access = PL1_W }, + .type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tsw }, { .name = "DCCMVAU", .cp = 15, .opc1 = 0, .crn = 7, .crm = 11, .opc2 = 1, .type = ARM_CP_NOP, .access = PL1_W }, { .name = "DCCIMVAC", .cp = 15, .opc1 = 0, .crn = 7, .crm = 14, .opc2 = 1, .type = ARM_CP_NOP, .access = PL1_W }, { .name = "DCCISW", .cp = 15, .opc1 = 0, .crn = 7, .crm = 14, .opc2 = 2, - .type = ARM_CP_NOP, .access = PL1_W }, + .type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tsw }, /* MMU Domain access control / MPU write buffer control */ { .name = "DACR", .cp = 15, .opc1 = 0, .crn = 3, .crm = 0, .opc2 = 0, .access = PL1_RW, .accessfn = access_tvm_trvm, .resetvalue = 0, From patchwork Tue Feb 18 19:09:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 183602 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp6459274ile; Tue, 18 Feb 2020 11:10:48 -0800 (PST) X-Google-Smtp-Source: APXvYqwlIYoJ3M3kVVDxQG8Ow07jk1I2d1/Uu6L8YLCYcRuw8eGbFfgK5qJfzfedp2Ots7/akAt/ X-Received: by 2002:a05:620a:1464:: with SMTP id j4mr20338108qkl.29.1582053047911; Tue, 18 Feb 2020 11:10:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582053047; cv=none; d=google.com; s=arc-20160816; b=fUH6lUYywRWk5+CavmMxUw9Mks5A8gZwLYrPvOG3w5qwSXXAQcIaZt2OjPjJXfJGUT p+jPxrOEXxkTYG7lq6HNF9fdW47eARblGmdnkExb5x5CF5mg79ChhaUHhXyup2ISRA6T RU2ai/PGBsY305wvanKG2npYD5yID3JSMkorQJJQIg5QtKG2BXU9oNdGZlNHJxRtGvl8 rHYBcQSNp9wrU0FRh/791rDvx5UKMW0zX74oY4OmxzvZWkoz1HrJG49xXZpnLEADLO6R M/pETJKe1OIzHZJDYcvndbKQ2Kxlb5Vk/gllJG3pBayIN1vM2qcq1NhALCox5U5gQXWa 8gGw== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=macsUf7RwNXBE0fmKKCjQlSCUWHuv/3Gu30XsvyGcpY=; b=kHcPuZpi+em8Qb9nO0M0ldEWz48fanLzTLWtwTHIT9s9VSbfwsEppsOn5cDDLvf687 LpaRRPiOYaXcpJfSMPkgVG+y/bKeYCVoJxYrDmP93EzPYPgG/qWobzZByffBMYoSfFUB R5tDC9fxDpeneF5Pb/U7xrS1F2PcuaLFLm3HfCK7NszPEcrpu18DLT8HR2VtCFlAJeIy f/7O+2XSc8IKfvYlfXH6tyZ5g5CUgJpaF5JmSMjsMcRANG1tZExAx5h+8aC6tZLsUZV+ BfnEhJHSnidgyuYxsFxiGQApauPvStRhi5Hm+ACJ5+nT4TxzUUdkUBQCSFKBEryc5/Tv S5CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ap0lFfBa; 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=pass (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 k10si1987179qvw.216.2020.02.18.11.10.47 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 18 Feb 2020 11:10:47 -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=pass header.i=@linaro.org header.s=google header.b=ap0lFfBa; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:40426 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j48Gd-00056Z-Cs for patch@linaro.org; Tue, 18 Feb 2020 14:10:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46922) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j48G1-000500-B6 for qemu-devel@nongnu.org; Tue, 18 Feb 2020 14:10:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j48Fz-0001uj-T4 for qemu-devel@nongnu.org; Tue, 18 Feb 2020 14:10:09 -0500 Received: from mail-pj1-x1042.google.com ([2607:f8b0:4864:20::1042]:50641) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j48Fz-0001s4-M4 for qemu-devel@nongnu.org; Tue, 18 Feb 2020 14:10:07 -0500 Received: by mail-pj1-x1042.google.com with SMTP id r67so1447093pjb.0 for ; Tue, 18 Feb 2020 11:10:07 -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 :mime-version:content-transfer-encoding; bh=macsUf7RwNXBE0fmKKCjQlSCUWHuv/3Gu30XsvyGcpY=; b=ap0lFfBawvYsao7AIava1O4L4J8JPIPlsgvKjLKk/m5K5/K6dRHpWbzlRkGL52Tr1l jYY/jCvZR2BGfEwmRv1iecNjZ19mAJA7O0zP5UdSsdv3yvWZQilzWwqSM+NcE/dss3y9 RPjuQ8zG6DiR4KK6YDpdFD6qnBY8uwkwnIhJsLVVvlGcCAW0TNwsmjeGXUA0E8gly8li XnNfswl1eAgkgWM0AqbkaWhtK2Xh0kfA5GLG/utz9bvhge95lWk9Q+ZHf/DjqASJsq9o Pclnq9mSd2dcKuGTuajCSJqo2mNjY6h5QMES8U4ylqvI/OT0ihUVCy31I+ufZdYtSJd+ DbGA== 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:mime-version:content-transfer-encoding; bh=macsUf7RwNXBE0fmKKCjQlSCUWHuv/3Gu30XsvyGcpY=; b=Yo0pi1GITZLwDGvVTLWUgLDbwEQvc1KPot6RQd3Ci59lnvwoKpV8+k9QFBn1T+H/4q nu0LzHj/qSD0hW4Kz18ZhEBRxHZqSTaKFh71Uxpv6CFAx9s6bAF5k2MVQso1Sk9KbieF 7arooNuSqIw26TYSOAhkGc8RkqTyNb4Fumc7LrC6lOFjl6ODHjqDU3eIGISSORRHEPZn FWLanuYWAQZFcFGmStemxi+axFAUIeY1UzrhGGfvT9DjwbHsrY+UjZZ7pPr3UBW2dK7o uJcpt4EzxFdIObG6fCjMlHdbGuegEZZ84snv54FssK6l4rGd8BTN8lUdAmNydZ0YXAlG fX0w== X-Gm-Message-State: APjAAAVtr1r57L0oXHKJDtWonaeFQw0oj3lbniPJrr7aLgMgv7WFlYni l4FYlpkm7DrkrmAzHLhkrVBL1ZYpAZc= X-Received: by 2002:a17:90a:5285:: with SMTP id w5mr4470243pjh.77.1582053006040; Tue, 18 Feb 2020 11:10:06 -0800 (PST) Received: from localhost.localdomain (97-126-123-70.tukw.qwest.net. [97.126.123.70]) by smtp.gmail.com with ESMTPSA id i68sm5139399pfe.173.2020.02.18.11.10.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Feb 2020 11:10:05 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 4/7] target/arm: Honor the HCR_EL2.TACR bit Date: Tue, 18 Feb 2020 11:09:55 -0800 Message-Id: <20200218190958.745-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200218190958.745-1-richard.henderson@linaro.org> References: <20200218190958.745-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::1042 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, qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This bit traps EL1 access to the auxiliary control registers. Signed-off-by: Richard Henderson --- target/arm/helper.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) -- 2.20.1 Reviewed-by: Peter Maydell diff --git a/target/arm/helper.c b/target/arm/helper.c index dc99ee5d18..52b6e68659 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -553,6 +553,16 @@ static CPAccessResult access_tsw(CPUARMState *env, const ARMCPRegInfo *ri, return CP_ACCESS_OK; } +/* Check for traps from EL1 due to HCR_EL2.TACR. */ +static CPAccessResult access_tacr(CPUARMState *env, const ARMCPRegInfo *ri, + bool isread) +{ + if (arm_current_el(env) == 1 && (arm_hcr_el2_eff(env) & HCR_TACR)) { + return CP_ACCESS_TRAP_EL2; + } + return CP_ACCESS_OK; +} + static void dacr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { ARMCPU *cpu = env_archcpu(env); @@ -6911,8 +6921,8 @@ static const ARMCPRegInfo ats1cp_reginfo[] = { static const ARMCPRegInfo actlr2_hactlr2_reginfo[] = { { .name = "ACTLR2", .state = ARM_CP_STATE_AA32, .cp = 15, .opc1 = 0, .crn = 1, .crm = 0, .opc2 = 3, - .access = PL1_RW, .type = ARM_CP_CONST, - .resetvalue = 0 }, + .access = PL1_RW, .accessfn = access_tacr, + .type = ARM_CP_CONST, .resetvalue = 0 }, { .name = "HACTLR2", .state = ARM_CP_STATE_AA32, .cp = 15, .opc1 = 4, .crn = 1, .crm = 0, .opc2 = 3, .access = PL2_RW, .type = ARM_CP_CONST, @@ -7668,8 +7678,8 @@ void register_cp_regs_for_features(ARMCPU *cpu) ARMCPRegInfo auxcr_reginfo[] = { { .name = "ACTLR_EL1", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 1, .crm = 0, .opc2 = 1, - .access = PL1_RW, .type = ARM_CP_CONST, - .resetvalue = cpu->reset_auxcr }, + .access = PL1_RW, .accessfn = access_tacr, + .type = ARM_CP_CONST, .resetvalue = cpu->reset_auxcr }, { .name = "ACTLR_EL2", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 0, .opc2 = 1, .access = PL2_RW, .type = ARM_CP_CONST, From patchwork Tue Feb 18 19:09:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 183609 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp6468407ile; Tue, 18 Feb 2020 11:20:15 -0800 (PST) X-Google-Smtp-Source: APXvYqz+d2uxwQmR7hxx5YtidX92TiKAbTbHEFBVMiL+Ez0cvIB+14BzY5EvTuHoXoZh5fugnZxW X-Received: by 2002:a0c:f6c8:: with SMTP id d8mr18410733qvo.234.1582053615649; Tue, 18 Feb 2020 11:20:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582053615; cv=none; d=google.com; s=arc-20160816; b=xtImiZO5D6fjtUvxyz1lfJoTL7lxb3dD60tQwMxmPwLIIaZ39AN6h2BLg5z4HbfHDQ TaPKNA5hpTKk+ggAMD9AA7X/v8Z/9M3X+u7FDNfpdjpYgGkAlMSslqnM1x1eEkg6auM4 XKcqRHQpZFetsrNnzujlcjRlH/MsvVCOzi2D2h8m10vwpdaHwsILhGfcrpoXq55+oqQx US+/CNs8tF1mUhv3ZzHHHsvSosKUDxqGdH6HyA0YyRsvUXIaLw+jhcgm7SMxWC1wWQ+2 uUSzptGEEWix8IdObLiFp+m55l8dDqhOKIOTYJ9gUAkixcXxKj0I9Je0wzo5HTG0+sjg RWBg== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=5k7tlvEB9/rsMbuI3aToULa8WUIjX1E0iDo+FSiobiY=; b=Iv2QJLjKep6fbYJXfA/i9guygXAIjzvShTMdet8yQRheJ+WZnRANGIg7KlnCelc16j wSUcE7zi3Lx1f0EXQO9e3A/YqkHrNpY+hfRgKALGLj0I6o5vA/v2lYYLg5xO2JKNzkGE bynQ1h4N3QKVD4Hp27r5igW9dn+iMVUlrqOXOO31gY4ABSBTVn7CsoWdgVHAUUHXyaPG rKtaoYk/NKTNM3+KGgBUwnDS5rGeCX41LtHJ67MvmaZ5ErBoWDzxRhEWOHEF6C/9GyhY yhrqdwTLUavELSGYIBlQG1A7hcqxA++4a8vDbaSwPEJKIWjPqHOuu+88Q5ukw7gKM80Z ZLiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GXQTHFae; 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=pass (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 p68si2382185qke.320.2020.02.18.11.20.15 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 18 Feb 2020 11:20:15 -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=pass header.i=@linaro.org header.s=google header.b=GXQTHFae; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:40684 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j48Pn-0001va-2j for patch@linaro.org; Tue, 18 Feb 2020 14:20:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47087) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j48G3-00054E-Rh for qemu-devel@nongnu.org; Tue, 18 Feb 2020 14:10:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j48G1-0001yw-Dt for qemu-devel@nongnu.org; Tue, 18 Feb 2020 14:10:11 -0500 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:34547) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j48G1-0001x4-6r for qemu-devel@nongnu.org; Tue, 18 Feb 2020 14:10:09 -0500 Received: by mail-pf1-x442.google.com with SMTP id i6so11138768pfc.1 for ; Tue, 18 Feb 2020 11:10:09 -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 :mime-version:content-transfer-encoding; bh=5k7tlvEB9/rsMbuI3aToULa8WUIjX1E0iDo+FSiobiY=; b=GXQTHFae6PA4ZmF7WMXLg+OhuuEv40//FDA0oPWididXI2Twdh/xJ3wlzSIMF8yvI0 X/A6rXSCnI7RFv8KXc9MIF+qnqU5CSTJw8IsHqvl+ahBd3yP77C3Kaq8Fag26oAAyZ8P 9EqTaLH8ExANR8bEartWhJeVxWdwFqr9gv0cwncFCQ9elT+N/smaXJ9YiaEKWVFCyoob Uij33shXnhWd40f/vn5TBZKTzAXvbvxoqM7cU4eslexAv+6m5VncCNsEAu+qoocWq2US UT5bfoSJbBp+SAGmSRf0n8Cm+iYL8JNWox47kqCls+CW0rbcwOgn5XjWbch6hln15Zs7 GLnQ== 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:mime-version:content-transfer-encoding; bh=5k7tlvEB9/rsMbuI3aToULa8WUIjX1E0iDo+FSiobiY=; b=kWpyjsyG7Vjcs72NKOdVJ4bFsujLVjgam3qzDo10aoLY2yGNHSOUYvcVmsROD/Orhr 2VOmgOjyT0HxsW2mqHE1V6LSAR6UyLnPsPhET/W0bCFOCLVStjPpOJ/W7bNGY9ptX5mr os2BNO2HNpzUVz67OVkeoW7hy4QTYbw+bIivV5nT+68ZjEb76QrQjZ8eeeuwYu6UBacj Dph2e38ynCkLXKiqVtQu7CjBfOq9xwrw9drigrzkNTU+HasPNxxV/Mb/R81kuVw93GD7 cVntvUYfAL/O9/cGe5+bq1NV49Z3SnkztLTzI4SS9bHD4PjR3nyeuINcTAgBqcwRs4c4 A4Lw== X-Gm-Message-State: APjAAAVZUi95qakKBAxIGDXep7uc4bavi9mIdCLZI9KOkbgT0Q90lpya yt6erGuxqGnInkE/LqmlfeoJb2yqfXk= X-Received: by 2002:a63:5345:: with SMTP id t5mr23936562pgl.254.1582053007849; Tue, 18 Feb 2020 11:10:07 -0800 (PST) Received: from localhost.localdomain (97-126-123-70.tukw.qwest.net. [97.126.123.70]) by smtp.gmail.com with ESMTPSA id i68sm5139399pfe.173.2020.02.18.11.10.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Feb 2020 11:10:07 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 5/7] target/arm: Honor the HCR_EL2.TPCP bit Date: Tue, 18 Feb 2020 11:09:56 -0800 Message-Id: <20200218190958.745-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200218190958.745-1-richard.henderson@linaro.org> References: <20200218190958.745-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::442 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, qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This bit traps EL1 access to cache maintenance insns that operate to the point of coherency or persistence. Signed-off-by: Richard Henderson --- target/arm/helper.c | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) -- 2.20.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index 52b6e68659..ed34d4200f 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -4314,6 +4314,28 @@ static CPAccessResult aa64_cacheop_access(CPUARMState *env, return CP_ACCESS_OK; } +static CPAccessResult aa64_cacheop_poc_access(CPUARMState *env, + const ARMCPRegInfo *ri, + bool isread) +{ + /* Cache invalidate/clean to Point of Coherency or Persistence... */ + switch (arm_current_el(env)) { + case 0: + /* ... EL0 must UNDEF unless SCTLR_EL1.UCI is set. */ + if (!(arm_sctlr(env, 0) & SCTLR_UCI)) { + return CP_ACCESS_TRAP; + } + break; + case 1: + /* ... EL1 must trap to EL2 if HCR_EL2.TPCP is set. */ + if (arm_hcr_el2_eff(env) & HCR_TPCP) { + return CP_ACCESS_TRAP_EL2; + } + break; + } + return CP_ACCESS_OK; +} + /* See: D4.7.2 TLB maintenance requirements and the TLB maintenance instructions * Page D4-1736 (DDI0487A.b) */ @@ -4721,14 +4743,15 @@ static const ARMCPRegInfo v8_cp_reginfo[] = { .accessfn = aa64_cacheop_access }, { .name = "DC_IVAC", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 6, .opc2 = 1, - .access = PL1_W, .type = ARM_CP_NOP }, + .access = PL1_W, .accessfn = aa64_cacheop_poc_access, + .type = ARM_CP_NOP }, { .name = "DC_ISW", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 6, .opc2 = 2, .access = PL1_W, .accessfn = access_tsw, .type = ARM_CP_NOP }, { .name = "DC_CVAC", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 10, .opc2 = 1, .access = PL0_W, .type = ARM_CP_NOP, - .accessfn = aa64_cacheop_access }, + .accessfn = aa64_cacheop_poc_access }, { .name = "DC_CSW", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 10, .opc2 = 2, .access = PL1_W, .accessfn = access_tsw, .type = ARM_CP_NOP }, @@ -4739,7 +4762,7 @@ static const ARMCPRegInfo v8_cp_reginfo[] = { { .name = "DC_CIVAC", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 14, .opc2 = 1, .access = PL0_W, .type = ARM_CP_NOP, - .accessfn = aa64_cacheop_access }, + .accessfn = aa64_cacheop_poc_access }, { .name = "DC_CISW", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 14, .opc2 = 2, .access = PL1_W, .accessfn = access_tsw, .type = ARM_CP_NOP }, @@ -4921,17 +4944,17 @@ static const ARMCPRegInfo v8_cp_reginfo[] = { { .name = "BPIMVA", .cp = 15, .opc1 = 0, .crn = 7, .crm = 5, .opc2 = 7, .type = ARM_CP_NOP, .access = PL1_W }, { .name = "DCIMVAC", .cp = 15, .opc1 = 0, .crn = 7, .crm = 6, .opc2 = 1, - .type = ARM_CP_NOP, .access = PL1_W }, + .type = ARM_CP_NOP, .access = PL1_W, .accessfn = aa64_cacheop_poc_access }, { .name = "DCISW", .cp = 15, .opc1 = 0, .crn = 7, .crm = 6, .opc2 = 2, .type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tsw }, { .name = "DCCMVAC", .cp = 15, .opc1 = 0, .crn = 7, .crm = 10, .opc2 = 1, - .type = ARM_CP_NOP, .access = PL1_W }, + .type = ARM_CP_NOP, .access = PL1_W, .accessfn = aa64_cacheop_poc_access }, { .name = "DCCSW", .cp = 15, .opc1 = 0, .crn = 7, .crm = 10, .opc2 = 2, .type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tsw }, { .name = "DCCMVAU", .cp = 15, .opc1 = 0, .crn = 7, .crm = 11, .opc2 = 1, .type = ARM_CP_NOP, .access = PL1_W }, { .name = "DCCIMVAC", .cp = 15, .opc1 = 0, .crn = 7, .crm = 14, .opc2 = 1, - .type = ARM_CP_NOP, .access = PL1_W }, + .type = ARM_CP_NOP, .access = PL1_W, .accessfn = aa64_cacheop_poc_access }, { .name = "DCCISW", .cp = 15, .opc1 = 0, .crn = 7, .crm = 14, .opc2 = 2, .type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tsw }, /* MMU Domain access control / MPU write buffer control */ @@ -6715,7 +6738,7 @@ static const ARMCPRegInfo dcpop_reg[] = { { .name = "DC_CVAP", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 12, .opc2 = 1, .access = PL0_W, .type = ARM_CP_NO_RAW | ARM_CP_SUPPRESS_TB_END, - .accessfn = aa64_cacheop_access, .writefn = dccvap_writefn }, + .accessfn = aa64_cacheop_poc_access, .writefn = dccvap_writefn }, REGINFO_SENTINEL }; @@ -6723,7 +6746,7 @@ static const ARMCPRegInfo dcpodp_reg[] = { { .name = "DC_CVADP", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 13, .opc2 = 1, .access = PL0_W, .type = ARM_CP_NO_RAW | ARM_CP_SUPPRESS_TB_END, - .accessfn = aa64_cacheop_access, .writefn = dccvap_writefn }, + .accessfn = aa64_cacheop_poc_access, .writefn = dccvap_writefn }, REGINFO_SENTINEL }; #endif /*CONFIG_USER_ONLY*/ From patchwork Tue Feb 18 19:09:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 183606 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp6463075ile; Tue, 18 Feb 2020 11:14:40 -0800 (PST) X-Google-Smtp-Source: APXvYqz1nVnoxwlrZ4VGJ6FsDTyUP0PAHitwrMZEyUPuhTqRwi2xj1dbpV9bZ2WMZ0rMRlVLv9SR X-Received: by 2002:ac8:65d3:: with SMTP id t19mr18988128qto.369.1582053280020; Tue, 18 Feb 2020 11:14:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582053280; cv=none; d=google.com; s=arc-20160816; b=x3wqtdbFbMNp1F9H1lAPsZKBQvBDI//yN58Q8w1D6GY7N7kVggpT5jqUm6VyApZAwo /A54Ksvk/3qrq3Ci0pDnWGtAJXepl8aWmL3DyJlEZoz2+saRIvRMoK+jTiTwPdexciqP fv9p0FTRWEVLLHD63TuUSNnPLwohYeFTnJosjclxkjF6uKiZLow9oPRkNzQ/bBbOWmKS DNRoLriNqLVGw4sTsihfvLQFGQhiIC28twyjMp64+frGUrF6ds3CaVQkG5VMtJ7nOQgF qFdUCmWNziHXG184f7CA8zPicp4L3gAhI0jGng8mlKmeelT5WUbJIcfqv5p4a31dW20p L4Yg== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=d8VQKU6rv4Pu6l3hpA5VgoL0EnHokMCgM3rMhYXv+l4=; b=HE56W3Kp82I10QFL9kOE/daZjGANCyXAWm2i8ATQJZwDkNrmLF+CJsE7ydrB6uDYoi zsn9/VLVTXfkR7Z412jtnMJSQwUMdiTxDhids55AhfuViQo7g8+jc1hX0QOJqqROlEQc NZ+CirxqOUGTyuAum9NQqtcucd6w5CJ5D+i7k3MAsWf3LYbMOCJ9qXL4mlIFyAWbdaeE lQs2fYe55LyrCTaklcZKy3IbPdvae5HpanJbimsoC2Ap4qoiwm+adQrUBCZ0IeK9cgxM 0ZbDL3+SstWo3AVqR3thMHgevlYh4MbZYaC3CK5Yu03xoAX9g9iLGr3cHagEcpLK5ill BIsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iSdVw9rz; 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=pass (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 c8si2200056qtg.53.2020.02.18.11.14.39 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 18 Feb 2020 11:14:40 -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=pass header.i=@linaro.org header.s=google header.b=iSdVw9rz; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:40576 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j48KN-0003gG-HW for patch@linaro.org; Tue, 18 Feb 2020 14:14:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47205) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j48G5-00057t-HT for qemu-devel@nongnu.org; Tue, 18 Feb 2020 14:10:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j48G3-00026i-SG for qemu-devel@nongnu.org; Tue, 18 Feb 2020 14:10:13 -0500 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:37019) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j48G3-00020O-Gp for qemu-devel@nongnu.org; Tue, 18 Feb 2020 14:10:11 -0500 Received: by mail-pg1-x543.google.com with SMTP id z12so11424350pgl.4 for ; Tue, 18 Feb 2020 11:10: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 :mime-version:content-transfer-encoding; bh=d8VQKU6rv4Pu6l3hpA5VgoL0EnHokMCgM3rMhYXv+l4=; b=iSdVw9rzE92iebe/A9OrratQX/Vu8tbEoCAedhD6vLfuzXejm1whRjBMyWODOhtgs2 xD/UJpV4xLSNmGYHHdQxr3WpNxoT10JUjgLHLcDGk8u+REBMn9f3cMF9Sh3dDLOsfGEY 38/5i24t8saybaahzI27wnpv3CmwguwslFjSdeXV4b5MLQ8CzlvPciLvb4UcSE0mZFaY IsbZwU2wXMOgeCjCGK2guLsUSYCnYIQLLkOTDILSvcaWKYNmhUGKWUM2wAbOeVEerya8 NGaWW8nDC6FRm0P0JubQiYifvj/0Nhzc+JZweDRftopftU3fXYUei3PCZwcpo15axo6n hG4A== 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:mime-version:content-transfer-encoding; bh=d8VQKU6rv4Pu6l3hpA5VgoL0EnHokMCgM3rMhYXv+l4=; b=XBrsBqEBeydIGZKpYDeYiQJGeE/2GrsYTsHR38nqcsHtioiKo9jpwFzU9O9HB9ygtO KYoOHtCzqUGQGAVMRplT4J0U8EkLoOhtc3O9rVeuzOwNcveRw+7rCh0oHlSYUWTNwgPy /5BVDLCD6/Bzrh018QI55PvvjmLSaylAIY5ShJqHACH1JflJBAbNscG91wNQlYF7Dxjo Ws8hzSXUksqQb6EtpmJfHw3ke2Za3t2YZIhbLDEUGAThOHsyyuf/HV6g3JN7zOPaK4RI lAlZyZjpt5WRukJF3ElEOhNALnwsAR+3N+jWk9enEeUoxCyvXVBJ/eRex1c0/bXBnRGd dAJg== X-Gm-Message-State: APjAAAW5RwYXOceCbKUTH8OupCpuk6En3O6Dug3lqjFjR1ZT7ybYICfD TZrOVuSk4E4Rj+up7FwzONpZ1t5L0/M= X-Received: by 2002:a62:7681:: with SMTP id r123mr22675100pfc.169.1582053009053; Tue, 18 Feb 2020 11:10:09 -0800 (PST) Received: from localhost.localdomain (97-126-123-70.tukw.qwest.net. [97.126.123.70]) by smtp.gmail.com with ESMTPSA id i68sm5139399pfe.173.2020.02.18.11.10.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Feb 2020 11:10:08 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 6/7] target/arm: Honor the HCR_EL2.TPU bit Date: Tue, 18 Feb 2020 11:09:57 -0800 Message-Id: <20200218190958.745-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200218190958.745-1-richard.henderson@linaro.org> References: <20200218190958.745-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::543 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, qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This bit traps EL1 access to cache maintenance insns that operate to the point of unification. There are no longer any references to plain aa64_cacheop_access, so remove it. Signed-off-by: Richard Henderson --- target/arm/helper.c | 53 +++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 21 deletions(-) -- 2.20.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index ed34d4200f..21ee9cf7de 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -4301,19 +4301,6 @@ static const ARMCPRegInfo uao_reginfo = { .readfn = aa64_uao_read, .writefn = aa64_uao_write }; -static CPAccessResult aa64_cacheop_access(CPUARMState *env, - const ARMCPRegInfo *ri, - bool isread) -{ - /* Cache invalidate/clean: NOP, but EL0 must UNDEF unless - * SCTLR_EL1.UCI is set. - */ - if (arm_current_el(env) == 0 && !(arm_sctlr(env, 0) & SCTLR_UCI)) { - return CP_ACCESS_TRAP; - } - return CP_ACCESS_OK; -} - static CPAccessResult aa64_cacheop_poc_access(CPUARMState *env, const ARMCPRegInfo *ri, bool isread) @@ -4336,6 +4323,28 @@ static CPAccessResult aa64_cacheop_poc_access(CPUARMState *env, return CP_ACCESS_OK; } +static CPAccessResult aa64_cacheop_pou_access(CPUARMState *env, + const ARMCPRegInfo *ri, + bool isread) +{ + /* Cache invalidate/clean to Point of Unification... */ + switch (arm_current_el(env)) { + case 0: + /* ... EL0 must UNDEF unless SCTLR_EL1.UCI is set. */ + if (!(arm_sctlr(env, 0) & SCTLR_UCI)) { + return CP_ACCESS_TRAP; + } + break; + case 1: + /* ... EL1 must trap to EL2 if HCR_EL2.TPU is set. */ + if (arm_hcr_el2_eff(env) & HCR_TPU) { + return CP_ACCESS_TRAP_EL2; + } + break; + } + return CP_ACCESS_OK; +} + /* See: D4.7.2 TLB maintenance requirements and the TLB maintenance instructions * Page D4-1736 (DDI0487A.b) */ @@ -4733,14 +4742,16 @@ static const ARMCPRegInfo v8_cp_reginfo[] = { /* Cache ops: all NOPs since we don't emulate caches */ { .name = "IC_IALLUIS", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 1, .opc2 = 0, - .access = PL1_W, .type = ARM_CP_NOP }, + .access = PL1_W, .type = ARM_CP_NOP, + .accessfn = aa64_cacheop_pou_access }, { .name = "IC_IALLU", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 5, .opc2 = 0, - .access = PL1_W, .type = ARM_CP_NOP }, + .access = PL1_W, .type = ARM_CP_NOP, + .accessfn = aa64_cacheop_pou_access }, { .name = "IC_IVAU", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 5, .opc2 = 1, .access = PL0_W, .type = ARM_CP_NOP, - .accessfn = aa64_cacheop_access }, + .accessfn = aa64_cacheop_pou_access }, { .name = "DC_IVAC", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 6, .opc2 = 1, .access = PL1_W, .accessfn = aa64_cacheop_poc_access, @@ -4758,7 +4769,7 @@ static const ARMCPRegInfo v8_cp_reginfo[] = { { .name = "DC_CVAU", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 11, .opc2 = 1, .access = PL0_W, .type = ARM_CP_NOP, - .accessfn = aa64_cacheop_access }, + .accessfn = aa64_cacheop_pou_access }, { .name = "DC_CIVAC", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 14, .opc2 = 1, .access = PL0_W, .type = ARM_CP_NOP, @@ -4932,13 +4943,13 @@ static const ARMCPRegInfo v8_cp_reginfo[] = { .writefn = tlbiipas2_is_write }, /* 32 bit cache operations */ { .name = "ICIALLUIS", .cp = 15, .opc1 = 0, .crn = 7, .crm = 1, .opc2 = 0, - .type = ARM_CP_NOP, .access = PL1_W }, + .type = ARM_CP_NOP, .access = PL1_W, .accessfn = aa64_cacheop_pou_access }, { .name = "BPIALLUIS", .cp = 15, .opc1 = 0, .crn = 7, .crm = 1, .opc2 = 6, .type = ARM_CP_NOP, .access = PL1_W }, { .name = "ICIALLU", .cp = 15, .opc1 = 0, .crn = 7, .crm = 5, .opc2 = 0, - .type = ARM_CP_NOP, .access = PL1_W }, + .type = ARM_CP_NOP, .access = PL1_W, .accessfn = aa64_cacheop_pou_access }, { .name = "ICIMVAU", .cp = 15, .opc1 = 0, .crn = 7, .crm = 5, .opc2 = 1, - .type = ARM_CP_NOP, .access = PL1_W }, + .type = ARM_CP_NOP, .access = PL1_W, .accessfn = aa64_cacheop_pou_access }, { .name = "BPIALL", .cp = 15, .opc1 = 0, .crn = 7, .crm = 5, .opc2 = 6, .type = ARM_CP_NOP, .access = PL1_W }, { .name = "BPIMVA", .cp = 15, .opc1 = 0, .crn = 7, .crm = 5, .opc2 = 7, @@ -4952,7 +4963,7 @@ static const ARMCPRegInfo v8_cp_reginfo[] = { { .name = "DCCSW", .cp = 15, .opc1 = 0, .crn = 7, .crm = 10, .opc2 = 2, .type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tsw }, { .name = "DCCMVAU", .cp = 15, .opc1 = 0, .crn = 7, .crm = 11, .opc2 = 1, - .type = ARM_CP_NOP, .access = PL1_W }, + .type = ARM_CP_NOP, .access = PL1_W, .accessfn = aa64_cacheop_pou_access }, { .name = "DCCIMVAC", .cp = 15, .opc1 = 0, .crn = 7, .crm = 14, .opc2 = 1, .type = ARM_CP_NOP, .access = PL1_W, .accessfn = aa64_cacheop_poc_access }, { .name = "DCCISW", .cp = 15, .opc1 = 0, .crn = 7, .crm = 14, .opc2 = 2, From patchwork Tue Feb 18 19:09:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 183603 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp6460133ile; Tue, 18 Feb 2020 11:11:38 -0800 (PST) X-Google-Smtp-Source: APXvYqyMA5G2MXqWpsdjWmuksT4FUIEUh61DJXLM/px71mYXEaL4h88Ez50PAkEvlueMF8NWUJN7 X-Received: by 2002:ad4:46af:: with SMTP id br15mr18049556qvb.216.1582053097950; Tue, 18 Feb 2020 11:11:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582053097; cv=none; d=google.com; s=arc-20160816; b=Ugwpv0U8tVqVO2XQSv9wuRnG88mP+qskVOlYmqMSXi+mrk6g8zpvgW5JEWbgMP46vd gAB4Ig8RrD7NqotjH4SUig0hTVhG4TqkLe3jCYav3577FcQQia6SldxL2r3NAgoFG6ca RvC7sPFMOb8L8fimq3oGFvFqT1ui5GR6JhFLkMvWEZKAc76rzyyEtw09dRhEqcA5h20c o9FysIOpl7FVD/4Q/nYzKf18at6m3a+TkC1vz17HIIreZZR4DPtWvfAWm0l+IuMGVNmY pRBymnIYC0R+DR9OQBceTifgbRh+z3vPV5EXoT3kNGlnVwKOdQgFIdalQQkUtKWdS1LC FQtA== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=nhoZN+6W0yWgtc6EACu9ulVuQ0nYIKeOYAuOPcONJJc=; b=RXbUAOnr6ucBnGYa0UzIGs+qUwJK3vTZwL9hw5QtsZBiFWAv9yaGf2rgKp5gP1znl6 zLGj4+mxp/tNSfpDX2BcdaRoT/5hn+3bILIxKwpnifZAg/ssklMe540eGQSGGlNacSKh mgVNvejUTCTkQQpzis3x6rGydv6N92+8JAeefdO6UMO04GljWCFlDid5CfeLRZBK0C+C 9OErRiVRIRujIPNvBsbi7PE+yR79vTGRM1A9pZQV76q6mIXVVab6JppdPWkz73AJD9Dz 6o0qx6Iey0h7iRGt0H/W7e/FAKcI+aMQ8UQUKyGeDtSMDNgNf8X25smf7SkaCFQZ8hm8 X7Uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S8bGvkee; 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=pass (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 w17si2290283qkj.162.2020.02.18.11.11.37 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 18 Feb 2020 11:11:37 -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=pass header.i=@linaro.org header.s=google header.b=S8bGvkee; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:40480 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j48HR-0006OK-DI for patch@linaro.org; Tue, 18 Feb 2020 14:11:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47308) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j48G7-0005Ar-ET for qemu-devel@nongnu.org; Tue, 18 Feb 2020 14:10:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j48G4-000287-9p for qemu-devel@nongnu.org; Tue, 18 Feb 2020 14:10:15 -0500 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:44056) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j48G3-00024J-W3 for qemu-devel@nongnu.org; Tue, 18 Feb 2020 14:10:12 -0500 Received: by mail-pf1-x442.google.com with SMTP id y5so11112415pfb.11 for ; Tue, 18 Feb 2020 11:10:11 -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 :mime-version:content-transfer-encoding; bh=nhoZN+6W0yWgtc6EACu9ulVuQ0nYIKeOYAuOPcONJJc=; b=S8bGvkeeSkkxZdAk501M7LROquguS4xuyhQqnKvP620ZaHKJ5ObgnzeERm0BJl0G34 fkiRo0sWMS0mMo7E91pZju/H99ZlJOS5CCFshJb82nqt/pPrYidygBymakS09nLfl7R8 GspJBPU6YvmgXdy+0YZYPQXYWvxPH58JhXU/4EtgBomwHrDCWsU3Eq9sR2sj+OWJfi5A QcKAsPfab5U0xVB3yCCqlcBVLOJ2+Js8wV6HSiIYG9gEFq2/CETcBiSk3rf2+ji54b/P FRGBUOsj+rnraHV6P5a/Snw5r8+g3rlsfzqy+8RB0Pf+5Ba/yFi6b8X2x4XSzx1Yr8hj kxyA== 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:mime-version:content-transfer-encoding; bh=nhoZN+6W0yWgtc6EACu9ulVuQ0nYIKeOYAuOPcONJJc=; b=ZiqnAbNyzjs6bCkV+QBVUQtHXfH6zf8y7yPdHiaEXzeKHcZF995n0mFCq8Nr+wOCkK RPpuskfrZDXT4Swpr+54WtNqhrL4lvngmtAj7YcqxCQoZYuf9xVE/u1A7jnzpmFRq9/8 w8sZwTK5KbwtSPD9nTUp3R1cVZ7JNVSvVdy5f6sK+Db6UcIZycoztSyJrpdRS+FZhtCM 6N38Br4XckiDnAR4oxic7FBU5AbSrv+LqjJ36yEGjzsr1eYn4o6/5HNARziVWhtZa5DO SonKwtoLYzy8rK8zP6hh9PrAwFnBLjSBWkSkbXbcqiKxTnsDEcOXAd9j2fATUxqDaJl6 rQ4g== X-Gm-Message-State: APjAAAU9tvu1c8aP1jegz+ASPvRrUQakkBxJLxIeCf8nZjuWCDDMEPdz yHpbVlCoz2IPOUkgGPUNKjl/h5VWjF0= X-Received: by 2002:a63:34e:: with SMTP id 75mr25160468pgd.286.1582053010300; Tue, 18 Feb 2020 11:10:10 -0800 (PST) Received: from localhost.localdomain (97-126-123-70.tukw.qwest.net. [97.126.123.70]) by smtp.gmail.com with ESMTPSA id i68sm5139399pfe.173.2020.02.18.11.10.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Feb 2020 11:10:09 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 7/7] target/arm: Honor the HCR_EL2.TTLB bit Date: Tue, 18 Feb 2020 11:09:58 -0800 Message-Id: <20200218190958.745-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200218190958.745-1-richard.henderson@linaro.org> References: <20200218190958.745-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::442 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, qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This bit traps EL1 access to tlb maintenance insns. Signed-off-by: Richard Henderson --- target/arm/helper.c | 85 +++++++++++++++++++++++++++++---------------- 1 file changed, 55 insertions(+), 30 deletions(-) -- 2.20.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index 21ee9cf7de..87c0cf4a96 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -563,6 +563,16 @@ static CPAccessResult access_tacr(CPUARMState *env, const ARMCPRegInfo *ri, return CP_ACCESS_OK; } +/* Check for traps from EL1 due to HCR_EL2.TTLB. */ +static CPAccessResult access_ttlb(CPUARMState *env, const ARMCPRegInfo *ri, + bool isread) +{ + if (arm_current_el(env) == 1 && (arm_hcr_el2_eff(env) & HCR_TTLB)) { + return CP_ACCESS_TRAP_EL2; + } + return CP_ACCESS_OK; +} + static void dacr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { ARMCPU *cpu = env_archcpu(env); @@ -2287,41 +2297,53 @@ static const ARMCPRegInfo v7_cp_reginfo[] = { .type = ARM_CP_NO_RAW, .access = PL1_R, .readfn = isr_read }, /* 32 bit ITLB invalidates */ { .name = "ITLBIALL", .cp = 15, .opc1 = 0, .crn = 8, .crm = 5, .opc2 = 0, - .type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbiall_write }, + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, + .writefn = tlbiall_write }, { .name = "ITLBIMVA", .cp = 15, .opc1 = 0, .crn = 8, .crm = 5, .opc2 = 1, - .type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbimva_write }, + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, + .writefn = tlbimva_write }, { .name = "ITLBIASID", .cp = 15, .opc1 = 0, .crn = 8, .crm = 5, .opc2 = 2, - .type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbiasid_write }, + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, + .writefn = tlbiasid_write }, /* 32 bit DTLB invalidates */ { .name = "DTLBIALL", .cp = 15, .opc1 = 0, .crn = 8, .crm = 6, .opc2 = 0, - .type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbiall_write }, + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, + .writefn = tlbiall_write }, { .name = "DTLBIMVA", .cp = 15, .opc1 = 0, .crn = 8, .crm = 6, .opc2 = 1, - .type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbimva_write }, + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, + .writefn = tlbimva_write }, { .name = "DTLBIASID", .cp = 15, .opc1 = 0, .crn = 8, .crm = 6, .opc2 = 2, - .type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbiasid_write }, + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, + .writefn = tlbiasid_write }, /* 32 bit TLB invalidates */ { .name = "TLBIALL", .cp = 15, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 0, - .type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbiall_write }, + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, + .writefn = tlbiall_write }, { .name = "TLBIMVA", .cp = 15, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 1, - .type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbimva_write }, + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, + .writefn = tlbimva_write }, { .name = "TLBIASID", .cp = 15, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 2, - .type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbiasid_write }, + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, + .writefn = tlbiasid_write }, { .name = "TLBIMVAA", .cp = 15, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 3, - .type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbimvaa_write }, + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, + .writefn = tlbimvaa_write }, REGINFO_SENTINEL }; static const ARMCPRegInfo v7mp_cp_reginfo[] = { /* 32 bit TLB invalidates, Inner Shareable */ { .name = "TLBIALLIS", .cp = 15, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 0, - .type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbiall_is_write }, + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, + .writefn = tlbiall_is_write }, { .name = "TLBIMVAIS", .cp = 15, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 1, - .type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbimva_is_write }, + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, + .writefn = tlbimva_is_write }, { .name = "TLBIASIDIS", .cp = 15, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 2, - .type = ARM_CP_NO_RAW, .access = PL1_W, + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, .writefn = tlbiasid_is_write }, { .name = "TLBIMVAAIS", .cp = 15, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 3, - .type = ARM_CP_NO_RAW, .access = PL1_W, + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, .writefn = tlbimvaa_is_write }, REGINFO_SENTINEL }; @@ -4780,51 +4802,51 @@ static const ARMCPRegInfo v8_cp_reginfo[] = { /* TLBI operations */ { .name = "TLBI_VMALLE1IS", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 0, - .access = PL1_W, .type = ARM_CP_NO_RAW, + .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, .writefn = tlbi_aa64_vmalle1is_write }, { .name = "TLBI_VAE1IS", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 1, - .access = PL1_W, .type = ARM_CP_NO_RAW, + .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, .writefn = tlbi_aa64_vae1is_write }, { .name = "TLBI_ASIDE1IS", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 2, - .access = PL1_W, .type = ARM_CP_NO_RAW, + .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, .writefn = tlbi_aa64_vmalle1is_write }, { .name = "TLBI_VAAE1IS", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 3, - .access = PL1_W, .type = ARM_CP_NO_RAW, + .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, .writefn = tlbi_aa64_vae1is_write }, { .name = "TLBI_VALE1IS", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 5, - .access = PL1_W, .type = ARM_CP_NO_RAW, + .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, .writefn = tlbi_aa64_vae1is_write }, { .name = "TLBI_VAALE1IS", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 7, - .access = PL1_W, .type = ARM_CP_NO_RAW, + .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, .writefn = tlbi_aa64_vae1is_write }, { .name = "TLBI_VMALLE1", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 0, - .access = PL1_W, .type = ARM_CP_NO_RAW, + .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, .writefn = tlbi_aa64_vmalle1_write }, { .name = "TLBI_VAE1", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 1, - .access = PL1_W, .type = ARM_CP_NO_RAW, + .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, .writefn = tlbi_aa64_vae1_write }, { .name = "TLBI_ASIDE1", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 2, - .access = PL1_W, .type = ARM_CP_NO_RAW, + .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, .writefn = tlbi_aa64_vmalle1_write }, { .name = "TLBI_VAAE1", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 3, - .access = PL1_W, .type = ARM_CP_NO_RAW, + .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, .writefn = tlbi_aa64_vae1_write }, { .name = "TLBI_VALE1", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 5, - .access = PL1_W, .type = ARM_CP_NO_RAW, + .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, .writefn = tlbi_aa64_vae1_write }, { .name = "TLBI_VAALE1", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 7, - .access = PL1_W, .type = ARM_CP_NO_RAW, + .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, .writefn = tlbi_aa64_vae1_write }, { .name = "TLBI_IPAS2E1IS", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 0, .opc2 = 1, @@ -4910,14 +4932,17 @@ static const ARMCPRegInfo v8_cp_reginfo[] = { #endif /* TLB invalidate last level of translation table walk */ { .name = "TLBIMVALIS", .cp = 15, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 5, - .type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbimva_is_write }, + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, + .writefn = tlbimva_is_write }, { .name = "TLBIMVAALIS", .cp = 15, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 7, - .type = ARM_CP_NO_RAW, .access = PL1_W, + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, .writefn = tlbimvaa_is_write }, { .name = "TLBIMVAL", .cp = 15, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 5, - .type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbimva_write }, + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, + .writefn = tlbimva_write }, { .name = "TLBIMVAAL", .cp = 15, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 7, - .type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbimvaa_write }, + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, + .writefn = tlbimvaa_write }, { .name = "TLBIMVALH", .cp = 15, .opc1 = 4, .crn = 8, .crm = 7, .opc2 = 5, .type = ARM_CP_NO_RAW, .access = PL2_W, .writefn = tlbimva_hyp_write },