Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B3A0C54E94 for ; Tue, 24 Jan 2023 05:49:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232941AbjAXFtJ (ORCPT ); Tue, 24 Jan 2023 00:49:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233034AbjAXFtC (ORCPT ); Tue, 24 Jan 2023 00:49:02 -0500 Received: from mail.zytor.com (unknown [IPv6:2607:7c80:54:3::138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 793253C294; Mon, 23 Jan 2023 21:48:14 -0800 (PST) Received: from [IPV6:2601:646:8600:40c0:425:cd56:6750:e1bf] ([IPv6:2601:646:8600:40c0:425:cd56:6750:e1bf]) (authenticated bits=0) by mail.zytor.com (8.17.1/8.17.1) with ESMTPSA id 30O5j52V2628757 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NO); Mon, 23 Jan 2023 21:45:07 -0800 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 30O5j52V2628757 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2023010601; t=1674539111; bh=1PBmtzTOvoQB1NIFT9gzjuVDOXpEJFnIM/BFNCdi4UA=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=FgKFvQgQuXtAEPMUNy7oaizi2x7WHXMtfVem1W87yPbrEwnT1A+cqjLuf+cS9I3XK 87mL7vIlCRR82Tafi/DJGcQEP+5sF+S/viv9woS004+wfWm6rcHrZw7/g6JuouxamY 8x0Ss1WVbdVHH/4oI5yT/SYbd5OghFXF7ICEUrQHMbODrlocpOtHrg9YPk9Uipbdbv bcIND06el5Py3JD52lvTpzZagAkruMCOFMrBKymZyJBbernDEGSlDKHKHV/eSNSy+v DTLh4wANulqbQdTN8hyUx/e4d5nTsBpIEmRYOwJy6e8xaQKPA6oTsVIvMBlI9N+Eff ukFIJIIvGbnmg== Message-ID: Date: Mon, 23 Jan 2023 21:44:59 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: Re: [RFC PATCH v2 1/2] selftests/x86: sysret_rip: Handle syscall in a FRED system Content-Language: en-US To: Ammar Faizi , x86 Mailing List Cc: Dave Hansen , Dave Hansen , Xin Li , Thomas Gleixner , Andrew Cooper , Brian Gerst , Ingo Molnar , Borislav Petkov , Peter Zijlstra , Shuah Khan , Ingo Molnar , Andy Lutomirski , "Kirill A. Shutemov" , Linux Kselftest Mailing List , Linux Kernel Mailing List References: <5d4ad3e3-034f-c7da-d141-9c001c2343af@intel.com> <18B5DB6D-AEBD-4A67-A7B3-CE64940819B7@zytor.com> <25b96960-a07e-a952-5c23-786b55054126@zytor.com> <6cd0db14-c9e2-3598-fd10-4b473d78c373@citrix.com> <5ecc383c-621b-57d9-7f6d-d63496fca3b3@zytor.com> <20230124022729.596997-1-ammarfaizi2@gnuweeb.org> <20230124022729.596997-2-ammarfaizi2@gnuweeb.org> From: "H. Peter Anvin" In-Reply-To: <20230124022729.596997-2-ammarfaizi2@gnuweeb.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/23/23 18:27, Ammar Faizi wrote: > From: Ammar Faizi > > The current selftest asserts %r11 == %rflags after the 'syscall' > returns to user. Such an assertion doesn't apply to a FRED system > because in a FRED system the 'syscall' instruction does not set > %r11=%rflags and %rcx=%rip. > > Handle the FRED case. Now, test that: > > - "syscall" in a FRED system doesn't clobber %rcx and %r11. > - "syscall" in a non-FRED system sets %rcx=%rip and %r11=%rflags. > > The 'raise()' function from libc can't be used to control those > registers. Therefore, create a syscall wrapper in inline Assembly to > fully control them. > > Fixes: 660602140103 ("selftests/x86: Add a selftest for SYSRET to noncanonical addresses") > Link: https://lore.kernel.org/lkml/25b96960-a07e-a952-5c23-786b55054126@zytor.com > Reported-by: Xin Li > Co-developed-by: "H. Peter Anvin" > Signed-off-by: Ammar Faizi > --- > > Need hpa's sign off. > For both patches: Acked-by: H. Peter Anvin (Intel)