From: Vineet Gupta <Vineet.Gupta1@synopsys.com>
To: <stable@vger.kernel.org>
Cc: <noamc@ezchip.com>, <Anton.Kolesov@synopsys.com>,
<linux-kernel@vger.kernel.org>,
Vineet Gupta <Vineet.Gupta1@synopsys.com>
Subject: [PATCH 1/2] ARC: gdbserver breakage in Big-Endian configuration #1
Date: Thu, 8 Aug 2013 19:22:37 +0530 [thread overview]
Message-ID: <1375969958-16454-1-git-send-email-vgupta@synopsys.com> (raw)
Exception handling keeps additional state (whether exception was Trap
and if it was due to a breakpoint) in pt_regs->event, a bitfield member
unsigned long orig_r8:16, event:16;
A bitfield esentially has an "offset" and a "length". What I wasn't
aware of was that, bitfields in a union loose the "offset" attribute
and all of them are laid out at offset 0.
This obviously means that both @event and @orig_r8 will be incorrectly
referenced to at same "0" offset by "C" generated code which is
certainly wrong, not because both members are accessed, but because asm
code updates it at different address.
In Little Endian config, @event is at offset 0 and @orig_r8 (not
actively used at all) clashing with it is OK. However in Big Endian
config,
ST 0xNNNN_EEEE, [addr]
writes 0xEEEE to @event (offset 2 in memory) while "C" code references
it from 0.
Needless to say, this causes ptrace machinery to not detect the breakpoint
scenario (and incorrect stop_pc returned to gdbserver).
------>8---------------
Thi issue is already fixed in mainline 3.11 kernel as part of commit:
502a0c775c7f0a "ARC: pt_regs update #5"
However that patch has lot more changes than I would like backporting,
hence this seperate change.
------>8---------------
Reported-by: Noam Camus <noamc@ezchip.com>
Cc: <stable@vger.kernel.org> # [3.9 and 3.10 only]
Tested-by: Anton Kolesov <akolesov@synopsys.com>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
---
arch/arc/include/asm/ptrace.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/arc/include/asm/ptrace.h b/arch/arc/include/asm/ptrace.h
index 6179de7..2046a89 100644
--- a/arch/arc/include/asm/ptrace.h
+++ b/arch/arc/include/asm/ptrace.h
@@ -52,12 +52,14 @@ struct pt_regs {
/*to distinguish bet excp, syscall, irq */
union {
+ struct {
#ifdef CONFIG_CPU_BIG_ENDIAN
/* so that assembly code is same for LE/BE */
unsigned long orig_r8:16, event:16;
#else
unsigned long event:16, orig_r8:16;
#endif
+ };
long orig_r8_word;
};
};
--
1.8.1.2
next reply other threads:[~2013-08-08 13:54 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-08 13:52 Vineet Gupta [this message]
2013-08-08 13:52 ` [PATCH 2/2] ARC: gdbserver breakage in Big-Endian configuration #2 Vineet Gupta
2013-08-19 9:08 ` [PATCH 1/2] ARC: gdbserver breakage in Big-Endian configuration #1 Vineet Gupta
2013-08-19 14:57 ` greg Kroah-Hartman
2013-08-20 5:20 ` Vineet Gupta
2013-08-20 6:29 ` greg Kroah-Hartman
2013-08-20 8:08 ` [PATCH 0/2] ARC fixes for 3.9/3.10 stable backport Vineet Gupta
2013-08-20 8:08 ` [PATCH 1/2] ARC: gdbserver breakage in Big-Endian configuration #1 Vineet Gupta
2013-08-22 22:37 ` Patch "ARC: gdbserver breakage in Big-Endian configuration #1" has been added to the 3.10-stable tree gregkh
2013-08-20 8:08 ` [PATCH 2/2] ARC: gdbserver breakage in Big-Endian configuration #2 Vineet Gupta
2013-08-22 22:37 ` Patch "ARC: gdbserver breakage in Big-Endian configuration #2" has been added to the 3.10-stable tree gregkh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1375969958-16454-1-git-send-email-vgupta@synopsys.com \
--to=vineet.gupta1@synopsys.com \
--cc=Anton.Kolesov@synopsys.com \
--cc=linux-kernel@vger.kernel.org \
--cc=noamc@ezchip.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).