Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1103434rwd; Tue, 16 May 2023 11:51:14 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5TdTw0/+lkx57kvfxDpDZrdopKh8CcB5Q2Bx2hF57lDt9tIxZEy9JRHUvrqOsTd9IygnlK X-Received: by 2002:a05:6a00:849:b0:649:dd0d:69d1 with SMTP id q9-20020a056a00084900b00649dd0d69d1mr25417846pfk.31.1684263073735; Tue, 16 May 2023 11:51:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684263073; cv=none; d=google.com; s=arc-20160816; b=JnRzhYBepK1Ubx0gA8SgxZL+5onaGKOids4Vt5+IWm7ExkhALtu+LxvHBQjNSKOcYR NIo3b/bV6VcTDgls4otSIffVqUXTzyQ6lhUyMGoQ5JYu2fSq9wHWv9HgFcuAKiZYgjaP EBQtjrD41XriamR2oTGP4X+eT+LTgzNh8bG41plcwrDYuWae6CkTSJdw0Y82gNT8dbeI 6/uDwsMNGV0QVSgCxNdi/H+uundF/14V5m/qaZ0G8f0jM+VKPlk60bVD6nsS8/JU76Ws lQjyeqitrYE+rPUAsnpWnNdUEbo0qfQhf0hitBvwc5WptzAf+WXk/obe9ZDbOx4A+/C8 pehQ== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:dkim-signature:date; bh=CK/p0lkmv/Tqb9sGLpB8/chiSJ3ZIxj/h3TTrpNfdf0=; b=Odq/4/PLIao0Va2xkvtAa4haMBeYm3SjOBXgAT048SFuK4PS4tFmf0C4M2Jn4YfzLP Bzj6RSoFaqQqGstso8P8mMt5SNGUTCUmk1CX93suBCZTqdj0uTQZ0+JZSjBR8VxKbdmF CU7FDtgEegkSoK/Dm39GuMxnuvMsBpE8Vv4+DTHlOqjzuZ4r054pg+dTZBPRVyiIleFt 8XBe/MB/pkLZkz7St2QCwUzL/a47XitV5FxAVdLo2+F5AWPi+VdAlvXa6d85bEfvsDbe l++W2AaxkJQECnCy/Q0+WEEA+p+fmpHrrYYjrYsSB3fLfNzUTpOxKakV9W91tj4J3CKt etyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=qSWvpu06; 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=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w5-20020aa79545000000b0063b652ff9cdsi19840303pfq.404.2023.05.16.11.50.59; Tue, 16 May 2023 11:51:13 -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=@linux.dev header.s=key1 header.b=qSWvpu06; 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=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230115AbjEPSqu (ORCPT + 99 others); Tue, 16 May 2023 14:46:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229635AbjEPSqt (ORCPT ); Tue, 16 May 2023 14:46:49 -0400 Received: from out-42.mta1.migadu.com (out-42.mta1.migadu.com [IPv6:2001:41d0:203:375::2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 489F81B5 for ; Tue, 16 May 2023 11:46:45 -0700 (PDT) Date: Tue, 16 May 2023 18:46:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1684262803; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CK/p0lkmv/Tqb9sGLpB8/chiSJ3ZIxj/h3TTrpNfdf0=; b=qSWvpu06QCE5s64r+PVFlGYriE800M/aXScyB5KM89Zg+oqn7rzUouemstYn358I7LD1ls 5WoW4Zx7WP9gKceNrz60JC7iLfhmswWhHyFEygWlweByUM2sU2vgpUySPZT08qooY1NQMA h9lbI4NSqmSwKFYh1/3EXybhLdC436w= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Raghavendra Rao Ananta Cc: Marc Zyngier , James Morse , Suzuki K Poulose , Ricardo Koller , Paolo Bonzini , Jing Zhang , Colton Lewis , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Subject: Re: [PATCH v3 7/7] KVM: arm64: Use TLBI range-based intructions for unmap Message-ID: References: <20230414172922.812640-1-rananta@google.com> <20230414172922.812640-8-rananta@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Migadu-Flow: FLOW_OUT 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_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,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 Tue, May 16, 2023 at 10:21:33AM -0700, Raghavendra Rao Ananta wrote: > On Fri, May 12, 2023 at 10:02 AM Oliver Upton wrote: > > > int kvm_pgtable_stage2_unmap(struct kvm_pgtable *pgt, u64 addr, u64 size) > > > { > > > + int ret; > > > + struct stage2_unmap_data unmap_data = { > > > + .pgt = pgt, > > > + /* > > > + * If FEAT_TLBIRANGE is implemented, defer the individial PTE > > > + * TLB invalidations until the entire walk is finished, and > > > + * then use the range-based TLBI instructions to do the > > > + * invalidations. Condition this upon S2FWB in order to avoid > > > + * a page-table walk again to perform the CMOs after TLBI. > > > + */ > > > + .skip_pte_tlbis = system_supports_tlb_range() && > > > + stage2_has_fwb(pgt), > > > > Why can't the underlying walker just call these two helpers directly? > > There are static keys behind these... > > > I wasn't aware of that. Although, I tried to look into the > definitions, but couldn't understand how static keys are at play here. > By any chance are you referring to the alternative_has_feature_*() > implementations when checking for cpu capabilities? Ah, right, these were recently changed to rely on alternative patching in commit 21fb26bfb01f ("arm64: alternatives: add alternative_has_feature_*()"). Even still, the significance remains as the alternative patching completely eliminates a conditional branch on the presence of a particular feature. Initializing a local with the presence/absence of a feature defeats such an optimization. -- Thanks, Oliver