Re: [PATCH V7 08/18] x86/entry: Preserve PKRS MSR across exceptions

2021-12-02 Thread Andy Lutomirski
On 11/12/21 16:50, Ira Weiny wrote: On Tue, Aug 03, 2021 at 09:32:21PM -0700, 'Ira Weiny' wrote: From: Ira Weiny The PKRS MSR is not managed by XSAVE. It is preserved through a context switch but this support leaves exception handling code open to memory accesses during exceptions. 2

Re: [RFC Part2 PATCH 04/30] x86/mm: split the physmap when adding the page in RMP table

2021-04-19 Thread Andy Lutomirski
> On Apr 19, 2021, at 11:33 AM, Dave Hansen wrote: > > On 4/19/21 11:10 AM, Andy Lutomirski wrote: >> I’m confused by this scenario. This should only affect physical pages >> that are in the 2M area that contains guest memory. But, if we have a >> 2M direct map PMD

Re: [RFC Part2 PATCH 04/30] x86/mm: split the physmap when adding the page in RMP table

2021-04-19 Thread Andy Lutomirski
> On Apr 19, 2021, at 10:58 AM, Dave Hansen wrote: > > On 4/19/21 10:46 AM, Brijesh Singh wrote: >> - guest wants to make gpa 0x1000 as a shared page. To support this, we >> need to psmash the large RMP entry into 512 4K entries. The psmash >> instruction breaks the large RMP entry into 512

Re: [PATCH 05/15] x86: Implement function_nocfi

2021-04-19 Thread Andy Lutomirski
> On Apr 19, 2021, at 8:26 AM, David Laight wrote: > > From: Andy Lutomirski >> Sent: 18 April 2021 01:12 > .. >> Slightly more complicated: >> >> struct opaque_symbol; >> extern struct opaque_symbol entry_SYSCALL_64; >> >> The op

Re: [PATCH 05/15] x86: Implement function_nocfi

2021-04-18 Thread Andy Lutomirski
On Sun, Apr 18, 2021 at 9:17 AM Thomas Gleixner wrote: > > On Sat, Apr 17 2021 at 17:11, Andy Lutomirski wrote: > > On Sat, Apr 17, 2021 at 4:53 PM Thomas Gleixner wrote: > >> which works for > >> > >> foo = function_nocfi(bar); > > > >

Re: [PATCH 05/15] x86: Implement function_nocfi

2021-04-17 Thread Andy Lutomirski
On Sat, Apr 17, 2021 at 4:53 PM Thomas Gleixner wrote: > > On Sat, Apr 17 2021 at 16:19, Andy Lutomirski wrote: > > On Fri, Apr 16, 2021 at 4:40 PM Kees Cook wrote: > >> Okay, you're saying you want __builtin_gimme_body_p() to be a constant > >> expression fo

Re: [PATCH 05/15] x86: Implement function_nocfi

2021-04-17 Thread Andy Lutomirski
On Fri, Apr 16, 2021 at 4:40 PM Kees Cook wrote: > > > 1. I defined a function in asm. I want to tell clang that this > > function is defined in asm, and for clang to behave accordingly: > > > > .globl func > > func: > > ; do stuff > > > > later: > > > > extern void func(void) [something

Re: [PATCH 05/15] x86: Implement function_nocfi

2021-04-17 Thread Andy Lutomirski
> On Apr 17, 2021, at 7:20 AM, David Laight wrote: > > From: Kees Cook >> Sent: 16 April 2021 23:28 >> >>> On Fri, Apr 16, 2021 at 03:06:17PM -0700, Andy Lutomirski wrote: >>> On Fri, Apr 16, 2021 at 3:03 PM Borislav Petkov wrote: >>>>

Re: [PATCH 05/15] x86: Implement function_nocfi

2021-04-16 Thread Andy Lutomirski
On Fri, Apr 16, 2021 at 3:28 PM Kees Cook wrote: > > On Fri, Apr 16, 2021 at 03:06:17PM -0700, Andy Lutomirski wrote: > > On Fri, Apr 16, 2021 at 3:03 PM Borislav Petkov wrote: > > > > > > On Fri, Apr 16, 2021 at 02:49:23PM -0700, Sami Tolvanen wrote: > > &g

Re: [PATCH 05/15] x86: Implement function_nocfi

2021-04-16 Thread Andy Lutomirski
On Fri, Apr 16, 2021 at 3:14 PM Borislav Petkov wrote: > > On Fri, Apr 16, 2021 at 03:06:17PM -0700, Andy Lutomirski wrote: > > On Fri, Apr 16, 2021 at 3:03 PM Borislav Petkov wrote: > > > > > > On Fri, Apr 16, 2021 at 02:49:23PM -0700, Sami Tolvanen wrote: >

Re: Candidate Linux ABI for Intel AMX and hypothetical new related features

2021-04-16 Thread Andy Lutomirski
On Fri, Apr 16, 2021 at 3:11 PM Len Brown wrote: > > > I get it. That does not explain why LDMXCSR and VLDMXCSR cause > > pipelines stalls. > > Sorry, I thought this thread was about AMX. > I don't know the answer to your LDMXCSR and VLDMXCSR question. My point is that every single major math

Re: [PATCH 05/15] x86: Implement function_nocfi

2021-04-16 Thread Andy Lutomirski
On Fri, Apr 16, 2021 at 3:03 PM Borislav Petkov wrote: > > On Fri, Apr 16, 2021 at 02:49:23PM -0700, Sami Tolvanen wrote: > > __nocfi only disables CFI checking in a function, the compiler still > > changes function addresses to point to the CFI jump table, which is > > why we need

Re: Candidate Linux ABI for Intel AMX and hypothetical new related features

2021-04-16 Thread Andy Lutomirski
On Fri, Apr 16, 2021 at 2:54 PM Len Brown wrote: > > On Thu, Apr 15, 2021 at 12:24 PM Andy Lutomirski wrote: > > On Wed, Apr 14, 2021 at 2:48 PM Len Brown wrote: > > > > > ... the transition penalty into and out of AMX code > > The concept of 'transition' exists

Re: Candidate Linux ABI for Intel AMX and hypothetical new related features

2021-04-15 Thread Andy Lutomirski
> On Apr 15, 2021, at 10:00 AM, Dave Hansen wrote: > > On 4/15/21 9:24 AM, Andy Lutomirski wrote: >> In the patches, *as submitted*, if you trip the XFD #NM *once* and you >> are the only thread on the system to do so, you will eat the cost of a >> WRMSR on ever

Re: Candidate Linux ABI for Intel AMX and hypothetical new related features

2021-04-15 Thread Andy Lutomirski
On Wed, Apr 14, 2021 at 2:48 PM Len Brown wrote: > > > > Then I take the transition penalty into and out of AMX code (I'll > > believe there is no penalty when I see it -- we've had a penalty with > > VEX and with AVX-512) and my program runs *slower*. > > If you have a clear definition of what

Re: [PATCH V3 2/2] perf/x86: Reset the dirty counter to prevent the leak for an RDPMC task

2021-04-13 Thread Andy Lutomirski
On Tue, Apr 13, 2021 at 12:05 PM wrote: > > From: Kan Liang > > The counter value of a perf task may leak to another RDPMC task. > For example, a perf stat task as below is running on CPU 0. > > perf stat -e 'branches,cycles' -- taskset -c 0 ./workload I assume this doesn't fix the leak if

Re: Candidate Linux ABI for Intel AMX and hypothetical new related features

2021-04-13 Thread Andy Lutomirski
On Tue, Apr 13, 2021 at 3:47 PM Len Brown wrote: > > On Tue, Apr 13, 2021 at 4:16 PM Andy Lutomirski wrote: > > > > On Mon, Apr 12, 2021 at 4:46 PM Len Brown wrote: > > > > > > On Mon, Apr 12, 2021 at 11:21 AM Andy Lutomirski wrote: > > > > &g

Re: Candidate Linux ABI for Intel AMX and hypothetical new related features

2021-04-13 Thread Andy Lutomirski
On Mon, Apr 12, 2021 at 4:46 PM Len Brown wrote: > > On Mon, Apr 12, 2021 at 11:21 AM Andy Lutomirski wrote: > > > AMX: Multiplying a 4x4 matrix probably looks *great* in a > > microbenchmark. Do it once and you permanently allocate 8kB (is that > > even a constant?

Re: [PATCH] x86/efi: Do not release sub-1MB memory regions when the crashkernel option is specified

2021-04-12 Thread Andy Lutomirski
On Mon, Apr 12, 2021 at 2:52 AM Baoquan He wrote: > > On 04/11/21 at 06:49pm, Andy Lutomirski wrote: > > > > > > > On Apr 11, 2021, at 6:14 PM, Baoquan He wrote: > > > > > > On 04/09/21 at 07:59pm, H. Peter Anvin wrote: > > >> Why don't

Re: Candidate Linux ABI for Intel AMX and hypothetical new related features

2021-04-12 Thread Andy Lutomirski
On Mon, Apr 12, 2021 at 7:19 AM Florian Weimer wrote: > > * Andy Lutomirski: > > Maybe we could have done this in 2016 when I reported this for the first > time. Now it is too late, as more and more software is using > CPUID-based detection for AVX-512. Our users have

Re: Candidate Linux ABI for Intel AMX and hypothetical new related features

2021-04-12 Thread Andy Lutomirski
> On Apr 12, 2021, at 7:38 AM, Florian Weimer wrote: > > * Borislav Petkov: > >>> On Mon, Apr 12, 2021 at 04:19:29PM +0200, Florian Weimer wrote: >>> Maybe we could have done this in 2016 when I reported this for the first >>> time. Now it is too late, as more and more software is using

Re: [PATCH] x86/efi: Do not release sub-1MB memory regions when the crashkernel option is specified

2021-04-11 Thread Andy Lutomirski
> On Apr 11, 2021, at 6:14 PM, Baoquan He wrote: > > On 04/09/21 at 07:59pm, H. Peter Anvin wrote: >> Why don't we do this unconditionally? At the very best we gain half a >> megabyte of memory (except the trampoline, which has to live there, but it >> is only a few kilobytes.) > > This

Re: [PATCH] x86/msr: Block writes to certain MSRs unconditionally

2021-04-11 Thread Andy Lutomirski
On Sun, Apr 11, 2021 at 10:04 AM Borislav Petkov wrote: > > On Sun, Apr 11, 2021 at 09:57:20AM -0700, Andy Lutomirski wrote: > > Working around a kernel bug. The workaround only worked on AMD > > systems. The correct solution was to fix the kernel bug, not poke > > MSRs. &

Re: [PATCH] x86/msr: Block writes to certain MSRs unconditionally

2021-04-11 Thread Andy Lutomirski
> On Apr 11, 2021, at 9:43 AM, Andi Kleen wrote: > >  >> >> I have actually seen real user programs poke MSR_SYSCALL_MASK. > > Hmm, what was the use case? > > Working around a kernel bug. The workaround only worked on AMD systems. The correct solution was to fix the kernel bug, not

Re: [PATCH] x86/msr: Block writes to certain MSRs unconditionally

2021-04-11 Thread Andy Lutomirski
On Sat, Apr 10, 2021 at 11:52 AM Andi Kleen wrote: > > Borislav Petkov writes: > > > From: Borislav Petkov > > Date: Sat, 10 Apr 2021 14:08:13 +0200 > > > > There are a bunch of MSRs which luserspace has no business poking at, > > whatsoever. Add a ban list and put the TSC-related MSRs in

Re: [PATCH] x86/msr: Block writes to certain MSRs unconditionally

2021-04-10 Thread Andy Lutomirski
> On Apr 10, 2021, at 5:11 AM, Borislav Petkov wrote: > > From: Borislav Petkov > Date: Sat, 10 Apr 2021 14:08:13 +0200 > > There are a bunch of MSRs which luserspace has no business poking at, > whatsoever. Add a ban list and put the TSC-related MSRs in there. Issue > a big juicy splat to

Re: Candidate Linux ABI for Intel AMX and hypothetical new related features

2021-04-09 Thread Andy Lutomirski
On Fri, Apr 9, 2021 at 1:53 PM Len Brown wrote: > > On Wed, Mar 31, 2021 at 6:45 PM Andy Lutomirski wrote: > > > > On Wed, Mar 31, 2021 at 3:28 PM Len Brown wrote: > > > > > We added compiler annotation for user-level interrupt handlers. > > > I'm n

Re: [RFC PATCH 13/37] mm: implement speculative handling in __handle_mm_fault().

2021-04-07 Thread Andy Lutomirski
On 4/6/21 6:44 PM, Michel Lespinasse wrote: > The page table tree is walked with local irqs disabled, which prevents > page table reclamation (similarly to what fast GUP does). The logic is > otherwise similar to the non-speculative path, but with additional > restrictions: in the speculative

Re: [PATCH v24 25/30] x86/cet/shstk: Handle signals for shadow stack

2021-04-06 Thread Andy Lutomirski
On Thu, Apr 1, 2021 at 3:11 PM Yu-cheng Yu wrote: > > When shadow stack is enabled, a task's shadow stack states must be saved > along with the signal context and later restored in sigreturn. However, > currently there is no systematic facility for extending a signal context. > > Introduce a

Re: [PATCH v24 24/30] x86/cet/shstk: Introduce shadow stack token setup/verify routines

2021-04-06 Thread Andy Lutomirski
On Thu, Apr 1, 2021 at 3:12 PM Yu-cheng Yu wrote: > > A shadow stack restore token marks a restore point of the shadow stack, and > the address in a token must point directly above the token, which is within > the same shadow stack. This is distinctively different from other pointers > on the

Re: Candidate Linux ABI for Intel AMX and hypothetical new related features

2021-03-31 Thread Andy Lutomirski
On Wed, Mar 31, 2021 at 3:28 PM Len Brown wrote: > > On Wed, Mar 31, 2021 at 12:53 PM Andy Lutomirski wrote: > > > But this whole annotation thing will require serious compiler support. > > We already have problems with compilers inlining functions and getting > >

Re: Candidate Linux ABI for Intel AMX and hypothetical new related features

2021-03-31 Thread Andy Lutomirski
> On Mar 31, 2021, at 9:31 AM, Len Brown wrote: > > On Tue, Mar 30, 2021 at 6:01 PM David Laight wrote: > >>> Can we leave it in live registers? That would be the speed-of-light >>> signal handler approach. But we'd need to teach the signal handler to >>> not clobber it. Perhaps that

Re: Candidate Linux ABI for Intel AMX and hypothetical new related features

2021-03-30 Thread Andy Lutomirski
> On Mar 30, 2021, at 12:12 PM, Dave Hansen wrote: > > On 3/30/21 10:56 AM, Len Brown wrote: >> On Tue, Mar 30, 2021 at 1:06 PM Andy Lutomirski wrote: >>>> On Mar 30, 2021, at 10:01 AM, Len Brown wrote: >>>> Is it required (by the "ABI") tha

Re: Candidate Linux ABI for Intel AMX and hypothetical new related features

2021-03-30 Thread Andy Lutomirski
> On Mar 30, 2021, at 10:01 AM, Len Brown wrote: > > Andy, > > I agree, completely, with your description of the challenge, > thank you for focusing the discussion on that problem statement. > > Question: > > Is it required (by the "ABI") that a user program has everything > on the stack

Re: [PATCH v3 1/1] x86/tdx: Handle MWAIT, MONITOR and WBINVD

2021-03-30 Thread Andy Lutomirski
> On Mar 30, 2021, at 8:14 AM, Sean Christopherson wrote: > > On Mon, Mar 29, 2021, Andy Lutomirski wrote: >> >>>> On Mar 29, 2021, at 7:04 PM, Andi Kleen wrote: >>> >>>  >>>> >>>>> No, if these instructions take

Re: Candidate Linux ABI for Intel AMX and hypothetical new related features

2021-03-29 Thread Andy Lutomirski
On Mon, Mar 29, 2021 at 3:38 PM Len Brown wrote: > > On Mon, Mar 29, 2021 at 2:16 PM Andy Lutomirski wrote: > > > Hi Andy, > > Can you provide a concise definition of the exact problemI(s) this thread > is attempting to address? The AVX-512 state, all by itself,

Re: [PATCH v3 1/1] x86/tdx: Handle MWAIT, MONITOR and WBINVD

2021-03-29 Thread Andy Lutomirski
> On Mar 29, 2021, at 7:04 PM, Andi Kleen wrote: > >  >> >>> No, if these instructions take a #VE then they were executed at CPL=0. >>> MONITOR >>> and MWAIT will #UD without VM-Exit->#VE. Same for WBINVD, s/#UD/#GP. >> >> Dare I ask about XSETBV? > > XGETBV does not cause a #VE, it

Re: [PATCH v3 1/1] x86/tdx: Handle MWAIT, MONITOR and WBINVD

2021-03-29 Thread Andy Lutomirski
On Mon, Mar 29, 2021 at 4:42 PM Sean Christopherson wrote: > > On Mon, Mar 29, 2021, Kuppuswamy, Sathyanarayanan wrote: > > > > > > On 3/29/21 4:23 PM, Andy Lutomirski wrote: > > > > > > > On Mar 29, 2021, at 4:17 PM, Kuppuswamy Sathyanarayanan >

Re: I915 CI-run with kfence enabled, issues found

2021-03-29 Thread Andy Lutomirski
> On Mar 29, 2021, at 2:55 PM, Marco Elver wrote: > > On Mon, 29 Mar 2021 at 23:47, Andy Lutomirski wrote: >> >> >>>> On Mar 29, 2021, at 2:34 PM, Marco Elver wrote: >>> >>> On Mon, 29 Mar 2021 at 23:03, Dave Hansen wrote: >>>

Re: [PATCH v3 1/1] x86/tdx: Handle MWAIT, MONITOR and WBINVD

2021-03-29 Thread Andy Lutomirski
> On Mar 29, 2021, at 4:17 PM, Kuppuswamy Sathyanarayanan > wrote: > > In non-root TDX guest mode, MWAIT, MONITOR and WBINVD instructions > are not supported. So handle #VE due to these instructions > appropriately. Is there something I missed elsewhere in the code that checks CPL?

Re: I915 CI-run with kfence enabled, issues found

2021-03-29 Thread Andy Lutomirski
> On Mar 29, 2021, at 2:34 PM, Marco Elver wrote: > > On Mon, 29 Mar 2021 at 23:03, Dave Hansen wrote: >>> On 3/29/21 10:45 AM, Marco Elver wrote: On Mon, 29 Mar 2021 at 19:32, Dave Hansen wrote: >>> Doing it to all CPUs is too expensive, and we can tolerate this being >>> approximate

Re: Candidate Linux ABI for Intel AMX and hypothetical new related features

2021-03-29 Thread Andy Lutomirski
> On Mar 29, 2021, at 8:47 AM, Len Brown wrote: > > On Sat, Mar 27, 2021 at 5:58 AM Greg KH wrote: >>> On Fri, Mar 26, 2021 at 11:39:18PM -0400, Len Brown wrote: >>> Hi Andy, >>> Say a mainline links with a math library that uses AMX without the >>> knowledge of the mainline. > > sorry for

Re: Candidate Linux ABI for Intel AMX and hypothetical new related features

2021-03-29 Thread Andy Lutomirski
> On Mar 29, 2021, at 9:39 AM, Len Brown wrote: > >  >> >> In particular, the library may use instructions that main() doesn't know >> exist. > > And so I'll ask my question another way. > > How is it okay to change the value of XCR0 during the run time of a program? > > I submit that

Re: [PATCH v4 14/22] x86/fpu/xstate: Expand the xstate buffer on the first use of dynamic user state

2021-03-29 Thread Andy Lutomirski
> On Mar 29, 2021, at 9:06 AM, Len Brown wrote: > > On Mon, Mar 29, 2021 at 11:43 AM Len Brown wrote: >> >> On Mon, Mar 29, 2021 at 9:33 AM Thomas Gleixner wrote: >> I found the author of this passage, and he agreed to revise it to say this was targeted primarily at VMMs. >>>

Re: [PATCH v1 1/1] x86/tdx: Handle MWAIT, MONITOR and WBINVD

2021-03-27 Thread Andy Lutomirski
> On Mar 26, 2021, at 8:40 PM, Kuppuswamy, Sathyanarayanan > wrote: > >  > > On 3/26/21 7:40 PM, Andy Lutomirski wrote: >>>> On Mar 26, 2021, at 5:18 PM, Kuppuswamy Sathyanarayanan >>>> wrote: >>> >>> In non

Re: [PATCH v1 1/1] x86/tdx: Handle MWAIT, MONITOR and WBINVD

2021-03-26 Thread Andy Lutomirski
> On Mar 26, 2021, at 5:18 PM, Kuppuswamy Sathyanarayanan > wrote: > > In non-root TDX guest mode, MWAIT, MONITOR and WBINVD instructions > are not supported. So handle #VE due to these instructions as no ops. These should at least be WARN. Does TDX send #UD if these instructions have the

Re: Candidate Linux ABI for Intel AMX and hypothetical new related features

2021-03-26 Thread Andy Lutomirski
Sigh, cc linux-api, not linux-abi. On Fri, Mar 26, 2021 at 4:12 PM Andy Lutomirski wrote: > > Hi all- > > After some discussion on IRC, I have a proposal for a Linux ABI for > using Intel AMX and other similar features. It works like this: > > First, we make XCR0 dynamic.

Candidate Linux ABI for Intel AMX and hypothetical new related features

2021-03-26 Thread Andy Lutomirski
Hi all- After some discussion on IRC, I have a proposal for a Linux ABI for using Intel AMX and other similar features. It works like this: First, we make XCR0 dynamic. This looks a lot like Keno's patch but with a different API, outlined below. Different tasks can have different XCR0 values.

Re: Why does glibc use AVX-512?

2021-03-26 Thread Andy Lutomirski
> On Mar 26, 2021, at 2:11 PM, Florian Weimer wrote: > > * Andy Lutomirski: > >>> On Fri, Mar 26, 2021 at 1:35 PM Florian Weimer wrote: >>> >>> I mean the immense slowdown you get if you use %xmm registers after > their %ymm counterparts (doesn'

Re: Why does glibc use AVX-512?

2021-03-26 Thread Andy Lutomirski
On Fri, Mar 26, 2021 at 1:35 PM Florian Weimer wrote: > > * Andy Lutomirski: > > > On Fri, Mar 26, 2021 at 12:34 PM Florian Weimer wrote: > >> x86: Sporadic failures in tst-cpu-features-cpuinfo > >> <https://sourceware.org/bugzilla/show_bug.cgi?id

Re: Why does glibc use AVX-512?

2021-03-26 Thread Andy Lutomirski
On Fri, Mar 26, 2021 at 12:34 PM Florian Weimer wrote: > > * Andy Lutomirski: > > >> > AVX-512 cleared, and programs need to explicitly request enablement. > >> > This would allow programs to opt into not saving/restoring across > >> > signal

Re: Why does glibc use AVX-512?

2021-03-26 Thread Andy Lutomirski
On Fri, Mar 26, 2021 at 3:08 AM Borislav Petkov wrote: > > On Thu, Mar 25, 2021 at 09:38:24PM -0700, Andy Lutomirski wrote: > > I think we should seriously consider solutions in which, for new > > tasks, XCR0 has new giant features (e.g. AMX) and possibly even > > AVX-5

Re: Why does glibc use AVX-512?

2021-03-26 Thread Andy Lutomirski
On Fri, Mar 26, 2021 at 5:12 AM Florian Weimer wrote: > > * Andy Lutomirski-alpha: > > > glibc appears to use AVX512F for memcpy by default. (Unless > > Prefer_ERMS is default-on, but I genuinely can't tell if this is the > > case. I did some searching.) The commit

Re: [PATCH v4 22/22] x86/fpu/xstate: Introduce boot-parameters to control state component support

2021-03-26 Thread Andy Lutomirski
On Fri, Mar 26, 2021 at 10:54 AM Len Brown wrote: > > On Fri, Mar 26, 2021 at 11:48 AM Andy Lutomirski wrote: > > > > I submit, that after the generic XFD support is in place, > > > there is exactly 1 bit that needs to be flipped to enable > > > u

Re: [PATCH v4 22/22] x86/fpu/xstate: Introduce boot-parameters to control state component support

2021-03-26 Thread Andy Lutomirski
On Fri, Mar 26, 2021 at 8:34 AM Len Brown wrote: > > On Thu, Mar 25, 2021 at 9:42 PM Andy Lutomirski wrote: > > > Regardless of what you call AMX, AMX requires kernel enabling. > > I submit, that after the generic XFD support is in place, > there is exactly 1 bit

Re: [PATCH v7 5/6] x86/signal: Detect and prevent an alternate signal stack overflow

2021-03-25 Thread Andy Lutomirski
I forgot to mention why I cc'd all you fine Xen folk: On Thu, Mar 25, 2021 at 11:13 AM Andy Lutomirski wrote: > > > } else if (IS_ENABLED(CONFIG_X86_32) && > >!onsigstack && > >regs->ss != __USER_DS &&am

Re: [PATCH v7 5/6] x86/signal: Detect and prevent an alternate signal stack overflow

2021-03-25 Thread Andy Lutomirski
On Thu, Mar 25, 2021 at 11:54 AM Borislav Petkov wrote: > > On Thu, Mar 25, 2021 at 11:13:12AM -0700, Andy Lutomirski wrote: > > diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c > > index ea794a083c44..53781324a2d3 100644 > > --- a/arch/x86/kernel/sig

Why does glibc use AVX-512?

2021-03-25 Thread Andy Lutomirski
Hi all- glibc appears to use AVX512F for memcpy by default. (Unless Prefer_ERMS is default-on, but I genuinely can't tell if this is the case. I did some searching.) The commit adding it refers to a 2016 email saying that it's 30% on KNL. Unfortunately, AVX-512 is now available in normal

Re: [PATCH v4 22/22] x86/fpu/xstate: Introduce boot-parameters to control state component support

2021-03-25 Thread Andy Lutomirski
On Thu, Mar 25, 2021 at 3:59 PM Len Brown wrote: > > On Sat, Mar 20, 2021 at 4:57 PM Thomas Gleixner wrote: > > > We won't enable features which are unknown ever. Keep that presilicon > > test gunk where it belongs: In the Intel poison cabinet along with the > > rest of the code which nobody

Re: [PATCH v7 5/6] x86/signal: Detect and prevent an alternate signal stack overflow

2021-03-25 Thread Andy Lutomirski
On Mon, Mar 15, 2021 at 11:57 PM Chang S. Bae wrote: > > The kernel pushes context on to the userspace stack to prepare for the > user's signal handler. When the user has supplied an alternate signal > stack, via sigaltstack(2), it is easy for the kernel to verify that the > stack size is

Re: [PATCH v4 14/22] x86/fpu/xstate: Expand the xstate buffer on the first use of dynamic user state

2021-03-24 Thread Andy Lutomirski
> On Mar 24, 2021, at 2:58 PM, Dave Hansen wrote: > > On 3/24/21 2:42 PM, Andy Lutomirski wrote: >>>>> 3. user space always uses fully uncompacted XSAVE buffers. >>>>> >>>> There is no reason we have to do this for new states. Arguably we &

Re: [PATCH v4 14/22] x86/fpu/xstate: Expand the xstate buffer on the first use of dynamic user state

2021-03-24 Thread Andy Lutomirski
> On Mar 24, 2021, at 2:30 PM, Dave Hansen wrote: > > On 3/24/21 2:26 PM, Andy Lutomirski wrote: >>> 3. user space always uses fully uncompacted XSAVE buffers. >>> >> There is no reason we have to do this for new states. Arguably we >> shouldn’

Re: [PATCH v4 14/22] x86/fpu/xstate: Expand the xstate buffer on the first use of dynamic user state

2021-03-24 Thread Andy Lutomirski
> On Mar 24, 2021, at 2:09 PM, Len Brown wrote: > > On Tue, Mar 23, 2021 at 11:15 PM Liu, Jing2 > wrote: > >>> IMO, the problem with AVX512 state >>> is that we guaranteed it will be zero for XINUSE=0. >>> That means we have to write 0's on saves. > >> why "we have to write 0's on

Re: Is s390's new generic-using syscall code actually correct?

2021-03-24 Thread Andy Lutomirski
On Wed, Mar 24, 2021 at 10:39 AM Vasily Gorbik wrote: > > Hi Andy, > > On Sat, Mar 20, 2021 at 08:48:34PM -0700, Andy Lutomirski wrote: > > Hi all- > > > > I'm working on my kentry patchset, and I encountered: > > > > commit 56e62a73702836017564eaac

Re: [RFC Part2 PATCH 06/30] x86/fault: dump the RMP entry on #PF

2021-03-24 Thread Andy Lutomirski
On Wed, Mar 24, 2021 at 10:04 AM Brijesh Singh wrote: > > If hardware detects an RMP violation, it will raise a page-fault exception > with the RMP bit set. To help the debug, dump the RMP entry of the faulting > address. > > Cc: Thomas Gleixner > Cc: Ingo Molnar > Cc: Borislav Petkov > Cc:

Is s390's new generic-using syscall code actually correct?

2021-03-20 Thread Andy Lutomirski
Hi all- I'm working on my kentry patchset, and I encountered: commit 56e62a73702836017564eaacd5212e4d0fa1c01d Author: Sven Schnelle Date: Sat Nov 21 11:14:56 2020 +0100 s390: convert to generic entry As part of this work, I was cleaning up the generic syscall helpers, and I encountered

Re: [PATCH v4 14/22] x86/fpu/xstate: Expand the xstate buffer on the first use of dynamic user state

2021-03-20 Thread Andy Lutomirski
On Sat, Mar 20, 2021 at 3:13 PM Thomas Gleixner wrote: > > On Sun, Feb 21 2021 at 10:56, Chang S. Bae wrote: > > + > > +/* Update MSR IA32_XFD with xfirstuse_not_detected() if needed. */ > > +static inline void xdisable_switch(struct fpu *prev, struct fpu *next) > > +{ > > + if

Re: [PATCH] Document that PF_KTHREAD _is_ ABI

2021-03-20 Thread Andy Lutomirski
> On Mar 20, 2021, at 9:31 AM, Alexey Dobriyan wrote: > > PF_KTHREAD value is visible via field number 9 of /proc/*/stat > >$ sudo cat /proc/2/stat >2 (kthreadd) S 0 0 0 0 -1 2129984 0 ... > ^^^ > > It is used by at least systemd to check for kernel-threadness: >

[tip: x86/misc] selftests/x86: Add a missing .note.GNU-stack section to thunks_32.S

2021-03-18 Thread tip-bot2 for Andy Lutomirski
The following commit has been merged into the x86/misc branch of tip: Commit-ID: f706bb59204ba1c47e896b456c97977fc97b7964 Gitweb: https://git.kernel.org/tip/f706bb59204ba1c47e896b456c97977fc97b7964 Author:Andy Lutomirski AuthorDate:Thu, 04 Mar 2021 09:01:55 -08:00

[PATCH v4 8/9] kentry: Check that syscall entries and syscall exits match

2021-03-17 Thread Andy Lutomirski
If arch code calls the wrong kernel entry helpers, syscall entries and exits can get out of sync. Add a new field to task_struct to track the syscall state and validate that it transitions correctly. Signed-off-by: Andy Lutomirski --- include/linux/sched.h | 4 init/init_task.c | 8

[PATCH v4 9/9] kentry: Verify kentry state in instrumentation_begin/end()

2021-03-17 Thread Andy Lutomirski
-by: Andy Lutomirski --- arch/x86/kernel/traps.c | 4 ++-- include/asm-generic/bug.h | 8 include/linux/instrumentation.h | 25 - kernel/entry/common.c | 7 +++ 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/arch/x86/kernel

[PATCH v4 7/9] kentry: Add debugging checks for proper kentry API usage

2021-03-17 Thread Andy Lutomirski
It's quite easy to mess up kentry calls. Add debgging checks that kentry transitions to and from user mode match up and that kentry_nmi_enter() and kentry_nmi_exit() match up. Checking full matching of kentry_enter() with kentry_exit() needs per-task state. Signed-off-by: Andy Lutomirski

[PATCH v4 4/9] kentry: Simplify the common syscall API

2021-03-17 Thread Andy Lutomirski
Signed-off-by: Andy Lutomirski --- arch/x86/entry/common.c | 57 +++- include/linux/entry-common.h | 86 ++-- kernel/entry/common.c| 57 +++- 3 files changed, 54 insertions(+), 146 deletions(-) diff --git

[PATCH v4 6/9] entry: Make CONFIG_DEBUG_ENTRY available outside x86

2021-03-17 Thread Andy Lutomirski
. If an architecture wants to use DEBUG_ENTRY without using GENERIC_ENTRY, this could be changed. Signed-off-by: Andy Lutomirski --- arch/x86/Kconfig.debug | 10 -- lib/Kconfig.debug | 11 +++ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/arch/x86/Kconfig.debug b/arch

[PATCH v4 5/9] kentry: Remove enter_from/exit_to_user_mode()

2021-03-17 Thread Andy Lutomirski
isn't built on arm64. So this patch also reduces confusion for people who grep the tree and might previously have thought that arm64 used this code. Signed-off-by: Andy Lutomirski --- include/linux/entry-common.h | 41 kernel/entry/common.c| 10

[PATCH v4 3/9] x86/entry: Convert ret_from_fork to C

2021-03-17 Thread Andy Lutomirski
Poimboeuf Signed-off-by: Andy Lutomirski --- arch/x86/entry/common.c | 23 ++ arch/x86/entry/entry_32.S| 51 +--- arch/x86/entry/entry_64.S| 33 + arch/x86/include/asm/switch_to.h | 2 +- arch/x86/kernel

[PATCH v4 1/9] x86/dumpstack: Remove unnecessary range check fetching opcode bytes

2021-03-17 Thread Andy Lutomirski
copy_from_user_nmi() validates that the pointer is in the user range, so there is no need for an extra check in copy_code(). Signed-off-by: Andy Lutomirski --- arch/x86/kernel/dumpstack.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel

[PATCH v4 2/9] x86/kthread,dumpstack: Set task_pt_regs->cs.RPL=3 for kernel threads

2021-03-17 Thread Andy Lutomirski
of fetch failed. This makes it much easier to understand what's happening. Cc: Josh Poimboeuf Signed-off-by: Andy Lutomirski --- arch/x86/kernel/dumpstack.c | 4 ++-- arch/x86/kernel/process.c | 13 + 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel

[PATCH v4 0/9] kentry: A stable bugfix and a bunch of improvements

2021-03-17 Thread Andy Lutomirski
work involved a small change to ret_from_fork, and adjusting the asm is a mess. So C it is. Changes from v3: Get rid of arm64 special cases Changes from v1 and v2: Complete rewrite Andy Lutomirski (9): x86/dumpstack: Remove unnecessary range check fetching opcode bytes x86/kthread,dumpstack

Re: [PATCH -tip 0/3] x86/kprobes: Remoev single-step trap from x86 kprobes

2021-03-17 Thread Andy Lutomirski
On Wed, Mar 17, 2021 at 9:27 AM Peter Zijlstra wrote: > > On Wed, Mar 17, 2021 at 11:55:22PM +0900, Masami Hiramatsu wrote: > > Hi Andy, > > > > Would you think you still need this series to remove iret to kernel? > > They're an improvement anyway, let me queue them so that they don't get > lost.

Re: [PATCH v3 07/11] kentry: Make entry/exit_to_user_mode() arm64-only

2021-03-13 Thread Andy Lutomirski
On Mon, Mar 8, 2021 at 2:06 AM Mark Rutland wrote: > > On Thu, Mar 04, 2021 at 11:06:00AM -0800, Andy Lutomirski wrote: > > exit_to_user_mode() does part, but not all, of the exit-to-user-mode work. > > It's used only by arm64, and arm64 should stop using it (hint, hint!).

Re: [syzbot] WARNING in handle_mm_fault

2021-03-11 Thread Andy Lutomirski
Your warning is odd, but I see the bug. It's in KVM. On Thu, Mar 11, 2021 at 4:37 PM syzbot wrote: > > Hello, > > syzbot found the following issue on: > > HEAD commit:05a59d79 Merge git://git.kernel.org:/pub/scm/linux/kernel/.. > git tree: upstream > console output:

Re: [PATCH v3] x86/fault: Send a SIGBUS to user process always for hwpoison page access.

2021-03-10 Thread Andy Lutomirski
On Wed, Mar 10, 2021 at 5:19 PM Aili Yao wrote: > > On Mon, 8 Mar 2021 11:00:28 -0800 > Andy Lutomirski wrote: > > > > On Mar 8, 2021, at 10:31 AM, Luck, Tony wrote: > > > > > >  > > >> > > >> Can you point me at that SIGB

Re: [PATCH v3] x86/fault: Send a SIGBUS to user process always for hwpoison page access.

2021-03-08 Thread Andy Lutomirski
> On Mar 8, 2021, at 10:31 AM, Luck, Tony wrote: > >  >> >> Can you point me at that SIGBUS code in a current kernel? > > It is in kill_me_maybe(). mce_vaddr is setup when we disassemble whatever > get_user() > or copy from user variant was in use in the kernel when the poison memory was

Re: [PATCH v3] x86/fault: Send a SIGBUS to user process always for hwpoison page access.

2021-03-08 Thread Andy Lutomirski
> On Mar 8, 2021, at 1:49 AM, Aili Yao wrote: > > On Sun, 7 Mar 2021 11:16:24 -0800 > Andy Lutomirski wrote: > >>>>>>> Some programs may use read(2), write(2), etc as ways to check if >>>>>>> memory is valid without getting a

[tip: x86/core] x86/stackprotector/32: Make the canary into a regular percpu variable

2021-03-08 Thread tip-bot2 for Andy Lutomirski
The following commit has been merged into the x86/core branch of tip: Commit-ID: 3fb0fdb3bbe7aed495109b3296b06c2409734023 Gitweb: https://git.kernel.org/tip/3fb0fdb3bbe7aed495109b3296b06c2409734023 Author:Andy Lutomirski AuthorDate:Sat, 13 Feb 2021 11:19:44 -08:00

[tip: x86/core] x86/entry/32: Remove leftover macros after stackprotector cleanups

2021-03-08 Thread tip-bot2 for Andy Lutomirski
The following commit has been merged into the x86/core branch of tip: Commit-ID: d0962f2b24c99889a386f0658c71535f56358f77 Gitweb: https://git.kernel.org/tip/d0962f2b24c99889a386f0658c71535f56358f77 Author:Andy Lutomirski AuthorDate:Sat, 13 Feb 2021 11:19:45 -08:00

Re: [PATCH v3] x86/fault: Send a SIGBUS to user process always for hwpoison page access.

2021-03-07 Thread Andy Lutomirski
On Wed, Mar 3, 2021 at 4:51 AM Aili Yao wrote: > > On Wed, 3 Mar 2021 20:24:02 +0800 > Aili Yao wrote: > > > On Mon, 1 Mar 2021 11:09:36 -0800 > > Andy Lutomirski wrote: > > > > > > On Mar 1, 2021, at 11:02 AM, Luck, Tony wrote: > > > > &g

[tip: x86/urgent] x86/entry: Fix entry/exit mismatch on failed fast 32-bit syscalls

2021-03-06 Thread tip-bot2 for Andy Lutomirski
The following commit has been merged into the x86/urgent branch of tip: Commit-ID: 5d5675df792ff67e74a500c4c94db0f99e6a10ef Gitweb: https://git.kernel.org/tip/5d5675df792ff67e74a500c4c94db0f99e6a10ef Author:Andy Lutomirski AuthorDate:Thu, 04 Mar 2021 11:05:54 -08:00

[tip: x86/urgent] x86/entry: Fix entry/exit mismatch on failed fast 32-bit syscalls

2021-03-06 Thread tip-bot2 for Andy Lutomirski
The following commit has been merged into the x86/urgent branch of tip: Commit-ID: e59ba7bf71a09e474198741563e0e587ae43d1c7 Gitweb: https://git.kernel.org/tip/e59ba7bf71a09e474198741563e0e587ae43d1c7 Author:Andy Lutomirski AuthorDate:Thu, 04 Mar 2021 11:05:54 -08:00

[tip: x86/urgent] x86/entry: Fix entry/exit mismatch on failed fast 32-bit syscalls

2021-03-05 Thread tip-bot2 for Andy Lutomirski
The following commit has been merged into the x86/urgent branch of tip: Commit-ID: dabf017539988a9bfc40a38dbafd35c501bacc44 Gitweb: https://git.kernel.org/tip/dabf017539988a9bfc40a38dbafd35c501bacc44 Author:Andy Lutomirski AuthorDate:Thu, 04 Mar 2021 11:05:54 -08:00

[PATCH v3 10/11] kentry: Check that syscall entries and syscall exits match

2021-03-04 Thread Andy Lutomirski
If arch code calls the wrong kernel entry helpers, syscall entries and exits can get out of sync. Add a new field to task_struct to track the syscall state and validate that it transitions correctly. Signed-off-by: Andy Lutomirski --- include/linux/sched.h | 4 init/init_task.c | 8

[PATCH v3 07/11] kentry: Make entry/exit_to_user_mode() arm64-only

2021-03-04 Thread Andy Lutomirski
(). It's also only used by arm64. Give it the same treatment. Signed-off-by: Andy Lutomirski --- include/linux/entry-common.h | 34 ++ kernel/entry/common.c| 4 2 files changed, 10 insertions(+), 28 deletions(-) diff --git a/include/linux/entry-common.h

[PATCH v3 11/11] kentry: Verify kentry state in instrumentation_begin/end()

2021-03-04 Thread Andy Lutomirski
-by: Andy Lutomirski --- arch/x86/kernel/traps.c | 4 ++-- include/asm-generic/bug.h | 8 include/linux/instrumentation.h | 25 - kernel/entry/common.c | 7 +++ 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/arch/x86/kernel

[PATCH v3 08/11] entry: Make CONFIG_DEBUG_ENTRY available outside x86

2021-03-04 Thread Andy Lutomirski
of the kentry code, and trying to debug the resulting state machine will be painful. arm64 can turn it back on when it starts using the entire generic path. Signed-off-by: Andy Lutomirski --- arch/x86/Kconfig.debug | 10 -- lib/Kconfig.debug | 11 +++ 2 files changed, 11

[PATCH v3 09/11] kentry: Add debugging checks for proper kentry API usage

2021-03-04 Thread Andy Lutomirski
It's quite easy to mess up kentry calls. Add debgging checks that kentry transitions to and from user mode match up and that kentry_nmi_enter() and kentry_nmi_exit() match up. Checking full matching of kentry_enter() with kentry_exit() needs per-task state. Signed-off-by: Andy Lutomirski

[PATCH v3 05/11] x86/entry: Convert ret_from_fork to C

2021-03-04 Thread Andy Lutomirski
Poimboeuf Signed-off-by: Andy Lutomirski --- arch/x86/entry/common.c | 23 ++ arch/x86/entry/entry_32.S| 51 +--- arch/x86/entry/entry_64.S| 33 + arch/x86/include/asm/switch_to.h | 2 +- arch/x86/kernel

[PATCH v3 06/11] kentry: Simplify the common syscall API

2021-03-04 Thread Andy Lutomirski
The new common syscall API had a large and confusing API surface. Simplify it. Now there is exactly one way to use it. It's a bit more verbose than the old way for the simple x86_64 native case, but it's much easier to use right, and the diffstat should speak for itself. Signed-off-by: Andy

[PATCH v3 03/11] x86/dumpstack: Remove unnecessary range check fetching opcode bytes

2021-03-04 Thread Andy Lutomirski
copy_from_user_nmi() validates that the pointer is in the user range, so there is no need for an extra check in copy_code(). Signed-off-by: Andy Lutomirski --- arch/x86/kernel/dumpstack.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel

[PATCH v3 02/11] kentry: Rename irqentry to kentry

2021-03-04 Thread Andy Lutomirski
contemplate changing that later. That code predates the common entry code. Signed-off-by: Andy Lutomirski --- arch/x86/entry/common.c | 8 ++--- arch/x86/include/asm/idtentry.h | 28 +++ arch/x86/kernel/cpu/mce/core.c | 10 +++--- arch/x86/kernel/kvm.c | 6 ++-- arch

  1   2   3   4   5   6   7   8   9   10   >