From: Peter Zijlstra <peterz@infradead.org>
To: Ondrej Zary <linux@zary.sk>
Cc: Thomas Gleixner <tglx@linutronix.de>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: IOPL emulation breaks hpasmd (hp-health) needed by HP DL380 G4 servers
Date: Thu, 16 Sep 2021 23:05:09 +0200 [thread overview]
Message-ID: <20210916210509.GG4323@worktop.programming.kicks-ass.net> (raw)
In-Reply-To: <202109162227.17415.linux@zary.sk>
On Thu, Sep 16, 2021 at 10:27:17PM +0200, Ondrej Zary wrote:
> (gdb) run
> Starting program: /opt/hp/hp-health/bin/IrqRouteTbl
>
> Program received signal SIGSEGV, Segmentation fault.
> 0xf7fc509b in ?? ()
> (gdb) bt
> #0 0xf7fc509b in ?? ()
> #1 0x08048848 in ?? ()
> #2 0x08048aa1 in ?? ()
> #3 0x08048e05 in ?? ()
> #4 0xf7df9e46 in __libc_start_main () from /lib32/libc.so.6
> #5 0xf7ffd000 in ?? () from /lib/ld-linux.so.2
> Backtrace stopped: previous frame inner to this frame (corrupt stack?)
> (gdb) x/3i $pc
> => 0xf7fc509b: cli
> 0xf7fc509c: push %ebp
> 0xf7fc509d: mov %esp,%ebp
>
> OMG, maybe is it calling into the mmapped BIOS area?
Lol... does something like the below (which *really* wants to be behind
something like sysctl.iopl_fake_if) work for you?
---
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index a58800973aed..55c3904e656d 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -528,6 +528,34 @@ static enum kernel_gp_hint get_kernel_gp_address(struct pt_regs *regs,
#define GPFSTR "general protection fault"
+bool fixup_iopl_exception(struct pt_regs *regs)
+{
+ struct thread_struct *t = ¤t->thread;
+ unsigned char buf[MAX_INSN_SIZE];
+ struct insn insn;
+ int nr_copied;
+
+ if (!IS_ENABLED(CONFIG_X86_IOPL_IOPERM) || t->iopl_emul != 3 || !regs)
+ return false;
+
+ nr_copied = insn_fetch_from_user(regs, buf);
+ if (nr_copied <= 0)
+ return false;
+
+ if (!insn_decode_from_regs(&insn, regs, buf, nr_copied))
+ return false;
+
+ if (insn.length != 1)
+ return false;
+
+ if (insn.opcode.bytes[0] != 0xfa &&
+ insn.opcode.bytes[0] != 0xfb)
+ return false;
+
+ regs->ip += 1;
+ return true;
+}
+
DEFINE_IDTENTRY_ERRORCODE(exc_general_protection)
{
char desc[sizeof(GPFSTR) + 50 + 2*sizeof(unsigned long) + 1] = GPFSTR;
@@ -553,6 +581,9 @@ DEFINE_IDTENTRY_ERRORCODE(exc_general_protection)
tsk = current;
if (user_mode(regs)) {
+ if (fixup_iopl_exception(regs))
+ goto exit;
+
tsk->thread.error_code = error_code;
tsk->thread.trap_nr = X86_TRAP_GP;
next prev parent reply other threads:[~2021-09-16 21:06 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-15 12:23 Ondrej Zary
2021-09-16 17:09 ` Thomas Gleixner
2021-09-16 20:27 ` Ondrej Zary
2021-09-16 21:05 ` Peter Zijlstra [this message]
2021-09-17 8:11 ` Ondrej Zary
2021-09-17 9:20 ` [PATCH] x86/iopl: Fake iopl(3) CLI/STI usage Peter Zijlstra
2021-09-17 10:29 ` Ondrej Zary
2021-09-17 11:54 ` Peter Zijlstra
2021-09-17 12:33 ` Thomas Gleixner
2021-09-17 12:54 ` Ondrej Zary
2021-09-17 10:40 ` Thomas Gleixner
2021-09-17 22:23 ` Linus Torvalds
2021-09-17 22:24 ` Linus Torvalds
2021-09-18 7:05 ` Peter Zijlstra
2021-09-18 9:06 ` Peter Zijlstra
2021-09-18 15:53 ` Ondrej Zary
2021-09-18 16:35 ` Linus Torvalds
2021-09-21 7:28 ` [tip: x86/core] " tip-bot2 for Peter Zijlstra
2021-09-21 11:09 ` Ondrej Zary
2021-09-21 12:00 ` Peter Zijlstra
2021-09-21 17:31 ` Ondrej Zary
2021-09-21 12:41 ` tip-bot2 for Peter Zijlstra
2021-09-21 21:01 ` [PATCH] " Andy Lutomirski
2021-09-16 21:25 ` IOPL emulation breaks hpasmd (hp-health) needed by HP DL380 G4 servers Thomas Gleixner
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=20210916210509.GG4323@worktop.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@zary.sk \
--cc=tglx@linutronix.de \
--cc=x86@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
Powered by JetHome