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 384D6C61D97 for ; Tue, 24 Jan 2023 21:40:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235042AbjAXVkZ (ORCPT ); Tue, 24 Jan 2023 16:40:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229851AbjAXVkX (ORCPT ); Tue, 24 Jan 2023 16:40:23 -0500 Received: from mail.zytor.com (unknown [IPv6:2607:7c80:54:3::138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C96F448A; Tue, 24 Jan 2023 13:40:22 -0800 (PST) Received: from [127.0.0.1] ([73.223.250.219]) (authenticated bits=0) by mail.zytor.com (8.17.1/8.17.1) with ESMTPSA id 30OLbhtZ2875378 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NO); Tue, 24 Jan 2023 13:37:44 -0800 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 30OLbhtZ2875378 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2023010601; t=1674596265; bh=FYpw+DyQo6/Zeyp/1DrOHhEA63iP6n4iCeDIbepaNsY=; h=Date:From:To:CC:Subject:In-Reply-To:References:From; b=DHVv04PucDlTaMfDdkOIauIG7IlNyhe12mIe8glApPxXoInLtYGNOaJ9UYs62IHhb My/GMi1qGY3BA3uMiDjVZfLI2rwUqiEtwJRxWNTyLvw4cNGKiC15Q0fepnx831610j MTqQwSt6f2n21undMG9onhe3/pLD2CRjIK1wAMayBEyGIv43C+0JYWApCIUA300Nc6 T1agihripZAo4Q5sGozRnsDKXDP7zpg+bAGT2GiN9QI0gz2JRv0qQfbUngeR2rMuGD bybK9WfTlvZaaQvQ2Hy7C542sAQ5rZ4I+ntxQhD69BMzcSgHIH6Z/UpM7ySbzViwEV ELDRBqFWBbvTQ== Date: Tue, 24 Jan 2023 13:37:43 -0800 From: "H. Peter Anvin" To: "Li, Xin3" , Ammar Faizi , x86 Mailing List CC: "Hansen, Dave" , Dave Hansen , Thomas Gleixner , "andrew.cooper3@citrix.com" , Brian Gerst , Ingo Molnar , Borislav Petkov , Peter Zijlstra , Shuah Khan , Ingo Molnar , "Lutomirski, Andy" , "Kirill A. Shutemov" , Linux Kselftest Mailing List , Linux Kernel Mailing List Subject: =?US-ASCII?Q?RE=3A_=5BRFC_PATCH_v3_0/2=5D_selftests/x8?= =?US-ASCII?Q?6=3A_sysret=5Frip_update_for_FRED_system?= User-Agent: K-9 Mail for Android 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> <20230124100926.637335-1-ammarfaizi2@gnuweeb.org> Message-ID: <7E935340-B596-4663-80FF-CDC4E31896B4@zytor.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On January 24, 2023 1:32:14 PM PST, "Li, Xin3" wrot= e: >> From: Ammar Faizi >>=20 >> This is an RFC patchset v3: >> sysret_rip test update for Intel FRED architecture=2E >>=20 >> Xin Li reported sysret_rip test fails at: >>=20 >> assert(ctx->uc_mcontext=2Egregs[REG_EFL] =3D=3D >> ctx->uc_mcontext=2Egregs[REG_R11]); > >On FRED systems, flags is 0x200a93 and r11 is 0xfeedfacedeadbeef here=2E > >We need to remove or change this assertion, maybe: > assert(ctx->uc_mcontext=2Egregs[REG_EFL] =3D=3D ctx->uc_mcontext=2Egreg= s[REG_R11] || > r11_sentinel =3D=3D ctx->uc_mcontext=2Egregs[REG_R11]); > >>=20 >> in a FRED system=2E Let's handle the FRED system scenario too=2E The 's= yscall' >> instruction in a FRED system doesn't set %r11=3D%rflags=2E >>=20 >> There are two patches in this series=2E >>=20 >> How to test this: >>=20 >> $ make -C tools/testing/selftests/x86 >> $ tools/testing/selftests/x86/sysret_rip_64 >>=20 >> Link: https://lore=2Ekernel=2Eorg/lkml/5d4ad3e3-034f-c7da-d141- >> 9c001c2343af@intel=2Ecom >> Fixes: 660602140103 ("selftests/x86: Add a selftest for SYSRET to nonca= nonical >> addresses") >> Link: https://lore=2Ekernel=2Eorg/lkml/25b96960-a07e-a952-5c23- >> 786b55054126@zytor=2Ecom >> Reported-by: Xin Li >> Co-developed-by: H=2E Peter Anvin (Intel) >> Signed-off-by: H=2E Peter Anvin (Intel) >> Acked-by: H=2E Peter Anvin (Intel) >> Signed-off-by: Ammar Faizi >> --- >>=20 >> ## Changelog v3: >>=20 >> - Test that we don't get a mix of REGS_SAVED and REGS_SYSRET, >> which is a major part of the point (hpa)=2E >>=20 >> ## Changelog v2: >>=20 >> - Use "+r"(rsp) as the right way to avoid redzone problems >> per Andrew's comment (hpa)=2E >> (Ref: https://lore=2Ekernel=2Eorg/lkml/8f5c24df-514d-5d89-f58f- >> ec8c3eb1e049@zytor=2Ecom ) >>=20 >> --- >>=20 >> Ammar Faizi (2): >> selftests/x86: sysret_rip: Handle syscall in a FRED system >> selftests/x86: sysret_rip: Add more syscall tests with respect to `%r= cx` and `%r11` >>=20 >> tools/testing/selftests/x86/sysret_rip=2Ec | 120 +++++++++++++++++++++= +- >> 1 file changed, 119 insertions(+), 1 deletion(-) >>=20 >>=20 >> base-commit: e12ad468c22065a2826b2fc4c11d2113a7975301 >> -- >> Ammar Faizi > > This should use check_regs_result() =E2=80=93 which is exactly the reason = I made that a separate function=2E