From patchwork Mon Sep 20 02:44:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514292 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1667915jao; Sun, 19 Sep 2021 19:47:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRWXcU5O68xT65m9pPIdxBdnl9qIpyfTShL6GeUnOCXaouGgrtYEXDzc8V2l6v1G9P34P2 X-Received: by 2002:a05:6214:1444:: with SMTP id b4mr23013086qvy.33.1632106028045; Sun, 19 Sep 2021 19:47:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632106028; cv=none; d=google.com; s=arc-20160816; b=SdQfMCYUeH/kefuCV63Is0JdaH1K4VD9hUS7tEufqFM6uf+mDom1P3cdypo+n3PdeG 9JyVa/Um1lSjqH0a16WUvWidAl96X9E+bZKOP2XCb/XlG5NTqNliBzgJZnuUunVAu+EB P/ga7Kq0tuxm1hgwEOWTbvdSIesIji6Bmd/mP8muBtsnobtS77POVVVXvBgDzy5Ts/ke Dcjib9fmbEsUWw5Y4dmABtXnZgUvPAqwIQ110i03PKVbt9oYuX57ww2wF2MQ2SgbRd5x pf4hvD+iv7NbOzMEp5IdQylVvAhT3ffuqXW0SsuDe9J1SKM9T/R6D69dBKnKjkzxctVG yN9w== 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=CtQUY+VgkQT1rox5MwFOniOvDKV16giSUD56+x0u+Dc=; b=CHwN0ZoBekhz0mcKYVDF1dTCzT+QkW7qAihXN3s0M8RKH881Ngij1TLOEiTCZfsovu U3ZVmhjLQ00ZUQ5NhvPytrVcau0bCJ9QbpArBB9F+EUpVpNXSnxQ1n2frlgOcdS4Bu4o I0wTjlO4cXwxLGYW2H3TXvERn/IwVUi7YtohwasUdZf7DlZkGCArKE3MxYNNwJJcL3H7 /G6J9quAWO4gSSbDTfZGRrQw/X08k6QSALmzZ1h7xVoTzUHpOAUUYXb2sIGYyXWC7bKu P2lu8xnDjOlIoFit25e7hj5R2igwmP0M/0aRk8NCtNBTWDyxFdvlEH7003hhoOB2+Zjj BlDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jq+L2dnp; 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 f16si8470094qko.262.2021.09.19.19.47.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 19 Sep 2021 19:47:08 -0700 (PDT) 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=jq+L2dnp; 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]:40128 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mS9Kl-0005EO-IL for patch@linaro.org; Sun, 19 Sep 2021 22:47:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57442) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mS9Is-0005Cm-Ky for qemu-devel@nongnu.org; Sun, 19 Sep 2021 22:45:10 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]:34576) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mS9Iq-0008Ca-NC for qemu-devel@nongnu.org; Sun, 19 Sep 2021 22:45:10 -0400 Received: by mail-pf1-x42c.google.com with SMTP id g14so14936718pfm.1 for ; Sun, 19 Sep 2021 19:45:08 -0700 (PDT) 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=CtQUY+VgkQT1rox5MwFOniOvDKV16giSUD56+x0u+Dc=; b=jq+L2dnpHgrIK8wcRbWEzdX1zmYvJLjQfMVbUGR4wS88LLKplbSxzc4XWI6Aik9tJ1 PH/bvimKg1PX70MeUorumde1SLeQgR7AmRRIjDxFihVrgnsHDg/8dAZBzByqroPcPJa1 UH0cawgvVP3AUID2VAIcK0pAr7YYvzqyWu2cr9RDvTbmnE2Jench5Hur/ggt/6nnwExk 9qWnipQvfkI+Kd3/7cTvJUg96W/2a5PO0XW6oDio2+RWdWB/4EBLIHApSV6Z9kTWC5cO a1kRrEdzysZS11olOY8N4Hra8SKhE+Aqaz8RtOwKdrIzbubzRRC61W+16bf+racCXJHB sGhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CtQUY+VgkQT1rox5MwFOniOvDKV16giSUD56+x0u+Dc=; b=0u7O/08xkQlyGdP/uCUyLiyw3YGH0E0sTNc5Gfbt6marp3ajH7sl04Nbp1E1mbeqkN dMBnJ74YztKAlCEjVnSJntH1MZ4miLUEagCG0xhvfEUkrLrnmM/iUiuLCiakUoYuFe1K gWflzsnmwefz6yAYZB4NyJcjDVWg2NBxUR4sCgsBpRJTIeopkz0SR5Im+Onca++x5QMt hIXMByqjZPAFByfPwqGsJKc/wVt+tnMZxuz3d0GK0wx2trmJ6hqk1Zfvuel/YTgyOhHB uaIR1wkz4zbkGI7JJfsLPJ4LFvU/tzsLxZ06LlA8otwfpbXSXGKDExn0JYyq+6U4M1mG RvVg== X-Gm-Message-State: AOAM531FbhEsHkPqg1odLz8orMMyWl0CnMtRUySBuU5Son0FfATKjvkc xqpePgRr5Wwc0F3hyk5kN+HIPon1fKMMtw== X-Received: by 2002:a65:6487:: with SMTP id e7mr21295360pgv.27.1632105907014; Sun, 19 Sep 2021 19:45:07 -0700 (PDT) Received: from localhost.localdomain ([71.212.134.125]) by smtp.gmail.com with ESMTPSA id fh3sm16164767pjb.8.2021.09.19.19.45.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Sep 2021 19:45:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 1/6] linux-user/aarch64: Handle EC_PCALIGNMENT Date: Sun, 19 Sep 2021 19:44:59 -0700 Message-Id: <20210920024504.625965-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210920024504.625965-1-richard.henderson@linaro.org> References: <20210920024504.625965-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42c; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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 , qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This will shortly be raised for execution with a misaligned pc. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- linux-user/aarch64/cpu_loop.c | 44 +++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 17 deletions(-) -- 2.25.1 diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c index 11e34cb100..6e03afb2bd 100644 --- a/linux-user/aarch64/cpu_loop.c +++ b/linux-user/aarch64/cpu_loop.c @@ -78,7 +78,7 @@ void cpu_loop(CPUARMState *env) { CPUState *cs = env_cpu(env); - int trapnr, ec, fsc, si_code; + int trapnr, ec, fsc, si_sig, si_code; abi_long ret; for (;;) { @@ -112,28 +112,38 @@ void cpu_loop(CPUARMState *env) break; case EXCP_PREFETCH_ABORT: case EXCP_DATA_ABORT: - /* We should only arrive here with EC in {DATAABORT, INSNABORT}. */ ec = syn_get_ec(env->exception.syndrome); - assert(ec == EC_DATAABORT || ec == EC_INSNABORT); - - /* Both EC have the same format for FSC, or close enough. */ - fsc = extract32(env->exception.syndrome, 0, 6); - switch (fsc) { - case 0x04 ... 0x07: /* Translation fault, level {0-3} */ - si_code = TARGET_SEGV_MAPERR; + switch (ec) { + case EC_DATAABORT: + case EC_INSNABORT: + /* Both EC have the same format for FSC, or close enough. */ + fsc = extract32(env->exception.syndrome, 0, 6); + switch (fsc) { + case 0x04 ... 0x07: /* Translation fault, level {0-3} */ + si_sig = TARGET_SIGSEGV; + si_code = TARGET_SEGV_MAPERR; + break; + case 0x09 ... 0x0b: /* Access flag fault, level {1-3} */ + case 0x0d ... 0x0f: /* Permission fault, level {1-3} */ + si_sig = TARGET_SIGSEGV; + si_code = TARGET_SEGV_ACCERR; + break; + case 0x11: /* Synchronous Tag Check Fault */ + si_sig = TARGET_SIGSEGV; + si_code = TARGET_SEGV_MTESERR; + break; + default: + g_assert_not_reached(); + } break; - case 0x09 ... 0x0b: /* Access flag fault, level {1-3} */ - case 0x0d ... 0x0f: /* Permission fault, level {1-3} */ - si_code = TARGET_SEGV_ACCERR; - break; - case 0x11: /* Synchronous Tag Check Fault */ - si_code = TARGET_SEGV_MTESERR; + case EC_PCALIGNMENT: + si_sig = TARGET_SIGBUS; + si_code = TARGET_BUS_ADRALN; break; default: g_assert_not_reached(); } - - force_sig_fault(TARGET_SIGSEGV, si_code, env->exception.vaddress); + force_sig_fault(si_sig, si_code, env->exception.vaddress); break; case EXCP_DEBUG: case EXCP_BKPT: