From patchwork Wed Oct 13 02:46:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 515712 Delivered-To: patch@linaro.org Received: by 2002:ac0:b5cc:0:0:0:0:0 with SMTP id x12csp6097584ime; Tue, 12 Oct 2021 20:18:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWAyWmfqal5l2Np+26MeFTW0v/iEMu3pFBHV4Qux1OjnyEs8jWw4e3S5YVGgD75yNs5u+F X-Received: by 2002:a37:2f02:: with SMTP id v2mr22502653qkh.232.1634095130070; Tue, 12 Oct 2021 20:18:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634095130; cv=none; d=google.com; s=arc-20160816; b=0x4CLFFaJ2xWVooBWv83fv78zEFv9X3/r6AHM0etznHWCQeTRp362o/A89PKHWZDld wd3lv8vONw4RlU8MrZWenx2u9yCdCEjVVu0lDJBcpVhYOTj76rBOf0QPuNP9r/oXWbkv gwaFlZiAYjbOQ9tjVds+7KortMqOHgBfrIfyV9Zlgoqi9lEKJ+Car7v2P4FqHOJxSwFB 2F9Z9tCraS46LXVySrDcSNFHWeiVnTGjKjT9r/y96EwfhuHwkAEGkqatHg2D5AjVckMA 3D5In1xvKjkFqt83n3NVUlR80jxzhzflV1tYBrNfdMfKp38kSg1XAiCTUJ/WMJRAdYLN A1Ww== 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=g06UIpFMVvSvANx+Qg+u743yK9fN9ISDaQhh0blxyhQ=; b=EAtBrZlSf0m3ucPrnWjSUR7vFO/Bbxq10IJiP1hq41mIBiFYRR58/9QzctEDr5lXKM xcd420REJY2IsMccGjBD+pVO6DQYYFz0S0+mHeXQplSvyb7ZGOQ/MjPWpNifPPB77PmJ I5clz3oq9JcvvJMrgy5e2DHdqTe0jOFeXQ/7wCHZC73ZkV7O8zQ+dqL0mCBgJ/9ksOnL blqhEwhwSQdiIBH1rz4whGNhtwRJ7lYqz87UeEWjXBEU6mMa8EOGlCVJiGgmOBLpof76 zHvNEBsUak5EmlbadB+V5WTcv8BfvfKCmrP8fmwHBDZ6siXuWFBk4Y2kqJla9W+ouUSP r07w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rWH2sNAy; 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 bm32si3438320qkb.309.2021.10.12.20.18.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Oct 2021 20:18:50 -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=rWH2sNAy; 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]:47372 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1maUn2-0008Oc-Vp for patch@linaro.org; Tue, 12 Oct 2021 23:18:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57564) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1maUL7-0005fW-EH for qemu-devel@nongnu.org; Tue, 12 Oct 2021 22:49:57 -0400 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]:40849) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1maUL5-0001Ak-HM for qemu-devel@nongnu.org; Tue, 12 Oct 2021 22:49:57 -0400 Received: by mail-pg1-x534.google.com with SMTP id q5so886992pgr.7 for ; Tue, 12 Oct 2021 19:49:55 -0700 (PDT) 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=g06UIpFMVvSvANx+Qg+u743yK9fN9ISDaQhh0blxyhQ=; b=rWH2sNAyl6VwARlJuXiYuEPh8vKbGXHX2PcFXHgVO5WrLk2aMnPqDoSXH3sLozgDTV bdHPlG8UrxrqZrfFXjKZ895GFx2bz6bUmmghH/UT1HmEwMA+fPwPhv9rZ1xbqYbw7uQf YL/1+tUkX6XSSxeNVQGVAYyB24CvNN1ToApMB6Vsw3setmpYseXYdUZY22BcYlx5sdlk GRSXjrZ36IxM2PM46BFMK1GQkNiO0LKbpY411lDKr+/F54ha+gGXaVvEtWA+j+DF7pPA jio/5+n7l8P0/w7lWFX5NRgi3mWrSTIew08OWXwRg2pXi7rVnOac///WcO0LkIk7vCJh hDug== 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=g06UIpFMVvSvANx+Qg+u743yK9fN9ISDaQhh0blxyhQ=; b=Shi5lcX9zhF8bUWfgyb1eoJZSGZZiHNAnND47wUtl1Dfe8W175/7bNvEJRPd80kEBZ iRGHopPxwRW4toBwE+s+gTzRGTpckcXG1nnJ6OH83LKqPab8IkFNEuzDO9NZhFAPCcur dkDzd3WSP2GCiB8MW3LoeZ86kb2rIWbKfSCyxhJOrRA89FRmntb2pknUNabPvxI7LTMM G5EHOmOFDL9d6310zUHnvcnqg4Tugp06L3qoY31dy1dV320PSXt8OqGuDq7wUwJvusGz zF+Et1O4iPNURFYrQu3ACipFNYHX4kuTZuOUr+g58F4EWP4b+NkRkTrCNISO1BL9Q3IO eO5Q== X-Gm-Message-State: AOAM533gJ5SVkZ1vAvyCnjkAlzHyZXS8UFdHCNSLH0gdjsagSHBaECyR FPr9Pff6BoiqFkrzNqjWLIUeAEsVbmrv2w== X-Received: by 2002:aa7:92d0:0:b0:44c:ab24:cce7 with SMTP id k16-20020aa792d0000000b0044cab24cce7mr35084278pfa.6.1634093394172; Tue, 12 Oct 2021 19:49:54 -0700 (PDT) Received: from localhost.localdomain ([71.212.134.125]) by smtp.gmail.com with ESMTPSA id y20sm12579610pfp.68.2021.10.12.19.49.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Oct 2021 19:49:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 46/48] tcg/tci: Support raising sigbus for user-only Date: Tue, 12 Oct 2021 19:46:05 -0700 Message-Id: <20211013024607.731881-47-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211013024607.731881-1-richard.henderson@linaro.org> References: <20211013024607.731881-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::534; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x534.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- tcg/tci.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) -- 2.25.1 diff --git a/tcg/tci.c b/tcg/tci.c index e76087ccac..92a7c81674 100644 --- a/tcg/tci.c +++ b/tcg/tci.c @@ -292,11 +292,11 @@ static bool tci_compare64(uint64_t u0, uint64_t u1, TCGCond condition) static uint64_t tci_qemu_ld(CPUArchState *env, target_ulong taddr, MemOpIdx oi, const void *tb_ptr) { - MemOp mop = get_memop(oi) & (MO_BSWAP | MO_SSIZE); + MemOp mop = get_memop(oi); uintptr_t ra = (uintptr_t)tb_ptr; #ifdef CONFIG_SOFTMMU - switch (mop) { + switch (mop & (MO_BSWAP | MO_SSIZE)) { case MO_UB: return helper_ret_ldub_mmu(env, taddr, oi, ra); case MO_SB: @@ -326,10 +326,14 @@ static uint64_t tci_qemu_ld(CPUArchState *env, target_ulong taddr, } #else void *haddr = g2h(env_cpu(env), taddr); + unsigned a_mask = (1u << get_alignment_bits(mop)) - 1; uint64_t ret; set_helper_retaddr(ra); - switch (mop) { + if (taddr & a_mask) { + helper_unaligned_ld(env, taddr); + } + switch (mop & (MO_BSWAP | MO_SSIZE)) { case MO_UB: ret = ldub_p(haddr); break; @@ -377,11 +381,11 @@ static uint64_t tci_qemu_ld(CPUArchState *env, target_ulong taddr, static void tci_qemu_st(CPUArchState *env, target_ulong taddr, uint64_t val, MemOpIdx oi, const void *tb_ptr) { - MemOp mop = get_memop(oi) & (MO_BSWAP | MO_SSIZE); + MemOp mop = get_memop(oi); uintptr_t ra = (uintptr_t)tb_ptr; #ifdef CONFIG_SOFTMMU - switch (mop) { + switch (mop & (MO_BSWAP | MO_SIZE)) { case MO_UB: helper_ret_stb_mmu(env, taddr, val, oi, ra); break; @@ -408,9 +412,13 @@ static void tci_qemu_st(CPUArchState *env, target_ulong taddr, uint64_t val, } #else void *haddr = g2h(env_cpu(env), taddr); + unsigned a_mask = (1u << get_alignment_bits(mop)) - 1; set_helper_retaddr(ra); - switch (mop) { + if (taddr & a_mask) { + helper_unaligned_st(env, taddr); + } + switch (mop & (MO_BSWAP | MO_SIZE)) { case MO_UB: stb_p(haddr, val); break;