From patchwork Thu Jan 28 00:32:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 60668 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp172101lbb; Wed, 27 Jan 2016 16:54:58 -0800 (PST) X-Received: by 10.98.80.79 with SMTP id e76mr369448pfb.126.1453942498061; Wed, 27 Jan 2016 16:54:58 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l23si12836398pfi.182.2016.01.27.16.54.57; Wed, 27 Jan 2016 16:54:58 -0800 (PST) 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; 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; dkim=pass header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935452AbcA1Ay4 (ORCPT + 30 others); Wed, 27 Jan 2016 19:54:56 -0500 Received: from mail-pa0-f41.google.com ([209.85.220.41]:33580 "EHLO mail-pa0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934390AbcA1Ayw (ORCPT ); Wed, 27 Jan 2016 19:54:52 -0500 Received: by mail-pa0-f41.google.com with SMTP id cy9so13403509pac.0 for ; Wed, 27 Jan 2016 16:54:52 -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; bh=zqu76pqML6ROH3SOcXU0w18CByeTp6WIXY3q95UB+qo=; b=jRqgnQsAqeWk2S7c9D+mdhf7UyP90lWV3Y77IKd+CMHqwwFF+GOKky0hklVdR8zoHJ KCjl4jASlpJ/x7XIrgg3iVzBAoz+5QbNH0kdE586NuLoQ8De2Oa9Fvg9MXspq9VS+b5R 1cy5g8wiKnXed8+rwtNr/2CJcx8gGrSUdd8Eo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=zqu76pqML6ROH3SOcXU0w18CByeTp6WIXY3q95UB+qo=; b=XqgV7C+UTdZXCFU5ldzYNg6U/Zw8VDzLErRJn4b3feRcN0QMImJRRGfQ7ub/+5KkGk l8h7zqATDDE+1sYY6W0lJ6evdHvgdjxNFaKPk4mnM4Bj3l+19Sl6urcr/5ZMM8QsmTHR TV/c2wRz+rgFDHPaH/ybEEUwxK1Cg2aXOrhYNwP7R7lcDv8Vtapm+cTX4FvIdICwefBZ 8ObjZ1ZsmqJ37MCrQgCVIcrsTuryJPb2MRJ66ZVzjlTQuXZyvRMXQTF8kxJmRiPu5IkB b/YkMuoblij3JWumke1eC2xkm812SAZs8xL9uCJigzoXNNXN2OQna19KqbP8q+Mlffxa ee2Q== X-Gm-Message-State: AG10YOTS1A/nVH6ResLxG3R/LV3aljR7yK7/yKAXE5L4nvo/rL7J5jqRDdHYYYt1knFX+lnk X-Received: by 10.66.148.99 with SMTP id tr3mr329693pab.19.1453942492287; Wed, 27 Jan 2016 16:54:52 -0800 (PST) Received: from yshi-Precision-T5600.corp.ad.wrs.com (unknown-216-82.windriver.com. [147.11.216.82]) by smtp.gmail.com with ESMTPSA id fi16sm11678046pac.12.2016.01.27.16.54.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jan 2016 16:54:51 -0800 (PST) From: Yang Shi To: jason.wessel@windriver.com Cc: linux-kernel@vger.kernel.org, linaro-kernel@lists.linaro.org, yang.shi@linaro.org Subject: [PATCH] kgdb: disable do_fork and sys_open tests on boot when DEBUG_RODATA is enabled Date: Wed, 27 Jan 2016 16:32:50 -0800 Message-Id: <1453941170-12319-1-git-send-email-yang.shi@linaro.org> X-Mailer: git-send-email 2.0.2 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org kgdbts do_fork and sys_open tests are scheduled before mark_rodata_ro gets called when kgdbts is run on boot. But, the breakpoint is removed by a kernel thread which may be scheduled after mark_rodata_ro is called. So, this will cause the below kernel panic: KGDB: BP remove failed: ffffffc0000c36a8 KGDB: re-enter exception: ALL breakpoints killed CPU: 0 PID: 2 Comm: kthreadd Not tainted 4.5.0-rc1 #110 Hardware name: Freescale Layerscape 2085a RDB Board (DT) Call trace: [] dump_backtrace+0x0/0x1b0 [] show_stack+0x24/0x30 [] dump_stack+0x8c/0xc8 [] kgdb_handle_exception+0x228/0x238 [] kgdb_step_brk_fn+0x2c/0x40 [] single_step_handler+0x7c/0x108 [] do_debug_exception+0x54/0xb8 Exception stack(0xffffffc0797175b0 to 0xffffffc0797176d0) 75a0: ffffffc079714000 ffffffffffffffff 75c0: ffffffc079717770 ffffffc000085418 deadbeefdeadbeef deadbeefdeadbeef 75e0: deadbeefdeadbeef deadbeefdeadbeef deadbeefdeadbeef deadbeefdeadbeef 7600: deadbeefdeadbeef deadbeefdeadbeef deadbeefdeadbeef deadbeefdeadbeef 7620: deadbeefdeadbeef deadbeefdeadbeef deadbeefdeadbeef deadbeefdeadbeef 7640: deadbeefdeadbeef deadbeefdeadbeef ffffffc0000c36a8 000000009600004f 7660: 0000000000000004 00000000d4208000 ffffffc079709580 ffffffc0000c36ac 7680: ffffffc0000c36a8 622f2f2f2f626565 7f7f7f7f7f7f7f7f 63ff332b37603532 76a0: 7f7f7f7f7f7f7f7f 0101010101010101 0000000000000030 0000000000000000 76c0: 0000000000000000 ffffffc001abb11d [] el1_dbg+0x18/0x6c [] kgdb_arch_set_breakpoint+0x64/0xe8 [] kgdb_validate_break_address+0x28/0x68 [] dbg_set_sw_break+0x20/0x118 [] gdb_serial_stub+0xc60/0xcc0 [] kgdb_cpu_enter+0x428/0x6c0 [] kgdb_handle_exception+0x108/0x238 [] kgdb_step_brk_fn+0x2c/0x40 [] single_step_handler+0x7c/0x108 [] do_debug_exception+0x54/0xb8 Exception stack(0xffffffc079717b50 to 0xffffffc079717c70) 7b40: 0000000000000611 ffffffc0000eab88 7b60: ffffffc079717d10 ffffffc000085598 ffffffc079717d10 00000000f2000400 7b80: ffffffc000cbd000 ffffffc000096a38 ffffffc000d84cf3 ffffffc00011a940 7ba0: 0000000500000001 0000000000000000 0000000000000000 0000000000000000 7bc0: 0000000000000000 0000000000000002 ffffffc079717d10 0000000000000000 7be0: ffffffc079717c00 ffffffc000096a60 0000000000800711 ffffffc0000eab88 7c00: ffffffc0763f0e00 0000000000000000 0000000000000000 0000000000000000 7c20: ffffffc079717e60 0000000000000000 0000000000000000 ffffffc000d2d000 7c40: 0000000000001150 010181a300000002 00000000bdb6099c ffffffc0017a96f0 7c60: ed81000001000000 ffffffc07630fb4c [] el1_dbg+0x18/0x6c [] kthreadd+0x1d8/0x268 [] ret_from_fork+0x10/0x40 Kernel panic - not syncing: Recursive entry to debugger Disable do_fork and sys_open tests on boot, but they still can be run after the system is bootup. Signed-off-by: Yang Shi --- drivers/misc/kgdbts.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) -- 2.0.2 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c index 99635dd..4464489 100644 --- a/drivers/misc/kgdbts.c +++ b/drivers/misc/kgdbts.c @@ -980,10 +980,12 @@ static void kgdbts_run_tests(void) int i; ptr = strchr(config, 'F'); - if (ptr) + if (ptr && + (!IS_ENABLED(CONFIG_DEBUG_RODATA) || !IS_ENABLED(CONFIG_KGDB_TESTS_ON_BOOT))) fork_test = simple_strtol(ptr + 1, NULL, 10); ptr = strchr(config, 'S'); - if (ptr) + if (ptr && + (!IS_ENABLED(CONFIG_DEBUG_RODATA) || !IS_ENABLED(CONFIG_KGDB_TESTS_ON_BOOT))) do_sys_open_test = simple_strtol(ptr + 1, NULL, 10); ptr = strchr(config, 'N'); if (ptr)