Received: by 2002:a05:622a:1442:b0:3a5:28ea:c4b9 with SMTP id v2csp755192qtx; Thu, 17 Nov 2022 07:39:15 -0800 (PST) X-Google-Smtp-Source: AA0mqf63DIu0SdJTecSvs+Gss4gPYPdQ0Eo9uOuJbDIDwag3uIwYERNN5wbt+L+bTblyeSMkUe0a X-Received: by 2002:a17:906:c449:b0:7ae:cbae:af1 with SMTP id ck9-20020a170906c44900b007aecbae0af1mr2629818ejb.31.1668699554972; Thu, 17 Nov 2022 07:39:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668699554; cv=none; d=google.com; s=arc-20160816; b=aErmvW9kWyaG6zYWZr1LnT28hfXzybhVbqm+u/Nvj6WR9aDee7db62gg7NbmAi6Slf IYj6Sd3xsiQRw5q6MOi79CyXuK3fZ0hH7Uvkf5R+s9vNnhBYumkxV6iMUX84B1biFYZT ceeagtMuDiUmVGUXLZb13iYWZSsYptxo+COwMv30aXtxTNGnSInNCc81+kC38DTny0lz H+xfZ2adyiq40yiqGRIN5f8EAtxr9vC+JWeWHOjtZEZkDzilA/QI7yzVBPQthKeW95OP BGwVZfPAxcB5M/1W6CdnwZWHlKTMvmVqKqbR+UuX8ztZRSbx8gd4j7ajwJ4g7A7YYdq2 rKNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=54/qpLgKvMYRxZZN8WRThBEEYZ9T1CEvYfUVPrQm8ww=; b=iPBcNVRNZTcY1+wtMbXJ4zuNur5Xfs7cJcQAwYFsx5eNcOza10FK/Plo1wB29hPFIe AX5JyjQueK9GJqqzg3XzQNvq9aGJ0FUAiDswn+MfUIN+1QbKDGFKDyZUy4tvUHcVR62s oOgEZG61sZqv3ZMBeanRCWSqXsrAXN0JaAxBP2KBlGcStE15qx3Q0pOtINX8zXNKixmV BuHC/MI8LXN0O9iVzbQSnnEmuea1nS0DI5wKkSlcGc1k+Xlk83b/8ej9d+m1SERA83ug 7Zyhc4/QEqvlN69ehd2Rroku+mHUwNo8+I1yYfOYFxbDJyDroJ630UBUlFnACxtt7FLj auPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="iMSmmJd/"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oz13-20020a170906cd0d00b007a46fa50b26si651205ejb.517.2022.11.17.07.38.53; Thu, 17 Nov 2022 07:39:14 -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=@google.com header.s=20210112 header.b="iMSmmJd/"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240032AbiKQPW5 (ORCPT + 92 others); Thu, 17 Nov 2022 10:22:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240684AbiKQPV3 (ORCPT ); Thu, 17 Nov 2022 10:21:29 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29ECF490B9 for ; Thu, 17 Nov 2022 07:19:27 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id k2-20020a17090a4c8200b002187cce2f92so490596pjh.2 for ; Thu, 17 Nov 2022 07:19:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=54/qpLgKvMYRxZZN8WRThBEEYZ9T1CEvYfUVPrQm8ww=; b=iMSmmJd/PxvPh5Sz4Mhlv1D7h60/wqpXa0IlfaaP18ffK5JF15qrDhUVUrU0mPM8j5 +yh01SuAl11IdhGv9HRnwbEbasiIbUwNJEroOSBoHC0PSRXsMxFlfF8m0vO27W0kb1Pm KpWAdkZ8OeO3IpRpd7GTMe3WaNU7LXQu8BNCDaNhWSHry1EDfm4x45qAKDcZTJ20US1O HaNzNoB5jQwXfuuGssFqSarSg2xv7H8v2ew9s7NTFe7wL3tI+gGTER+rUYg94g+fS9ez W2tfqJxdHRLZU8/vA1csfuG18K2GHHfSzgBem4hC01N5DJZYllLM7dekVdhJHFeniQQy KmQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=54/qpLgKvMYRxZZN8WRThBEEYZ9T1CEvYfUVPrQm8ww=; b=ObfcJ7EY69MCqTIsNDu4c+L7ptjGwxkuINJ1DUwod3zQiwtJGhjOGxS+QYJlgWrj4M 9uW7PHQknvUTkfSR/LRKnXWjphbmRmEnvwe4E/WaNAsJSXha6sA2TDHkl1Ep7n25x9jI 6D4ZPLAEweaqiZu32JzaKaI8seH3H5300keuWrk28iXshcHGtflHC8atG5cxpYns6Ufl sMwrjEkQsP9hkbqW3l1I+cmzhwY7nk7a8UcUrYYZEAvhXIl6CKuEKTBUMwJG1+R5wbrs 2m2njzYZTGI2W9iY3Js9k6fppkXGOEMCDYupwk0Wik+Sw6SK1b7auWca8VaIEBe2DMPz XdpQ== X-Gm-Message-State: ANoB5plI9nvCFZJWvdeSpcrv3Gt94xSHcuFEYZV55taPJHhX2VGQATR+ ekrV46XJML8UwyQ0sLaWtzHFYQ== X-Received: by 2002:a17:902:cf05:b0:186:de22:7968 with SMTP id i5-20020a170902cf0500b00186de227968mr3286934plg.3.1668698366550; Thu, 17 Nov 2022 07:19:26 -0800 (PST) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id b4-20020a62cf04000000b005668b26ade0sm1242098pfg.136.2022.11.17.07.19.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Nov 2022 07:19:25 -0800 (PST) Date: Thu, 17 Nov 2022 15:19:21 +0000 From: Sean Christopherson To: Oliver Upton Cc: Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, Reiji Watanabe Subject: Re: [PATCH 2/2] KVM: arm64: selftests: Disable single-step without relying on ucall() Message-ID: References: <20221117002350.2178351-1-seanjc@google.com> <20221117002350.2178351-3-seanjc@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 Thu, Nov 17, 2022, Sean Christopherson wrote: > On Thu, Nov 17, 2022, Oliver Upton wrote: > > On Thu, Nov 17, 2022 at 12:23:50AM +0000, Sean Christopherson wrote: > > > Automatically disable single-step when the guest reaches the end of the > > > verified section instead of using an explicit ucall() to ask userspace to > > > disable single-step. An upcoming change to implement a pool-based scheme > > > for ucall() will add an atomic operation (bit test and set) in the guest > > > ucall code, and if the compiler generate "old school" atomics, e.g. > > > > Off topic, but I didn't ask when we were discussing this issue. What is > > the atomic used for in the pool-based ucall implementation? > > To avoid having to plumb an "id" into the guest, vCPUs grab a ucall entry from > the pool on a first-come first-serve basis, and then release the entry when the > ucall is complete. The current implementation is a bitmap, e.g. every possible > entry has a bit in the map, and vCPUs do an atomic bit-test-and-set to claim an > entry. > > Ugh. And there's a bug. Of course I notice it after sending the pull request. > Depsite being defined in atomic.h, and despite clear_bit() being atomic in the > kernel, tools' clear_bit() isn't actually atomic. Grr. > > Doesn't cause problems because there are so few multi-vCPU selftests, but that > needs to be fixed. Best thing would be to fix clear_bit() itself. Ha! And I bet when clear_bit() is fixed, this test will start failing again because the ucall() to activate single-step needs to release the entry _after_ exiting to the host, i.e. single-step will be enabled across the atomic region again.