From: Borislav Petkov <bp@suse.de>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: Andy Lutomirski <luto@amacapital.net>,
Brian Gerst <brgerst@gmail.com>,
the arch/x86 maintainers <x86@kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@kernel.org>,
Denys Vlasenko <dvlasenk@redhat.com>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH] x86: static_cpu_has_safe: discard dynamic check after init
Date: Wed, 20 Jan 2016 11:33:45 +0100 [thread overview]
Message-ID: <20160120103345.GA23350@pd.tnic> (raw)
In-Reply-To: <569F072B.1020504@zytor.com>
On Tue, Jan 19, 2016 at 08:03:55PM -0800, H. Peter Anvin wrote:
> On 01/19/16 05:57, Borislav Petkov wrote:
> >
> > old insn VA: 0xffffffff8108c0d0, CPU feat: X86_BUG_SYSRET_SS_ATTRS, size: 2, padlen: 0
> > __switch_to:
> > ffffffff8108c0d0: eb 70 jmp ffffffff8108c142
> > repl insn: 0xffffffff8ca7a1a7, size: 0
> >
>
> This is the only one I could possibly imagine mattering. Would it be
> possible to get the disassembly here?
Sure, I've kept the vmlinux, see below:
ffffffff8108c0d0: eb 70 jmp ffffffff8108c142 <__switch_to+0x838>
jumps to:
ffffffff8108c142: 48 ff 05 b7 08 aa 0b incq 0xbaa08b7(%rip)
which is something-gcov. In any case, it jumps over the SS fixup code:
if (static_cpu_has_bug(X86_BUG_SYSRET_SS_ATTRS)) {
...
unsigned short ss_sel;
savesegment(ss, ss_sel);
if (ss_sel != __KERNEL_DS)
loadsegment(ss, __KERNEL_DS);
}
I guess we could fix that with an alternative_call() where @oldinstr is
empty so that on !X86_BUG_SYSRET_SS_ATTRS machines we simply return and
on the others, we do a CALL fixup_ss or so.
We have to pay attention to clobbers, though, similar to the POPCNT fun
in __arch_hweight32().
ffffffff8108b90a <__switch_to>:
ffffffff8108b90a: 55 push %rbp
ffffffff8108b90b: 48 8d 87 c0 2d 00 00 lea 0x2dc0(%rdi),%rax
ffffffff8108b912: 48 c7 c1 80 f6 1d 00 mov $0x1df680,%rcx
ffffffff8108b919: 48 89 e5 mov %rsp,%rbp
ffffffff8108b91c: 41 57 push %r15
ffffffff8108b91e: 45 31 ff xor %r15d,%r15d
ffffffff8108b921: 41 56 push %r14
...
ffffffff8108c0c2: 48 ff 05 07 09 aa 0b incq 0xbaa0907(%rip) # ffffffff8cb2c9d0 <__gcov0.__switch_to+0xc0>
ffffffff8108c0c9: 48 ff 05 08 09 aa 0b incq 0xbaa0908(%rip) # ffffffff8cb2c9d8 <__gcov0.__switch_to+0xc8>
ffffffff8108c0d0: eb 70 jmp ffffffff8108c142 <__switch_to+0x838>
ffffffff8108c0d2: 48 ff 05 07 09 aa 0b incq 0xbaa0907(%rip) # ffffffff8cb2c9e0 <__gcov0.__switch_to+0xd0>
ffffffff8108c0d9: 48 ff 05 08 09 aa 0b incq 0xbaa0908(%rip) # ffffffff8cb2c9e8 <__gcov0.__switch_to+0xd8>
ffffffff8108c0e0: 48 ff 05 11 09 aa 0b incq 0xbaa0911(%rip) # ffffffff8cb2c9f8 <__gcov0.__switch_to+0xe8>
ffffffff8108c0e7: 66 8c d0 mov %ss,%ax
ffffffff8108c0ea: 66 83 f8 18 cmp $0x18,%ax
ffffffff8108c0ee: 75 17 jne ffffffff8108c107 <__switch_to+0x7fd>
ffffffff8108c0f0: eb 57 jmp ffffffff8108c149 <__switch_to+0x83f>
ffffffff8108c0f2: 48 ff 05 cf 08 aa 0b incq 0xbaa08cf(%rip) # ffffffff8cb2c9c8 <__gcov0.__switch_to+0xb8>
ffffffff8108c0f9: e8 db b0 01 00 callq ffffffff810a71d9 <warn_pre_alternatives>
ffffffff8108c0fe: 48 ff 05 eb 08 aa 0b incq 0xbaa08eb(%rip) # ffffffff8cb2c9f0 <__gcov0.__switch_to+0xe0>
ffffffff8108c105: eb 3b jmp ffffffff8108c142 <__switch_to+0x838>
ffffffff8108c107: 48 ff 05 fa 08 aa 0b incq 0xbaa08fa(%rip) # ffffffff8cb2ca08 <__gcov0.__switch_to+0xf8>
ffffffff8108c10e: b8 18 00 00 00 mov $0x18,%eax
ffffffff8108c113: 8e d0 mov %eax,%ss
ffffffff8108c115: 48 ff 05 f4 08 aa 0b incq 0xbaa08f4(%rip) # ffffffff8cb2ca10 <__gcov0.__switch_to+0x100>
ffffffff8108c11c: eb 2b jmp ffffffff8108c149 <__switch_to+0x83f>
ffffffff8108c11e: 48 ff 05 9b 02 aa 0b incq 0xbaa029b(%rip) # ffffffff8cb2c3c0 <__gcov0.copy_xregs_to_kernel+0x30>
ffffffff8108c125: e9 91 f9 ff ff jmpq ffffffff8108babb <__switch_to+0x1b1>
ffffffff8108c12a: 48 ff 05 bf 02 aa 0b incq 0xbaa02bf(%rip) # ffffffff8cb2c3f0 <__gcov0.copy_kernel_to_xregs+0x20>
ffffffff8108c131: e9 84 fe ff ff jmpq ffffffff8108bfba <__switch_to+0x6b0>
ffffffff8108c136: 48 ff 05 43 02 aa 0b incq 0xbaa0243(%rip) # ffffffff8cb2c380 <__gcov0.copy_kernel_to_fxregs+0x20>
ffffffff8108c13d: e9 db fe ff ff jmpq ffffffff8108c01d <__switch_to+0x713>
ffffffff8108c142: 48 ff 05 b7 08 aa 0b incq 0xbaa08b7(%rip) # ffffffff8cb2ca00 <__gcov0.__switch_to+0xf0>
ffffffff8108c149: 48 83 c4 28 add $0x28,%rsp
ffffffff8108c14d: 4c 89 e0 mov %r12,%rax
ffffffff8108c150: 5b pop %rbx
ffffffff8108c151: 41 5c pop %r12
ffffffff8108c153: 41 5d pop %r13
ffffffff8108c155: 41 5e pop %r14
ffffffff8108c157: 41 5f pop %r15
ffffffff8108c159: 5d pop %rbp
ffffffff8108c15a: c3 retq
--
Regards/Gruss,
Boris.
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
--
next prev parent reply other threads:[~2016-01-20 10:34 UTC|newest]
Thread overview: 66+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-16 19:22 [PATCH] x86: static_cpu_has_safe: discard dynamic check after init Brian Gerst
2016-01-16 19:36 ` Borislav Petkov
2016-01-16 19:58 ` Brian Gerst
2016-01-17 10:33 ` Borislav Petkov
2016-01-18 16:52 ` Brian Gerst
2016-01-18 17:49 ` Andy Lutomirski
2016-01-18 18:14 ` Borislav Petkov
2016-01-18 18:29 ` Andy Lutomirski
2016-01-18 18:39 ` Borislav Petkov
2016-01-18 19:45 ` H. Peter Anvin
2016-01-18 23:05 ` Borislav Petkov
2016-01-18 23:13 ` H. Peter Anvin
2016-01-18 23:25 ` Borislav Petkov
2016-01-19 13:57 ` Borislav Petkov
2016-01-19 16:23 ` Borislav Petkov
2016-01-19 23:10 ` Borislav Petkov
2016-01-19 23:26 ` Andy Lutomirski
2016-01-19 23:49 ` Boris Petkov
2016-01-20 4:03 ` H. Peter Anvin
2016-01-20 10:33 ` Borislav Petkov [this message]
2016-01-20 10:41 ` H. Peter Anvin
2016-01-21 22:14 ` Borislav Petkov
2016-01-21 22:22 ` H. Peter Anvin
2016-01-21 22:56 ` Borislav Petkov
2016-01-21 23:36 ` H. Peter Anvin
2016-01-21 23:37 ` H. Peter Anvin
2016-01-22 10:32 ` Borislav Petkov
2016-01-18 18:51 ` Borislav Petkov
2016-01-19 1:10 ` Borislav Petkov
2016-01-19 1:33 ` H. Peter Anvin
2016-01-19 9:22 ` Borislav Petkov
2016-01-20 4:02 ` H. Peter Anvin
2016-01-20 4:39 ` Brian Gerst
2016-01-20 4:42 ` H. Peter Anvin
2016-01-20 10:50 ` Borislav Petkov
2016-01-20 10:55 ` H. Peter Anvin
2016-01-20 11:05 ` Borislav Petkov
2016-01-20 14:48 ` H. Peter Anvin
2016-01-20 15:01 ` Borislav Petkov
2016-01-20 15:09 ` H. Peter Anvin
2016-01-20 16:04 ` Borislav Petkov
2016-01-20 16:16 ` H. Peter Anvin
-- strict thread matches above, loose matches on Subject: below --
2016-01-23 6:50 [PATCH] x86/head_64.S: do not use temporary register to check alignment Alexander Kuleshov
2016-01-26 9:31 ` Borislav Petkov
2016-01-26 21:12 [PATCH 00/10] tip-queue 2016-01-26, rest Borislav Petkov
2016-01-26 21:12 ` [PATCH 01/10] x86/asm: Add condition codes clobber to memory barrier macros Borislav Petkov
2016-01-26 21:12 ` [PATCH 02/10] x86/asm: Drop a comment left over from X86_OOSTORE Borislav Petkov
2016-01-26 21:12 ` [PATCH 03/10] x86/asm: Tweak the comment about wmb() use for IO Borislav Petkov
2016-01-26 21:12 ` [PATCH 04/10] x86/cpufeature: Carve out X86_FEATURE_* Borislav Petkov
2016-01-30 13:18 ` [tip:x86/asm] " tip-bot for Borislav Petkov
2016-01-26 21:12 ` [PATCH 05/10] x86/cpufeature: Replace the old static_cpu_has() with safe variant Borislav Petkov
2016-01-30 13:19 ` [tip:x86/asm] " tip-bot for Borislav Petkov
2016-01-26 21:12 ` [PATCH 06/10] x86/cpufeature: Get rid of the non-asm goto variant Borislav Petkov
2016-01-27 3:36 ` Brian Gerst
2016-01-27 8:41 ` Borislav Petkov
2016-01-27 8:43 ` [PATCH -v1.1 " Borislav Petkov
2016-01-30 13:19 ` [tip:x86/asm] " tip-bot for Borislav Petkov
2016-01-27 8:45 ` [PATCH -v1.1 8/10] x86/alternatives: Discard dynamic check after init Borislav Petkov
2016-01-30 13:20 ` [tip:x86/asm] " tip-bot for Brian Gerst
2016-01-26 21:12 ` [PATCH 07/10] x86/alternatives: Add an auxilary section Borislav Petkov
2016-01-30 13:19 ` [tip:x86/asm] " tip-bot for Borislav Petkov
2016-01-26 21:12 ` [PATCH 08/10] x86/alternatives: Discard dynamic check after init Borislav Petkov
2016-01-26 21:12 ` [PATCH 09/10] x86/vdso: Use static_cpu_has() Borislav Petkov
2016-01-30 13:20 ` [tip:x86/asm] " tip-bot for Borislav Petkov
2016-01-26 21:12 ` [PATCH 10/10] x86/head_64: Simplify kernel load address alignment check Borislav Petkov
2016-01-30 13:20 ` [tip:x86/boot] x86/boot: " tip-bot for Alexander Kuleshov
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=20160120103345.GA23350@pd.tnic \
--to=bp@suse.de \
--cc=brgerst@gmail.com \
--cc=dvlasenk@redhat.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=mingo@kernel.org \
--cc=torvalds@linux-foundation.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.