From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v4 ltp] Add Intel umip(User Mode Instruction Prevention) basic function tests
Date: Wed, 16 Jan 2019 14:45:24 +0100 [thread overview]
Message-ID: <20190116134523.GE24833@rei> (raw)
In-Reply-To: <20190110105856.32422-1-pengfei.xu@intel.com>
Hi!
> +static void sig_handler(int signal)
> +{
> + int exp_sigsegv = 11;
> +
> + if (exp_sigsegv == signal) {
> + sigsegv_cnt++;
> + tst_res(TPASS, "Received SIGSEGV signal:%d, num:%d",
> + signal, sigsegv_cnt);
> + // signal handler by app, kernel will not kill, need exit
> + exit(EXIT_VALUE);
> + } else {
> + tst_res(TWARN, "Received unexpected signal:%d", signal);
> + SAFE_KILL(pid, SIGINT);
> + }
> +}
I think I already tried to explain that signal handler runs
asynchronously to the rest of the code and that calling anything else
than a few signal-async-safe functions may cause undefined behavior,
which mostly translates to deadlocks.
Why can't we write the test as:
static void asm_sgdt(void)
{
unsigned char val[GDT_LEN];
tst_res(TINFO, "TEST sgdt, sgdt result save at [%p]", val);
asm volatile("sgdt %0\n" : "=m" (val));
exit(0);
}
...
static void do_test(unsigned int n)
{
int pid, status;
pid = SAFE_FORK();
if (!pid) {
switch (n) {
case 0:
asm_sgdt();
break;
...
}
}
SAFE_WAITPID(pid, &status, 0);
if (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV) {
tst_res(TPASS, "Got SIGSEGV");
return;
}
tst_res(TFAIL, "Child exitted with %s", tst_strstatus(status));
}
--
Cyril Hrubis
chrubis@suse.cz
next prev parent reply other threads:[~2019-01-16 13:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-10 10:58 [LTP] [PATCH v4 ltp] Add Intel umip(User Mode Instruction Prevention) basic function tests Pengfei Xu
2019-01-16 13:45 ` Cyril Hrubis [this message]
2019-01-16 17:39 ` Pengfei Xu
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=20190116134523.GE24833@rei \
--to=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
/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