From patchwork Tue Feb 25 18:08:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 183877 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp2058579ile; Tue, 25 Feb 2020 10:10:19 -0800 (PST) X-Google-Smtp-Source: APXvYqwp7b/bWCeHeYXVPnycbFFoDCClJ13kWU3zReafY4BOkrvMGnyuPEX0X22pncLk6pduS8f2 X-Received: by 2002:a05:620a:13b8:: with SMTP id m24mr54910qki.378.1582654219231; Tue, 25 Feb 2020 10:10:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582654219; cv=none; d=google.com; s=arc-20160816; b=Do6r06NuvNgemPNRQfA6fUfBa/wOPz9HfhlzvJaUagAlD0J5xXzJIc/QvgbhYR74sr NRmISjuTOmRrgZB4/dhaZkhiBWpc173SgQkC9rYKDzWHxjX8BRHg4neUMyngZ4zDlriP F9gX571P0QictHnLr6/Wg8CMACZHro/3Yrd7KJeZ7Sgo0HO1uZUpb+eW9Pwye/KVpdjr 6Np+/1dPi3XlyW+4MFunhHK0NdhbHXYYSQbXAjpC/TlVJqx83K2gEei6zCfSZwPxN39g zqv/dRroFIii7MhUq53r4HKAMTTabnJOdZzxuNlwvFJ+3QnnYT2X0gEvHDJa8pr3Nzx8 O5/g== 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=DwAs9/rYNqhhr3pFyNf/EdZW6lZM71lcIqrzETrYP1w=; b=bEaVfxcbKIlaoCWB3dpyjmYIObDt/PctiM5d40Z4f1mi2Uttcw2c/06KA+MQJ4Kdpu i7uWX1qylfla462Fw/pPrpo90WvWrW7bch/15bjqg4GXc+v0KqqfyKQHiXwXpSot2C0o zR7u2idJ2RV6WeySWPaaAU/rLyiyDbx3bgocIRLnMT3gdtnlOX/wWPaE9kZnO+llZ92F gvB6c+KbFkcjIwidxn9ta2XjbpdwHBzOxMS7tDz/4myic9UNGVI7uiF8N6BjbLByR/7O JsBmSne+JBQS73r7htWYRt+FvtF59Ibjpxr+9ptDHeoYS0TgGE8jLbat58fTpKTKdtl1 G1Bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sv0jYyvu; 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 n12si7137873qvl.43.2020.02.25.10.10.19 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Feb 2020 10:10:19 -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=sv0jYyvu; 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]:33398 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6eew-0005B9-O4 for patch@linaro.org; Tue, 25 Feb 2020 13:10:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34857) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6edL-0002C9-21 for qemu-devel@nongnu.org; Tue, 25 Feb 2020 13:08:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j6edI-0004F9-Nf for qemu-devel@nongnu.org; Tue, 25 Feb 2020 13:08:38 -0500 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:42031) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j6edI-0004DH-DJ for qemu-devel@nongnu.org; Tue, 25 Feb 2020 13:08:36 -0500 Received: by mail-pf1-x444.google.com with SMTP id 4so7593847pfz.9 for ; Tue, 25 Feb 2020 10:08:36 -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=DwAs9/rYNqhhr3pFyNf/EdZW6lZM71lcIqrzETrYP1w=; b=sv0jYyvuypkYelj8nyHQnFZhbmkV0C3Y51Hp+84NBywENmG9FOJqZpyxMBvmY6JObX 3xMPn1LO2kVhRZDU/8woSGQwOAN7vLjYedwybPuEjYMCZwOmFlAS3Z6Gror50uZdqIZC BQg3VrcA0y8/vkepUeeRPPL8XHVTzV7XqEYLiWbxW9hS89xigBv/hzSVPkbrfrd8nDC0 VEFB9NaI9fU9d0KsemigWMyV6lacmFg8Io86QvuuBYLwY30uOwRfXHljp/H4Fci69kSy MiqvWypLm8jDCnzu5ItM7ry3ZX6Kg/FbvCU6kzgKtU0hgle2ELdTI3oL5113Gdc0SGt+ 3Grw== 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=DwAs9/rYNqhhr3pFyNf/EdZW6lZM71lcIqrzETrYP1w=; b=GlGYvIt8agfc63OPAl+sEHNVLtUZ8U2JfZlzFDvsYzYoNdoDbiQpLKE2jin/I1alIv l6UWKtYFW7A0fq1oDw0Gs8+mgXYgBxu6bInvvUxKcIshEHwmUP8hnxZIJM8JP1sx102u U8SbP/hCfqjwpCEOB6eWjw7JGX0FK37LWYVKrgux0sxjWGD5fNtYnxPwEvx/TmAIXcvv wkvEkMLILhZlblF3lfo/Q9go4M/0LupA94oS/z/+dxylWKRlJ/ot9AIUWlzmd95SyXzN xSeIQaGd4US25mFwFNapelO6w6vaeLqn/x3BcjKc865dLPYM7HdBHFNCqlcFtDh/Ej9A Krgg== X-Gm-Message-State: APjAAAW78s1vvQU0XUmIAiTDhGJ5Ej4+7hn8ysrspiwHpblLt+DzuoqE 5RNFTvmkDm2Qeg9OPmnT7vZWmY9JP8o= X-Received: by 2002:a62:446:: with SMTP id 67mr55553627pfe.109.1582654114693; Tue, 25 Feb 2020 10:08:34 -0800 (PST) Received: from localhost.localdomain (97-126-123-70.tukw.qwest.net. [97.126.123.70]) by smtp.gmail.com with ESMTPSA id d69sm19069704pfd.72.2020.02.25.10.08.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Feb 2020 10:08:34 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 1/7] target/arm: Improve masking of HCR RES0 bits Date: Tue, 25 Feb 2020 10:08:25 -0800 Message-Id: <20200225180831.26078-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200225180831.26078-1-richard.henderson@linaro.org> References: <20200225180831.26078-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::444 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" Don't merely start with v8.0, handle v7VE as well. Notice writes from aarch32 mode, and the bits that ought not be settable from there. Suggested-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/helper.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) -- 2.20.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index 79db169e04..d65160fdb3 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -5089,8 +5089,13 @@ static const ARMCPRegInfo el3_no_el2_v8_cp_reginfo[] = { static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { ARMCPU *cpu = env_archcpu(env); - /* Begin with bits defined in base ARMv8.0. */ - uint64_t valid_mask = MAKE_64BIT_MASK(0, 34); + uint64_t valid_mask; + + if (arm_feature(env, ARM_FEATURE_V8)) { + valid_mask = MAKE_64BIT_MASK(0, 34); /* ARMv8.0 */ + } else { + valid_mask = MAKE_64BIT_MASK(0, 28); /* ARMv7VE */ + } if (arm_feature(env, ARM_FEATURE_EL3)) { valid_mask &= ~HCR_HCD; @@ -5114,6 +5119,14 @@ static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) valid_mask |= HCR_API | HCR_APK; } + if (ri->state == ARM_CP_STATE_AA32) { + /* + * Writes from aarch32 mode have more RES0 bits. + * This includes TDZ, RW, E2H, and more. + */ + valid_mask &= ~0xff80ff8c90000000ull; + } + /* Clear RES0 bits. */ value &= valid_mask; From patchwork Tue Feb 25 18:08:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 183878 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp2060527ile; Tue, 25 Feb 2020 10:12:14 -0800 (PST) X-Google-Smtp-Source: APXvYqxfiGsgy6rTUIJYhMpdTEcpCB/qMsnOpuGmggSzfZrZWlUFq35PPMHoSIIoUVSbtqLH7GXw X-Received: by 2002:a0c:b920:: with SMTP id u32mr75658qvf.173.1582654334692; Tue, 25 Feb 2020 10:12:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582654334; cv=none; d=google.com; s=arc-20160816; b=CmCgPW2MvlhRQ8zhP0d2Goy9D8PSpxmIsRlAKgZjSM2oPUQqCdYbwbB27HgtPjZ5Ph /Q7ajIDHEaSF9b52LU5y3Au5ePK/ci/EhnVVENoHilp2rZ+dxeS8m7lzdhe4S8xIjE/w Hs6DSD1wcIHvAlI431YaqpMEkSe+hjsj5/qrmRy6ZTo2Hfq6wkJVMvuzZLolgGXeodKN pCORiiUM9Ic3xKRKjSFpyLwqzp18hHQwol5Q1hiZGx9bTKq7FJzXv9n1IbdhoIGJ5p+c 5otBHbNnaoySh74UqBQEPBPHy8qhTLCoQ1IGj1W/dKUMy1/udFhZAi1QHH0alJMNpdeU nYHQ== 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=kg83INNsGeNuc+mh9kVOJT9F2Wgw05zli9vuc8tEEAQ=; b=o9rpnSa4rXO8x4psCnE+uxOraLSqbaflJde7kUEte5pAn4AKpLfly8cQzJ/OV6F3lK KTNaV0W5OUlJ4eNHEcYktOQDK2WJskZ1Ngn39mAJ1deuzo6zK5YWVcbL5CJ1hleHgqYh io4i3iGt5fe8t+LRak+IeoYexfv6vko/KISri6Bij6EhoinLX1RII40C9mVGDAUCwg6g Vx/hi39Aa9Mku1YaHTHQ99ZQegSTg6eMSZKAc7vgozAjzKw3FkzF2JQpGEmVz8YcMNi9 KBLJtidTBgptYlZImOsAjkPY4pvTBHgRZGvL6t6rN7k8JigxKDdGD0a2DhhXfGf3jtjW CXmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NhIy4qjK; 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 l90si33632qtd.153.2020.02.25.10.12.14 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Feb 2020 10:12:14 -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=NhIy4qjK; 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]:33446 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6ego-0007E3-74 for patch@linaro.org; Tue, 25 Feb 2020 13:12:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34963) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6edN-0002F1-N2 for qemu-devel@nongnu.org; Tue, 25 Feb 2020 13:08:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j6edL-0004K3-2m for qemu-devel@nongnu.org; Tue, 25 Feb 2020 13:08:41 -0500 Received: from mail-pj1-x1043.google.com ([2607:f8b0:4864:20::1043]:52960) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j6edK-0004Hd-Lt for qemu-devel@nongnu.org; Tue, 25 Feb 2020 13:08:39 -0500 Received: by mail-pj1-x1043.google.com with SMTP id ep11so37552pjb.2 for ; Tue, 25 Feb 2020 10:08:38 -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=kg83INNsGeNuc+mh9kVOJT9F2Wgw05zli9vuc8tEEAQ=; b=NhIy4qjKJdUbcYmtmLx2KEGpCHFJzDAYHp2GCB2xZ1b/k0x/C6eYQzW3JmnCXhrWFo RTnIsw3M1zLFjJe9nqpVCUwnf8eKHdP+oRlOsaaAPvbmPLRSuhNbi+zs8HYEP4h1w4L7 Jt4KXjPhkqpAkruenDfLA2/DPBPvHRtjHu7hQ/yH+0WeW6VrLYUaIngjRb3XWRFfc9RU tb8rbNaX1CO2hKAecXQJG7Orh1FYM+gJ1x+JXo2szKpgo301g7kXkBy8K3wEPMzUQjyT z7u5aIYNNmGi7N6YtNmkDdsN27vF3eUGlcnvZSQ+EuQJ0CWD4ms0j1F2Jvr801lZYgdm 1GlQ== 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=kg83INNsGeNuc+mh9kVOJT9F2Wgw05zli9vuc8tEEAQ=; b=TFaggu4lDRY7Taz+n8TMmI9dvvdbvNah/bjbq5G39UAh9k0J5rQZGL9k7Nzai4Tucx y0DQR35s+60mlI9UfQIKINOQ+jAbh4jypCgqsfUUSPgfJuKUCrqSG+eol7z3ZE6cFfxu JHaiR124PLw4PUjECmjJkbue/B9kg1ZM5blyN2v8ujrKP3VMhHYd7qE9AQVgLfsxtWKx DUE6UlKkrODkowWeCZ+bem1bWthq11pZ9DaUfmT9Muh1+aGC+bQzxV6PTMLJK1s1K6Ao Io6ynkxRy+4XbXBy8cosg16ci8vZ8KBndt/J45djgA1YoBGICkMiAz0x8Vn285pDbFxF /elg== X-Gm-Message-State: APjAAAVGN6tTXpWn++AgD+mV00k9B4cR/2gO9QqiiyS3nI1VmtH9rDbA LsPEEEIAAZlL6Zmeh7daSBVBNjHVM/I= X-Received: by 2002:a17:902:ff08:: with SMTP id f8mr58981693plj.261.1582654116253; Tue, 25 Feb 2020 10:08:36 -0800 (PST) Received: from localhost.localdomain (97-126-123-70.tukw.qwest.net. [97.126.123.70]) by smtp.gmail.com with ESMTPSA id d69sm19069704pfd.72.2020.02.25.10.08.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Feb 2020 10:08:35 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 2/7] target/arm: Honor the HCR_EL2.{TVM,TRVM} bits Date: Tue, 25 Feb 2020 10:08:26 -0800 Message-Id: <20200225180831.26078-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200225180831.26078-1-richard.henderson@linaro.org> References: <20200225180831.26078-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::1043 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. v4: Include not_v8_cp_reginfo, lpae_cp_reginfo, CONTEXTIDR_S; exclude not_v7_cp_reginfo (pmm). --- target/arm/helper.c | 82 ++++++++++++++++++++++++++++++--------------- 1 file changed, 55 insertions(+), 27 deletions(-) -- 2.20.1 Reviewed-by: Peter Maydell diff --git a/target/arm/helper.c b/target/arm/helper.c index d65160fdb3..e45d717cf3 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,12 +798,14 @@ 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, .cp = 15, .opc1 = 0, .crn = 13, .crm = 0, .opc2 = 1, - .access = PL1_RW, .secure = ARM_CP_SECSTATE_S, + .access = PL1_RW, .accessfn = access_tvm_trvm, + .secure = ARM_CP_SECSTATE_S, .fieldoffset = offsetof(CPUARMState, cp15.contextidr_s), .resetvalue = 0, .writefn = contextidr_write, .raw_writefn = raw_write, }, REGINFO_SENTINEL @@ -803,7 +818,7 @@ static const ARMCPRegInfo not_v8_cp_reginfo[] = { /* MMU Domain access control / MPU write buffer control */ { .name = "DACR", .cp = 15, .opc1 = CP_ANY, .crn = 3, .crm = CP_ANY, .opc2 = CP_ANY, - .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) } }, @@ -996,7 +1011,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, }, @@ -2208,16 +2223,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, @@ -2231,12 +2249,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 }, @@ -3886,20 +3906,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 }; @@ -3907,25 +3928,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])} }, @@ -3937,7 +3962,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]) }, }; @@ -4157,23 +4183,25 @@ 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), offsetof(CPUARMState, cp15.par_ns)} }, { .name = "TTBR0", .cp = 15, .crm = 2, .opc1 = 0, - .access = PL1_RW, .type = ARM_CP_64BIT | ARM_CP_ALIAS, + .access = PL1_RW, .accessfn = access_tvm_trvm, + .type = ARM_CP_64BIT | ARM_CP_ALIAS, .bank_fieldoffsets = { offsetof(CPUARMState, cp15.ttbr0_s), offsetof(CPUARMState, cp15.ttbr0_ns) }, .writefn = vmsa_ttbr_write, }, { .name = "TTBR1", .cp = 15, .crm = 2, .opc1 = 1, - .access = PL1_RW, .type = ARM_CP_64BIT | ARM_CP_ALIAS, + .access = PL1_RW, .accessfn = access_tvm_trvm, + .type = ARM_CP_64BIT | ARM_CP_ALIAS, .bank_fieldoffsets = { offsetof(CPUARMState, cp15.ttbr1_s), offsetof(CPUARMState, cp15.ttbr1_ns) }, .writefn = vmsa_ttbr_write, }, @@ -4888,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) } }, @@ -7728,7 +7756,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 25 18:08:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 183875 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp2057513ile; Tue, 25 Feb 2020 10:09:13 -0800 (PST) X-Google-Smtp-Source: APXvYqyJzEGoq9ApMvesJg9Y6hI+9isjGeNCzjILnvSTC/aIRW2E+2OXgKasoBTcTthgWsVH8D9/ X-Received: by 2002:aed:34c1:: with SMTP id x59mr56259175qtd.236.1582654152948; Tue, 25 Feb 2020 10:09:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582654152; cv=none; d=google.com; s=arc-20160816; b=eddpH2RVLc+talXfU/2C2gvt9gepXMl+TCU+oz4EGSELuYFSeheSVRdlGsB0GcL/Dm 8SKGd7VK+5Ip6cyqqBvxZAmkkdg4G2l5FSSLOa0H8XgMlhnmtIdtpljdkJdnKJLulSLD lwdYwDBpKzVYysmd72/DIwtryw7x1Qh/V61o9EgutQZDLc6MwjcZROihxmRtzKSZhvQD KgwaAbEJIItjhkZZ6xxl2ZhmZrbZK55DMGMlSngstVXEHFm6sXy83Y/IIVKpyV4SOGrY /SyBmlZ9pv/DzTcl1WPsf6/ZvDpP2Ao+8ZNhBM+8RUI+cCyxhHZutynYQpwc50a03KTu MerQ== 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=oDXzsq0/YvSiQdzdpF94Ig5JPRMqXV2OYmMtHFtNL2o=; b=aDdEsBVDxfc188bPdTaKwsoPvI4KMMO/A87OaInjWhrSx+sSs7+BLuSUwPXeXaNJDn F5lmcE9mYEPO9XvR3RKAecqtOdmIywBRJPl/zW3zOKB2ypPNoUqKUcr8zcOl3XbAJrrW /Biq1lIKKFBEXZDtboLrUXRiG24SLlm4QqWVewPK9S9mFZe2ppnrP1LFOlBs6QEbedHp AB6oA29Ygr5CWMyji/W4b+CyfUXT7cgM87zw8aeiaz/yBSlFqaRvtH+PKzgf8AujD2xT HerIlCu+vIYZwIZPcrAdWFVVS/gS80ww7l6PeFgSdXZcmlqxZYNgOhUKObPDM3RrcMa4 mlew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Dj+Avin1; 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 c20si7734781qvw.19.2020.02.25.10.09.12 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Feb 2020 10:09:12 -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=Dj+Avin1; 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]:33358 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6eds-0002im-Bd for patch@linaro.org; Tue, 25 Feb 2020 13:09:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35001) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6edO-0002FI-NV for qemu-devel@nongnu.org; Tue, 25 Feb 2020 13:08:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j6edN-0004OE-1g for qemu-devel@nongnu.org; Tue, 25 Feb 2020 13:08:42 -0500 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:45217) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j6edM-0004Kz-RW for qemu-devel@nongnu.org; Tue, 25 Feb 2020 13:08:40 -0500 Received: by mail-pf1-x444.google.com with SMTP id 2so7584380pfg.12 for ; Tue, 25 Feb 2020 10:08:40 -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=oDXzsq0/YvSiQdzdpF94Ig5JPRMqXV2OYmMtHFtNL2o=; b=Dj+Avin13YTXRoFhgeuU/WW/jvjBnqXw/h3/iQXc7B/TESIkkXIZlponud6ocxp1M+ 2QlNczoDFKT4JUmWHuXn77kGM7GPVAG8GeconevLLl9qS8QxkB4GasXgnuP/DSX3ShlF s+jjtHanP7Uxl7Oi0ZWbivrvYI2vx8NBTD3Xdfi6q4HiWNyC790dXGjdtev8NetN/QVb I1YarIgfiSG8uzwmaoyRPf2hfeS3t4Rk2a1GQcfljS0bHgBFgg0geyPSfE0TsfQ8pym2 b9/VvuowBkYaHu9vVqtmPi1SNvRYSgJMr3hIJ+pDNm0afdx5NC4PLwymSTenJOBtucE6 jljA== 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=oDXzsq0/YvSiQdzdpF94Ig5JPRMqXV2OYmMtHFtNL2o=; b=SIpupKQDnUIKUe9HEGfZy27M0jZ9Vd4EiC+5ynJ/WNyAIeC30lajsPdL9z0Z7dx0Ys w7/dmKxmSG3GmwyfvajRKBXVMh6IHhJZs62u1PYHMQgFdGIJAabHw2eR7INA5Znvjr0S qVswySfy7aqiVh8phc6mwQxRrrA9wEeIA1FE+2VB3+uOnv1i+Obq3Ww65e0TctqFFF9o gb8w3dK3fnWnYQuB8Z3GgVeYxbJ6LBRiRmz2Adc9Y0qZZpXDlrHa14jlRZ86MrbiHL8Q qWmdsHIy+U3E5ZUjCxBuFhrBN2p7TCCWUDTGb96KxKQahZWVnCxQ/amPGva8TF0zH9gG kqlg== X-Gm-Message-State: APjAAAVGeRFmwbDRe5H8mSJczfUIJIeyWuuSmxyDHCnw0OXLqBTH2IvR GlJR/X+nnulJRwvwMf+KhbS4s0Ndl9A= X-Received: by 2002:aa7:9a52:: with SMTP id x18mr58712858pfj.73.1582654118239; Tue, 25 Feb 2020 10:08:38 -0800 (PST) Received: from localhost.localdomain (97-126-123-70.tukw.qwest.net. [97.126.123.70]) by smtp.gmail.com with ESMTPSA id d69sm19069704pfd.72.2020.02.25.10.08.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Feb 2020 10:08:37 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 3/7] target/arm: Honor the HCR_EL2.TSW bit Date: Tue, 25 Feb 2020 10:08:27 -0800 Message-Id: <20200225180831.26078-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200225180831.26078-1-richard.henderson@linaro.org> References: <20200225180831.26078-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::444 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 Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/helper.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) -- 2.20.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index e45d717cf3..ea42e0d26d 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 25 18:08:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 183879 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp2060795ile; Tue, 25 Feb 2020 10:12:29 -0800 (PST) X-Google-Smtp-Source: APXvYqw0OOARGn4FODC6sjuabdHcDX05+YJfZIeAaE+StSu4pm/+FtnBuSvjAuc3HpIA5KHRczjX X-Received: by 2002:a05:6214:10cb:: with SMTP id r11mr99448qvs.59.1582654349476; Tue, 25 Feb 2020 10:12:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582654349; cv=none; d=google.com; s=arc-20160816; b=DfE2O7nTTF8AUNcAibDkZjtC8BegnGV0Ql3ftki5qSkhNNrNfbShszBaAPuwENVECY K09+p2dun4lJ+pFUkmWrkr0du5RHLQ73MUqiHucySOHtdsgHoewy3iVcut5CvDzIGK6i 8Y7hYd3dwQCcQQIbgKtoKHwpcYmpauiipXgJhIKSZeMD0/tquG5fquWzE/46+4Ab2O1E OftJqex+LEEXUB2Ew60S3JHDndYx0le9Vw5eQsdfTQ7piK0C5LPEzmKyw2vsuvB0tHAp Fe9O4Tb4YzlDLwojBm4IxpRTlU0BabsbVLqZZZAyliKTDV1bKEfLw/f22+TLU0r3dk4D 6GOQ== 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=rCn9KEM9PXXgFtnK73d+AiT9YkDrEQbzS/XrB8FG7Ao=; b=B9B31FBc9r72gwnMcYfEG7aMM6RyIunaLnigtMPoh/fnSzu2eLY+TS3vVAzWFnNmUf y1mPEsiyLKnCkoxkYX1lyP6o0bO5bRlE6T+GQGK9IddagFzvWr3cjf+BCikkgs1sp/5X wcR2BYzmht7QsiedahIR0zRVfcrL6jG339ei5X/C1W10k4yAHeZXhHjVjCl9C1PEwuue PIhYEuf1a02UGW3zpF696GPqPf8m9L3BUT79IdnhGPrfvAt/eN1CkJr7OfoEY7QaPW8f n3vXcZDjhYDRL14S5XPLtkY4tFXbdDyJeZ8P0e967mtrxqC/dypodo2yBaGttcD1RhcB fpkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vflkItrc; 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 h10si33974qtp.161.2020.02.25.10.12.29 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Feb 2020 10:12: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=pass header.i=@linaro.org header.s=google header.b=vflkItrc; 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]:33456 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6eh3-0007Ry-1W for patch@linaro.org; Tue, 25 Feb 2020 13:12:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35075) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6edP-0002Ha-V1 for qemu-devel@nongnu.org; Tue, 25 Feb 2020 13:08:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j6edO-0004Rg-Rc for qemu-devel@nongnu.org; Tue, 25 Feb 2020 13:08:43 -0500 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:37796) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j6edO-0004QB-Ln for qemu-devel@nongnu.org; Tue, 25 Feb 2020 13:08:42 -0500 Received: by mail-pl1-x641.google.com with SMTP id q4so115842pls.4 for ; Tue, 25 Feb 2020 10:08:42 -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=rCn9KEM9PXXgFtnK73d+AiT9YkDrEQbzS/XrB8FG7Ao=; b=vflkItrc76uuDrQG3Tf30j6zvOA2ZxcI4pATWtQjVFikv4q0rLhi8sBYziu61Y94qB fxVX/1YjWKKC/HyHcHNrkNIKRJunZhg1UBLl+iKbIlO/wj3Z50cPEg6NKtb3xEmfT037 mGWtSkJ+UgIEzQPAKyEcUG3VbTAIf7GmclcE1T2rHOPEo2USHMWF/cfglm/S/9N7kbLN EsqW6f0FGbsDdpRigVoB2XEMwRiX/wsX8VMLBnPM5oqJP75NYGrxjYhTjmuhAZ+VRvf+ crW6Jvu6TCux6c1xO83lE5UzAdzwZTQmkKG0D4LXPP7BJs8xVpxm2WsXk26X3HWJJ2uQ Heyw== 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=rCn9KEM9PXXgFtnK73d+AiT9YkDrEQbzS/XrB8FG7Ao=; b=hVZD9RKIwY+RdAtnrcZmh1f44JaFGgar98z83C5h0avrNsIZMIjgCoZNb0CrM4QqKv wcI8u1mRUlpBWakl9tGWeVfzpf8/ZLl+IlzElK1t3RR2YvEiVdNgdF+h524hoRR5rnpI WBfxb3FsCpioje4XxXU9tMOj0wErTyLWXNDmD4E+SuCx0Sr4Hxr5tSl7UV0uh+OqyVTP gdk3TWkdsBWVAdrnmMD0eE1aCr6l2uN7sDTrMoEziPdFDno9vbXVfnsLRG19M6q0UTJn w8ciU/YMj+MY77I9AucUCDrt0i7AtBQ+OEuY0k7GiwtAFw0FAKED23+atREsE14Lvxro tYkw== X-Gm-Message-State: APjAAAWAZEO28OZ8qaCJU8Xs9s+YUXJglaRVlmviljEytsqun4Bmdj+L KkrQ+zFX6c/Z2Acv+cscIYMMTJAgpSA= X-Received: by 2002:a17:90a:8c0f:: with SMTP id a15mr248731pjo.86.1582654121046; Tue, 25 Feb 2020 10:08:41 -0800 (PST) Received: from localhost.localdomain (97-126-123-70.tukw.qwest.net. [97.126.123.70]) by smtp.gmail.com with ESMTPSA id d69sm19069704pfd.72.2020.02.25.10.08.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Feb 2020 10:08:38 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 4/7] target/arm: Honor the HCR_EL2.TACR bit Date: Tue, 25 Feb 2020 10:08:28 -0800 Message-Id: <20200225180831.26078-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200225180831.26078-1-richard.henderson@linaro.org> References: <20200225180831.26078-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::641 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. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/helper.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) -- 2.20.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index ea42e0d26d..5cb7844f3f 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); @@ -6924,8 +6934,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, @@ -7681,8 +7691,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 25 18:08:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 183880 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp2061960ile; Tue, 25 Feb 2020 10:13:32 -0800 (PST) X-Google-Smtp-Source: APXvYqyv1zMvOuBarxScxEmZjW6v2SuHhmJ47CAdPNcXK+1zk/Cx/zz8I9xzdy6ji2WV6kk3+9k1 X-Received: by 2002:ad4:58e4:: with SMTP id di4mr91411qvb.185.1582654412627; Tue, 25 Feb 2020 10:13:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582654412; cv=none; d=google.com; s=arc-20160816; b=V7YUUizJ/zrMeDgIXBG3kuJaNMXoE1KXjGtzuk0tTgMHfqLiOoz5DJ0vXTHWCu/SgQ +1wXvQIDpbDqQ2gNvDOsSHajBTBMXofRpBwr4GQ6Oezgi9+t/7cTg7FW/jHYKogxLwmM 8Dx4wCd+9w1HOVlNj+YudII/CAUGzBrS3ofhcBlsEHVXZm8wKG0lwN302hzMmeE5Gxkz fkZfPzQugXAoi7Yf4G63LMpda9eJu3NhHDwDfvJswyDSZgQ500r3BFp0+0a7ASYOuR/P eIvrtNTMW2xz18CxApacM59uQAk9D0Aqbnspc102YCe2JTbmQT+IzQHl1KTWjdZ4WNz7 c9pg== 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=1+nBZoDaBAGVfWBfiFQULthtVj8wbsWbsm7r45A6ZqY=; b=Gia027G/XNLNOHuLkLWvoQuf0IjN8KQ0UBiLIqO5faRoO4W4vIgxrnGumjeBV1seow 7mjtphq4cK6qqi5hxkgCzyrBc4JuwJvHdsAb6Z8jmuLDAKXsl/jUCEy4q1vBb5Jftsah bCeyKaHvOWV1aUeYCuwNNtCcLcNcX2gFaJC/5oorf5TVaide8nvzBYMuuzeWwomjb4Ny gSm8V87u+KP7rMEVN2Ng6r9oFdUPaSU8/8Ix18Vvrz0XRhI4esa8YaCj1OO/znQXyYSr UBAl9SZm12ujeWRRvLVeJbPDzevfAag+ZQPDlS2SeEL3J3dVC628auBNyo5BYkBusHYX JQFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Xrg+UwIg; 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 j7si27459qtd.283.2020.02.25.10.13.32 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Feb 2020 10:13:32 -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=Xrg+UwIg; 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]:33468 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6ei4-0008Nc-4n for patch@linaro.org; Tue, 25 Feb 2020 13:13:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35216) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6edS-0002Ox-JU for qemu-devel@nongnu.org; Tue, 25 Feb 2020 13:08:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j6edR-0004Wc-7g for qemu-devel@nongnu.org; Tue, 25 Feb 2020 13:08:46 -0500 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:43305) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j6edR-0004Ux-1X for qemu-devel@nongnu.org; Tue, 25 Feb 2020 13:08:45 -0500 Received: by mail-pl1-x644.google.com with SMTP id p11so100991plq.10 for ; Tue, 25 Feb 2020 10:08:44 -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=1+nBZoDaBAGVfWBfiFQULthtVj8wbsWbsm7r45A6ZqY=; b=Xrg+UwIgd2VBTIgfHkiRViOB/P9/VAD+BIIOqXfQwaIXs5Ftn9Ditm163s1n3zOy0v xOAw1N3iRm7RIb1EjgSwtu1dki+HaETltEUgBs0bd5v1YTnuwSLPmcarpEGM9eqNMcd2 De3jWgICdh+1WeUynrTS6d9rcbykWI/kSYFhmQ0tHI6KBSjMCaW1E9mX3U4ykmrONJ1e yVETPDL/tiDmB81oGrbVSS/GE/SMiyGUCO3ybAB05A2ouH1fij6Ve9kIcGFBZuEmtjeY lgJZ492NUf1JolZLDchcg671CIu9mKIT9gUK/wjHpVsgSdDWMprTCscJkTE9OCZcFO5I s1nw== 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=1+nBZoDaBAGVfWBfiFQULthtVj8wbsWbsm7r45A6ZqY=; b=dV5syXtUO7nrA+ar9vibuQOu9O0ad7f2qibOrgZNmiIWlkejEzBPB+U3xr/DxEOAtb Pn/8Rf6iDNvUQEhce1j6NEhib2uhbssrwxbfEGBYLHrzILHZuNvrMJKs0HEmitmDvoy9 gF9KRIZd2FRZJXOsBhqk89G6bGwGRbvqRjX4Ob7vK/IS4/iI+/D8m3LZvV0fyyUNZOTB Kp2nXnRKTzlbYRYMXCOSAv79CEXu+KCRnNnl8Whf4nHu7eB+Ol8JSdmArpsbSw8vn4/J GDUDkgY/6T5was8BRcZX/ZF2ugRIuurVEiWvsbyL01Vj0G+HSBJXKehLKmreS9uEe+1y 3RxA== X-Gm-Message-State: APjAAAXWh7cmnO5aN/L69HKu2Hm9VkWrhE+zBF4edOJUc0i30ywAWhO3 jhmsiOxISIRFgXPLA+XsI8rPgiCf2kA= X-Received: by 2002:a17:90a:3841:: with SMTP id l1mr242449pjf.108.1582654122942; Tue, 25 Feb 2020 10:08:42 -0800 (PST) Received: from localhost.localdomain (97-126-123-70.tukw.qwest.net. [97.126.123.70]) by smtp.gmail.com with ESMTPSA id d69sm19069704pfd.72.2020.02.25.10.08.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Feb 2020 10:08:41 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 5/7] target/arm: Honor the HCR_EL2.TPCP bit Date: Tue, 25 Feb 2020 10:08:29 -0800 Message-Id: <20200225180831.26078-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200225180831.26078-1-richard.henderson@linaro.org> References: <20200225180831.26078-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::644 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 --- v4: Fix el0 fallthru (pmm). --- target/arm/helper.c | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) -- 2.20.1 Reviewed-by: Peter Maydell diff --git a/target/arm/helper.c b/target/arm/helper.c index 5cb7844f3f..2d488554b7 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; + } + /* fall through */ + 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 */ @@ -6728,7 +6751,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 }; @@ -6736,7 +6759,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 25 18:08:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 183881 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp2063566ile; Tue, 25 Feb 2020 10:14:55 -0800 (PST) X-Google-Smtp-Source: APXvYqwg7ck0q/KgSlHt49a3jsuequ98M/2MJyKiJ6LEOpi9iQTgmn5pM9okMDW5Q/zvzfmpnizS X-Received: by 2002:ac8:2263:: with SMTP id p32mr7173679qtp.326.1582654495688; Tue, 25 Feb 2020 10:14:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582654495; cv=none; d=google.com; s=arc-20160816; b=yrqGqM8RMt2vc8D4inQfax48rtb+hSJDPTJIT5wGo4Scl/MAssIHZWtF2eKp5jPrkj z0ZqHhGzcEDdQQaF4sazujGrFZxfIp26ZgzGabgihvF3up1zgAK/t7nP2UTORQQLgWTD 3u0v1b8vIA5uxGNrXhkP0ttV6jOnzBNa2d1ZJZaoqXHEgR8rJcwBgBMA5FxaUeKP3tgf wp2Fdpykb5nwtWrnlafhyoBxaMiYrk41g/5aHs14MJ+4XpkJSfHMh1H6sPagLKMNaRlW tOpFfC7LIUEmwdqYUb9BUiRLCCpMs0kjAlwnaU8TZ5m+cDVct8fRskoH114LG+AYqGS3 R2Sw== 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=VKycPInt6AkbSPRRcFBDTfCzpdXuH+EqY1piUn22Z/U=; b=d8Y5UDqWTN/KaM5i8oeYExCuGtF+RKfVXLp26HwyCTpMZWLwQz4fb7dhsLQ9pwpDIv JQgWyFFULEludLYtFogSPfMISsGiroLGiPFOPxCDK+yJkX7eMfUj2/5hZlun5qdKXgHC RYFRkf/Xeq+rB98B4etzpZA9B7OrY1uv9CKCZby2iZBNERk9/GtzEPtJBljNk+uhBcMp K7TFq96EGm//9BRS0vkcuVlwwLgWRGi6rd85+pZt0ta2B6x2YcJy2fVm3Pbw4X0JwcVw XeTq4d3i/slhLFow2+iuUp7h6i1lP/EJRxmIRKcQT2J5QP79WGRoBbCV04gK0uL2cybs v24Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gcoX65pX; 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 o6si140524qkg.172.2020.02.25.10.14.55 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Feb 2020 10:14:55 -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=gcoX65pX; 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]:33488 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6ejO-000102-Us for patch@linaro.org; Tue, 25 Feb 2020 13:14:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35411) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6edW-0002ZX-FR for qemu-devel@nongnu.org; Tue, 25 Feb 2020 13:08:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j6edV-0004fD-0w for qemu-devel@nongnu.org; Tue, 25 Feb 2020 13:08:50 -0500 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:45908) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j6edU-0004d4-Ne for qemu-devel@nongnu.org; Tue, 25 Feb 2020 13:08:48 -0500 Received: by mail-pl1-x642.google.com with SMTP id b22so96535pls.12 for ; Tue, 25 Feb 2020 10:08:48 -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=VKycPInt6AkbSPRRcFBDTfCzpdXuH+EqY1piUn22Z/U=; b=gcoX65pX5P31puoa4CaN+lbwv6Li0z1XpohXEVfO5jperOWidBsQk+KiKSjxy2LQ39 MPx8G/ILZd+t2kJvwI1/bjngDFyxolXEpeh9f3/wqbolGSwcvd/s/ErN0NxLrE+ZYGYA ddv6MnLkpOeCfzrd1BLhXTgYy6de0U57Diyvn7FyOOCSgatZv7bMgM/2jQhm3TVxD/lM 6UaLjjGndXWb6SmDRaajGXSVKk3FB5gth62Rdj+PSwqkG7zVx8fjCvnWYf6FeoP8UZx2 1+NMn+DxEGZat62Oiq8VtTsrxNcYjfifJQAwYV/oJUlaTf0Y5XQ1r+XxBcldxqjSCnA2 pgFA== 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=VKycPInt6AkbSPRRcFBDTfCzpdXuH+EqY1piUn22Z/U=; b=fxIkujS2tSy/fmjnkI9g/zJspJc7pL46B5M4dIbyOuUXykmMq0K0rk6jJWq/wAlNiW 0oyS6zklDr48yS47ka63c8pxfNDGGv14EZW+aEfF2Ety1rp/nBzhnCDbWFrJfTOdEm3i HkYSR8sY2jGaTjteIPvHzNGKZxI15OopH/N99RDsCJKHGjnUgQuwHEnYehcdPzkrjcKz krzGIVA5zDRDy085h2P6SCJv4ZB1D4Xv3QpTlK7b5XBSsvcypjJBzzO2ARjuCvtsXQzF GVYe7s/6OqwU7U4xfXV8M0fZ72juHTOCKDVRLuorYLGw/uVvRew6j4qD6qHHZtBhGo6a bqNw== X-Gm-Message-State: APjAAAVCOCDUsAzrU04jy11L8iMzipvqSgFF09LtkqXg3j+qx8LNIH93 WBO4CyNI1eF9yZ7eBumeZUswFuuPBw8= X-Received: by 2002:a17:90a:c390:: with SMTP id h16mr181939pjt.131.1582654125937; Tue, 25 Feb 2020 10:08:45 -0800 (PST) Received: from localhost.localdomain (97-126-123-70.tukw.qwest.net. [97.126.123.70]) by smtp.gmail.com with ESMTPSA id d69sm19069704pfd.72.2020.02.25.10.08.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Feb 2020 10:08:43 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 6/7] target/arm: Honor the HCR_EL2.TPU bit Date: Tue, 25 Feb 2020 10:08:30 -0800 Message-Id: <20200225180831.26078-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200225180831.26078-1-richard.henderson@linaro.org> References: <20200225180831.26078-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::642 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 --- v4: Fix el0 fallthru (pmm). --- target/arm/helper.c | 53 +++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 21 deletions(-) -- 2.20.1 Reviewed-by: Peter Maydell diff --git a/target/arm/helper.c b/target/arm/helper.c index 2d488554b7..ca67d6a770 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; + } + /* fall through */ + 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 25 18:08:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 183882 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp2065110ile; Tue, 25 Feb 2020 10:16:26 -0800 (PST) X-Google-Smtp-Source: APXvYqwZf6I5NzczqczdqkLYV3Flu6rf4hOw40ZBU7OyMlL1PrVXTzdjF5s0P/Hszh1JeLVZ0TYx X-Received: by 2002:a05:620a:6cb:: with SMTP id 11mr134342qky.12.1582654586218; Tue, 25 Feb 2020 10:16:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582654586; cv=none; d=google.com; s=arc-20160816; b=XpykzTsKUasgbKZv0SAkvch0EGegdj1Y3zkrMdDJBWilufS7sKC/EPX+1z0YF8YmiO EuBh+IY9HDikGTkGto5Gdze81FBI+DKW41YCs7Lw7G4EbCc5QoYyxeNazpALABbso+Uu UipBXjKhZgiJLj3cZIPf8IL/7z0YlgFUOOUD57yjFzkC56YXvVHF6OAlgp3mwH4u2ivc XiIVZ7h4/GdEb50L5Qym1Mkr36g52gqZR+gnc/rc8WWaDS5CiPhSEDJ4ZDc872lSUinq 9OviUOEI5VodcYwggL8LfykydT19zR6oZECFXzqInKFyGP2ss5nNk/EVTYJ8bueHMqSh tBpA== 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=XSq3h8eAOylAKZlE56of8ferQEzDe3R6wID0JCCEJjA=; b=ckZ8vnJgmpYYRvO5Zwq7vTCoa6gHcVGSM0MJ+QfkuBGiZq3t5ba8ofwrh9kFvNEDQa 4A03kc4tHO26b24uXq0676wvmTbIIYU5J6ta06+GrDKTSECY7rLPw2JJkoxv+WuDCCP4 lldiMkJ9tfSy104JvXOViUmLX9EWrhrI4Vz+31fDs7eJsJN1h/LgNgaSuZHgRJNcbhuP vJ9k90Ep+w15lmgI3w+ltJv2d6ZcMolDaHZoq6J+WYmTgPp+E9uWgiKPLJL5JxopApnf EWiBYjiaswdRE3hZI9DuPD8K/e2/TI3bYJYO6J3xoo0VF/qwKKTyJi+ajaBclEPFtsVV ayBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oiMCnCKT; 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 y32si37817qtb.164.2020.02.25.10.16.26 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Feb 2020 10:16:26 -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=oiMCnCKT; 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]:33518 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6ekr-0001xb-Kp for patch@linaro.org; Tue, 25 Feb 2020 13:16:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35596) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6eda-0002ix-3n for qemu-devel@nongnu.org; Tue, 25 Feb 2020 13:08:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j6edY-0004mF-9T for qemu-devel@nongnu.org; Tue, 25 Feb 2020 13:08:53 -0500 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:35208) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j6edY-0004ko-1o for qemu-devel@nongnu.org; Tue, 25 Feb 2020 13:08:52 -0500 Received: by mail-pf1-x444.google.com with SMTP id i19so7617513pfa.2 for ; Tue, 25 Feb 2020 10:08:51 -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=XSq3h8eAOylAKZlE56of8ferQEzDe3R6wID0JCCEJjA=; b=oiMCnCKTwt+ySdRPwFSeo5Q8Z5l9k+4mZxN6gOAn1BRWIa1u1FUYE5AbQtDP/s/rK2 YbVWtLUOa6KEYcxJyU9/SS87alehtb5SKfxgsWiq/HS3iGKtq9WKZonAI7kpqOyLmyPJ m+hvD7ZQV3iKZcMngcYIzciE2hd2hw1mMrqD2Ly/J3d6II0k8+XVNHbih5AMjEpi7nlU mAygIMu0/KL8uT4kG5IQLiQpiwsYTdeXUFm3ZYrE6/G03gFIJHzZdvRe+D9bosqL7f4B Q+L7o7j9Gb3kKa1Lvv7XH3WDpIFTQo0IhFXGJnsDe9fdc1PcHEGcsNCCgOYfyQXGGIlc /UaQ== 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=XSq3h8eAOylAKZlE56of8ferQEzDe3R6wID0JCCEJjA=; b=ucSRW+MVrcwQ45qhO3R2toVqC8+9rNOQbPrr/TRg9f17Vflr7b3Vc4RH8ElyAv2tjZ p328Mzsiz/H/j6wRtkk0lIcEe6tLXTq3gaMt8eiTHPMxyoV3IRhSWC5iUM9X9AM+G/bU mrGC6U4hxBkHepYcdPqoaxh5MD4Pe/1K5FmqHvMh4e43RiiP6lyuzcaLNTYnGljQahT5 BybgXwlqyDItDxK8j7jJd4iQ1uXC4gDWh6XsiQzDvknM7LPCtr5Fz/SxF+mnl8+yoD87 SPiU9tXm+dH6/bKnu3YSzTi1WUt4u2H1vV9BxASIcpU2eKOpVXQ4i2wTWOmJok7ALsih JMFw== X-Gm-Message-State: APjAAAWMMtJo0yj0xU2nDdcSk+JkJioSI9vemdG/sXXIp+LkxSmbANe9 paukUaMZzrwsB3TAbQ3Ycv5D6QiZbLU= X-Received: by 2002:a63:1a50:: with SMTP id a16mr57812863pgm.389.1582654130035; Tue, 25 Feb 2020 10:08:50 -0800 (PST) Received: from localhost.localdomain (97-126-123-70.tukw.qwest.net. [97.126.123.70]) by smtp.gmail.com with ESMTPSA id d69sm19069704pfd.72.2020.02.25.10.08.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Feb 2020 10:08:46 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 7/7] target/arm: Honor the HCR_EL2.TTLB bit Date: Tue, 25 Feb 2020 10:08:31 -0800 Message-Id: <20200225180831.26078-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200225180831.26078-1-richard.henderson@linaro.org> References: <20200225180831.26078-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::444 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 Reviewed-by: Peter Maydell diff --git a/target/arm/helper.c b/target/arm/helper.c index ca67d6a770..20688d1a18 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); @@ -2285,41 +2295,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 },