From patchwork Tue Dec 3 02:29:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 180689 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp954576ile; Mon, 2 Dec 2019 18:55:28 -0800 (PST) X-Google-Smtp-Source: APXvYqwTDZt/i+9Hj+d3uXkA+KQ3vwiLkXrxK+s2HPNBLIUiIfMXqNw/5mPrZAZUwEikWH9XZlDK X-Received: by 2002:ac8:2361:: with SMTP id b30mr3115981qtb.322.1575341728288; Mon, 02 Dec 2019 18:55:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575341728; cv=none; d=google.com; s=arc-20160816; b=hKTt/Td6SoFqitO0PG5MOE5pUyhVnrSYNqXvlzMUoANSjS0nNeQfJ4+gJ0T3k2Uh8W 06CHrxzdN3J4O5e6DMzlEXKvhZOYLDfvNX7bfLRvNvHVb25cKio4aUmb5ba68TFUG28b N/LhUlhyHJBXXDI1N5HCyjXEqjaY4GfKKwQrvmt5DbXMi2VI9z0pXNIpm2Chiy4O0vcG SKg5XOWacRxOJy5ZGIUTykQnKSgz8j7JBXs6d/rs75h2fc9UMRo3Y6N/bZgB1TL/tqWj 1bEX6N5yKc2iVQRpNH2OP4iWgLP6xafk1Vy7etZkNdYtZmaDoqy9Gs5niH5+r5Wv4+AO hfow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=wrciTI1v/mNpw+XObN5cyZ1jMW9FF/u8Ocv1yHt3lTU=; b=THWd0huKnsGr9UockfW7B0c1C9T2IXcz0TTzwuO2lDQS/rorDUg3QJPX3LKQAXCCzz y6VBbUQBsvLF/IflzIX7gZbwskRnjRAWArR0Nybr/xEISUtQ9KXflzsc9w0jkyfBuSE3 mlYaAghZ0ZABQdSZgDapLzRoNztBS+7Rqsc0od82PrefRSZs6uyKKLMHldMyGhLtiNac sXynnRuUw2GogjUPSv/pRgPoS2pB0ycSzXtM8oGxLwK58Ee25+RV3bol5HLg9Q8RJKPI eJ+Hrij8YAnIiZWwGxeXkTpnx6D4XZ/kMtvop+4Rd4CIlVTkGosJ+G26pFVcRwBkVE13 sjnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ROljyHfZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v127si1232388qki.351.2019.12.02.18.55.28 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Dec 2019 18:55:28 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ROljyHfZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47566 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ibyLX-0000H8-9L for patch@linaro.org; Mon, 02 Dec 2019 21:55:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33140) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ibxxL-0003Pi-VM for qemu-devel@nongnu.org; Mon, 02 Dec 2019 21:30:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ibxxJ-0000Ch-Tr for qemu-devel@nongnu.org; Mon, 02 Dec 2019 21:30:27 -0500 Received: from mail-pj1-x1041.google.com ([2607:f8b0:4864:20::1041]:46177) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ibxxH-00008j-MV for qemu-devel@nongnu.org; Mon, 02 Dec 2019 21:30:24 -0500 Received: by mail-pj1-x1041.google.com with SMTP id z21so799042pjq.13 for ; Mon, 02 Dec 2019 18:30:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wrciTI1v/mNpw+XObN5cyZ1jMW9FF/u8Ocv1yHt3lTU=; b=ROljyHfZLuEU7PDLX5pc8bRpKTjz3BSqEn6fOyHa83GBVEttSWWx9z5tvzkEkjvI8h UKRTQkhq6zi+qaE44qNM1eDK1a+gnALoa6zbi5Jel34Kngqm+ulgFwYfSKUXHLLDnd1A Cc6MEdcHCLo7QDD/acEBz4+3mEARCOtkeN/jCp3ozTn2tJPSmDMQjrRWEJgNFm9/8B4T KENKnHcrmg9ScOh1nokDBPdJBsALUgKUTEfIqKzhHp9UIZOwKSV9iv/qThMZvGj3CzdE e9B9eofKxugshmVPgsfzmUP6GrewLR0liAm1cy6A9RM5MFUtNn5FtBd/45prCeE6CbM/ 1aAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wrciTI1v/mNpw+XObN5cyZ1jMW9FF/u8Ocv1yHt3lTU=; b=oy39EynBvYCjKufsDMHGQNnIdAEudnh2ObrxBDfmMqq2fXBdlbysUnJAp1j+6hnLXC iquhm7etA5UXWgJnyfRxqmypR0zySj3rS+qHWgEMTxPSlT2KHZhyusYHBLKe7ra9J1v5 bj92J7386mKTlKBA8ONXyp+CB+/FfHsD0+u99tYTNwuas/vsqFELCgETZDXWR9VMd2uH cE8MTf0W/9zwWcxrzxiHGtguP9gMWvXyJzVF7I7JH/UgjBvzTVg1er8h2X6JBQ9fxXpL lR0Trwg+Qk04OyKOAnuBkG+4W++m6r0/z94WRR6Ywe5L9aD5Poj0TC27S8BHVtHeJ6yM y0VQ== X-Gm-Message-State: APjAAAUZgzRelLPcwZyisRstEWYxqavQOYFyjgOxtuoAGURIqwL1tTeJ VuFcY7kbvD2VajcknfqwUcKwFWThIMQ= X-Received: by 2002:a17:902:322:: with SMTP id 31mr2709960pld.244.1575340220163; Mon, 02 Dec 2019 18:30:20 -0800 (PST) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q22sm873695pfg.170.2019.12.02.18.30.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2019 18:30:19 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 32/40] target/arm: Update {fp,sve}_exception_el for VHE Date: Mon, 2 Dec 2019 18:29:29 -0800 Message-Id: <20191203022937.1474-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191203022937.1474-1-richard.henderson@linaro.org> References: <20191203022937.1474-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::1041 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" When TGE+E2H are both set, CPACR_EL1 is ignored. Signed-off-by: Richard Henderson --- target/arm/helper.c | 53 ++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 25 deletions(-) -- 2.17.1 Reviewed-by: Peter Maydell diff --git a/target/arm/helper.c b/target/arm/helper.c index e0b8c81c5f..3e025eb22e 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -5743,7 +5743,9 @@ static const ARMCPRegInfo debug_lpae_cp_reginfo[] = { int sve_exception_el(CPUARMState *env, int el) { #ifndef CONFIG_USER_ONLY - if (el <= 1) { + uint64_t hcr_el2 = arm_hcr_el2_eff(env); + + if (el <= 1 && (hcr_el2 & (HCR_E2H | HCR_TGE)) != (HCR_E2H | HCR_TGE)) { bool disabled = false; /* The CPACR.ZEN controls traps to EL1: @@ -5758,8 +5760,7 @@ int sve_exception_el(CPUARMState *env, int el) } if (disabled) { /* route_to_el2 */ - return (arm_feature(env, ARM_FEATURE_EL2) - && (arm_hcr_el2_eff(env) & HCR_TGE) ? 2 : 1); + return hcr_el2 & HCR_TGE ? 2 : 1; } /* Check CPACR.FPEN. */ @@ -11565,8 +11566,6 @@ uint32_t HELPER(crc32c)(uint32_t acc, uint32_t val, uint32_t bytes) int fp_exception_el(CPUARMState *env, int cur_el) { #ifndef CONFIG_USER_ONLY - int fpen; - /* CPACR and the CPTR registers don't exist before v6, so FP is * always accessible */ @@ -11594,30 +11593,34 @@ int fp_exception_el(CPUARMState *env, int cur_el) * 0, 2 : trap EL0 and EL1/PL1 accesses * 1 : trap only EL0 accesses * 3 : trap no accesses + * This register is ignored if E2H+TGE are both set. */ - fpen = extract32(env->cp15.cpacr_el1, 20, 2); - switch (fpen) { - case 0: - case 2: - if (cur_el == 0 || cur_el == 1) { - /* Trap to PL1, which might be EL1 or EL3 */ - if (arm_is_secure(env) && !arm_el_is_aa64(env, 3)) { + if ((arm_hcr_el2_eff(env) & (HCR_E2H | HCR_TGE)) != (HCR_E2H | HCR_TGE)) { + int fpen = extract32(env->cp15.cpacr_el1, 20, 2); + + switch (fpen) { + case 0: + case 2: + if (cur_el == 0 || cur_el == 1) { + /* Trap to PL1, which might be EL1 or EL3 */ + if (arm_is_secure(env) && !arm_el_is_aa64(env, 3)) { + return 3; + } + return 1; + } + if (cur_el == 3 && !is_a64(env)) { + /* Secure PL1 running at EL3 */ return 3; } - return 1; + break; + case 1: + if (cur_el == 0) { + return 1; + } + break; + case 3: + break; } - if (cur_el == 3 && !is_a64(env)) { - /* Secure PL1 running at EL3 */ - return 3; - } - break; - case 1: - if (cur_el == 0) { - return 1; - } - break; - case 3: - break; } /*