Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp6097866pxv; Thu, 29 Jul 2021 06:29:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxRkAwB9EnqrUtsXF9zSo/CMTohJgdgldgFZ4x8JNZhLHTAKHDmP2mKfIJan4yDpdelbhrB X-Received: by 2002:a05:6638:130b:: with SMTP id r11mr4539763jad.79.1627565373695; Thu, 29 Jul 2021 06:29:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627565373; cv=none; d=google.com; s=arc-20160816; b=pF2a4vEJv5mqHXDR8FMb1GBiwgDvn50QHx2HGfvQ+GY4Q3ZWiQVcDKMXKJQIRibw1r NB0AH4BhYiLLOBMpUssV2mgyFH87DZL9vv3gFRxzruADx+x3XNTLFTH6XPblHSrO/LvC vml3wwceZLUbqO0t48/oOtNgDzMkb2bYecE6DjaPKG2IvfED7atABNTVNdwti8QzHTZx v4/WfdPPkCuH2HcsJx7jBvV3gWJEKRvWjlnBsOJ9kzz2PBOaH9LbdROZxqTkADxfoN1f wg8Zvazg1PisbW/ZmG7po0hReS+bcU827afsvwmVbPib6v9qMT/0XFHUrVXpBfZtmqTf dclA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=crBqYydgsM0lLmpXbxrQzqnfwJboPEMWJ5uFG+CB388=; b=kkur8UpijcB7HSB8TQdlTXdRu3w/0eQRNnfhSpRWAZTH7K8uc7qMz3GmPdhc6wyrM+ UqMq/1Mk3Jhl5ADeY+9lAPzuFZnbG9zQmaP194uzhFU0nC2KcL+skvSTAIl/diGALOFx peXVOyp3hFtLXB9FmnuFhvQsaaWoyTYXwtDVvzKICqk3yQvgKF9pQChsBKkzxHI9njBt lkLP3M40MdT15ddcUWD4zsYzMEiZIqc9RDQMkMe4fqj4IVQVqSccsTI9lXixdWKihB7U LUKcwXV/QvWqW61XslpGBY92275MgypWCZjddTAtUMt/vY0pVL+xLDTspR4cJfIDqLK3 Zbxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=JOIVCVkT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x90si3149787jah.3.2021.07.29.06.29.22; Thu, 29 Jul 2021 06:29:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=JOIVCVkT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S237559AbhG2N23 (ORCPT + 99 others); Thu, 29 Jul 2021 09:28:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237462AbhG2N22 (ORCPT ); Thu, 29 Jul 2021 09:28:28 -0400 Received: from mail-qk1-x749.google.com (mail-qk1-x749.google.com [IPv6:2607:f8b0:4864:20::749]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 777F1C061765 for ; Thu, 29 Jul 2021 06:28:25 -0700 (PDT) Received: by mail-qk1-x749.google.com with SMTP id j12-20020a05620a146cb02903ad9c5e94baso3795910qkl.16 for ; Thu, 29 Jul 2021 06:28:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=crBqYydgsM0lLmpXbxrQzqnfwJboPEMWJ5uFG+CB388=; b=JOIVCVkTKSE7PwC39f/uN10vnOvi7Vzp2RTafhg3kyIB15DlDdxcNRRjKoM75ogyTS sjmXizIUunrQ4Q2yIkfgmJDrNF8nuB33MW7tB7YPCbcNhgcnStKG61TKLA9OHyXOwzKH i7uDNzA+PPHFpfTHJs2M5QoYOwbb6NUXBh++UvXlYe3cdezMzPl1EZ3sOx0jBVOxIit7 DsJ4Rk2OJv96rif4hnZqeL50UBKsRJGWc8A2EaMc0YZVDJkZTXTjcJfL1x72E+Z4uyBi PGyvbycBPgY92pQ84g5f29LjEY96+E8Pod3jV3Xa3E41vkI8XuIPX9jDrr0GlJ2pzzRS RQTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=crBqYydgsM0lLmpXbxrQzqnfwJboPEMWJ5uFG+CB388=; b=dypNxDTa3+Z75+4T6HPjpXDQnwWh0DBlnJcuDd1JNSUovP1/8ueSx1UaUz3Ta8XLzX jzDPCi8zhp3l1rDBG8fKnTxTTrk02c1wi2AoRQFUTHuXFhO/zevRol1akJlW7xtAux+y 5nzgDF8OnbqbVQKcBExA5pIadJ8pP0daFN0XdjKbquvJ00cPF0Y5zKjLNff4+btN9kqQ +XUVxcmpUhtNjs8ejHxlq/xMG7/XGfaczRKq1nqb3hoD0czGlRz/8UQccURWqjaADyIK OSG1bCHPHEvKoD4/wghpTi4CEIuVGqR7IA+5isSxUquEvbLTIwlvUyDQt1dYWmgJzlf1 OXIw== X-Gm-Message-State: AOAM530JMjc38DmzwA/2I5oXBSQHcJEgbVnGkt8F8Rnfiful0n5Wwuiz kKv8UcJmzR38LS1Ebpx7eWcEkmPrWxtj X-Received: from luke.lon.corp.google.com ([2a00:79e0:d:210:293a:bc89:7514:5218]) (user=qperret job=sendgmr) by 2002:a05:6214:1021:: with SMTP id k1mr5318862qvr.4.1627565304476; Thu, 29 Jul 2021 06:28:24 -0700 (PDT) Date: Thu, 29 Jul 2021 14:27:58 +0100 In-Reply-To: <20210729132818.4091769-1-qperret@google.com> Message-Id: <20210729132818.4091769-2-qperret@google.com> Mime-Version: 1.0 References: <20210729132818.4091769-1-qperret@google.com> X-Mailer: git-send-email 2.32.0.432.gabb21c7263-goog Subject: [PATCH v3 01/21] KVM: arm64: Add hyp_spin_is_locked() for basic locking assertions at EL2 From: Quentin Perret To: maz@kernel.org, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, will@kernel.org Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, ardb@kernel.org, qwandor@google.com, tabba@google.com, dbrazdil@google.com, kernel-team@android.com, Quentin Perret Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Will Deacon Introduce hyp_spin_is_locked() so that functions can easily assert that a given lock is held (albeit possibly by another CPU!) without having to drag full lockdep support up to EL2. Signed-off-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/kvm/hyp/include/nvhe/spinlock.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/arm64/kvm/hyp/include/nvhe/spinlock.h b/arch/arm64/kvm/hyp/include/nvhe/spinlock.h index 76b537f8d1c6..04f65b655fcf 100644 --- a/arch/arm64/kvm/hyp/include/nvhe/spinlock.h +++ b/arch/arm64/kvm/hyp/include/nvhe/spinlock.h @@ -15,6 +15,7 @@ #include #include +#include typedef union hyp_spinlock { u32 __val; @@ -89,4 +90,11 @@ static inline void hyp_spin_unlock(hyp_spinlock_t *lock) : "memory"); } +static inline bool hyp_spin_is_locked(hyp_spinlock_t *lock) +{ + hyp_spinlock_t lockval = READ_ONCE(*lock); + + return lockval.owner != lockval.next; +} + #endif /* __ARM64_KVM_NVHE_SPINLOCK_H__ */ -- 2.32.0.432.gabb21c7263-goog