LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Andy Lutomirski <luto@amacapital.net>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Denys Vlasenko <vda.linux@googlemail.com>,
Denys Vlasenko <dvlasenk@redhat.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ingo Molnar <mingo@kernel.org>, Borislav Petkov <bp@alien8.de>,
Oleg Nesterov <oleg@redhat.com>,
Frederic Weisbecker <fweisbec@gmail.com>,
Alexei Starovoitov <ast@plumgrid.com>,
Will Drewry <wad@chromium.org>, Kees Cook <keescook@chromium.org>,
"the arch/x86 maintainers" <x86@kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] x86: entry_32.S: change ESPFIX test to not touch PT_OLDSS(%esp)
Date: Mon, 9 Mar 2015 12:13:24 -0700 [thread overview]
Message-ID: <CALCETrViW_rhzYQ+re8=KMLtc=_4YDceWKLzCOk=ReEUbe+rfg@mail.gmail.com> (raw)
In-Reply-To: <54FDDBF7.9080207@zytor.com>
[-- Attachment #1: Type: text/plain, Size: 717 bytes --]
On Mon, Mar 9, 2015 at 10:44 AM, H. Peter Anvin <hpa@zytor.com> wrote:
> On 03/09/2015 09:44 AM, Linus Torvalds wrote:
>>
>> And remember: those zero-cost out-of-order branches turn quite
>> expensive if they *ever* mispredict. Even a 5% mispredict rate is
>> likely to mean "it's better to have a data dependency chain".
>>
>> So it could easily go either way. I'm not convinced the old code is bad at all.
>>
>
> I'm inclined to side with Linus here. I'm hesitant to change this based
> on pure speculation.
>
> To answer Andy's question: I do believe we need espfix for V86 mode as well.
>
I think we don't. Did I screw up my test?
--Andy
> -hpa
>
>
--
Andy Lutomirski
AMA Capital Management, LLC
[-- Attachment #2: vm86regs.c --]
[-- Type: text/x-csrc, Size: 1740 bytes --]
/*
* vm86 regs test.
* Copyright (c) 2014-2015 Andrew Lutomirski.
*
* This tests that vm86 regs work as expected.
*
* GPL v2.
*/
#define _GNU_SOURCE
#include <time.h>
#include <stdlib.h>
#include <sys/syscall.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#include <sys/mman.h>
#include <sys/signal.h>
#include <sys/ucontext.h>
#include <asm/ldt.h>
#include <err.h>
#include <setjmp.h>
#include <stddef.h>
#include <stdbool.h>
#include <sys/user.h>
#include <errno.h>
#include <asm/vm86.h>
static void sethandler(int sig, void (*handler)(int, siginfo_t *, void *),
int flags)
{
struct sigaction sa;
memset(&sa, 0, sizeof(sa));
sa.sa_sigaction = handler;
sa.sa_flags = SA_SIGINFO | flags;
sigemptyset(&sa.sa_mask);
if (sigaction(sig, &sa, 0))
err(1, "sigaction");
}
static void sigsegv_vm86(int sig, siginfo_t *info, void *ctx_void)
{
ucontext_t *ctx = (ucontext_t*)ctx_void;
printf("Back from vm86. EIP = %lx\n",
(unsigned long)ctx->uc_mcontext.gregs[REG_EIP]);
}
static void test_vm86(unsigned short cs, unsigned short ss)
{
struct vm86plus_struct v86, req_v86;
long ret;
memset(&v86, 0, sizeof(v86));
v86.regs.eip = 0;
v86.regs.cs = cs;
v86.regs.ss = ss;
v86.regs.esp = 0xbaadf00d;
req_v86 = v86;
printf("[RUN]\tcs = 0x%hx, ss = 0x%hx\n", cs, ss);
ret = syscall(SYS_vm86, VM86_ENTER, &v86);
if (ret == -1 && errno == ENOSYS) {
printf("[SKIP]\tvm86 not supported\n");
return;
}
printf("[OK]\tSurvived vm86 roundtrip. esp = %lx, should be %lx\n", v86.regs.esp, req_v86.regs.esp);
}
int main(void)
{
sethandler(SIGSEGV, sigsegv_vm86, SA_ONSTACK);
test_vm86(0, 0);
test_vm86(0, 3);
test_vm86(3, 0);
test_vm86(3, 3);
return 0;
}
next prev parent reply other threads:[~2015-03-09 19:13 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-09 14:05 Denys Vlasenko
2015-03-09 14:18 ` Andy Lutomirski
2015-03-09 15:00 ` Denys Vlasenko
2015-03-09 15:09 ` Andy Lutomirski
2015-03-09 19:31 ` Denys Vlasenko
2015-03-09 15:13 ` Ingo Molnar
2015-03-09 15:18 ` Andy Lutomirski
2015-03-09 15:47 ` Steven Rostedt
2015-03-09 15:54 ` Ingo Molnar
2015-03-09 16:08 ` Linus Torvalds
2015-03-09 16:28 ` Denys Vlasenko
2015-03-09 16:44 ` Linus Torvalds
2015-03-09 17:44 ` H. Peter Anvin
2015-03-09 19:13 ` Andy Lutomirski [this message]
2015-03-09 19:26 ` H. Peter Anvin
2015-03-09 19:51 ` Andy Lutomirski
2015-03-09 17:42 ` H. Peter Anvin
2015-03-09 17:45 ` Andy Lutomirski
2015-03-09 17:59 ` Linus Torvalds
2015-03-09 18:04 ` Andy Lutomirski
2015-03-09 18:16 ` Linus Torvalds
2015-03-09 18:32 ` Denys Vlasenko
2015-03-09 18:36 ` Andy Lutomirski
2015-03-10 6:25 ` Ingo Molnar
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='CALCETrViW_rhzYQ+re8=KMLtc=_4YDceWKLzCOk=ReEUbe+rfg@mail.gmail.com' \
--to=luto@amacapital.net \
--cc=ast@plumgrid.com \
--cc=bp@alien8.de \
--cc=dvlasenk@redhat.com \
--cc=fweisbec@gmail.com \
--cc=hpa@zytor.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=rostedt@goodmis.org \
--cc=torvalds@linux-foundation.org \
--cc=vda.linux@googlemail.com \
--cc=wad@chromium.org \
--cc=x86@kernel.org \
--subject='Re: [PATCH] x86: entry_32.S: change ESPFIX test to not touch PT_OLDSS(%esp)' \
/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
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).