From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 76283 invoked by alias); 28 Mar 2019 06:08:04 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 76214 invoked by uid 89); 28 Mar 2019 06:08:04 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-3.7 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 28 Mar 2019 06:08:02 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 20657307EAA9; Thu, 28 Mar 2019 06:08:01 +0000 (UTC) Received: from f29-4.lan (ovpn-117-184.phx2.redhat.com [10.3.117.184]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C21B660CC0; Thu, 28 Mar 2019 06:08:00 +0000 (UTC) Date: Thu, 28 Mar 2019 06:08:00 -0000 From: Kevin Buettner To: gdb-patches@sourceware.org Cc: Sandra Loosemore Subject: Re: [patch, nios2] fix stepping past unwritable kernel helper Message-ID: <20190327230800.0a358dc0@f29-4.lan> In-Reply-To: <80464f56-fccb-0bb4-dcdd-6a547e5418b0@codesourcery.com> References: <80464f56-fccb-0bb4-dcdd-6a547e5418b0@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2019-03/txt/msg00699.txt.bz2 On Wed, 27 Mar 2019 22:47:44 -0600 Sandra Loosemore wrote: > Fix stepping past unwritable kernel helper on nios2-linux-gnu. > > This patch fixes a problem on nios2-linux-gnu with stepping past the > kernel helper __kuser_cmpxchg, which was exposed by the testcase > gdb.threads/watchpoint-fork.exp. The kernel maps this function into > user space on an unwritable page. In this testcase, the cmpxchg > helper is invoked indirectly from the setbuf call in the test program. > Since this target lacks hardware breakpoint/watchpoint support, GDB > tries to single-step through the program by setting software > breakpoints, and was just giving an error when it reached the function > on the unwritable page. > > The solution here is to always step over the call instead of stepping > into it; cmpxchg is supposed to be an atomic operation so this > behavior seems reasonable. The hook in nios2_get_next_pc is somewhat > generic, but at present cmpxchg is the only helper provided by the > Linux kernel that is invoked by an ordinary function call. (Signal > return trampolines also go through the unwritable page but not by a > function call.) > > Fixing this issue also revealed that the testcase needs a much larger > timeout factor when software single-stepping is used. That has also > been fixed in this patch. > > gdb/ChangeLog > > 2019-03-27 Sandra Loosemore > > * nios2-tdep.h (struct gdbarch_tdep): Add is_kernel_helper. > * nios2-tdep.c (nios2_get_next_pc): Skip over kernel helpers. > * nios2-linux-tdep.c (nios2_linux_is_kernel_helper): New. > (nios2_linux_init_abi): Install it. > > gdb/testsuite/ChangeLog > > 2019-03-27 Sandra Loosemore > > * gdb.threads/watchpoint-fork.exp (test): Use large timeout > factor when no hardware watchpoint support. Thanks for the explanation, above. The one thing that concerned me when I first saw it was the use of the constant 0x1004 as the address for __kuser_cmpxchg. But after checking the glibc sources at the path indicated in the comment, I saw that it's hardcoded using the same constant there as well. So... this patch is okay. Kevin