From patchwork Tue Jan 24 00:26:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ammar Faizi X-Patchwork-Id: 13113235 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 B3DB0C05027 for ; Tue, 24 Jan 2023 00:26:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231868AbjAXA0k (ORCPT ); Mon, 23 Jan 2023 19:26:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231305AbjAXA0j (ORCPT ); Mon, 23 Jan 2023 19:26:39 -0500 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A779217173; Mon, 23 Jan 2023 16:26:38 -0800 (PST) Received: from localhost.localdomain (unknown [182.253.88.152]) by gnuweeb.org (Postfix) with ESMTPSA id 294AD824E0; Tue, 24 Jan 2023 00:26:31 +0000 (UTC) X-GW-Data: lPqxHiMPbJw1wb7CM9QUryAGzr0yq5atzVDdxTR0iA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1674519998; bh=Rm91CZ7I/MJC6OiVuT0l3UbvtdpMXxbIrv7tQGRv8Uw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zx2jdgGWhRdcd9E3uozALYXl5fyP7p2/C3Wr4os4Fby9zXCH/xihfP2eUUkzFM+s/ CI/UkIH4pMHrCIdokYu/2/HHoYCYAdRhzL7MnnB2RiKr/XsCvDtkhLLxkzf6nXof/x iEvY6Rjm93sw5UFDv4GY8lY8DZz/A+d5xle7t1rq4flobpKLjInO+1zQ5VVsx0x2ua Mdnf36OQs+PxRiTAuUCrwzc5gx9l9OGY2gaPAPARvZc908oUIqOt+sVZKDT63gMgME tqZwWesDvfKqphg9wovl/It3RX0Ivw/B/U2H6qiUVNRZiTxXvuFF3LcZamTDyTjITR D09dyd8f/qPwA== From: Ammar Faizi To: x86 Mailing List Cc: Ammar Faizi , "H. Peter Anvin" , 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 Subject: [RFC PATCH v1 0/2] selftests/x86: sysret_rip update for FRED system Date: Tue, 24 Jan 2023 07:26:23 +0700 Message-Id: <20230124002625.581323-1-ammarfaizi2@gnuweeb.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <509443c8-e0fd-935f-63d8-7264f5dd3c05@zytor.com> References: <5d4ad3e3-034f-c7da-d141-9c001c2343af@intel.com> <18B5DB6D-AEBD-4A67-A7B3-CE64940819B7@zytor.com> <25b96960-a07e-a952-5c23-786b55054126@zytor.com> <509443c8-e0fd-935f-63d8-7264f5dd3c05@zytor.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org From: Ammar Faizi On Mon, 23 Jan 2023 15:58:12 -0800, "H. Peter Anvin" wrote: > On 1/23/23 15:43, Ammar Faizi wrote: > > > > Align them to spot differences: > > > > 0x200893 = 0b1000000000100010010011 > > 0x200a93 = 0b1000000000101010010011 > > ^ > > > > Or just xor them to find the differences: > > > > (gdb) p/x 0x200893 ^ 0x200a93 > > $3 = 0x200 > > > > ** Checks my Intel SDM cheat sheets. ** > > > > Then, I was like "Oh, that's (1 << 9) a.k.a. IF. Of course we can't > > change rflags[IF] from userspace!!!". > > > > In short, we can't use 0x200893 as the rflags_sentinel value because it > > clears the interrupt flag. > > > > Right, my mistake. I changed it to 0x200a93. The test passed on my machine. But I don't have a FRED system to test the special case. Didn't manage to apply the feedback from Andrew about the way to handle redzone properly, though. Something like this... ---------- This is just an RFC patchset. Xin Li reported sysret_rip test fails at: assert(ctx->uc_mcontext.gregs[REG_EFL] == ctx->uc_mcontext.gregs[REG_R11]); in a FRED system. Handle the FRED system scenario too. There are two patches in this series. Comments welcome... Note: Only tested for 'syscall' sets %rcx=%rip and %r11=%rflags case. I don't have a FRED system to test it. How to test this: $ make -C tools/testing/selftests/x86 $ tools/testing/selftests/x86/sysret_rip_64 Link: https://lore.kernel.org/lkml/5d4ad3e3-034f-c7da-d141-9c001c2343af@intel.com Signed-off-by: Ammar Faizi --- Ammar Faizi (2): selftests/x86: sysret_rip: Handle syscall in a FRED system selftests/x86: sysret_rip: Add more syscall tests with respect to `%rcx` and `%r11` tools/testing/selftests/x86/sysret_rip.c | 105 ++++++++++++++++++++++- 1 file changed, 104 insertions(+), 1 deletion(-) base-commit: e12ad468c22065a2826b2fc4c11d2113a7975301