From patchwork Fri Feb 11 01:30:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 541755 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp2710572imo; Thu, 10 Feb 2022 17:48:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJxv85PnBxyeBn45HLnMmGF3yESfSp38LEwq5CU5vkF3TcERZZIBTwAI8/t/h3rJ2qLk0sGl X-Received: by 2002:a25:d53:: with SMTP id 80mr9710079ybn.165.1644544135156; Thu, 10 Feb 2022 17:48:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644544135; cv=none; d=google.com; s=arc-20160816; b=KTqVbG/pHBZjwLMbTWNh38izAEb5zvd4HWFdEZqcX/bQJqaDl+7yJst6qGbNsWJM2i c9gw/GlKyndnPULa+qJ2yR82IuhKw56613d6BCinFxDLffWDDhTlVcIt96bj/rV+ZEm5 /EL4pjXGmPeAWU6MVhZ6LFdh6edAn3DWC4E05hPU+ABFdfn+XjcsCq46JaWi/lDQ+7tJ uTCeVyU4MulJLjkFOYpgYN9xYL5YeyUkfViAKijIHVXx1KXSAQGavh1mZ9cGqPCp1Lso 3NnD4MjNy9QXuEOpmmQCkfSCNGuwX4CNGkYImO5mdGwL9nsU7huzx/hZWxJTe6HPpYBl ATZQ== 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=eqQZpXDeCV1SzzmmGSe5uysSf0Qll8u+UkCjmQOI+nE=; b=bZwLCWh1LO65FPkFer9qshx+bPvSMOHemt8XR8l4k03AvzWKazD8zz5/CxBOstmYeA T1OrjRCyQ4wcaYlD+UTiS3+x/9yWnaeRn8PxZbFDPKbnWR6zfntfJKKXSyThe2+gDUzj QbBUh2UnjyN4fyhJCDMklQyv/8/dtxElaC5XhW6sB/GI0+NdtreQKGd1Xa6SRh4zrRdY qVAxXLDzWSsxIqwAMC17GG3NBPzRN0ofEmWXqguabrFcB5Gqzt8+F+zGCZU7lkP9AJpW QQgxcEHm/9G9TqnIlsghiQY9h7Rn8zDloLjDo/9es4ocMksnzKgNT3EIjbqLWnOWCuP3 iqUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oCjlMNx4; 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 c72si10311226ywa.179.2022.02.10.17.48.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Feb 2022 17:48:55 -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=oCjlMNx4; 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]:43766 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nIL3O-0005Q6-JV for patch@linaro.org; Thu, 10 Feb 2022 20:48:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38742) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIKnK-00049t-8c for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:32:18 -0500 Received: from [2607:f8b0:4864:20::631] (port=45601 helo=mail-pl1-x631.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIKnG-0007PQ-0c for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:32:15 -0500 Received: by mail-pl1-x631.google.com with SMTP id w20so3391846plq.12 for ; Thu, 10 Feb 2022 17:32:13 -0800 (PST) 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=eqQZpXDeCV1SzzmmGSe5uysSf0Qll8u+UkCjmQOI+nE=; b=oCjlMNx4fPvaMHkeF8P5Dbv7pEihIBintUIYvJYwXoSddqFaEut8YlWwKjki7CxnAT iNm9hnzxFwPgEOtDmJ5hDjL1tZXwSNvzBkD4NYd3awxmbXzjf7/I5mM4e6BFX5uHs0oT aIkr+Mx5n2vqSPQfUay1T9C9SDO6xp1l8alxCWPi/DzQ3WWDL6t4VQGvLJFa953D8ejx YWOkVX/r3L/L5Lt5cCTu+shVSKUWxxul219QKphmWnzkItjT8XLB5SOYo246UdMyVzHn 88w6BR2KHgnXohBgYSUETUOa6iliB0PahEaGunQII5uDk+1fob8Qwmge3DEA0nEG2npL LRXg== 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=eqQZpXDeCV1SzzmmGSe5uysSf0Qll8u+UkCjmQOI+nE=; b=Ypwj/s0LeZpvoSt4RbCOd2xlV/ouM9mKqGT4ABdfu9lOzKusvkfjBLKm8q1eG6ysPd W9FNsb4G4GheXv71lAsTDGKc8eO8Za4woscOASfxA1CVFeQH9SG4y4FKXJeCu9WX/a6c 8E4Oq/EdvyFLc86ZRAyhBaZgT9Qi2Xr40srr8HV14ofxjzRiPQRQ6IIuRiWMH2Vpma75 SXolzAdE7VsocGPsSQv5sgnjMFmGK+Blc+EW25vsd0b+ww4pb9lP+tpBWMPGl77b3IhB EubTchwwcE+QxjYfcvu/d/y8BSd6iIg8Z34OM5+mt54lm85q3xbYRI2o10zkM4rfcDWb tKVA== X-Gm-Message-State: AOAM5332qzIgDlQx1Ag/g2MsxAE6GIyFiw9ccOs4Lx79Kha4HAwFHZv+ wGu7VEQXjurGIvXEvVoGwyI9Y+drm6Ith/8P X-Received: by 2002:a17:90b:707:: with SMTP id s7mr198320pjz.99.1644543132735; Thu, 10 Feb 2022 17:32:12 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id h5sm25738788pfi.111.2022.02.10.17.32.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 17:32:12 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 15/34] tcg/tci: Support raising sigbus for user-only Date: Fri, 11 Feb 2022 12:30:40 +1100 Message-Id: <20220211013059.17994-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220211013059.17994-1-richard.henderson@linaro.org> References: <20220211013059.17994-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::631 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Cc: peter.maydell@linaro.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/tci.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/tcg/tci.c b/tcg/tci.c index 336af5945a..fe92b5d084 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;