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 23585C54E94 for ; Wed, 25 Jan 2023 23:24:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235239AbjAYXY3 (ORCPT ); Wed, 25 Jan 2023 18:24:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229539AbjAYXY1 (ORCPT ); Wed, 25 Jan 2023 18:24:27 -0500 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26E04EB43; Wed, 25 Jan 2023 15:24:26 -0800 (PST) Received: from localhost.localdomain (unknown [182.253.88.152]) by gnuweeb.org (Postfix) with ESMTPSA id 68211824E0; Wed, 25 Jan 2023 23:24:19 +0000 (UTC) X-GW-Data: lPqxHiMPbJw1wb7CM9QUryAGzr0yq5atzVDdxTR0iA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1674689065; bh=zhEhASVFM/Au5cThaAVr8lOzqAVrP1V8SBnPOSUlAds=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BfnpgP1gwAvctQdGaPovsk+HWtJf1Bg3IRFpUq0p8YF87IASfmnBs8XkcF/9qTFIi utlFTPX6kEKPmFEDxRgamtXR5Dw+K44F+QZlLQJwe/2puvmqegrVzczv2F6hnHESgt jyxi9TPWCUJ1rxuIOUtyNozmbZhI6C+mhc/tqKAbD/9BpyjDZ9I7ImpcGjdUJd5r8g TLIGvS6vHzadmyN3boa2PftPeVf6RQrOrKY3lCMSiN+l/wp1S/VSQUR8NkI7S4VilK IcvTttCV1W5BrIBk9WAmjY00cnj9nNw9GQwPekIbZ5y8tu4wq/PWpGfAhR65XzXBI6 B4r16r+bbuE+A== From: Ammar Faizi To: "H. Peter Anvin" , Xin Li Cc: Dave Hansen , Dave Hansen , "Kirill A. Shutemov" , Thomas Gleixner , Andrew Cooper , Peter Zijlstra , Brian Gerst , Borislav Petkov , Shuah Khan , Ingo Molnar , Andy Lutomirski , x86 Mailing List , Linux Kselftest Mailing List , Linux Kernel Mailing List Subject: [RFC PATCH v7 0/3] sysret_rip update for the Intel FRED architecture Date: Thu, 26 Jan 2023 06:24:12 +0700 Message-Id: <20230125232415.860397-1-ammarfaizi2@gnuweeb.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: <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-3-ammarfaizi2@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ammar Faizi Hi, This is an RFC patchset v7. There are three patches in this series. Xin Li reported that the sysret_rip test fails at: assert(ctx->uc_mcontext.gregs[REG_EFL] == ctx->uc_mcontext.gregs[REG_R11]); on the Intel FRED architecture. Let's handle the FRED system scenario too. The 'syscall' instruction in a FRED system doesn't set %rcx=%rip and %r11=%rflags. Syscall and sysenter in a FRED system are treated equivalently to software interrupts, e.g. INT 0x80. They do not modify any registers. Link: https://lore.kernel.org/lkml/5d4ad3e3-034f-c7da-d141-9c001c2343af@intel.com ## Changelog v7: - Fix comment, REGS_ERROR no longer exists in the enum (Ammar). - Update commit message (Ammar). ## Changelog v6: - Move the check-regs assertion in sigusr1() to check_regs_result() (HPA). - Add a new test just like sigusr1(), but don't modify REG_RCX and REG_R11. This is used to test SYSRET behavior consistency (HPA). ## Changelog v5: - Fix do_syscall() return value (Ammar). ## Changelog v4: - Fix the assertion condition inside the SIGUSR1 handler (Xin Li). - Explain the purpose of patch #2 in the commit message (HPA). - Update commit message (Ammar). - Repeat test_syscall_rcx_r11_consistent() 32 times to be more sure that the result is really consistent (Ammar). ## Changelog v3: - Test that we don't get a mix of REGS_SAVED and REGS_SYSRET, which is a major part of the point (HPA). ## Changelog v2: - Use "+r"(rsp) as the right way to avoid redzone problems per Andrew's comment (HPA). Co-developed-by: H. Peter Anvin (Intel) Signed-off-by: H. Peter Anvin (Intel) Signed-off-by: Ammar Faizi --- Ammar Faizi (3): selftests/x86: sysret_rip: Handle syscall in a FRED system selftests/x86: sysret_rip: Add more syscall tests with respect to `%rcx` and `%r11` selftests/x86: sysret_rip: Test SYSRET with a signal handler tools/testing/selftests/x86/sysret_rip.c | 171 +++++++++++++++++++++-- 1 file changed, 162 insertions(+), 9 deletions(-) base-commit: e12ad468c22065a2826b2fc4c11d2113a7975301 -- Ammar Faizi