From patchwork Mon Nov 20 21:21:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 10067355 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CB536602B7 for ; Mon, 20 Nov 2017 21:33:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE7F52929C for ; Mon, 20 Nov 2017 21:33:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B371A292E1; Mon, 20 Nov 2017 21:33:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3627B2929C for ; Mon, 20 Nov 2017 21:33:18 +0000 (UTC) Received: from localhost ([::1]:59852 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGtgr-0005BJ-F4 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 20 Nov 2017 16:33:17 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58248) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGtW0-0004kO-Er for qemu-devel@nongnu.org; Mon, 20 Nov 2017 16:22:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eGtVz-0007yQ-Hb for qemu-devel@nongnu.org; Mon, 20 Nov 2017 16:22:04 -0500 Received: from mail-lf0-x241.google.com ([2a00:1450:4010:c07::241]:42561) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eGtVz-0007xn-Af for qemu-devel@nongnu.org; Mon, 20 Nov 2017 16:22:03 -0500 Received: by mail-lf0-x241.google.com with SMTP id m1so11692656lfj.9 for ; Mon, 20 Nov 2017 13:22:03 -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=jpBWKIEaeGIsqdpEFfpflzsn3MKjwBVJ5ygjem87Imo=; b=cLwHPXu3vckAVVL11Il6vTsI8bEr/O3dLSQWkGE/3UP5WxIfS9bT5u/Om4TnUVN4I6 pbCCXGlu+YJ953JHkKaatUOidLEX6F9jqIxUqAQ4CgGLuIPpUQzrQb20BMwL8FPfFEwB fxw/qyqj+AAz9IGHs4kGU4trl5jZ/cn0v4rIE= 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:mime-version:content-transfer-encoding; bh=jpBWKIEaeGIsqdpEFfpflzsn3MKjwBVJ5ygjem87Imo=; b=hMY/OeTid2rZ1RhYEJ7dQrmOzDYz7CcAtriZTLYKHFcKUUDHRtUsn2cqiPSxqhH5qD iO3MbyhtUPQG9ht0TYJEQ4NmpLWfWxt6Jn7+DlyQW68zce6WH4xI4KBtOoVbqXdA0ly3 YXY+BTU4aBQhLZQU2mCbUUmnm+SjVIRJVA2ADj6D19VCHUJhOYaATX6XO+bA5A+nDhuT nUbpeM/eeHnqs3cdoTUkNZa8DpeMkagUji4KrCh+X0rj/T6b/Rd6GMxH9iZFm0a+lcpH fWnoXbLfEnGP1J9UPzeEwjM2cE2BPb8SmY8aUEnGfrTS4s4inf0jKbX56ajCZ41fMib0 4Hlw== X-Gm-Message-State: AJaThX4t3umJJ7TVd5jU1ecAPLwo7LmLlwsfM2xZXchc5ds6m4pTQECm 6+3WcZcqkcWS0U+zWOnmTGHlMLUg/b4= X-Google-Smtp-Source: AGs4zMbs4W1eSa5udKDWBjJBLrAZ1bZFHkVQNetZZKql9IIlWEc+N2TDeBFoBUh4WCZD4QvHjJzSdg== X-Received: by 10.25.40.5 with SMTP id o5mr3738564lfo.238.1511212921889; Mon, 20 Nov 2017 13:22:01 -0800 (PST) Received: from beaming.home (91-157-170-157.elisa-laajakaista.fi. [91.157.170.157]) by smtp.gmail.com with ESMTPSA id v63sm1645409lje.39.2017.11.20.13.22.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Nov 2017 13:22:00 -0800 (PST) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Mon, 20 Nov 2017 23:21:39 +0200 Message-Id: X-Mailer: git-send-email 2.14.2 In-Reply-To: References: MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4010:c07::241 Subject: [Qemu-devel] [PULL 11/15] linux-user/s390x: Mask si_addr for SIGSEGV 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 Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Peter Maydell For s390x, the address passed to a signal handler in the siginfo_t si_addr field is masked (in the kernel this is done in do_sigbus() and do_sigsegv() in arch/s390/mm/fault.c). Implement this architecture-specific oddity in linux-user. This is one of the issues described in https://bugs.launchpad.net/qemu/+bug/1705118 Reviewed-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Peter Maydell Signed-off-by: Riku Voipio --- linux-user/main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/linux-user/main.c b/linux-user/main.c index aa02f25b85..b6dd9efd2d 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -3238,6 +3238,10 @@ void cpu_loop(CPUAlphaState *env) #endif /* TARGET_ALPHA */ #ifdef TARGET_S390X + +/* s390x masks the fault address it reports in si_addr for SIGSEGV and SIGBUS */ +#define S390X_FAIL_ADDR_MASK -4096LL + void cpu_loop(CPUS390XState *env) { CPUState *cs = CPU(s390_env_get_cpu(env)); @@ -3294,7 +3298,7 @@ void cpu_loop(CPUS390XState *env) sig = TARGET_SIGSEGV; /* XXX: check env->error_code */ n = TARGET_SEGV_MAPERR; - addr = env->__excp_addr; + addr = env->__excp_addr & S390X_FAIL_ADDR_MASK; goto do_signal; case PGM_EXECUTE: case PGM_SPECIFICATION: