From patchwork Wed Aug 18 19:19:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 498977 Delivered-To: patch@linaro.org Received: by 2002:a02:6f15:0:0:0:0:0 with SMTP id x21csp1001601jab; Wed, 18 Aug 2021 13:14:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxtSAUu4kiVzMzEMyZY17BSfK8LpVnd3HiBX93OiPEFhBg/dzKI6zbTxVsWS5pzrX2tKLUi X-Received: by 2002:a67:c988:: with SMTP id y8mr9737203vsk.46.1629317645769; Wed, 18 Aug 2021 13:14:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629317645; cv=none; d=google.com; s=arc-20160816; b=ogu8nGDcOzJBXKXmdpNsEhJ+nZYtE0GZnMCDzukYBJWJRxbPFtCTNOxvyi2UX3Udma SpGr9B2SxfpMOV8DaKv7/8oq5yOheY7E+qvYi/35sEiiQYqXeFkrwoSnvIdsxWUQFMEm D0YrlyqWhbM7WzfuuUoxYho16EPEpNMNRpTxIt/90JWQlrgyuSltXkdNOQNfJbr2qI6B 4Kfc43J9aC+Ew506Bs7cbLwWJm4VfPu0sjJQBk+T5fvsK+1ocdmjvC3S/7+chMRsBue8 wLARUS5LcCgtsZ1+m9cmQZGI0ScNxZxYyBPyfnX6U7XeYu/ykbZ6DbTr37/w7U74i1y8 MMrg== 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=9A8Rj2dWBZVd/2qEoygNTQVafGJWurEIjdRl4wrHP1s=; b=mIWWH5fCgE5tBnol00u3b6hsKK93UU07//H7v6y+aZATjy+8aMYHqoTlS4VIlxbI0o Ht2Yjtc+Kv2dyfwba3nCvSsFs7909esSRvdGzHA89a7CXeMLUm0G8LjRzR16wi1Er7Yj tITGRG9949TJxJJTTBXLtFPzeE4SYAE+K3rnNAsEyKoEoRRlQTpYk4ZF99/Tf37HySod jxplxTqlSB1hhzTIUMFcgsUE7ykNcZD7zcHe8DR0k6iJi8bJKC1u7ncnzsfZvLh+eWs8 3d1SjM7ikhkCOIvtIsYwvRsZVJfkqceuDwmBx0GMBfvjYZrbtJnwKVDXw6n20uk82swa cFGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yekeMA7Z; 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 r5si832708uan.66.2021.08.18.13.14.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 18 Aug 2021 13:14:05 -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=yekeMA7Z; 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]:53128 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mGRwr-0007JP-4n for patch@linaro.org; Wed, 18 Aug 2021 16:14:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59038) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGRA5-0008Dw-Mx for qemu-devel@nongnu.org; Wed, 18 Aug 2021 15:23:41 -0400 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]:35361) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mGRA4-0002vO-7n for qemu-devel@nongnu.org; Wed, 18 Aug 2021 15:23:41 -0400 Received: by mail-pg1-x52d.google.com with SMTP id e7so3313885pgk.2 for ; Wed, 18 Aug 2021 12:23:39 -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=9A8Rj2dWBZVd/2qEoygNTQVafGJWurEIjdRl4wrHP1s=; b=yekeMA7ZtZDWcv77lwhURJQETKJViGSmmZTT08QAQ4Lmz8Ur6WLqcRB6X6wTcR3E1E Tf4hSCr8/CFM013izNKkp4xxapJMoDkDITIyrGqyb59/23pgXrcKAAO4sbJOAR5zQz/r xYIzEkQsd53VswfSlzqmn+INsNdcyg+qfhhVxeLyheZEMrPOQD+Y/Ft1CBfmrBlwSNHy ol2rMx5Re3VXKL2QYQVv2uiPpmAnC/IcVWCVPobjc0kuilE+8POJbM7aJC7wzHMi4J9x n09+HZQ1zVsXmkNjy6i7VOTv4TjETF+XA4mTS5Shh457AdYgb7MZfqefuh17r9pzUazh 3BqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9A8Rj2dWBZVd/2qEoygNTQVafGJWurEIjdRl4wrHP1s=; b=oS00j5u0apoJXLQzUqVz/Bc4wAHEtl8IjVeBsVtMsioTxoc+OLnDIlBuUHZxO/Buhf 6bv6JbmOmGOmUATtuZnGz+TqNpm1R/qpVJXZQQZIhyrCG948d1z1DoONyC4IULYrJkfz pFAbo0Hb9WuyPTlGH4PCh2pwnsdxAGi1eGiFP6zvPzp5JQM6FyesD+Spkw3ZUeLN+gav 9oF/UvWnc7vgoCgi3D92XwHcJXLI/zRjr1rFaEq9OFNbDop1AuxTO9LdQNmQE2+UPxlL 1fkLZTAgxBHKl1KWEocfS4hL1ciqKOIa8OSE5hTj1x9/G3wNeOrKng3DtUSzDTWMEPJo g35g== X-Gm-Message-State: AOAM533cgboekF++178kH675/1GhlIUU4anGbfMh2uaK5N3RuEnnGYq2 ewqWEFTjwa0WDRWl0jG/4dgO9OWZ9BKMJw== X-Received: by 2002:a62:1ad2:0:b029:3e0:7eb7:a6bd with SMTP id a201-20020a621ad20000b02903e07eb7a6bdmr11058139pfa.51.1629314618973; Wed, 18 Aug 2021 12:23:38 -0700 (PDT) Received: from localhost.localdomain ([173.197.107.15]) by smtp.gmail.com with ESMTPSA id w82sm569302pff.112.2021.08.18.12.23.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 12:23:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 63/66] tcg/tci: Support raising sigbus for user-only Date: Wed, 18 Aug 2021 09:19:17 -1000 Message-Id: <20210818191920.390759-64-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210818191920.390759-1-richard.henderson@linaro.org> References: <20210818191920.390759-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52d; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52d.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 | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) -- 2.25.1 diff --git a/tcg/tci.c b/tcg/tci.c index e76087ccac..985c8a91cb 100644 --- a/tcg/tci.c +++ b/tcg/tci.c @@ -296,7 +296,7 @@ static uint64_t tci_qemu_ld(CPUArchState *env, target_ulong taddr, 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;