From patchwork Sat Sep 18 18:44:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514217 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp665734jao; Sat, 18 Sep 2021 11:47:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNt8ClfHsl3GsQhOHtwD6oqCM0bWvBGhxwOTLpUXc6G7E90Iz5W24ljrZOmQhs5XM3ltYE X-Received: by 2002:ac8:7444:: with SMTP id h4mr16073994qtr.337.1631990877829; Sat, 18 Sep 2021 11:47:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631990877; cv=none; d=google.com; s=arc-20160816; b=SAp/nFL85ZG7oz/vOwL03Cy2f7jf9Fdi/Qi1jgF/soXYyh1ms2jAmokksDdXAny3iq SFxH7qquSNn67P59+kexBw5WfwtHQCh5RFKsMBaDpwzRhe0lRbmElFpZViNks7w6i0+B hoVGgPhxzzke9SZ1NkHfyjm2W1/VPeV54Z3Zn7ShC34XLrCL99t3Noso2SpveujWca01 K+tpVFu5fgMPV6Y2m08pfvpqhv4eotc74WJ62oy/a9r4YHxR15FvgYlc/qD7MkwDf6pZ gcExq5AO1RvoTvRxAfK7pbIawuDN7+3YNY6RKW2susG1Y/zzGpkdLwwvk2bDww+tNF1o 1HdA== 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=QHZIGAsKEZU6jgHWjM6GlNTI+lnbqqDGKIT8+9oO0ok=; b=hskcf2w23fT+QbsLGbCjTNZ8g/nGxApQj/pjk1Nd3ERexp4mzRCMZIraodaNEKQqN8 xnp0F5TGtpKB+f5fgZnDljH3a31qQXQT/h6jIRJDjYYJddVDl2ycxh7/E6Bp9GjqWmsr p9qFVaOfm+3lr/Rf+z9dU/+DB4hwPAZdHnktZgE4HqyRO5fkIEyHOIKjspiWfIePBggH M0YLErkxV71gfTHdUEUpfO51h29ThCoqC9UC4CHUhUDlH2pyQSMGEsWSEJ9bU8zcAbp8 iy/CCpZ+6Va36KkBw0bBkuNuNgO/1BLYhRg9j5x90nan9oltgF1hqU9FEdj2rosIo1gw gpGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ZM8Xb/Rp"; 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 a9si5403780qtb.125.2021.09.18.11.47.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 18 Sep 2021 11:47:57 -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="ZM8Xb/Rp"; 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]:36008 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mRfNV-00055F-Az for patch@linaro.org; Sat, 18 Sep 2021 14:47:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54196) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mRfLK-000526-I4 for qemu-devel@nongnu.org; Sat, 18 Sep 2021 14:45:42 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]:39759) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mRfLF-0006kj-CA for qemu-devel@nongnu.org; Sat, 18 Sep 2021 14:45:42 -0400 Received: by mail-pf1-x434.google.com with SMTP id e16so12349759pfc.6 for ; Sat, 18 Sep 2021 11:45:36 -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=QHZIGAsKEZU6jgHWjM6GlNTI+lnbqqDGKIT8+9oO0ok=; b=ZM8Xb/RpdDj0khlx1dZap2im91hAMNYzu9BK6Uh1BWQdI91zWGTyKSNDTCbhBVuQmH WOMJqc02oCVqa7r7LlMZvQhERia/1iS5ZtrV1UV40Qp6Gnl+OozQOshRGUBoREQU6P+3 oAdZt3eNG8g7D1MekBqtpn9WI9+6mcZsdxpj2s7xKXg9ZBpD95vgvCtr8TfJUaVIgVDW 7qMTa1Hv2eAy6WUYZ8SAb5+ncwANgYl1Ejeo4MjME6Bd8SYvNM/Z+RMyVVK/x0AuT/aX zrk0L+yb9Ul+NH6iVBiWQvWoYoZaIVbD656M6Xm0s8oGbfRFGj8OW26hW7vBpT3amcvC LRNA== 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=QHZIGAsKEZU6jgHWjM6GlNTI+lnbqqDGKIT8+9oO0ok=; b=ER3QTWhoPQCy+5os0C75EYPow4r2ax4VZ36jAKsswK4eduqOSCGlekCaYOyZO21cTz 5NgWgIW6lVd3cw4bt7Lda35ivyf2oQlLUw6PYR7lEvyJfkwUZQZNhRqblCfjVGKAb06/ FipvI0ttyPv98INlbP7tta9UsZH1FE9o4qLh0zakVJJFRf0t++NUCDEC7koD7MkjGdbn LQLor8qne6XxlFhH1b+2dPmpNqnjHkvoWVDhyWOPRdJvWmTgJr4sFZ1uTnRPBBIWxVoO 0XIPSJUX80n1TTTcRnQR5Eduh+i3oC5/vV3xCkqNRinJWJp+ky6Q7V+d/7EEVbRY0517 zi/A== X-Gm-Message-State: AOAM531WEfsKmT3kt9gCaao6CwkZSxS3HEsLywioWSHJfr+BptPT6D0M 5H1ReTtqnJ25p3Q2NPKvHZm73biS4ZYe1A== X-Received: by 2002:a63:155d:: with SMTP id 29mr15965269pgv.118.1631990736018; Sat, 18 Sep 2021 11:45:36 -0700 (PDT) Received: from localhost.localdomain ([71.212.134.125]) by smtp.gmail.com with ESMTPSA id y26sm9555858pfe.69.2021.09.18.11.45.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Sep 2021 11:45:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 08/41] linux-user/host/ppc: Populate host_signal.h Date: Sat, 18 Sep 2021 11:44:54 -0700 Message-Id: <20210918184527.408540-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210918184527.408540-1-richard.henderson@linaro.org> References: <20210918184527.408540-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x434.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: , Cc: laurent@vivier.eu 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. Signed-off-by: Richard Henderson --- linux-user/host/ppc/host-signal.h | 25 ++++++++- linux-user/host/ppc64/host-signal.h | 2 +- accel/tcg/user-exec.c | 79 +---------------------------- 3 files changed, 26 insertions(+), 80 deletions(-) -- 2.25.1 Reviewed-by: Warner Losh diff --git a/linux-user/host/ppc/host-signal.h b/linux-user/host/ppc/host-signal.h index f4b4d65031..e09756c691 100644 --- a/linux-user/host/ppc/host-signal.h +++ b/linux-user/host/ppc/host-signal.h @@ -1 +1,24 @@ -#define HOST_SIGNAL_PLACEHOLDER +/* + * host-signal.h: signal info dependent on the host architecture + * + * Copyright (C) 2021 Linaro Limited + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#ifndef PPC_HOST_SIGNAL_H +#define PPC_HOST_SIGNAL_H + +static inline uintptr_t host_signal_pc(ucontext_t *uc) +{ + return uc->uc_mcontext.regs->nip; +} + +static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) +{ + return uc->uc_mcontext.regs->trap != 0x400 + && (uc->uc_mcontext.regs->dsisr & 0x02000000); +} + +#endif diff --git a/linux-user/host/ppc64/host-signal.h b/linux-user/host/ppc64/host-signal.h index f4b4d65031..a353c22a90 100644 --- a/linux-user/host/ppc64/host-signal.h +++ b/linux-user/host/ppc64/host-signal.h @@ -1 +1 @@ -#define HOST_SIGNAL_PLACEHOLDER +#include "../ppc/host-signal.h" diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index b5d06183db..e9e530e2e1 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -255,84 +255,7 @@ void *probe_access(CPUArchState *env, target_ulong addr, int size, return size ? g2h(env_cpu(env), addr) : NULL; } -#if defined(_ARCH_PPC) - -/*********************************************************************** - * signal context platform-specific definitions - * From Wine - */ -#ifdef linux -/* All Registers access - only for local access */ -#define REG_sig(reg_name, context) \ - ((context)->uc_mcontext.regs->reg_name) -/* Gpr Registers access */ -#define GPR_sig(reg_num, context) REG_sig(gpr[reg_num], context) -/* Program counter */ -#define IAR_sig(context) REG_sig(nip, context) -/* Machine State Register (Supervisor) */ -#define MSR_sig(context) REG_sig(msr, context) -/* Count register */ -#define CTR_sig(context) REG_sig(ctr, context) -/* User's integer exception register */ -#define XER_sig(context) REG_sig(xer, context) -/* Link register */ -#define LR_sig(context) REG_sig(link, context) -/* Condition register */ -#define CR_sig(context) REG_sig(ccr, context) - -/* Float Registers access */ -#define FLOAT_sig(reg_num, context) \ - (((double *)((char *)((context)->uc_mcontext.regs + 48 * 4)))[reg_num]) -#define FPSCR_sig(context) \ - (*(int *)((char *)((context)->uc_mcontext.regs + (48 + 32 * 2) * 4))) -/* Exception Registers access */ -#define DAR_sig(context) REG_sig(dar, context) -#define DSISR_sig(context) REG_sig(dsisr, context) -#define TRAP_sig(context) REG_sig(trap, context) -#endif /* linux */ - -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) -#include -#define IAR_sig(context) ((context)->uc_mcontext.mc_srr0) -#define MSR_sig(context) ((context)->uc_mcontext.mc_srr1) -#define CTR_sig(context) ((context)->uc_mcontext.mc_ctr) -#define XER_sig(context) ((context)->uc_mcontext.mc_xer) -#define LR_sig(context) ((context)->uc_mcontext.mc_lr) -#define CR_sig(context) ((context)->uc_mcontext.mc_cr) -/* Exception Registers access */ -#define DAR_sig(context) ((context)->uc_mcontext.mc_dar) -#define DSISR_sig(context) ((context)->uc_mcontext.mc_dsisr) -#define TRAP_sig(context) ((context)->uc_mcontext.mc_exc) -#endif /* __FreeBSD__|| __FreeBSD_kernel__ */ - -int cpu_signal_handler(int host_signum, void *pinfo, - void *puc) -{ - siginfo_t *info = pinfo; -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) - ucontext_t *uc = puc; -#else - ucontext_t *uc = puc; -#endif - unsigned long pc; - int is_write; - - pc = IAR_sig(uc); - is_write = 0; -#if 0 - /* ppc 4xx case */ - if (DSISR_sig(uc) & 0x00800000) { - is_write = 1; - } -#else - if (TRAP_sig(uc) != 0x400 && (DSISR_sig(uc) & 0x02000000)) { - is_write = 1; - } -#endif - return handle_cpu_signal(pc, info, is_write, &uc->uc_sigmask); -} - -#elif defined(__alpha__) +#if defined(__alpha__) int cpu_signal_handler(int host_signum, void *pinfo, void *puc)