From patchwork Tue Dec 25 20:55:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 154488 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp5217094ljp; Tue, 25 Dec 2018 13:10:02 -0800 (PST) X-Google-Smtp-Source: ALg8bN7sTw3E2kqmNkKe50JIcD0G2IameWrKYxLuiQI4lXPaV7csm/Tprv8DY839685bSrVUpI00 X-Received: by 2002:a05:6214:1087:: with SMTP id o7mr16739671qvr.115.1545772202663; Tue, 25 Dec 2018 13:10:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545772202; cv=none; d=google.com; s=arc-20160816; b=zp5fS7PKhudKtZRnSdNzWemiuRFyK+zLWUCmC4pOv7dZ1pymOMoq+NXqTVK/d6h96g c9rEi/4eyNyyJar62Y7jt0Ip19c2dUTXOeOKHzEUsYxg00bE+f7S9SfnJfU6f+jNErU8 asR0OAdI7zh3pzNozSsgIATvLLofDLHOZRMmh9SGFkf3TpCF3e+Wd2xAyPOgFmTO1ysB YyMgfUppkuCb6eUqvIyGgXxLXlixBTNBHmROR9OEjeSMa3CI+n7AyWQgLVZJtU+zgN+K QcSG2JTYJUTP40+mr84LQqFQon5X0vk8Vi0UO5pZ1ZG6NXZLCyknWPzpKI96vuA/y3Ln SSXQ== 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:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=ZTs2r59Ft+IG561CkrryL8mIt/UbyiqnLbp0AprPxMQ=; b=QMyiEApvYmpVmSdE+rKVs02QhIr5fu4mxucNkWAvrbu1fWe/PJILZRNc8mwAqxOGKN n+zGZ8BXr6jFUKDsEIvNyekOyngFokoJQDo1XVKPy441juccEBxTEBRQhqPzjREjcrnS 9iZzXYQmKwsDZd4xDXCbnCYCabfhnjuf/UPMzK8hHcybjt4YnPpMcW72zqhpOtHfZ8QM nu0MaB8N47qJ7PnGJ0J3Hi3TGKApU71TCo8eDlY+fVKpSeOonIlBmLbmIQqRcFCpDpCv 29GvdKQb6R6zqcgvJAj9NCFrzgrC5Q9L4OjFI4AAOmlJaQINz7KMYB/sQYpxbXHw08n9 BlOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ckmlMGPo; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 208.118.235.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. [208.118.235.17]) by mx.google.com with ESMTPS id u4si263021qkc.197.2018.12.25.13.10.02 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 25 Dec 2018 13:10:02 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ckmlMGPo; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 208.118.235.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 ([127.0.0.1]:43123 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gbtxi-0002XT-0y for patch@linaro.org; Tue, 25 Dec 2018 16:10:02 -0500 Received: from eggs.gnu.org ([208.118.235.92]:50273) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gbtmZ-0006QE-H7 for qemu-devel@nongnu.org; Tue, 25 Dec 2018 15:58:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gbtmV-0000LW-ML for qemu-devel@nongnu.org; Tue, 25 Dec 2018 15:58:31 -0500 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]:32996) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gbtmV-0000Gc-0y for qemu-devel@nongnu.org; Tue, 25 Dec 2018 15:58:27 -0500 Received: by mail-pg1-x52b.google.com with SMTP id z11so6832335pgu.0 for ; Tue, 25 Dec 2018 12:58:23 -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; bh=ZTs2r59Ft+IG561CkrryL8mIt/UbyiqnLbp0AprPxMQ=; b=ckmlMGPoXCp0DzfTKvupSGMSwuzMyVZi8p7hg5KsQD3ubKUhRfxSF5e+fFQLRkMhNX cfWNLRpDV3W08wodkW+KXKndHsv1vFW1+nSntZVYFdkME6eoTWlnkgGT1C4Wa/kxcuiX 7hztM1mD3ag2pcch9AB4moyCSlUfoxdHLAbQM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ZTs2r59Ft+IG561CkrryL8mIt/UbyiqnLbp0AprPxMQ=; b=qdP1oaKR8Y9EQHv4rZZXOsoY9eCXZIyANVp4auJjLxU7LdZwHC1flCcJwERAevZSEW 87PIuiMzLgUNb8bPcW1quRvXrnItLjLsJH5ijZ16qg//Smp3CSKA5fZDjsYVoJ5lw4sI fdBYZ61jZtipNAviOYDiA09wzRxJK+CT+e7aE9r8rTDjfGcb/4onLDNJTZdWmzZKJ8tk YOoQO2xiZxkl3DDD6PnmoxmMAUCqTqtoHMw7ugm9FNuz+LQhZkQmncxfpg1ZbrqZeyQX 8NNQMP/KZrXVeafyDZq7ckpFLD1eUlDi+nST/5We0Q4Oof3hlfIX3WJvPFDbI7iq+07Y NIIA== X-Gm-Message-State: AJcUukf46nrdSlLoIY9OhdgLaJ3IWhQ3Iy0hFEcdS5/+R1+AxhQNoneS eyDe1J+HMI2nPma303rbI4YH9onNR+Q= X-Received: by 2002:a63:9501:: with SMTP id p1mr16743458pgd.149.1545771502323; Tue, 25 Dec 2018 12:58:22 -0800 (PST) Received: from cloudburst.home (c211-28-135-144.sunsh3.vic.optusnet.com.au. [211.28.135.144]) by smtp.gmail.com with ESMTPSA id t21sm48501628pgg.24.2018.12.25.12.58.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Dec 2018 12:58:21 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 26 Dec 2018 07:55:08 +1100 Message-Id: <20181225205529.10874-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181225205529.10874-1-richard.henderson@linaro.org> References: <20181225205529.10874-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::52b Subject: [Qemu-devel] [PULL 21/42] tcg: Add RISC-V cpu signal handler X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Michael Clark , Alistair Francis Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Alistair Francis Signed-off-by: Alistair Francis Signed-off-by: Michael Clark Reviewed-by: Richard Henderson Message-Id: Signed-off-by: Richard Henderson --- accel/tcg/user-exec.c | 75 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) -- 2.17.2 diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index cd75829cf2..941295ea49 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -571,6 +571,81 @@ int cpu_signal_handler(int host_signum, void *pinfo, return handle_cpu_signal(pc, info, is_write, &uc->uc_sigmask); } +#elif defined(__riscv) + +int cpu_signal_handler(int host_signum, void *pinfo, + void *puc) +{ + siginfo_t *info = pinfo; + ucontext_t *uc = puc; + greg_t pc = uc->uc_mcontext.__gregs[REG_PC]; + uint32_t insn = *(uint32_t *)pc; + int is_write = 0; + + /* Detect store by reading the instruction at the program + counter. Note: we currently only generate 32-bit + instructions so we thus only detect 32-bit stores */ + switch (((insn >> 0) & 0b11)) { + case 3: + switch (((insn >> 2) & 0b11111)) { + case 8: + switch (((insn >> 12) & 0b111)) { + case 0: /* sb */ + case 1: /* sh */ + case 2: /* sw */ + case 3: /* sd */ + case 4: /* sq */ + is_write = 1; + break; + default: + break; + } + break; + case 9: + switch (((insn >> 12) & 0b111)) { + case 2: /* fsw */ + case 3: /* fsd */ + case 4: /* fsq */ + is_write = 1; + break; + default: + break; + } + break; + default: + break; + } + } + + /* Check for compressed instructions */ + switch (((insn >> 13) & 0b111)) { + case 7: + switch (insn & 0b11) { + case 0: /*c.sd */ + case 2: /* c.sdsp */ + is_write = 1; + break; + default: + break; + } + break; + case 6: + switch (insn & 0b11) { + case 0: /* c.sw */ + case 3: /* c.swsp */ + is_write = 1; + break; + default: + break; + } + break; + default: + break; + } + + return handle_cpu_signal(pc, info, is_write, &uc->uc_sigmask); +} + #else #error host CPU specific signal handler needed