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 85F0DC27C76 for ; Wed, 25 Jan 2023 08:54:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235009AbjAYIyK (ORCPT ); Wed, 25 Jan 2023 03:54:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234904AbjAYIx7 (ORCPT ); Wed, 25 Jan 2023 03:53:59 -0500 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B1262B08B; Wed, 25 Jan 2023 00:53:58 -0800 (PST) Received: from biznet-home.integral.gnuweeb.org (unknown [182.253.88.152]) by gnuweeb.org (Postfix) with ESMTPSA id 15A9D81845; Wed, 25 Jan 2023 08:53:51 +0000 (UTC) X-GW-Data: lPqxHiMPbJw1wb7CM9QUryAGzr0yq5atzVDdxTR0iA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1674636838; bh=Usb1qIWIxd9/d0PmwEs4g3lE3pfBZkCsLqszsd3+X28=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pxBbdk9pxAWEK8b2xeerhWMFJ3XgZ3DUvXz2ht0O99oj1Mbn3udhDQg9f18sqadtN yubUBw1yJl1GrbUQid3fRXheb5YJwz+oNcaus/Ozd+RbzwqTUaCHhug2PDD+P3jWeS Hfc498yTBJPHLa195c6mjzTHEfEIxDXX+ga4ml8pN58bg2YRiWHzhhpOSR65Tpunsp FMyXwyC52TtcRhqL7xaWTysie1jtJZLV5RN0UbURt7FHXz0LHmkiMY0F03tjPAdaHA znROt5+w9y4/22ja8v4KXoWcGmBeJTVTvemVpldx8oSk0wOe2QgcOE75lNsotUKfwy IqGjWyx7EhzhA== Date: Wed, 25 Jan 2023 15:53:47 +0700 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 Subject: Re: [RFC PATCH v5 1/2] selftests/x86: sysret_rip: Handle syscall in a FRED system Message-ID: 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8770815f-0f23-d0c5-e56a-d401827842c9@zytor.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 25, 2023 at 12:39:26AM -0800, H. Peter Anvin wrote: > > + ret = check_regs_result(ctx->uc_mcontext.gregs[REG_R11], > > + ctx->uc_mcontext.gregs[REG_RCX], > > + ctx->uc_mcontext.gregs[REG_RBX]); > > + > > + assert(ret != REGS_ERROR); > > + > > This instance, too, needs to be checked against regs_ok_result. It would > make most sense to move that handling, and the assert() into > check_regs_result() or into a separate function around it. OK. Sounds better. > > /* 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... We will have a new separate patch for that. -- Ammar Faizi