Re: [PATCH 01/23] x86, kaiser: prepare assembly for entry/exit CR3 switching

2017-11-01 Thread Dave Hansen
On 11/01/2017 02:01 PM, Thomas Gleixner wrote: > On Tue, 31 Oct 2017, Dave Hansen wrote: >> >> +pushq %rdi >> +SWITCH_TO_KERNEL_CR3 scratch_reg=%rdi >> +popq%rdi > > Can you please have a macro variant which does: > > SWITCH_TO_KERNEL_CR3_PUSH reg=%rdi > > So the pushq/po

Re: [PATCH 01/23] x86, kaiser: prepare assembly for entry/exit CR3 switching

2017-11-01 Thread Thomas Gleixner
On Tue, 31 Oct 2017, Dave Hansen wrote: > > + pushq %rdi > + SWITCH_TO_KERNEL_CR3 scratch_reg=%rdi > + popq%rdi Can you please have a macro variant which does: SWITCH_TO_KERNEL_CR3_PUSH reg=%rdi So the pushq/popq is inside the macro. This has two reasons: 1) If KAISER

Re: [PATCH 01/23] x86, kaiser: prepare assembly for entry/exit CR3 switching

2017-11-01 Thread Borislav Petkov
On Wed, Nov 01, 2017 at 11:27:48AM -0700, Dave Hansen wrote: > This allows for a tiny optimization of Andy's that I realize I must have > blown away at some point. It lets us do a 32-bit-register instruction > (and using %eXX) when checking KAISER_SWITCH_MASK instead of a 64-bit > register via %rX

Re: [PATCH 01/23] x86, kaiser: prepare assembly for entry/exit CR3 switching

2017-11-01 Thread Dave Hansen
On 11/01/2017 11:18 AM, Borislav Petkov wrote: >> +.macro SAVE_AND_SWITCH_TO_KERNEL_CR3 scratch_reg:req save_reg:req >> +movq%cr3, %r\scratch_reg >> +movq%r\scratch_reg, \save_reg > > So one of the args gets passed as "ax", for example, which then gets > completed to a register wit

Re: [PATCH 01/23] x86, kaiser: prepare assembly for entry/exit CR3 switching

2017-11-01 Thread Borislav Petkov
On Tue, Oct 31, 2017 at 03:31:48PM -0700, Dave Hansen wrote: > diff -puN arch/x86/entry/calling.h~kaiser-luto-base-cr3-work > arch/x86/entry/calling.h > --- a/arch/x86/entry/calling.h~kaiser-luto-base-cr3-work 2017-10-31 > 15:03:48.105007253 -0700 > +++ b/arch/x86/entry/calling.h2017

Re: [PATCH 01/23] x86, kaiser: prepare assembly for entry/exit CR3 switching

2017-10-31 Thread Dave Hansen
On 10/31/2017 05:43 PM, Brian Gerst wrote: >> >> + RESTORE_CR3 save_reg=%r14 >> + >> testl %ebx, %ebx /* swapgs needed? */ >> jnz nmi_restore >> nmi_swapgs: >> _ > This all needs to be conditional on a config option. Something with > this amount of

Re: [PATCH 01/23] x86, kaiser: prepare assembly for entry/exit CR3 switching

2017-10-31 Thread Brian Gerst
On Tue, Oct 31, 2017 at 6:31 PM, Dave Hansen wrote: > > This is largely code from Andy Lutomirski. I fixed a few bugs > in it, and added a few SWITCH_TO_* spots. > > KAISER needs to switch to a different CR3 value when it enters > the kernel and switch back when it exits. This essentially > need

[PATCH 01/23] x86, kaiser: prepare assembly for entry/exit CR3 switching

2017-10-31 Thread Dave Hansen
This is largely code from Andy Lutomirski. I fixed a few bugs in it, and added a few SWITCH_TO_* spots. KAISER needs to switch to a different CR3 value when it enters the kernel and switch back when it exits. This essentially needs to be done before we leave assembly code. This is extra challe