From patchwork Fri Apr 22 16:52:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 564898 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp702835map; Fri, 22 Apr 2022 10:55:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAanAmCOYw8uAfbyRHZlKXWABXrQknk1BXG+LCSoJj7GPEiLIxPUsEytDpHvlZi+KdyDfX X-Received: by 2002:a05:620a:2401:b0:69f:c66:10d2 with SMTP id d1-20020a05620a240100b0069f0c6610d2mr3429789qkn.229.1650650100872; Fri, 22 Apr 2022 10:55:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650650100; cv=none; d=google.com; s=arc-20160816; b=QAa5qUWRbziwVd0qMlXqn9iaNg+EBxAwfr6z/ECxQZYNcaYB2yKPp8DsscviRlmmB2 zQagydml/gFLQVMEHbJyEGxAzmJPIdQrI7omgWASeaTiUG8m3lOaz7cg4GsOplVLtzMQ yTPgfMGJZnEwBWZuSY+A9G95bE6EXSgDLpWc5oiWA3anBfwzxgZw2slA2U/kMXTETlcK gmv/K1YaRs6qvRIbZO/WNfMxIWoV4zkIiQ10qpM4sMZhDCDVIfw4n8P78u6ci74ReZow 6BeRZYg9fc/OzwkWyaEID7Cdq2Sixo9mi/o7fbrtJhTDUTRI0MXsZuOXhuFj3LVYYXos b47Q== 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=SrtdhebFHwQH2QuEUcsrlEhP5p9ppqhl2VFXayXosos=; b=sy5/trvCbTfrsJpTH6hiONGMnVpIGtLGsOCvsKgA1JnCvw6mbTb+2U8bY3JtsPWcX+ SGJGYC7cH1KElbQP862vPo33c97T9jvE5dc31jTokNKfeVXZ8UHMdEXVVccQr9eU4+47 7e83fnwh89xloQyIij+msgN9Zl23wR1jj6gyccPqqrVONaSk143w5vsD3J+KUk2Mfx+Q k3hAs7KS8ey75jSeJYu668GOBDkc09EcbsL+fziHO/pb9oege4R/NhgnU9gy1+oYrFS4 O8oiPY4gZOPgn4DABL9KmjSomqI2quy8tXxeIHVBoLQZ0USyYD42CwEqBkltayVAC3+v MjRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=y9eTBHoS; 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 x1-20020a05620a448100b0069c3a8852e4si2348245qkp.716.2022.04.22.10.55.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Apr 2022 10:55:00 -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=pass header.i=@linaro.org header.s=google header.b=y9eTBHoS; 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]:43916 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhxUi-0000Y1-FR for patch@linaro.org; Fri, 22 Apr 2022 13:55:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50062) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhwap-0000Ba-8n for qemu-devel@nongnu.org; Fri, 22 Apr 2022 12:57:15 -0400 Received: from mail-io1-xd32.google.com ([2607:f8b0:4864:20::d32]:43551) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhwan-00080k-Qx for qemu-devel@nongnu.org; Fri, 22 Apr 2022 12:57:15 -0400 Received: by mail-io1-xd32.google.com with SMTP id 125so9208607iov.10 for ; Fri, 22 Apr 2022 09:57:13 -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=SrtdhebFHwQH2QuEUcsrlEhP5p9ppqhl2VFXayXosos=; b=y9eTBHoSCvquzFsYyBFaTw+jHR3RuZ0KwdgRBHWmRgoYX4osFZe5aiXGU0JJVoLtq6 lAWqbRBZmd9dDz3+ej6Uq4K50Rpsx1HrW/esjj96RlX6wd4l9m6wVbuTMovlKbNqLtc/ 1icjiQE1+GRZL9xM0iebQFAhtcGQU49FGjer3QVz49CcSDJilOGrWWpH3KzlWBC/0+Ww JZo4EFolCFJmEkQtHa+PzyGFvFt0ugdknZjFiI7vmMvHJaEOOGlXtOk2RjVkSn815qv3 HW32bj6Zya88KPJGhoOBis9ZrrVGttkeDFYkfxy0nrmY6BETxgj27htyaNuxr+a0l/PS 2yGw== 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=SrtdhebFHwQH2QuEUcsrlEhP5p9ppqhl2VFXayXosos=; b=QskHlZ9a204raJj5iTjwkpdU6hmyfovONvVvY0lc2eUG4YIm9WPb2t//Lzv5kuhRDr SrX2phrS/tzoRj6sKzhPLPoO6yp5AuXfibwPOGink/ZoSxkYPLHtXpHHQr7WmFepeUTA AE4Vq5oH/y9RCw3WGhArdy1gvJcGLYcUZm6aqhFSXUX2fJk/gWVyNbegcINcP92epOSF HRckSr9Oh5PHMwr+J/XW4UkK3aPr9DxOpDSGDLzoYtoPz1WF0PDOz4ZV3rDupzkmiRGY 4h5qoAJYO+YbzUubqO3u2RHuShHWgdsydsVCwf0tasahWutYiYUdDi1E9OY/HUngm6/C GcJw== X-Gm-Message-State: AOAM531KyRGDoyIhJowcES2cYaQ4OwfjSSM21eUmuK/F+gdrVr9dIeis 5ZoWSLPZyVxHwdLnHDzhCHOisyXhyTKcHm0L X-Received: by 2002:a02:9999:0:b0:314:4a83:ac2e with SMTP id a25-20020a029999000000b003144a83ac2emr2423197jal.37.1650646632954; Fri, 22 Apr 2022 09:57:12 -0700 (PDT) Received: from stoup.. ([2607:fb90:27d0:b0f2:934d:3e2:9f8c:dd1]) by smtp.gmail.com with ESMTPSA id n23-20020a6b8b17000000b00649a2634725sm816380iod.17.2022.04.22.09.57.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 09:57:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v8 51/68] target/nios2: Enable unaligned traps for system mode Date: Fri, 22 Apr 2022 09:52:21 -0700 Message-Id: <20220422165238.1971496-52-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220422165238.1971496-1-richard.henderson@linaro.org> References: <20220422165238.1971496-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::d32; envelope-from=richard.henderson@linaro.org; helo=mail-io1-xd32.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Cc: Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Unaligned traps are optional, but required with an mmu. Turn them on always, because the fallback behaviour undefined. Enable alignment checks in the config file. Unwind the guest pc properly from do_unaligned_access. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-Id: <20220421151735.31996-48-richard.henderson@linaro.org> --- target/nios2/helper.c | 4 ++-- configs/targets/nios2-softmmu.mak | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/target/nios2/helper.c b/target/nios2/helper.c index c5a2dd65b1..2e9fea4a01 100644 --- a/target/nios2/helper.c +++ b/target/nios2/helper.c @@ -241,8 +241,8 @@ void nios2_cpu_do_unaligned_access(CPUState *cs, vaddr addr, CPUNios2State *env = &cpu->env; env->ctrl[CR_BADADDR] = addr; - env->ctrl[CR_EXCEPTION] = FIELD_DP32(0, CR_EXCEPTION, CAUSE, EXCP_UNALIGN); - helper_raise_exception(env, EXCP_UNALIGN); + cs->exception_index = EXCP_UNALIGN; + cpu_loop_exit_restore(cs, retaddr); } bool nios2_cpu_tlb_fill(CPUState *cs, vaddr address, int size, diff --git a/configs/targets/nios2-softmmu.mak b/configs/targets/nios2-softmmu.mak index 9a372f0717..1e93b54cd1 100644 --- a/configs/targets/nios2-softmmu.mak +++ b/configs/targets/nios2-softmmu.mak @@ -1 +1,2 @@ TARGET_ARCH=nios2 +TARGET_ALIGNED_ONLY=y