Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp5087606rwb; Sun, 22 Jan 2023 03:05:49 -0800 (PST) X-Google-Smtp-Source: AMrXdXuTp1rmT6YHXxBQHpfYCJt0nyQyY6kVHkcfwgudD3fQlr2fRYFF/qeFYrkAVMCT3L+B/hqN X-Received: by 2002:a17:90a:9409:b0:229:1de8:3cfd with SMTP id r9-20020a17090a940900b002291de83cfdmr21588424pjo.29.1674385549426; Sun, 22 Jan 2023 03:05:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674385549; cv=none; d=google.com; s=arc-20160816; b=eFZpLlcPl/64lO0zZUJnIAzdnEJVU6tBRgce/onS4oTDrE/f9l6IaSqogtGZpNZwNO CamN3hrJUAhrmhqFEi3JSnJ2l3VVTzv8F9fIoKL2gvbOylZIRtUjkN6iM4pEaBWOJjdW pgRD4iuSwhPXalheglXMd9VAS9298O1lKnw9WRMdJCBCDMfaUAPv9wGdI6KNG3MWFCk1 FjFAIhrNQr1lMCY2DGVoB9uxhawt8FYwDLS22MRy2D6a45kbsLhWS9PBSuZoZyYsXD2N Qje2K7AMmeam+LzKaSO3knY8mJWs0L4X0CBAEfD9v0bpTq1N5teHky/Xp4ONxmjY62vW g56w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:references:in-reply-to:user-agent:subject:cc:to:from :date:dkim-signature:dkim-filter; bh=BUz7GySCcyAaeNBP7q6NLLHUXrPwckpAejmAkm7+des=; b=sCyQmyfypV1Ey4orkr18M/1GkfLKfCtPHtiiN3SPppK3tot1l6CM0yVlFU5Fbl3UPo rfmZUYmtEsF5Ui2SDQc7OUH8Je/neD5QXYFegS88XzTkstORiD3PsTIP2BT1WweQQWhi LW1t8s1r6jhV9+G6tQU2wYZq2d/u3kKyWpv6qi4iWojkrSAR1+rUUJ2XiUjSK5IAwjKE Y1hCiJkpCcZvLP4mBARVxAcqMLXo8zd4G+7We2zGbP/Lj8YyZo4uxQFH7uGygC1DgnpF ZJGe08f0R+G4nMNyKVD2wWjzLS/p4AbkvbRCL+tGDs0Ijk0E8vOD1lLI9BdTbR0Sunln /TEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2023010601 header.b=AQ3ABt0l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 12-20020a63104c000000b0044c3ec9ea71si47091599pgq.630.2023.01.22.03.05.40; Sun, 22 Jan 2023 03:05:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@zytor.com header.s=2023010601 header.b=AQ3ABt0l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229749AbjAVJn1 (ORCPT + 50 others); Sun, 22 Jan 2023 04:43:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229656AbjAVJn0 (ORCPT ); Sun, 22 Jan 2023 04:43:26 -0500 Received: from mail.zytor.com (unknown [IPv6:2607:7c80:54:3::138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C237716AE7 for ; Sun, 22 Jan 2023 01:43:24 -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 30M9epow1888407 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NO); Sun, 22 Jan 2023 01:40:52 -0800 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 30M9epow1888407 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2023010601; t=1674380454; bh=BUz7GySCcyAaeNBP7q6NLLHUXrPwckpAejmAkm7+des=; h=Date:From:To:CC:Subject:In-Reply-To:References:From; b=AQ3ABt0lp2SQB8E82SgyW3dnjU/a1OQ23VLLo0jLS0XCjhSlyGwf9EUly0ZUCzITV KByl50AQW51N4Daa3z/fEUVu3fVelLNIwyxeylIuDFnKMLoguce8HS5HDbXAwY5StM WyrRWWd5I1h8SNmXmlqzRB7ifMpYgpONTqMKcjW8Ht9Wfcq87Yj+NK7O8x00gMPDCE PXg0PAnDYlnowO9kO4A0nAFBAGHqy8LPlY6+46ZZlz0TdBQRE6lMlRonPycflH5tzH 0Ftq6TSKm+dxyzVhlUs4lFFVtUcWQttBCHEhAjdMyD/GNCqPnaLTYi5x0N1280bd89 473RAiS09YAKA== Date: Sun, 22 Jan 2023 01:40:49 -0800 From: "H. Peter Anvin" To: Ammar Faizi , "Li, Xin3" CC: Dave Hansen , Peter Zijlstra , Dave Hansen , Ingo Molnar , Thomas Gleixner , Borislav Petkov , x86 Mailing List , Linux Kernel Mailing List Subject: Re: 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> <18B5DB6D-AEBD-4A67-A7B3-CE64940819B7@zytor.com> <65D9F1DE-96D4-4CC7-A21C-A740B7DDE0C8@zytor.com> Message-ID: <9300A0A3-B5DD-438A-911B-EEB6C1697B03@zytor.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On January 22, 2023 12:54:56 AM PST, Ammar Faizi wrote: >On 1/22/23 3:22 PM, Li, Xin3 wrote: >> The problem is where/how to set %r11 =3D %rflags in the test code=2E >>=20 >> The check happens in the USER1 signal handler, and we could set %r11 >> just before calling raise(SIGUSR1)=2E However, the C library implement= ation >> of raise() modifies %r11, thus we can't preserve %r11 until the SYSCALL >> instruction=2E And the test still fails=2E > >From "man 3 raise": > >""" >The raise() function sends a signal to the calling process or thread=2E >In a single-threaded program it is equivalent to > > kill(getpid(), sig); >""" > >Implementing kill syscall with %r11 modified before entering the kernel >may look like this? > >static void __raise(int sig) >{ > __asm__ volatile ( > "pushf\n\t" > "popq %%r11\n\t" > "syscall" > : > : "D"(getpid()), /* %rdi */ > "S"(sig), /* %rsi */ > "a"(__NR_kill) /* %rax */ > : "rcx", "r11", "memory" > ); >} > Exactly=2E