From patchwork Wed Dec 15 10:40:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 524249 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp231280imb; Wed, 15 Dec 2021 03:13:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJyc2bNMF/r34PT0lUnFEM3EG9XLi4P8PhphOZEduL1ieJfChBVN7z0veZn4+S2JoXlXS2ul X-Received: by 2002:ab0:35d2:: with SMTP id x18mr9229643uat.32.1639566785840; Wed, 15 Dec 2021 03:13:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639566785; cv=none; d=google.com; s=arc-20160816; b=hMevc/0X9MaOn5AOfmVkFzypdZc0jYJsicvj+kFGey8ASDsVJ0zLDG+ZnCGIPjBVAg ebY66W4jHrB7woJTD0RTzfaII0y8g0agQPZsdstehATOHhLNRzuHs/QE0Msd47af2tzU ID+Rv0WsaN5W2p2orwd0Mzz+yktRZ/oT+J1t8NSyZlNFh47Rk4lMSXi3UVUmtpubYHDP L+7tgoWC/PEAyq7CrSOWW19saD5Nlsa3lr3L89IGgHIjHQ/ilD8x/sJfDL1MM06rh73D ef1OtDsD10vQRw59/hj2xeZvB5Q/mggDTmkINx905K1vcdRFuY8bh4QakYsbRaw60PsI C8Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=EbvaOheGHih9OZWQqKwYHdzxPCbAj4qvSl18sxhGpuI=; b=LmM2xXvgTabximKBdGrbhNZ/FIsD49Aa1Is9SrSmG9uaExzOEVbUIuy8WH56Ugq3zS siqc/iagPqEMHCHZfShYlBcjtcQWGbM2dCZNb15EBno9xP/xceOfqMhtsVPRYWIhIBIO Q4SJD2hR9pwpRUC4Y85J5BqxfyfI7uCEdZjg9E8ZN0Gjzsap+1hKrcn2bdN4YqKFA6Tz lRIqtJ8I1etnC2Jv0UgWrST/wYJJGUacBKPqW21OYDDw0jrWUFFqxkOu3LTfGhJmiNZG Cy6z82Q38awV2Hsxa/wDmx6bFVOYPpqT4EBCd593uhg8zFi7pEljmaSTCVQhio23Wfb8 h56A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Se1jAZIV; 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 l16si127123vsv.460.2021.12.15.03.13.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 15 Dec 2021 03:13:05 -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=Se1jAZIV; 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]:43536 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mxSDZ-0002Nf-AD for patch@linaro.org; Wed, 15 Dec 2021 06:13:05 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41322) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxRia-0006s3-M7 for qemu-devel@nongnu.org; Wed, 15 Dec 2021 05:41:04 -0500 Received: from [2a00:1450:4864:20::435] (port=34465 helo=mail-wr1-x435.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mxRiW-0008R7-O4 for qemu-devel@nongnu.org; Wed, 15 Dec 2021 05:41:04 -0500 Received: by mail-wr1-x435.google.com with SMTP id s1so3230779wrg.1 for ; Wed, 15 Dec 2021 02:40:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=EbvaOheGHih9OZWQqKwYHdzxPCbAj4qvSl18sxhGpuI=; b=Se1jAZIVjSGoKMcURUBUghG8aaEDvTh4KjsjWxy3Yz3mJM+wi7VV0TqomkwIK7MFu1 Cibj6QYEfUrNJ7JwU6SW2V6vJVe0n6tC6D2c/3ByF+1eIJeL5gMTSyAUp2xvSoSqtFgz l6XIwCQLhtn3fMWbILkhyyn3xqUPQb3jgxcOcpalF+YIshqtRdgztsKvxzhxWpXtIBNp BJK9qdspadUHUXbooxhPAxi+8O4X3GCebv9PA8npKlNBU9R9nSuLfzX1hMmOJzHwwaMW cbGVj0xewVfxoUokRCxmVwz1UCyikC3nkQvAYHwaAOee9dSrzIM/vBd8Fn5k4js7JmHE iHkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EbvaOheGHih9OZWQqKwYHdzxPCbAj4qvSl18sxhGpuI=; b=TPIfK/jBTzFuM2V71KLPBa4U8guCbdYaeZTkz04f7cPhTEw5qxkPrP0ZAzT+2S5ttj XxSYpM/Dq816tQOeTF6wH1vKXUstfQI5AeZmo86hprI+eczmo+e84ZrMjoL7zDV3u82t dtIWGd4hk+ViKErx7PIAsvBEQRiYgFiZCGwLqvTzXMcToxj4Bc/4mj4GJLIatqWE5XFS Tqtf94C2w6LPcCh0n7iNhPcel2DY9hxJIaXS8c0Wi4SGEjB1aoQu9Cez1SGzoKeMCIJw YBzHguvJIhUAwCHwZBKECZzedUtD8/WxwvBPsNwN70yq+ozSHDQ73rt7q0wdU+SmmR2l 4knQ== X-Gm-Message-State: AOAM531Ljf/d4rJmyYiaCb/WGt95stAaunlHZwnGEa2CldUkguKIz8Ai OUt4IO2FMSm7/c8CQdpqHd6hbAHlJwC+Tg== X-Received: by 2002:adf:dc44:: with SMTP id m4mr3828848wrj.550.1639564858828; Wed, 15 Dec 2021 02:40:58 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id e18sm1600815wrs.48.2021.12.15.02.40.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Dec 2021 02:40:58 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 14/33] target/arm: Split compute_fsr_fsc out of arm_deliver_fault Date: Wed, 15 Dec 2021 10:40:30 +0000 Message-Id: <20211215104049.2030475-15-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211215104049.2030475-1-peter.maydell@linaro.org> References: <20211215104049.2030475-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::435 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x435.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson We will reuse this section of arm_deliver_fault for raising pc alignment faults. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/tlb_helper.c | 45 +++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/target/arm/tlb_helper.c b/target/arm/tlb_helper.c index 12a934e9248..4cacb9658fb 100644 --- a/target/arm/tlb_helper.c +++ b/target/arm/tlb_helper.c @@ -49,25 +49,11 @@ static inline uint32_t merge_syn_data_abort(uint32_t template_syn, return syn; } -static void QEMU_NORETURN arm_deliver_fault(ARMCPU *cpu, vaddr addr, - MMUAccessType access_type, - int mmu_idx, ARMMMUFaultInfo *fi) +static uint32_t compute_fsr_fsc(CPUARMState *env, ARMMMUFaultInfo *fi, + int target_el, int mmu_idx, uint32_t *ret_fsc) { - CPUARMState *env = &cpu->env; - int target_el; - bool same_el; - uint32_t syn, exc, fsr, fsc; ARMMMUIdx arm_mmu_idx = core_to_arm_mmu_idx(env, mmu_idx); - - target_el = exception_target_el(env); - if (fi->stage2) { - target_el = 2; - env->cp15.hpfar_el2 = extract64(fi->s2addr, 12, 47) << 4; - if (arm_is_secure_below_el3(env) && fi->s1ns) { - env->cp15.hpfar_el2 |= HPFAR_NS; - } - } - same_el = (arm_current_el(env) == target_el); + uint32_t fsr, fsc; if (target_el == 2 || arm_el_is_aa64(env, target_el) || arm_s1_regime_using_lpae_format(env, arm_mmu_idx)) { @@ -88,6 +74,31 @@ static void QEMU_NORETURN arm_deliver_fault(ARMCPU *cpu, vaddr addr, fsc = 0x3f; } + *ret_fsc = fsc; + return fsr; +} + +static void QEMU_NORETURN arm_deliver_fault(ARMCPU *cpu, vaddr addr, + MMUAccessType access_type, + int mmu_idx, ARMMMUFaultInfo *fi) +{ + CPUARMState *env = &cpu->env; + int target_el; + bool same_el; + uint32_t syn, exc, fsr, fsc; + + target_el = exception_target_el(env); + if (fi->stage2) { + target_el = 2; + env->cp15.hpfar_el2 = extract64(fi->s2addr, 12, 47) << 4; + if (arm_is_secure_below_el3(env) && fi->s1ns) { + env->cp15.hpfar_el2 |= HPFAR_NS; + } + } + same_el = (arm_current_el(env) == target_el); + + fsr = compute_fsr_fsc(env, fi, target_el, mmu_idx, &fsc); + if (access_type == MMU_INST_FETCH) { syn = syn_insn_abort(same_el, fi->ea, fi->s1ptw, fsc); exc = EXCP_PREFETCH_ABORT;