From: Ingo Molnar <mingo@elte.hu>
To: Brian Gerst <brgerst@gmail.com>
Cc: x86@kernel.org, linux-kernel@vger.kernel.org,
"H. Peter Anvin" <hpa@zytor.com>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH] x86, 64-bit: Move K8 B step iret fixup to fault entry asm (v2)
Date: Tue, 3 Nov 2009 19:10:14 +0100 [thread overview]
Message-ID: <20091103181014.GA19715@elte.hu> (raw)
In-Reply-To: <1257270936-5496-1-git-send-email-brgerst@gmail.com>
* Brian Gerst <brgerst@gmail.com> wrote:
> Move the handling of truncated %rip from an iret fault to the fault
> entry path.
>
> This allows x86-64 to use the standard search_extable() function.
>
> v2: Fixed jump to error_swapgs to be unconditional.
v1 is already in the tip:x86/asm topic tree. Mind sending a delta fix
against:
http://people.redhat.com/mingo/tip.git/README
?
Also, i'm having second thoughts about the change:
> Signed-off-by: Brian Gerst <brgerst@gmail.com>
> ---
> arch/x86/include/asm/uaccess.h | 1 -
> arch/x86/kernel/entry_64.S | 11 ++++++++---
> arch/x86/mm/extable.c | 31 -------------------------------
> 3 files changed, 8 insertions(+), 35 deletions(-)
>
> diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
> index d2c6c93..abd3e0e 100644
> --- a/arch/x86/include/asm/uaccess.h
> +++ b/arch/x86/include/asm/uaccess.h
> @@ -570,7 +570,6 @@ extern struct movsl_mask {
> #ifdef CONFIG_X86_32
> # include "uaccess_32.h"
> #else
> -# define ARCH_HAS_SEARCH_EXTABLE
> # include "uaccess_64.h"
> #endif
>
> diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
> index b5c061f..1579a6c 100644
> --- a/arch/x86/kernel/entry_64.S
> +++ b/arch/x86/kernel/entry_64.S
> @@ -1491,12 +1491,17 @@ error_kernelspace:
> leaq irq_return(%rip),%rcx
> cmpq %rcx,RIP+8(%rsp)
> je error_swapgs
> - movl %ecx,%ecx /* zero extend */
> - cmpq %rcx,RIP+8(%rsp)
> - je error_swapgs
> + movl %ecx,%eax /* zero extend */
> + cmpq %rax,RIP+8(%rsp)
> + je bstep_iret
> cmpq $gs_change,RIP+8(%rsp)
> je error_swapgs
> jmp error_sti
> +
> +bstep_iret:
> + /* Fix truncated RIP */
> + movq %rcx,RIP+8(%rsp)
> + jmp error_swapgs
> END(error_entry)
>
>
> diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
> index 61b41ca..d0474ad 100644
> --- a/arch/x86/mm/extable.c
> +++ b/arch/x86/mm/extable.c
> @@ -35,34 +35,3 @@ int fixup_exception(struct pt_regs *regs)
>
> return 0;
> }
> -
> -#ifdef CONFIG_X86_64
> -/*
> - * Need to defined our own search_extable on X86_64 to work around
> - * a B stepping K8 bug.
> - */
> -const struct exception_table_entry *
> -search_extable(const struct exception_table_entry *first,
> - const struct exception_table_entry *last,
> - unsigned long value)
> -{
> - /* B stepping K8 bug */
> - if ((value >> 32) == 0)
> - value |= 0xffffffffUL << 32;
> -
> - while (first <= last) {
> - const struct exception_table_entry *mid;
> - long diff;
> -
> - mid = (last - first) / 2 + first;
> - diff = mid->insn - value;
> - if (diff == 0)
> - return mid;
> - else if (diff < 0)
> - first = mid+1;
> - else
> - last = mid-1;
> - }
> - return NULL;
> -}
> -#endif
is this the only way how we can end up having a truncated 64-bit RIP
passed in to search_exception_tables()/search_extable()? Before your
commit we basically had a last-ditch safety net in 64-bit kernels that
zero-extended truncated RIPs - no matter how they got there (via known
or unknown erratums).
Thanks,
Ingo
next prev parent reply other threads:[~2009-11-03 18:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-03 17:55 [PATCH] x86, 64-bit: Move K8 B step iret fixup to fault entry asm (v2) Brian Gerst
2009-11-03 18:10 ` Ingo Molnar [this message]
2009-11-03 18:39 ` Brian Gerst
2009-11-03 19:02 ` [PATCH] x86, 64-bit: Fix bstep_iret jump Brian Gerst
2009-11-04 6:33 ` [tip:x86/asm] " tip-bot for Brian Gerst
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=20091103181014.GA19715@elte.hu \
--to=mingo@elte.hu \
--cc=brgerst@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--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