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 A88D3C54E94 for ; Wed, 25 Jan 2023 10:01:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235373AbjAYKBj (ORCPT ); Wed, 25 Jan 2023 05:01:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234742AbjAYKBi (ORCPT ); Wed, 25 Jan 2023 05:01:38 -0500 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B70D74997D; Wed, 25 Jan 2023 02:01:36 -0800 (PST) Received: from [10.7.7.5] (unknown [182.253.88.152]) by gnuweeb.org (Postfix) with ESMTPSA id A4B1481845; Wed, 25 Jan 2023 10:01:30 +0000 (UTC) X-GW-Data: lPqxHiMPbJw1wb7CM9QUryAGzr0yq5atzVDdxTR0iA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1674640896; bh=x9lHtMUH0x+G4Cs0bWdf77jIPMLuFaUkJSBDuX4bGVU=; h=Date:Subject:From:To:Cc:References:In-Reply-To:From; b=hJHyvsMf4ONEbmMqrxfad8XwkzL2XQhelvbJ5u98gs4W3jz+/XfcfbM6kz28ulwmK 0nniAmPLyER4LR/95aJS8RZB2yY+WXaxJX+02OayjyxhMay/z0taXTcDmZVoxu8Ysm Z5CSAjWuoSO6UdRhl2DgOOjIM5R30TBChFgdAGB3HwYjXuujEHRAT3h2tM+4lyZLkV SzMh83D/bJR9mdgLI4I1t31ceRbY7OwV3hleeVXoEXVfTuAxF+tJSUgeNLleChgEPq acilaBmIhO30b4fKnVuXrVRDghFrJxahza4cFS2bDdMpLyLVe1/I6fNH/Ozq8SERG5 FJXDlsDtqlc2A== Message-ID: <8d66a0ff-54b5-ab0a-2638-6f11c1c0d6f5@gnuweeb.org> Date: Wed, 25 Jan 2023 17:01:27 +0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [RFC PATCH v5 1/2] selftests/x86: sysret_rip: Handle syscall in a FRED system Content-Language: en-US From: Ammar Faizi To: "H. Peter Anvin" Cc: Xin Li , Dave Hansen , Dave Hansen , Thomas Gleixner , Andrew Cooper , Brian Gerst , Ingo Molnar , Borislav Petkov , Peter Zijlstra , Shuah Khan , Ingo Molnar , Andy Lutomirski , x86 Mailing List , "Kirill A. Shutemov" , Linux Kselftest Mailing List , Linux Kernel Mailing List References: <5ecc383c-621b-57d9-7f6d-d63496fca3b3@zytor.com> <20230124022729.596997-1-ammarfaizi2@gnuweeb.org> <20230124022729.596997-3-ammarfaizi2@gnuweeb.org> <20230125034958.734527-1-ammarfaizi2@gnuweeb.org> <20230125034958.734527-2-ammarfaizi2@gnuweeb.org> <8770815f-0f23-d0c5-e56a-d401827842c9@zytor.com> In-Reply-To: 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/25/23 4:57 PM, Ammar Faizi wrote: > On Wed, Jan 25, 2023 at 12:39:26AM -0800, H. Peter Anvin wrote: >>> /* Set IP and CX to match so that SYSRET can happen. */ >>> ctx->uc_mcontext.gregs[REG_RIP] = rip; >>> ctx->uc_mcontext.gregs[REG_RCX] = rip; >> >> It would be interesting to have the syscall handler try both with and >> without this (so it would end up doing both IRET and SYSCALL on legacy.) >> Perhaps SIGUSR1 versus SIGUSR2... > > Just to clarify this more so I am sure I understand it correctly. > > Did you mean to have the same signal handler without modifiying > 'REG_RCX' but still change 'REG_RIP'? > > IOW, we want to only *remove*: > > ctx->uc_mcontext.gregs[REG_RCX] = rip; > > and *keep*: > > ctx->uc_mcontext.gregs[REG_RIP] = rip; > > for the SIGUSR2 handler. Thus, inside the entry64 we will jump to the > iret path because %rcx != %r11 upon rt_sigreturn()? s/%rcx != %r11/%rcx != %rip/ -- Ammar Faizi