From patchwork Fri Oct 15 04:09:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 515797 Delivered-To: patch@linaro.org Received: by 2002:ac0:da11:0:0:0:0:0 with SMTP id d17csp137962imi; Thu, 14 Oct 2021 21:22:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZPl+cE9zUE67Ly6osEmL0jGhSpnXnA9HOSFFhK2HRvLiDu1hFf1oBTHHsufKfAVa56QC/ X-Received: by 2002:a25:3046:: with SMTP id w67mr10373728ybw.134.1634271761026; Thu, 14 Oct 2021 21:22:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634271761; cv=none; d=google.com; s=arc-20160816; b=KlVgH2WUsTeboUfNxQFNC3FyP8I9aWYGL0x0rbev+92V9LF1wrp4zCYmAGtqWR4VJo /OvmYrREnsF3aE72HumX1qKLG4lsBQQ9Ck+Mn2Y1j3dfWwOMb5cyC/nC78iUGsUId5J5 60TVtIZr3j6Y6WFB0OIMDmx2342J69+Y788X1oszzaZGj9aqrjtXEFwEIkDSS3FINOM9 cZO0zVfH+inDvM63rjzLVzxBg6xbebCMHDfQ0YIenpJ2jhGn8EaIntZcGsDlsEjJQaY3 uY5hsLrKK31vDy6tLsL28loUq0rIucTE0J7plYmbGmnO38oe38sWt8yuzwWE7PEEG4kz /C9Q== 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=ZrcsdPFY+Q0/rnzaDekoblOXqp3EpRf37OahPazOQjQ=; b=PdIPx0jtq4V4sDQFYBOTUpCxMt5P/mdV2twJIkBawyAKQz+FkombZIQu/LUiBs2U6S eZUykrSe5tfW4Nd+boI2+Bagjg6EGacf2OohVDzQ/kWIDRRGZElk917dNpMMMxT4No/T Vqe1yv+3dahzpy8EF3IEfcZu/PEKmrnfh+oj5xdYOy4f/Q/AEiZvm+aSAzPkFuOGe/Yi TDnwHkA4TieszdS7Nc+l9e13CZAnkCWoO2T76O7Hy/sgw0dMTPzICNJU33nFoZbmrSyM /N1G17T38DDe5yL6dyIZ2E0/z/vb6b7T+JLSdQ0NwLGGp8YAdttgnZEk2Bj9k6rwLn79 EBPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=wSRtpghW; 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=fail (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 6si5309733ybv.165.2021.10.14.21.22.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Oct 2021 21:22:41 -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=fail header.i=@linaro.org header.s=google header.b=wSRtpghW; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:56944 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mbEjw-0004ax-AV for patch@linaro.org; Fri, 15 Oct 2021 00:22:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38828) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mbEYp-00076Z-H4 for qemu-devel@nongnu.org; Fri, 15 Oct 2021 00:11:11 -0400 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]:46880) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mbEYm-0000EK-6x for qemu-devel@nongnu.org; Fri, 15 Oct 2021 00:11:11 -0400 Received: by mail-pg1-x52a.google.com with SMTP id m21so7413683pgu.13 for ; Thu, 14 Oct 2021 21:11:07 -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=ZrcsdPFY+Q0/rnzaDekoblOXqp3EpRf37OahPazOQjQ=; b=wSRtpghWv6ADMw7WA93ruInRkipr+MT4xA5vd7hwX4lmo+Iz3j3s3MCucc9/JFySU8 pZn/QTW7A5tmyzJECOnYNrOeZYsEQhdnrCIJCAq/z/NPMJMKB/RcN5XclqxqTHFco/f6 +PizEJjQAESbY1XV0nlEMJVJrngQ3c0LUOdm9DLBo4eZo62KD2/ETF42poeqIBx+iBKB d54mSDPAOzaN+O4IWJhpGXN3zKyDTzr77D9efAlo/Ln24QBLFwnDGAl/EGHQeDhE5tOf PDGd45sgHk9JgP71teA6pF8Y1dybq60CaGaw6tqgaa1H1XM5UtJdbaIyOwxgigtV0rSW BE4A== 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=ZrcsdPFY+Q0/rnzaDekoblOXqp3EpRf37OahPazOQjQ=; b=pjdadSwf5lwcZ5NOTSgaADLqK18OLk5P7mWXum471yvfJ5/4loDoaBCCN2gqkcQlc3 7V9IYsyXvZDOATGy37u3HY25YsM3Rb0sMEC339quOUhvPu8EEFoduvsR7sp1mFqpXc6l aIknzlsCATrdSKy97mXB64QMt1a6s//06TsgQvJRWEuGMndt+p0BK83e6VP9rd2s8Z5L QBJkMRsibeNe6g1t9OnIb7A121beZIrgXX7IRH8mHA62LwyLWH2t/z3Sztg4L0Owfe4u dAMrUiHXYaTT1o17d+nz/SWw6Xa0M7EPoNcSg4Dx6FtmRPqY7TN/cd/i/aQk1dHtBo0J 8dyg== X-Gm-Message-State: AOAM533CsMf1m/K2kMRnpEkHD5sx3gQOTAO9r8li08oGZwO7bCXrqDuS pXYBv8v5XnVEt9J4qsCqCH2C9vzjIwJYPg== X-Received: by 2002:a63:36ca:: with SMTP id d193mr7262471pga.73.1634271066659; Thu, 14 Oct 2021 21:11:06 -0700 (PDT) Received: from localhost.localdomain ([71.212.134.125]) by smtp.gmail.com with ESMTPSA id me12sm5718006pjb.27.2021.10.14.21.11.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Oct 2021 21:11:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 13/67] linux-user/host/s390: Populate host_signal.h Date: Thu, 14 Oct 2021 21:09:59 -0700 Message-Id: <20211015041053.2769193-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211015041053.2769193-1-richard.henderson@linaro.org> References: <20211015041053.2769193-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52a; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52a.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: alex.bennee@linaro.org, laurent@vivier.eu, imp@bsdimp.com, =?utf-8?q?P?= =?utf-8?q?hilippe_Mathieu-Daud=C3=A9?= 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. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/host/s390/host-signal.h | 93 ++++++++++++++++++++++++++++- linux-user/host/s390x/host-signal.h | 2 +- accel/tcg/user-exec.c | 88 +-------------------------- 3 files changed, 94 insertions(+), 89 deletions(-) -- 2.25.1 diff --git a/linux-user/host/s390/host-signal.h b/linux-user/host/s390/host-signal.h index f4b4d65031..21f59b612a 100644 --- a/linux-user/host/s390/host-signal.h +++ b/linux-user/host/s390/host-signal.h @@ -1 +1,92 @@ -#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 S390_HOST_SIGNAL_H +#define S390_HOST_SIGNAL_H + +static inline uintptr_t host_signal_pc(ucontext_t *uc) +{ + return uc->uc_mcontext.psw.addr; +} + +static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) +{ + uint16_t *pinsn = (uint16_t *)host_signal_pc(uc); + + /* + * ??? On linux, the non-rt signal handler has 4 (!) arguments instead + * of the normal 2 arguments. The 4th argument contains the "Translation- + * Exception Identification for DAT Exceptions" from the hardware (aka + * "int_parm_long"), which does in fact contain the is_write value. + * The rt signal handler, as far as I can tell, does not give this value + * at all. Not that we could get to it from here even if it were. + * So fall back to parsing instructions. Treat read-modify-write ones as + * writes, which is not fully correct, but for tracking self-modifying code + * this is better than treating them as reads. Checking si_addr page flags + * might be a viable improvement, albeit a racy one. + */ + /* ??? This is not even close to complete. */ + switch (pinsn[0] >> 8) { + case 0x50: /* ST */ + case 0x42: /* STC */ + case 0x40: /* STH */ + case 0xba: /* CS */ + case 0xbb: /* CDS */ + return true; + case 0xc4: /* RIL format insns */ + switch (pinsn[0] & 0xf) { + case 0xf: /* STRL */ + case 0xb: /* STGRL */ + case 0x7: /* STHRL */ + return true; + } + break; + case 0xc8: /* SSF format insns */ + switch (pinsn[0] & 0xf) { + case 0x2: /* CSST */ + return true; + } + break; + case 0xe3: /* RXY format insns */ + switch (pinsn[2] & 0xff) { + case 0x50: /* STY */ + case 0x24: /* STG */ + case 0x72: /* STCY */ + case 0x70: /* STHY */ + case 0x8e: /* STPQ */ + case 0x3f: /* STRVH */ + case 0x3e: /* STRV */ + case 0x2f: /* STRVG */ + return true; + } + break; + case 0xeb: /* RSY format insns */ + switch (pinsn[2] & 0xff) { + case 0x14: /* CSY */ + case 0x30: /* CSG */ + case 0x31: /* CDSY */ + case 0x3e: /* CDSG */ + case 0xe4: /* LANG */ + case 0xe6: /* LAOG */ + case 0xe7: /* LAXG */ + case 0xe8: /* LAAG */ + case 0xea: /* LAALG */ + case 0xf4: /* LAN */ + case 0xf6: /* LAO */ + case 0xf7: /* LAX */ + case 0xfa: /* LAAL */ + case 0xf8: /* LAA */ + return true; + } + break; + } + return false; +} + +#endif diff --git a/linux-user/host/s390x/host-signal.h b/linux-user/host/s390x/host-signal.h index f4b4d65031..0e83f9358d 100644 --- a/linux-user/host/s390x/host-signal.h +++ b/linux-user/host/s390x/host-signal.h @@ -1 +1 @@ -#define HOST_SIGNAL_PLACEHOLDER +#include "../s390/host-signal.h" diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 0915eb7f95..bfd964b578 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -255,93 +255,7 @@ void *probe_access(CPUArchState *env, target_ulong addr, int size, return size ? g2h(env_cpu(env), addr) : NULL; } -#if defined(__s390__) - -int cpu_signal_handler(int host_signum, void *pinfo, - void *puc) -{ - siginfo_t *info = pinfo; - ucontext_t *uc = puc; - unsigned long pc; - uint16_t *pinsn; - int is_write = 0; - - pc = uc->uc_mcontext.psw.addr; - - /* - * ??? On linux, the non-rt signal handler has 4 (!) arguments instead - * of the normal 2 arguments. The 4th argument contains the "Translation- - * Exception Identification for DAT Exceptions" from the hardware (aka - * "int_parm_long"), which does in fact contain the is_write value. - * The rt signal handler, as far as I can tell, does not give this value - * at all. Not that we could get to it from here even if it were. - * So fall back to parsing instructions. Treat read-modify-write ones as - * writes, which is not fully correct, but for tracking self-modifying code - * this is better than treating them as reads. Checking si_addr page flags - * might be a viable improvement, albeit a racy one. - */ - /* ??? This is not even close to complete. */ - pinsn = (uint16_t *)pc; - switch (pinsn[0] >> 8) { - case 0x50: /* ST */ - case 0x42: /* STC */ - case 0x40: /* STH */ - case 0xba: /* CS */ - case 0xbb: /* CDS */ - is_write = 1; - break; - case 0xc4: /* RIL format insns */ - switch (pinsn[0] & 0xf) { - case 0xf: /* STRL */ - case 0xb: /* STGRL */ - case 0x7: /* STHRL */ - is_write = 1; - } - break; - case 0xc8: /* SSF format insns */ - switch (pinsn[0] & 0xf) { - case 0x2: /* CSST */ - is_write = 1; - } - break; - case 0xe3: /* RXY format insns */ - switch (pinsn[2] & 0xff) { - case 0x50: /* STY */ - case 0x24: /* STG */ - case 0x72: /* STCY */ - case 0x70: /* STHY */ - case 0x8e: /* STPQ */ - case 0x3f: /* STRVH */ - case 0x3e: /* STRV */ - case 0x2f: /* STRVG */ - is_write = 1; - } - break; - case 0xeb: /* RSY format insns */ - switch (pinsn[2] & 0xff) { - case 0x14: /* CSY */ - case 0x30: /* CSG */ - case 0x31: /* CDSY */ - case 0x3e: /* CDSG */ - case 0xe4: /* LANG */ - case 0xe6: /* LAOG */ - case 0xe7: /* LAXG */ - case 0xe8: /* LAAG */ - case 0xea: /* LAALG */ - case 0xf4: /* LAN */ - case 0xf6: /* LAO */ - case 0xf7: /* LAX */ - case 0xfa: /* LAAL */ - case 0xf8: /* LAA */ - is_write = 1; - } - break; - } - - return handle_cpu_signal(pc, info, is_write, &uc->uc_sigmask); -} - -#elif defined(__mips__) +#if defined(__mips__) #if defined(__misp16) || defined(__mips_micromips) #error "Unsupported encoding"