Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp5009545rwb; Sun, 22 Jan 2023 01:15:01 -0800 (PST) X-Google-Smtp-Source: AMrXdXslzkAV7LMFvQaWMF4EzG943NfP2EUaNNuG4JUsx+X9+HOnOif/3odEdd5nXiwUx6EFRDFi X-Received: by 2002:a17:906:3f87:b0:809:c1f4:ea09 with SMTP id b7-20020a1709063f8700b00809c1f4ea09mr19960187ejj.69.1674378900892; Sun, 22 Jan 2023 01:15:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674378900; cv=none; d=google.com; s=arc-20160816; b=z5CVwzkEsWo8Mf48zT5FPDlDWaGP8u53Dm9DS66XKE5nAc0e1Hg3upsBpWKB2FLboX H2vG2553olxHbEXlTgOjMcWXmGjAVxpfNhKBL8kjONoNyIHrLKsjaC4bf3KLBUvTb04L FsL0jDkrGOSRej6E+9viE6tZZ01FOLwivTGzQdsGWVumxnzwj2O5nMxPbIgVUuByfPxV KKqwu7ocaxLZoXGE2w5csMhwVPZ4ms3uVzzmgvba0t4o4+m3YhDLgb6GbWtvkS8VCWAF NTD2mnpjdVH39n4XO0sNvCrem0jfvILUqrC6lGN3fcKCyrO38/1/DCDJN5ebYESNMoFB opNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject :from:content-language:references:cc:to:user-agent:mime-version:date :message-id:dkim-signature; bh=E2bu4pHiy49c2QllRYU/QWOEzUKQRI5QGVhzQfSYdA0=; b=n0eBP9KYS4MScSA4HK6eRv2wVE2jWrqptKumGK02DD9+s3uyfOQw/j+JmGlYE9R/LD slMW06CLqbWbrlE/nusi6vSGq9FWPw0/dKTqLYf98wEHLiJOFBjuYmZzLJCQlKuZk7SM 6eiFnrzM8KD6ko1Gy02LfC6C/wAr83VPwlQfD69M0T9QADQCqXvck5FpUPHW386uK7zw j7nhv95vNDPiO+ZOCOlDI7FG9loDHulwbxTpR9y4aTIPQcQ2Zejdv06aO4zudYICBMRZ cN8hTFmIknEbrYyTbOPHT6swgN8MOM79mxyFhF4h79yM9T3rWuzWGrnk3bCCW/0vsve7 xBbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gnuweeb.org header.s=default header.b=Z2YBuWkE; 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=gnuweeb.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id go34-20020a1709070da200b00871969cddafsi22132805ejc.530.2023.01.22.01.14.45; Sun, 22 Jan 2023 01:15:00 -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=@gnuweeb.org header.s=default header.b=Z2YBuWkE; 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=gnuweeb.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229890AbjAVIzG (ORCPT + 50 others); Sun, 22 Jan 2023 03:55:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229480AbjAVIzF (ORCPT ); Sun, 22 Jan 2023 03:55:05 -0500 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 287D71284F for ; Sun, 22 Jan 2023 00:55:04 -0800 (PST) Received: from [10.7.7.5] (unknown [182.253.88.152]) by gnuweeb.org (Postfix) with ESMTPSA id CF8F382051; Sun, 22 Jan 2023 08:54:59 +0000 (UTC) X-GW-Data: lPqxHiMPbJw1wb7CM9QUryAGzr0yq5atzVDdxTR0iA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1674377703; bh=o0g9l6yH+SEb5Ixg0oOgGfCDD5DUXhW5WsSzssjcTks=; h=Date:To:Cc:References:From:Subject:In-Reply-To:From; b=Z2YBuWkEhtR33/Euace9ubrjpCRZ/xbZJjMYqvtJMZ7sqISv24U8jXMSP6CRQCwCr mOWONzgbAkmNjPpbe9nGEfN1fuRmiKgQbkDE5yoNZzeq2qwLiZ57lLRKN5ZQNjKRp2 imjusysFrnfAN4nqrvEosB1GDWklr+wLsD+DXhiyxZf66cgCtODN9i/d2UYUYLBy7S kIFHSTKHYlhlpic5bGq/RK0ZK9KHqO1OwO6NjVJXgn7HWSPjMsEuUQeH64TAuZzQQw /Rm5d1+AMBagEIiHBaBbDKYVDeHH1yMQzDs1T1WxNSUpmpCODn94HgvNoPAhP+atxv lr5EDQrC+6qhA== Message-ID: Date: Sun, 22 Jan 2023 15:54:56 +0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 To: "Li, Xin3" Cc: "H. Peter Anvin" , Dave Hansen , Peter Zijlstra , Dave Hansen , Ingo Molnar , Thomas Gleixner , Borislav Petkov , x86 Mailing List , Linux Kernel Mailing List References: <5d4ad3e3-034f-c7da-d141-9c001c2343af@intel.com> <18B5DB6D-AEBD-4A67-A7B3-CE64940819B7@zytor.com> <65D9F1DE-96D4-4CC7-A21C-A740B7DDE0C8@zytor.com> Content-Language: en-US From: Ammar Faizi Subject: Re: RE: the x86 sysret_rip test fails on the Intel FRED architecture In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,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 1/22/23 3:22 PM, Li, Xin3 wrote: > The problem is where/how to set %r11 = %rflags in the test code. > > The check happens in the USER1 signal handler, and we could set %r11 > just before calling raise(SIGUSR1). However, the C library implementation > of raise() modifies %r11, thus we can't preserve %r11 until the SYSCALL > instruction. And the test still fails. From "man 3 raise": """ The raise() function sends a signal to the calling process or thread. 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" ); } -- Ammar Faizi