Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1631809rwr; Fri, 5 May 2023 18:07:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6RzprBH077lk25YdUMycJmMuY0J2suL0JOVCKKKrYbt9O455U/5EdDIiR4UISn7cNvSyHm X-Received: by 2002:a17:90b:3609:b0:247:2437:d5c4 with SMTP id ml9-20020a17090b360900b002472437d5c4mr3470550pjb.13.1683335266311; Fri, 05 May 2023 18:07:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683335266; cv=none; d=google.com; s=arc-20160816; b=vaxWsGVc13BYbnvJ06nRc559QNvPrmU0/uW1vusCNomwBqgrb0poHxGg5mwjBJYk9L WM1D06CwvEAmHOtEK3/V+Xqqv916Nde/6pm1zLcMvTVTSNDpoOE6prMdAzmhz/D/BeVv DpPEQx1XezBotfpK7mKtARSu2yZKNtjzNhYWj/UeUlItTwVospwpFKGap2Uydc3GTUqM EiPC09FnF7HsexMuxIWve80/5Ro3jYvpXZBcb3/Nl/B8B9JPpJMJkJQVRwkEGS5VGP4m HH+74CVqp72mf2PjtW+JZOoyUxGeVF3NQaBHD+gStDUo6Zd5WP4hhqrewOqYDdQ6gCgm I9cA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=uKg9ooWeNyIkgIgwiRq1E2syoa7nncxzMKLzyswsRsc=; b=vRlLvONNvTgTKMRcMpzzX+wtD32OsE/CmIDl8L9DH3N1Nu7oW+qqxYDvIj3BrLMWAV bKetChX4e3KG0swpWOzts4GYC4RSO7DZr5H6i1iEfh+mbUhwuJuKaVVolYUllYzdqqhB VIlpcck/onH0Wq4DMHecX7V40KDxAxqc4LdPAhuNvOX9JAJBkMnOZebErjWhFkjWsmXJ iU5TIcd/LSnYbGNf0zh5eEfkj55j1BGbmOk54zRzgzH4TEQjjxb7WAlOYxnbNc7XlM+J kqSrvNBD//XB5fR7b4C0++vkcKfmEAUie6ybaDcJkHJShcFJU+l1lbkhryf8ubvbSxiG L1nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=oEYCubX2; 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 s201-20020a632cd2000000b0050bea5bf413si3425735pgs.705.2023.05.05.18.07.31; Fri, 05 May 2023 18:07:46 -0700 (PDT) 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=20221208 header.b=oEYCubX2; 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 S232759AbjEFA4N (ORCPT + 99 others); Fri, 5 May 2023 20:56:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232281AbjEFA4L (ORCPT ); Fri, 5 May 2023 20:56:11 -0400 Received: from mail-yb1-xb35.google.com (mail-yb1-xb35.google.com [IPv6:2607:f8b0:4864:20::b35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A37A66EAF for ; Fri, 5 May 2023 17:56:03 -0700 (PDT) Received: by mail-yb1-xb35.google.com with SMTP id 3f1490d57ef6-ba1815e12efso2203380276.3 for ; Fri, 05 May 2023 17:56:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683334563; x=1685926563; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=uKg9ooWeNyIkgIgwiRq1E2syoa7nncxzMKLzyswsRsc=; b=oEYCubX2MVaZ3lIzvYofKvwQIDmS/lXvTaPe+nx4JYIouIEOq7/VZNJBz/955TtNWl rYZHJ+9qECqeg4RDvNtvrHP7Ui0lGMPDX2ubGmDW8gNEBQ4HBdjErLbRCtIQE4/ErBRb UlUMiTVsTHoQ8RelA4t0FXBYWpOlPMnSpnz4cQsoVWkXnKmP9FEXp+ofhhYThW6YyuE1 IHUvMHy+BC8pzZGtWZNz6yAWNfS98wy2U8g8HBZK4UcJlfQuJKNgMLKe1XbotZB+DRQJ E6hjwHB7/x0k7bAxrYPgZylFDAG4hiLFoxg569IPVzorgRuRk9NqLc9+2y4ttTt5sYY5 aecQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683334563; x=1685926563; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uKg9ooWeNyIkgIgwiRq1E2syoa7nncxzMKLzyswsRsc=; b=LHFDS0Bk9fFwTDm/Qh4Ajxq5gS2G4fWT64kyRhRXN8Is9mdVUnVp+/5IIvQJItufSv D2WMZmJ9ou0brXxyYJ/j/UQAGlflyEwRfBpo5tE5fAZQ3Qz/mE1ODZtGZL7rFE1mckai UI2pHwaYeyRt3X8wMeNBJGUwFALmbNitItTn7Er1OGV0iGa8kfyXbPV8cpu+pw+ZTD1c qLITGnP6xEkrasRKow+lhkJuIrOPDWKISwACBDUo3R+pvJ2ZPmGywAzK8/G7FjJIw6bC 4Sv/qWquWuAbga00Yf0bkLmNP74vIKt5QLu5e9LjSJTcujuKPHUSxVoB4LItvnGWeueV RcDA== X-Gm-Message-State: AC+VfDyRMRFVcuSCcL+oDNJO4wgPfkVzFbW94MRzxPIGCkGmBu56Kld/ RlvEb6YJUq1EI5XzbkAmOZpWkBrR8Vt/iS8idYW+Dw== X-Received: by 2002:a0d:cb44:0:b0:556:b029:e101 with SMTP id n65-20020a0dcb44000000b00556b029e101mr3457366ywd.19.1683334562650; Fri, 05 May 2023 17:56:02 -0700 (PDT) MIME-Version: 1.0 References: <20230421165305.804301-1-vipinsh@google.com> <20230421165305.804301-10-vipinsh@google.com> <86pm7xjh3y.wl-maz@kernel.org> In-Reply-To: <86pm7xjh3y.wl-maz@kernel.org> From: Vipin Sharma Date: Fri, 5 May 2023 17:55:26 -0700 Message-ID: Subject: Re: [PATCH 9/9] KVM: arm64: Run clear-dirty-log under MMU read lock To: Marc Zyngier Cc: oliver.upton@linux.dev, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, chenhuacai@kernel.org, aleksandar.qemu.devel@gmail.com, tsbogend@alpha.franken.de, anup@brainfault.org, atishp@atishpatra.org, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, seanjc@google.com, pbonzini@redhat.com, dmatlack@google.com, ricarkol@google.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kselftest@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable 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 Fri, Apr 21, 2023 at 10:11=E2=80=AFAM Marc Zyngier wrot= e: > > On Fri, 21 Apr 2023 17:53:05 +0100, > Vipin Sharma wrote: > > > > Take MMU read lock for write protecting PTEs and use shared page table > > walker for clearing dirty logs. > > > > Clearing dirty logs are currently performed under MMU write locks. This > > means vCPUs write protection fault, which also take MMU read lock, wil= l > > be blocked during this operation. This causes guest degradation and > > especially noticeable on VMs with lot of vCPUs. > > > > Taking MMU read lock will allow vCPUs to execute parallelly and reduces > > the impact on vCPUs performance. > > Sure. Taking no lock whatsoever would be even better. > > What I don't see is the detailed explanation that gives me the warm > feeling that this is safe and correct. Such an explanation is the > minimum condition for me to even read the patch. > Thanks for freaking me out. Your not getting warm feeling hunch was right, stage2_attr_walker() and stage2_update_leaf_attrs() combo do not retry if cmpxchg fails for write protection. Write protection callers don't check what the return status of the API is and just ignores cmpxchg failure. This means a vCPU (MMU read lock user) can cause cmpxchg to fail for write protection operation (under read lock, which this patch does) and clear ioctl will happily return as if everything is good. I will update the series and also work on validating the correctness to instill more confidence. Thanks