From mboxrd@z Thu Jan 1 00:00:00 1970 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 517B1C05027 for ; Fri, 20 Jan 2023 20:51:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229728AbjATUvt (ORCPT ); Fri, 20 Jan 2023 15:51:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229448AbjATUvs (ORCPT ); Fri, 20 Jan 2023 15:51:48 -0500 Received: from mail.zytor.com (unknown [IPv6:2607:7c80:54:3::138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E337D1633A for ; Fri, 20 Jan 2023 12:51:44 -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 30KKot2Q1327193 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NO); Fri, 20 Jan 2023 12:50:55 -0800 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 30KKot2Q1327193 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2023010601; t=1674247857; bh=OozNsf8rAfuwn9CoxcIek5bYmCojoGQsnmeZkcjPGVQ=; h=Date:From:To:CC:Subject:In-Reply-To:References:From; b=YxKvUX7WU7r0KamhV+ty/mDtyqx5Re/PvBOXexT5CiBoGllf59meZjJkoqpdIKk4M Rsy1dgkTutivfrBEGX/xu3EJH6eSYL0vrcb5fCoqYoOLvh7u6Xc/5WLy2QQgYmVrfK 5d4Xmza89DxAOcNde/uJcRu7b7K+ZQw+spzAhJO0ZccdIchKoH7wZkgDKEaXg4p3XI lLDpSlEWJJPbVP2iTQh/AO2xky0+ucixz7WEvMcBsWLxPZcJTNJyzVbtyYlkg6lmfS ww5C6nJ47xa4BFtIU3KucuhIyqBgBCuR8gLT+Y9IkLYmoXVu5T0auCKqOnvE8fDCZ7 3rmAflkeT2RzQ== Date: Fri, 20 Jan 2023 12:50:51 -0800 From: "H. Peter Anvin" To: Andrew Cooper , Dave Hansen , "Li, Xin3" , "tglx@linutronix.de" , "mingo@redhat.com" , "bp@alien8.de" , "peterz@infradead.org" , "dave.hansen@linux.intel.com" CC: "x86@kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: the x86 sysret_rip test fails on the Intel FRED architecture User-Agent: K-9 Mail for Android In-Reply-To: References: <5d4ad3e3-034f-c7da-d141-9c001c2343af@intel.com> Message-ID: 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 20, 2023 10:52:02 AM PST, Andrew Cooper wrote: >On 20/01/2023 5:45 pm, Dave Hansen wrote: >> On 1/19/23 23:49, Li, Xin3 wrote: >>> The x86 sysret_rip test has the following assertion: >>> >>> /* R11 and EFLAGS should already match=2E */ >>> assert(ctx->uc_mcontext=2Egregs[REG_EFL] =3D=3D >>> ctx->uc_mcontext=2Egregs[REG_R11]); >>> >>> This is being tested to avoid kernel state leak due to sysret vs iret, >>> but that on FRED r11 is *always* preserved, and the test just fails=2E >> Let's figure out the reason that FRED acts differently, first=2E Right >> now, the SDM says: >> >> SYSCALL also saves RFLAGS into R11 >> >> so that behavior of SYSCALL _looks_ architectural to me=2E Was this >> change in SYSCALL behavior with FRED intentional? > >FRED 3=2E0 Section 7=2E4 says the only changes for the SYSCALL and SYSENT= ER >instructions are the enablement conditions=2E=C2=A0 Nowhere else is there >mention of a FRED OS needing to emulate legacy syscall behaviour by >adjusting %r11/%rcx > >However, ERETU does handle flags different to SYSRET (in particular, I >think you can establish TF on the instruction boundary after SYSCALL >now)=2E=C2=A0 What are the raw values of REG_EFL and REG_R11 ? > >~Andrew > Just to avoid any confusion: Syscall and sysenter in a FRED system are treated equivalently to software= interrupts, e=2Eg=2E INT 0x80=2E They do not modify any registers=2E