Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1089396yba; Tue, 2 Apr 2019 01:57:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqx+Y80rvblZs3xZ6QqZxEJWWTdD9wvIAcYP5JTvginTJ6YC+crHUnN2VddYbxj2RiOmaJvH X-Received: by 2002:a62:75d7:: with SMTP id q206mr4220880pfc.213.1554195477387; Tue, 02 Apr 2019 01:57:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554195477; cv=none; d=google.com; s=arc-20160816; b=daZzxjoKXQMWeR9V/aUgAmnpLtJMwne91e2krYHxrYCYfMrKYJYMgpx1ELSZ9Lv1sd T8CoIA1vJhB9Xay3Y1ln5o9XP1attT8dHFm1zfQuGAz03ZqH4r74EE7JkUkRcRUVgvPV OpJNxjOIO+x4ylzdTRGJJDHGLSkd1MRYwJiyr8SpA5lyPI0Qy0obl+cmxihspaHUvp3G Jc6Z7gpBowDgsh6SH8UWoWsIYGHJ8CKzuHNNdAnYK1SqOfApfPdr1d+MrSb1yXhwpIRt 7N7SGcSIw1SlPwWiTmZm3UMyED79sQWR7eWkG+sQq3YINbRx5s6zVDQR8LKsfHD7+oNT e1bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=ypbiThmwvnm9O5zAv5MscDLaykwjfoNJi1gv0YMBBzY=; b=XfVCrHeWXiSrQv0jvgiALsknwaUIqbbBuvWm0LKsEcbJUO6DIxy5Pi7D7P3zfdW/bv 3WGXOKVZ8m+sTojGvSuRNI9Fds6DIZ14KrMKkQyunLG38vheLR+UDZAlojQudTzHiM6V rP/834P05wsuMcPuBITPAhUr7gzc5KulDaawP9XsPhTT8A/4zjBe4TX7HwRjSUb8j7Vi zSHbten+ONxMJTGTumbYp81rUo4d0YcLHmPzpz+o4Y1wHfBYJ28s7qVsDgdoS9nnJnv0 yRK1zV+hhPF4p/wS7rW8rJXXJgAhXWvNO0NJJdnprX6RISjAWMzNJEMAabD3K7c713MA R1cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fVLzstJb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id be8si10859986plb.72.2019.04.02.01.57.41; Tue, 02 Apr 2019 01:57:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fVLzstJb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729328AbfDBIDj (ORCPT + 99 others); Tue, 2 Apr 2019 04:03:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:41462 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725778AbfDBIDj (ORCPT ); Tue, 2 Apr 2019 04:03:39 -0400 Received: from localhost.localdomain (unknown [115.192.191.234]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 167F620830; Tue, 2 Apr 2019 08:03:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554192218; bh=lXG61drHYKWkH6JkBOWzJQigVdmu7d5++K4qQ0nR6fY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fVLzstJbIsNs/lJESTdus9nNjlp+OfV5VYENhKjX4AVWbE9YpNfZuZxVu3dN/1AO6 jOsUpiWtHRiwfFMOALwW0wSIYn/aDIDtluGkd/cINLiHJlDDsAsnhSWZLuzEGQq5P4 7mcPBIx97phlkSwKEKndqCtQfUfOrh6qkVCq2P2c= From: guoren@kernel.org To: arnd@arndb.de, palmer@sifive.com Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, ren_guo@c-sky.com, linux-riscv@lists.infradead.org Subject: [PATCH 3/3] riscv/signal: Fixup additional syscall restarting Date: Tue, 2 Apr 2019 16:02:33 +0800 Message-Id: <1554192153-2587-3-git-send-email-guoren@kernel.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554192153-2587-1-git-send-email-guoren@kernel.org> References: <1554192153-2587-1-git-send-email-guoren@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Guo Ren The function of do_notify_resume called by entry.S could be entered in loop when SIGPENDING was setted again before sret. So we must add prevent code to make syscall restart (regs->sepc -= 0x4) or it may re-execute unexpected instructions. Just like in_syscall & forget_syscall used by arm. Signed-off-by: Guo Ren Cc: Palmer Dabbelt Cc: Arnd Bergmann --- arch/riscv/kernel/signal.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/riscv/kernel/signal.c b/arch/riscv/kernel/signal.c index 837e164..804d6ee 100644 --- a/arch/riscv/kernel/signal.c +++ b/arch/riscv/kernel/signal.c @@ -234,6 +234,9 @@ static void handle_signal(struct ksignal *ksig, struct pt_regs *regs) /* Are we from a system call? */ if (regs->scause == EXC_SYSCALL) { + /* Avoid additional syscall restarting via ret_from_exception */ + regs->scause = -1UL; + /* If so, check system call restarting.. */ switch (regs->a0) { case -ERESTART_RESTARTBLOCK: @@ -272,6 +275,9 @@ static void do_signal(struct pt_regs *regs) /* Did we come from a system call? */ if (regs->scause == EXC_SYSCALL) { + /* Avoid additional syscall restarting via ret_from_exception */ + regs->scause = -1UL; + /* Restart the system call - no handlers present */ switch (regs->a0) { case -ERESTARTNOHAND: -- 2.7.4