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 X-Spam-Level: X-Spam-Status: No, score=-13.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7AB69C4320E for ; Fri, 20 Aug 2021 22:27:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5EC7F61040 for ; Fri, 20 Aug 2021 22:27:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233828AbhHTW1i (ORCPT ); Fri, 20 Aug 2021 18:27:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231334AbhHTW1i (ORCPT ); Fri, 20 Aug 2021 18:27:38 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08198C061575 for ; Fri, 20 Aug 2021 15:27:00 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id mw10-20020a17090b4d0a00b0017b59213831so2995319pjb.0 for ; Fri, 20 Aug 2021 15:27:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=muCZGHGXDtZhLnuzxIVauvI9vXUTWXNUIrBwCRdMVco=; b=RemefsbkLF0qjalfgS/QPFy+s0vrHUCCRwLs5Nng2oRX7YN+RbFWFDzyRbXDUTFeRe ZcR6b656WMkKHvh5XwIeexMOkIK6TBTyMgP20QtOJD1jsJYkiBEWihN2CVwUcoknSiZc kfCOTeIeF9ja69Sxfpo9Tze/gbXlfbWjwwnjO1rkWyU9/APS4tY7lkRghKHUYYvwXaoY XjV//yV1jErHSoGWkaqeUNTbYjSMDPGF7Bsh5VYUZeLtO3D4NwU7djoZEoOgIYKcigrl LaQ3UiKuwPAupo+Ikjg0jO22FUEuCmAC9TlZ9LlWOAqKDqGqdS7VTnu20IUdQ2TEEMfG 3dxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=muCZGHGXDtZhLnuzxIVauvI9vXUTWXNUIrBwCRdMVco=; b=tJ3ivu/xRQTeGWPBziQOVkaNZhWQSUgm5WGi8F7MV0KZQDdU5D2oBmnL4ygL9ogArf C6PgVoEd88W92+VfdYISy9SPfoYrFDApEKI9Dj70wCa98WaaeLmJ31EetoW5mCIcOo8w k2+IKgIEjiJfTpIIzQXjrQrvu/kjnJUqLCi2H0o7V9xIbaHAB5DeyrlmFl05kkOInmd1 KRiMpe7bgWAeOP639LsgWwThDzt94s/tZDdtr/4DTT2Vd0FKH7V89Ch4seh5ooDXatz2 IMnoVAJp96qEpT+KcZkWbwznKWWXvmUxMmESfCGkf2vKbr6jcxKME+ArnPrcBOvw/756 NUFg== X-Gm-Message-State: AOAM531M5T//dVVkvbEmwSQICTfFnMB2W9kCL6rksK9hY+J5HxuopibR 0EelILI9zFBYb5EFEQzqrhv7gw== X-Google-Smtp-Source: ABdhPJxsP8i0TWeDLg6wsQ9UPwVK0/yOGsDuiZiCVZBbzrivtJSRk9eK8LYUFD9Zq4FE5g5ke2YZTA== X-Received: by 2002:a17:902:7c15:b029:12c:78ec:bb61 with SMTP id x21-20020a1709027c15b029012c78ecbb61mr18323457pll.61.1629498419309; Fri, 20 Aug 2021 15:26:59 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id s1sm4169427pfd.13.2021.08.20.15.26.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Aug 2021 15:26:58 -0700 (PDT) Date: Fri, 20 Aug 2021 22:26:53 +0000 From: Sean Christopherson To: Mathieu Desnoyers Cc: "Russell King, ARM Linux" , Catalin Marinas , Will Deacon , Guo Ren , Thomas Bogendoerfer , Michael Ellerman , Heiko Carstens , gor , Christian Borntraeger , Oleg Nesterov , rostedt , Ingo Molnar , Thomas Gleixner , Peter Zijlstra , Andy Lutomirski , paulmck , Boqun Feng , Paolo Bonzini , shuah , Benjamin Herrenschmidt , Paul Mackerras , linux-arm-kernel , linux-kernel , linux-csky , linux-mips , linuxppc-dev , linux-s390 , KVM list , linux-kselftest , Peter Foley , Shakeel Butt , Ben Gardon Subject: Re: [PATCH 1/5] KVM: rseq: Update rseq when processing NOTIFY_RESUME on xfer to KVM guest Message-ID: References: <20210818001210.4073390-1-seanjc@google.com> <20210818001210.4073390-2-seanjc@google.com> <1673583543.19718.1629409152244.JavaMail.zimbra@efficios.com> <1872633041.20290.1629485463253.JavaMail.zimbra@efficios.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1872633041.20290.1629485463253.JavaMail.zimbra@efficios.com> Precedence: bulk List-ID: X-Mailing-List: linux-csky@vger.kernel.org On Fri, Aug 20, 2021, Mathieu Desnoyers wrote: > Without the lazy clear scheme, a rseq c.s. would look like: > > * init(rseq_cs) > * cpu = TLS->rseq::cpu_id_start > * [1] TLS->rseq::rseq_cs = rseq_cs > * [start_ip] ---------------------------- > * [2] if (cpu != TLS->rseq::cpu_id) > * goto abort_ip; > * [3] > * [post_commit_ip] ---------------------------- > * [4] TLS->rseq::rseq_cs = NULL > > But as a fast-path optimization, [4] is not entirely needed because the rseq_cs > descriptor contains information about the instruction pointer range of the critical > section. Therefore, userspace can omit [4], but if the kernel never clears it, it > means that it will have to re-read the rseq_cs descriptor's content each time it > needs to check it to confirm that it is not nested over a rseq c.s.. > > So making the kernel lazily clear the rseq_cs pointer is just an optimization which > ensures that the kernel won't do useless work the next time it needs to check > rseq_cs, given that it has already validated that the userspace code is currently > not within the rseq c.s. currently advertised by the rseq_cs field. Thanks for the explanation, much appreciated! 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 X-Spam-Level: X-Spam-Status: No, score=-3.5 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4BCDAC4338F for ; Fri, 20 Aug 2021 22:27:46 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 94E6B610A3 for ; Fri, 20 Aug 2021 22:27:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 94E6B610A3 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.ozlabs.org Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Grx8v66qgz3d8N for ; Sat, 21 Aug 2021 08:27:43 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20161025 header.b=Remefsbk; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=google.com (client-ip=2607:f8b0:4864:20::1032; helo=mail-pj1-x1032.google.com; envelope-from=seanjc@google.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20161025 header.b=Remefsbk; dkim-atps=neutral Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Grx875kBnz301N for ; Sat, 21 Aug 2021 08:27:03 +1000 (AEST) Received: by mail-pj1-x1032.google.com with SMTP id 28-20020a17090a031cb0290178dcd8a4d1so10097542pje.0 for ; Fri, 20 Aug 2021 15:27:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=muCZGHGXDtZhLnuzxIVauvI9vXUTWXNUIrBwCRdMVco=; b=RemefsbkLF0qjalfgS/QPFy+s0vrHUCCRwLs5Nng2oRX7YN+RbFWFDzyRbXDUTFeRe ZcR6b656WMkKHvh5XwIeexMOkIK6TBTyMgP20QtOJD1jsJYkiBEWihN2CVwUcoknSiZc kfCOTeIeF9ja69Sxfpo9Tze/gbXlfbWjwwnjO1rkWyU9/APS4tY7lkRghKHUYYvwXaoY XjV//yV1jErHSoGWkaqeUNTbYjSMDPGF7Bsh5VYUZeLtO3D4NwU7djoZEoOgIYKcigrl LaQ3UiKuwPAupo+Ikjg0jO22FUEuCmAC9TlZ9LlWOAqKDqGqdS7VTnu20IUdQ2TEEMfG 3dxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=muCZGHGXDtZhLnuzxIVauvI9vXUTWXNUIrBwCRdMVco=; b=ijgj5shcNoSQsAjCpK1P53d0hmYseh0kR/f2pRy/g9huro2uBSWNCHDJKM58GUCV1r g8hMr/UhxvmJZowY0AilYoXnXrisTRoEcVcuIkzwENgamMGS2on9nRU3fQPCxlybJLf8 vWhdPepfiS2LEesFE45UIuyFhLxRUuuTV/0uTh4m1S3F2W/YMRY8cWd/biXapLAHQUUF VabeUNhY2OiMkZSpFIhg70fFthuaxlse2JQe0bBXSWl8kouJujv204dXR9cHamMxl7La w+2Wg/aY4koqRqa5/AqklViqJx0jhu+KqGIzw8AmZvwuLTbZ5Fu3Q3lJGwXYwVTSXAfj xPfA== X-Gm-Message-State: AOAM532YAh7UKixkRj0x5OS5yc64YFCo2inJ7a9B1YDlGo/175YIy7YD ZB7pQF80BX3O65LHeORo4LSswA== X-Google-Smtp-Source: ABdhPJxsP8i0TWeDLg6wsQ9UPwVK0/yOGsDuiZiCVZBbzrivtJSRk9eK8LYUFD9Zq4FE5g5ke2YZTA== X-Received: by 2002:a17:902:7c15:b029:12c:78ec:bb61 with SMTP id x21-20020a1709027c15b029012c78ecbb61mr18323457pll.61.1629498419309; Fri, 20 Aug 2021 15:26:59 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id s1sm4169427pfd.13.2021.08.20.15.26.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Aug 2021 15:26:58 -0700 (PDT) Date: Fri, 20 Aug 2021 22:26:53 +0000 From: Sean Christopherson To: Mathieu Desnoyers Subject: Re: [PATCH 1/5] KVM: rseq: Update rseq when processing NOTIFY_RESUME on xfer to KVM guest Message-ID: References: <20210818001210.4073390-1-seanjc@google.com> <20210818001210.4073390-2-seanjc@google.com> <1673583543.19718.1629409152244.JavaMail.zimbra@efficios.com> <1872633041.20290.1629485463253.JavaMail.zimbra@efficios.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1872633041.20290.1629485463253.JavaMail.zimbra@efficios.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: KVM list , Peter Zijlstra , linux-kernel , Will Deacon , Guo Ren , linux-kselftest , Ben Gardon , shuah , Paul Mackerras , linux-s390 , gor , "Russell King, ARM Linux" , linux-csky , Christian Borntraeger , Ingo Molnar , Catalin Marinas , linux-mips , Boqun Feng , paulmck , Heiko Carstens , rostedt , Shakeel Butt , Andy Lutomirski , Thomas Gleixner , Peter Foley , linux-arm-kernel , Thomas Bogendoerfer , Oleg Nesterov , Paolo Bonzini , linuxppc-dev Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Fri, Aug 20, 2021, Mathieu Desnoyers wrote: > Without the lazy clear scheme, a rseq c.s. would look like: > > * init(rseq_cs) > * cpu = TLS->rseq::cpu_id_start > * [1] TLS->rseq::rseq_cs = rseq_cs > * [start_ip] ---------------------------- > * [2] if (cpu != TLS->rseq::cpu_id) > * goto abort_ip; > * [3] > * [post_commit_ip] ---------------------------- > * [4] TLS->rseq::rseq_cs = NULL > > But as a fast-path optimization, [4] is not entirely needed because the rseq_cs > descriptor contains information about the instruction pointer range of the critical > section. Therefore, userspace can omit [4], but if the kernel never clears it, it > means that it will have to re-read the rseq_cs descriptor's content each time it > needs to check it to confirm that it is not nested over a rseq c.s.. > > So making the kernel lazily clear the rseq_cs pointer is just an optimization which > ensures that the kernel won't do useless work the next time it needs to check > rseq_cs, given that it has already validated that the userspace code is currently > not within the rseq c.s. currently advertised by the rseq_cs field. Thanks for the explanation, much appreciated! 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 X-Spam-Level: X-Spam-Status: No, score=-4.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA813C4338F for ; Fri, 20 Aug 2021 22:28:52 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A421961040 for ; Fri, 20 Aug 2021 22:28:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A421961040 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hdMRvOKqn/+qj1O0rB1Hu2KedkqLICWG1iCVusdg1tw=; b=BUgMlRHC8Mk8iq rE/OZ0N0v8+KW+myhxBe5OEudIgPC7vIB++JRdxXihcW9JLRdIte0bS7eolru6nM1dBiLgamYV43q EIV1okXW/hnPlDXf2wHPO8oiNUo4u4XqNysr44DOzO6POTIYwJOE9K0Feqx5/oED0L+uTU8/4G4R3 QyJjaRA36A6RjBFJCWFeqOs0FuAPKhPD5CtsjR30oUwHaEWFfiut2ANPL9QIe/YFxPaG4BnAU2U5E nkM5pbzCSADPPYfk2vKqLNTw/516pveRlljL/SDgdQ0eoJDPkWvSANn+yfyP8GqMIHBEXCacHJJRq HfD2Pz6HoB5B51YEeFuw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mHCye-00CBbv-1p; Fri, 20 Aug 2021 22:27:04 +0000 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mHCya-00CBb1-AJ for linux-arm-kernel@lists.infradead.org; Fri, 20 Aug 2021 22:27:01 +0000 Received: by mail-pj1-x1032.google.com with SMTP id gz13-20020a17090b0ecdb0290178c0e0ce8bso10056955pjb.1 for ; Fri, 20 Aug 2021 15:26:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=muCZGHGXDtZhLnuzxIVauvI9vXUTWXNUIrBwCRdMVco=; b=RemefsbkLF0qjalfgS/QPFy+s0vrHUCCRwLs5Nng2oRX7YN+RbFWFDzyRbXDUTFeRe ZcR6b656WMkKHvh5XwIeexMOkIK6TBTyMgP20QtOJD1jsJYkiBEWihN2CVwUcoknSiZc kfCOTeIeF9ja69Sxfpo9Tze/gbXlfbWjwwnjO1rkWyU9/APS4tY7lkRghKHUYYvwXaoY XjV//yV1jErHSoGWkaqeUNTbYjSMDPGF7Bsh5VYUZeLtO3D4NwU7djoZEoOgIYKcigrl LaQ3UiKuwPAupo+Ikjg0jO22FUEuCmAC9TlZ9LlWOAqKDqGqdS7VTnu20IUdQ2TEEMfG 3dxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=muCZGHGXDtZhLnuzxIVauvI9vXUTWXNUIrBwCRdMVco=; b=mc2IeA0gXeQ5ZpN1W1K3c9n6mKERo5xqYb4O1GVmqodWm2Cvaw2tHpYC8LgKi2Hx1B fHdKOt8rFzh/EUow9c2bWZ2jLYA42CNHUcuNZL3TRjXePIrvwdfESsuS7ygjRyYxeG8t 3EiWPUfneWl+p+o1AnlmaH193rgKCI59l58rrRAVZ6sNMw4iCeRq+WkfJL1mJ2Cc8Tht HDpTMalgeGL2BXWwzOBM9F3uNlLhlMQDv2RaKxaz4yxrZsD/EWlr736br4BRyhR0AiPC tDGMD7VpY4PfBCg9K6weYzohJmP9aTspQEAV/3kHvD7H0b5/keD24KOIpJDV6AXuupip 39nA== X-Gm-Message-State: AOAM531Ror6nw2wYMs/I+ic84W4hpH7Z4BVh3Utjo5bIX20Vecln2aoj UOv+uJxWEvuK7eCV2pqg2BRdGA== X-Google-Smtp-Source: ABdhPJxsP8i0TWeDLg6wsQ9UPwVK0/yOGsDuiZiCVZBbzrivtJSRk9eK8LYUFD9Zq4FE5g5ke2YZTA== X-Received: by 2002:a17:902:7c15:b029:12c:78ec:bb61 with SMTP id x21-20020a1709027c15b029012c78ecbb61mr18323457pll.61.1629498419309; Fri, 20 Aug 2021 15:26:59 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id s1sm4169427pfd.13.2021.08.20.15.26.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Aug 2021 15:26:58 -0700 (PDT) Date: Fri, 20 Aug 2021 22:26:53 +0000 From: Sean Christopherson To: Mathieu Desnoyers Cc: "Russell King, ARM Linux" , Catalin Marinas , Will Deacon , Guo Ren , Thomas Bogendoerfer , Michael Ellerman , Heiko Carstens , gor , Christian Borntraeger , Oleg Nesterov , rostedt , Ingo Molnar , Thomas Gleixner , Peter Zijlstra , Andy Lutomirski , paulmck , Boqun Feng , Paolo Bonzini , shuah , Benjamin Herrenschmidt , Paul Mackerras , linux-arm-kernel , linux-kernel , linux-csky , linux-mips , linuxppc-dev , linux-s390 , KVM list , linux-kselftest , Peter Foley , Shakeel Butt , Ben Gardon Subject: Re: [PATCH 1/5] KVM: rseq: Update rseq when processing NOTIFY_RESUME on xfer to KVM guest Message-ID: References: <20210818001210.4073390-1-seanjc@google.com> <20210818001210.4073390-2-seanjc@google.com> <1673583543.19718.1629409152244.JavaMail.zimbra@efficios.com> <1872633041.20290.1629485463253.JavaMail.zimbra@efficios.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1872633041.20290.1629485463253.JavaMail.zimbra@efficios.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210820_152700_430348_8D397BAF X-CRM114-Status: GOOD ( 17.18 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Aug 20, 2021, Mathieu Desnoyers wrote: > Without the lazy clear scheme, a rseq c.s. would look like: > > * init(rseq_cs) > * cpu = TLS->rseq::cpu_id_start > * [1] TLS->rseq::rseq_cs = rseq_cs > * [start_ip] ---------------------------- > * [2] if (cpu != TLS->rseq::cpu_id) > * goto abort_ip; > * [3] > * [post_commit_ip] ---------------------------- > * [4] TLS->rseq::rseq_cs = NULL > > But as a fast-path optimization, [4] is not entirely needed because the rseq_cs > descriptor contains information about the instruction pointer range of the critical > section. Therefore, userspace can omit [4], but if the kernel never clears it, it > means that it will have to re-read the rseq_cs descriptor's content each time it > needs to check it to confirm that it is not nested over a rseq c.s.. > > So making the kernel lazily clear the rseq_cs pointer is just an optimization which > ensures that the kernel won't do useless work the next time it needs to check > rseq_cs, given that it has already validated that the userspace code is currently > not within the rseq c.s. currently advertised by the rseq_cs field. Thanks for the explanation, much appreciated! _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel