From patchwork Tue Dec 21 16:47:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 526625 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp5248307imb; Tue, 21 Dec 2021 09:18:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJyxdE7xysKcWYLmXJow5B/2o4RuIslEggzjUJq45qW78CDlEeWU/8qtLQk1GkAG8oc5yO2x X-Received: by 2002:ac8:5b82:: with SMTP id a2mr3065133qta.519.1640107103134; Tue, 21 Dec 2021 09:18:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640107103; cv=none; d=google.com; s=arc-20160816; b=Ib2Y+hA7K/ozr+LmKep2nGOIKbdVpWHZb73CMs/W0xOjZJW63Dz9PSQDnxXgxtBWbT oXgKmBKasM6AQQZvyDG0OKFsuxA6T/Uoj3TD7jPoJcdT6j2Kc7JDB1tY4VFUGsygDZ8T yj9SFfmKRsDWBR5OBb71ixhuMnskvfkScN0OGBMcC2QnITlB8L01D3bNtx5VyjFAGQRQ cDn/vfeSOUHY6fNb2kET3GnnQHMEQRJ5MqGRROvKuDzJZpZ2lnA3okRqHIUxeFcX7mjJ D9MnENUpuwI5r5B9XUM9xLcMUD8w50nLiyS3RBwpSeJGh9SpaXcKGN9Ce830vavhHzjG DEWw== 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=jwD0nklpaMv6uE7sTv0yiM3eKKOOZulK+Q3tBkY247E=; b=p8hdOrSjs5VDPZfBgJG0umdBkVV6Bzo3GM2upRc8ksAO7VC/vjqxD+6GOT23ryWU6I s+DdlEhl8gtn0zYOxUMJRieAVAPeHH2WsLEa3ATPmMYHl7HIDMnn0juph74ySFMAs42n CyiEhjwk2qiQxT/jrGXWR5AtK8Ic9sfQc3qgGw5aBJHhfCUKINYCE8/cYR4YIxlwRpA/ CVZEMpvjlK9IUiFh+KxbFT/D8+Ar67h4sf5O/0YL+aoM4VSPba36vdsrQAozPWpLV+Tk PTm778ID0lI8Y5McCm3culLZOilzgUbQigUIAfVF4dYI2E2qceJeyNqhuZsUscM+A/OA i0ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uJFJstex; 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 d2si8265778qtd.508.2021.12.21.09.18.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Dec 2021 09:18:23 -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=uJFJstex; 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]:56642 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzimM-0000zn-IO for patch@linaro.org; Tue, 21 Dec 2021 12:18:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56132) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mziJC-00014s-4V for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:14 -0500 Received: from [2607:f8b0:4864:20::1029] (port=42940 helo=mail-pj1-x1029.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mziJ4-0007fe-Hu for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:13 -0500 Received: by mail-pj1-x1029.google.com with SMTP id lr15-20020a17090b4b8f00b001b19671cbebso3741717pjb.1 for ; Tue, 21 Dec 2021 08:48:06 -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=jwD0nklpaMv6uE7sTv0yiM3eKKOOZulK+Q3tBkY247E=; b=uJFJstexeq5GyyAea3BtYp+1ddbSGHn+35lI0dlRzqJ1TcDB83TWGD17+2MgLabllP t2CrsfztYjjN1U7Vc/hWVnPmcodaU0pN+8rdDOemcVE/uqmfbZWE1gW1FwNZMO32KK9S JUn4Pgb+jsM5iKtydfHHVb+ufM71iefuQ63apI+1jn95XcZ8YxJYp4z3+Qs3wGm8SdNQ DbMi3MCNQ43FJWAHDoT3HZB4skCrDWWRzeZAXiWsOuj7Wxvtakt0cf6UuPZXiZuI+R0g 0qJ6NbbO/Lj9AzvtL9EahepjU0z+V5dlLyHkpgM6XH/qokyxf353Ua0Y/z/0uPKpGzFS mAwg== 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=jwD0nklpaMv6uE7sTv0yiM3eKKOOZulK+Q3tBkY247E=; b=4AU+LRmBZMKDbF6AsE8b+iqQ2z+tpU5C0RB45J2Q9V86be8SqSfeyOGPNpbDd6KLMq uLiRCbScC3pTxrcvn2XMD/X71KaNNsMB9yzvA7wNrEpU94GtfiPsbNggFmhTU7ecMsku XxtCRmq3rwylQDUzdDefYRGdCJXxTc1/c9V2jzosqOlE0p0eCH2hHxFTHlp1VQoIwTjU v3SZ1MH3m/pHIqhkboMK8lOznvlzl1lXT7Ia/Vfn1BDZnBU53QCcuxWL3giEzToDMqKl 6MFcDpr9qIKI/I1BjNLpSSp6KjMuN0Gb0VQUi+LcHNDEZTjuHWbl3qo8if7OZNoccpf5 NEdg== X-Gm-Message-State: AOAM532aeOLFgFhYjt9NMSZCPbhrenzsbMsPUQ6CV7JMZsc3hnGpJmn5 VHzYdtEitRaRgCr78ZxeOvB2J80tfnKNVg== X-Received: by 2002:a17:90a:c68a:: with SMTP id n10mr4911607pjt.119.1640105285294; Tue, 21 Dec 2021 08:48:05 -0800 (PST) Received: from localhost.localdomain ([156.19.246.20]) by smtp.gmail.com with ESMTPSA id b192sm2256818pga.35.2021.12.21.08.48.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 08:48:04 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 29/31] linux-user: Implement CPU-specific signal handler for loongarch64 hosts Date: Tue, 21 Dec 2021 08:47:35 -0800 Message-Id: <20211221164737.1076007-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221164737.1076007-1-richard.henderson@linaro.org> References: <20211221164737.1076007-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::1029 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::1029; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1029.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, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: WANG Xuerui , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: WANG Xuerui Signed-off-by: WANG Xuerui Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20211221054105.178795-30-git@xen0n.name> Signed-off-by: Richard Henderson --- linux-user/host/loongarch64/host-signal.h | 87 +++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 linux-user/host/loongarch64/host-signal.h diff --git a/linux-user/host/loongarch64/host-signal.h b/linux-user/host/loongarch64/host-signal.h new file mode 100644 index 0000000000..05e2c82371 --- /dev/null +++ b/linux-user/host/loongarch64/host-signal.h @@ -0,0 +1,87 @@ +/* + * host-signal.h: signal info dependent on the host architecture + * + * Copyright (c) 2003-2005 Fabrice Bellard + * Copyright (c) 2021 WANG Xuerui + * + * 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 LOONGARCH64_HOST_SIGNAL_H +#define LOONGARCH64_HOST_SIGNAL_H + +static inline uintptr_t host_signal_pc(ucontext_t *uc) +{ + return uc->uc_mcontext.__pc; +} + +static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +{ + uc->uc_mcontext.__pc = pc; +} + +static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) +{ + const uint32_t *pinsn = (const uint32_t *)host_signal_pc(uc); + uint32_t insn = pinsn[0]; + + /* Detect store by reading the instruction at the program counter. */ + switch ((insn >> 26) & 0b111111) { + case 0b001000: /* {ll,sc}.[wd] */ + switch ((insn >> 24) & 0b11) { + case 0b01: /* sc.w */ + case 0b11: /* sc.d */ + return true; + } + break; + case 0b001001: /* {ld,st}ox4.[wd] ({ld,st}ptr.[wd]) */ + switch ((insn >> 24) & 0b11) { + case 0b01: /* stox4.w (stptr.w) */ + case 0b11: /* stox4.d (stptr.d) */ + return true; + } + break; + case 0b001010: /* {ld,st}.* family */ + switch ((insn >> 22) & 0b1111) { + case 0b0100: /* st.b */ + case 0b0101: /* st.h */ + case 0b0110: /* st.w */ + case 0b0111: /* st.d */ + case 0b1101: /* fst.s */ + case 0b1111: /* fst.d */ + return true; + } + break; + case 0b001110: /* indexed, atomic, bounds-checking memory operations */ + uint32_t sel = (insn >> 15) & 0b11111111111; + + switch (sel) { + case 0b00000100000: /* stx.b */ + case 0b00000101000: /* stx.h */ + case 0b00000110000: /* stx.w */ + case 0b00000111000: /* stx.d */ + case 0b00001110000: /* fstx.s */ + case 0b00001111000: /* fstx.d */ + case 0b00011101100: /* fstgt.s */ + case 0b00011101101: /* fstgt.d */ + case 0b00011101110: /* fstle.s */ + case 0b00011101111: /* fstle.d */ + case 0b00011111000: /* stgt.b */ + case 0b00011111001: /* stgt.h */ + case 0b00011111010: /* stgt.w */ + case 0b00011111011: /* stgt.d */ + case 0b00011111100: /* stle.b */ + case 0b00011111101: /* stle.h */ + case 0b00011111110: /* stle.w */ + case 0b00011111111: /* stle.d */ + case 0b00011000000 ... 0b00011100011: /* am* insns */ + return true; + } + break; + } + + return false; +} + +#endif