From patchwork Tue Nov 2 11:06:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 516640 Delivered-To: patch@linaro.org Received: by 2002:ad5:5208:0:0:0:0:0 with SMTP id p8csp4407757iml; Tue, 2 Nov 2021 04:24:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwk0AKnd8S+/FwbZdt+JlP1rb+zU+WU++6yKXlsw1zrKFlbHm2q7JHfsrMwnGF3H7NpNAAR X-Received: by 2002:a9d:34c:: with SMTP id 70mr19776018otv.89.1635852279864; Tue, 02 Nov 2021 04:24:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635852279; cv=none; d=google.com; s=arc-20160816; b=DDF/khR/IFjrl76va8Vx7jg1OGQnTIR1hQP7XXoIfeSQY0WOAQaef0nJBsJ7JjtfFr 5zZSQsEStAkc9TKk2aEqEz90aemgAkkRpAAPJtLzfjlJboT12WQvXmfCJ0umHlzGDZJg J3bSRCHaeyXoqk1lf6H6PlU0IoTyOK5NBv8VqTpGnIU9cxAgiO2s1sxKW7hFgcc1Ueg6 02nLJ4nzaf9dcSVr2TsANkaU8+ikUQjsTN1y6kx31wcA51Bu+GACJBRv3SD0F+b/fsIc MbYlTrxt2ygUg7Qhajltw0xmW+Lw4UHr8ALBWGDgMoYrvo4QJgRGCnWIANsZOsKtOfU/ 3YCg== 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=09EXkfsXIChlE/LXOeHg30UK63IRh0uoWnU1yPu4O3s=; b=s4P1OALmzZ6EZpe2zY4UDB4J4PapuU+wdGBUxuK+dvYKaoz/s3WIOXucaeGS66sh6i /PPhp4toor03UEb0YQInfcRphYetNzV/1SRjhBHXv8Uc65lwE9PSzwbntPmA2XaMfPjV 4PATYz12htynbBdacJeFE+eAWPkLU1QSmB1joKByHq3t+Lapd7SN11CdxTiJOUHFl+M0 bztlIq7LM7twXh0XZYq7eXnUlBFPN3Pgzl6Iu/CSD5MVOZx56MHgQT2946nyO7PJZbNy uxxA8B5hGRR2IE/iJPreKHm4sb3AsvinRBiRyiqspILRKuWzxWtGqkpkD/7PpPTmB3T0 qLpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yv8JHmYl; 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 l14si18750999oth.332.2021.11.02.04.24.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Nov 2021 04:24:39 -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=yv8JHmYl; 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]:56962 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhruB-0005ew-6z for patch@linaro.org; Tue, 02 Nov 2021 07:24:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43198) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhrdz-0003jf-R2 for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:07:59 -0400 Received: from mail-qk1-x730.google.com ([2607:f8b0:4864:20::730]:33462) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrdt-0000sU-E9 for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:07:53 -0400 Received: by mail-qk1-x730.google.com with SMTP id p4so988131qkk.0 for ; Tue, 02 Nov 2021 04:07:48 -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=09EXkfsXIChlE/LXOeHg30UK63IRh0uoWnU1yPu4O3s=; b=yv8JHmYlFTvDXhygfBtED2Mbmufs2dOzX9Y1X9++1qoLODRNGvHjaZRf+TclBtwuKo oWh+u9hNUjzWZZNtPT3nwRbY7THvJYYPJQSxgNjVvx71hkr2oJPhpWcPfe4QJuM/iNEJ deXwVzlObhBPrky0vmRsoMdbj6iEuKk7cLfIk73FSBH3z83PtbvWf8ehVSRoIh+n22Cy l6ls2nlD9qemtlDw7n7HIKLEzoDSQJ9if9cZUZKr9tYJCZh+NfIw0xXLRZnl8n1CFDCq LmPoBfIXd7c5hIDHFepzyt9Fs0bjuxxdfGqHT8Xew5yn7gSdrVpsGx4/lAuqay6QP/4A BTEQ== 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=09EXkfsXIChlE/LXOeHg30UK63IRh0uoWnU1yPu4O3s=; b=Bi+oWTJwPj/H3fDZ5XW/NB2hIhbhwhndmKzjj5G49vOJY1fXhe897meLnaN6I/sf1j KEcIjVfsTHnhEB1Jcc1OIp8nWxIzubHhVtKaW1N+o7PLtq90D8Z3+v3ecXaJg1QgFJfY xi5LtqVOcrHOzcmZP/QDrx5BrXhuJ8LfuLUrawl6V5tOpbyqWdlDdoT1aiOPQLlRrzIf IF2ZC+iVXtsLrX9zRxKJBMynr8ATciwrzguE82RlS1IYlqFpSJ1VQT/8qebnkX1SciDF njgfhTVncjysR0KJl2XTPQymYxlxZEGIblxKp5SJgsE2Nv9kTPvoN+38NgLHQE9G0HLV e0Bg== X-Gm-Message-State: AOAM530ukHYMLc42OEQwhd+XoDK6QfNJf2Se41lXFrcRUDgQGsDqDmgf MKzLQV8vjgrLzHVYgLqVMRLfP/aPN58EQA== X-Received: by 2002:a37:2e03:: with SMTP id u3mr28505172qkh.313.1635851267555; Tue, 02 Nov 2021 04:07:47 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm7sm3568612qkb.86.2021.11.02.04.07.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:07:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 10/60] linux-user/host/sparc: Populate host_signal.h Date: Tue, 2 Nov 2021 07:06:50 -0400 Message-Id: <20211102110740.215699-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::730; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x730.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Warner Losh Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Split host_signal_pc and host_signal_write out of user-exec.c. Drop the *BSD code, to be re-created under bsd-user/ later. Drop the Solaris code as completely unused. Reviewed-by: Warner Losh Signed-off-by: Richard Henderson --- linux-user/host/sparc/host-signal.h | 55 +++++++++++++++++++++++- linux-user/host/sparc64/host-signal.h | 2 +- accel/tcg/user-exec.c | 62 +-------------------------- 3 files changed, 56 insertions(+), 63 deletions(-) -- 2.25.1 diff --git a/linux-user/host/sparc/host-signal.h b/linux-user/host/sparc/host-signal.h index f4b4d65031..5e71d33f8e 100644 --- a/linux-user/host/sparc/host-signal.h +++ b/linux-user/host/sparc/host-signal.h @@ -1 +1,54 @@ -#define HOST_SIGNAL_PLACEHOLDER +/* + * host-signal.h: signal info dependent on the host architecture + * + * Copyright (c) 2003-2005 Fabrice Bellard + * Copyright (c) 2021 Linaro Limited + * + * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. + * See the COPYING file in the top-level directory. + */ + +#ifndef SPARC_HOST_SIGNAL_H +#define SPARC_HOST_SIGNAL_H + +static inline uintptr_t host_signal_pc(ucontext_t *uc) +{ +#ifdef __arch64__ + return uc->uc_mcontext.mc_gregs[MC_PC]; +#else + return uc->uc_mcontext.gregs[REG_PC]; +#endif +} + +static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) +{ + uint32_t insn = *(uint32_t *)host_signal_pc(uc); + + if ((insn >> 30) == 3) { + switch ((insn >> 19) & 0x3f) { + case 0x05: /* stb */ + case 0x15: /* stba */ + case 0x06: /* sth */ + case 0x16: /* stha */ + case 0x04: /* st */ + case 0x14: /* sta */ + case 0x07: /* std */ + case 0x17: /* stda */ + case 0x0e: /* stx */ + case 0x1e: /* stxa */ + case 0x24: /* stf */ + case 0x34: /* stfa */ + case 0x27: /* stdf */ + case 0x37: /* stdfa */ + case 0x26: /* stqf */ + case 0x36: /* stqfa */ + case 0x25: /* stfsr */ + case 0x3c: /* casa */ + case 0x3e: /* casxa */ + return true; + } + } + return false; +} + +#endif diff --git a/linux-user/host/sparc64/host-signal.h b/linux-user/host/sparc64/host-signal.h index f4b4d65031..1191fe2d40 100644 --- a/linux-user/host/sparc64/host-signal.h +++ b/linux-user/host/sparc64/host-signal.h @@ -1 +1 @@ -#define HOST_SIGNAL_PLACEHOLDER +#include "../sparc/host-signal.h" diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index e9b6eb696f..694eff7f04 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -253,67 +253,7 @@ void *probe_access(CPUArchState *env, target_ulong addr, int size, return size ? g2h(env_cpu(env), addr) : NULL; } -#if defined(__sparc__) - -int cpu_signal_handler(int host_signum, void *pinfo, - void *puc) -{ - siginfo_t *info = pinfo; - int is_write; - uint32_t insn; -#if !defined(__arch64__) || defined(CONFIG_SOLARIS) - uint32_t *regs = (uint32_t *)(info + 1); - void *sigmask = (regs + 20); - /* XXX: is there a standard glibc define ? */ - unsigned long pc = regs[1]; -#else -#ifdef __linux__ - struct sigcontext *sc = puc; - unsigned long pc = sc->sigc_regs.tpc; - void *sigmask = (void *)sc->sigc_mask; -#elif defined(__OpenBSD__) - struct sigcontext *uc = puc; - unsigned long pc = uc->sc_pc; - void *sigmask = (void *)(long)uc->sc_mask; -#elif defined(__NetBSD__) - ucontext_t *uc = puc; - unsigned long pc = _UC_MACHINE_PC(uc); - void *sigmask = (void *)&uc->uc_sigmask; -#endif -#endif - - /* XXX: need kernel patch to get write flag faster */ - is_write = 0; - insn = *(uint32_t *)pc; - if ((insn >> 30) == 3) { - switch ((insn >> 19) & 0x3f) { - case 0x05: /* stb */ - case 0x15: /* stba */ - case 0x06: /* sth */ - case 0x16: /* stha */ - case 0x04: /* st */ - case 0x14: /* sta */ - case 0x07: /* std */ - case 0x17: /* stda */ - case 0x0e: /* stx */ - case 0x1e: /* stxa */ - case 0x24: /* stf */ - case 0x34: /* stfa */ - case 0x27: /* stdf */ - case 0x37: /* stdfa */ - case 0x26: /* stqf */ - case 0x36: /* stqfa */ - case 0x25: /* stfsr */ - case 0x3c: /* casa */ - case 0x3e: /* casxa */ - is_write = 1; - break; - } - } - return handle_cpu_signal(pc, info, is_write, sigmask); -} - -#elif defined(__arm__) +#if defined(__arm__) #if defined(__NetBSD__) #include