[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9300A0A3-B5DD-438A-911B-EEB6C1697B03@zytor.com>
Date: Sun, 22 Jan 2023 01:40:49 -0800
From: "H. Peter Anvin" <hpa@...or.com>
To: Ammar Faizi <ammarfaizi2@...weeb.org>,
"Li, Xin3" <xin3.li@...el.com>
CC: Dave Hansen <dave.hansen@...el.com>,
Peter Zijlstra <peterz@...radead.org>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Ingo Molnar <mingo@...hat.com>,
Thomas Gleixner <tglx@...utronix.de>,
Borislav Petkov <bp@...en8.de>,
x86 Mailing List <x86@...nel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: RE: the x86 sysret_rip test fails on the Intel FRED architecture
On January 22, 2023 12:54:56 AM PST, Ammar Faizi <ammarfaizi2@...weeb.org> wrote:
>On 1/22/23 3:22 PM, Li, Xin3 wrote:
>> The problem is where/how to set %r11 = %rflags in the test code.
>>
>> The check happens in the USER1 signal handler, and we could set %r11
>> just before calling raise(SIGUSR1). However, the C library implementation
>> of raise() modifies %r11, thus we can't preserve %r11 until the SYSCALL
>> instruction. And the test still fails.
>
>>From "man 3 raise":
>
>"""
>The raise() function sends a signal to the calling process or thread.
>In a single-threaded program it is equivalent to
>
> kill(getpid(), sig);
>"""
>
>Implementing kill syscall with %r11 modified before entering the kernel
>may look like this?
>
>static void __raise(int sig)
>{
> __asm__ volatile (
> "pushf\n\t"
> "popq %%r11\n\t"
> "syscall"
> :
> : "D"(getpid()), /* %rdi */
> "S"(sig), /* %rsi */
> "a"(__NR_kill) /* %rax */
> : "rcx", "r11", "memory"
> );
>}
>
Exactly.
Powered by blists - more mailing lists