From patchwork Mon Aug 9 15:24:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Perret X-Patchwork-Id: 12426801 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=-17.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 6857EC4338F for ; Mon, 9 Aug 2021 15:28:14 +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 334FC60EDF for ; Mon, 9 Aug 2021 15:28:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 334FC60EDF 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:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=IHpuEiENXAfu3cds7xynejLC0V1+0XHZiSXMjLZvWQw=; b=F0jSgkO58PbMwKxOBE02Cur1ZJ b3E9v0xPnZyKydYAipKX3+oNgcyrbcphcDkRdina8N0iQDBJAi9HXK+Lzu+M8rVKKY+Xqyq6Bcboo 8Ft4/DOgHse6TMeRRB6+gQSWrLqO4UUM5cfdUEVOO96YrlB3ey++WDcK6ZgPemPyCVwZUBPSYG3OZ pCRY/rkb5YeOsycip3ZNJgoL5DsYGWFnwmZniGQy3Opy8ZXONGtV3VtikJEg8X6pD7Vx2O7vnqa3x Gs/Zo0j2DPNYaw80e/hFyOhF67uqW2YPxTjbjTOApeSF8OpHq+nlq28fyF2IexpRQqnjPmBx92Tm7 2sKwgCpw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mD79I-0017ta-My; Mon, 09 Aug 2021 15:25:08 +0000 Received: from mail-qk1-x749.google.com ([2607:f8b0:4864:20::749]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mD795-0017pn-13 for linux-arm-kernel@lists.infradead.org; Mon, 09 Aug 2021 15:24:56 +0000 Received: by mail-qk1-x749.google.com with SMTP id h186-20020a37b7c30000b02903b914d9e335so12719706qkf.17 for ; Mon, 09 Aug 2021 08:24:53 -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=9BduUGnjsWum8FcOsM11gO3G+u8+79slhTeMYYKry4w=; b=g983I9YSVoWH/a7/cl0ZycwVjzqZeyo8x+fLCew59C7a0BnEu2wL6cysC50kAFs8Vi ehEdfCFNUnOWvVuDeMXGfwSfjkPO6irIfVDI1BOyVgOb2mistjn/3qc9aekGj3nyWfEP mv2IxEl7l/db3vL40dr7vcCKECuWFlGEQTsXsxS+OPHN8h4PW005Da05hkZ4QrGVi6/c iy5E1D2xv8HABlnaCg5SV0NZvQskMmKX3vG7+v7NRPhL/iuVTDX753+y/AxDWOc3l6hM igtE3JtznbdG+M1JR7b47U5TTSHB4/v8dAR/v0CBrRKmc9w4iH1rKAt2xMXY4Rmb58AP IwiA== 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=9BduUGnjsWum8FcOsM11gO3G+u8+79slhTeMYYKry4w=; b=m585Y+tqtByawvBwNqLbCW7YjQgK1xphnWCOPXxIPof0WKUlPQGC99R3CwJaYndn6v c1af6x3v/yrx7TrMXsYXRYlqyt5VZJobNOpzS4ExFuhMAvQNKb+EJicxxuUQ/95enj5J pvGRDC97Rts8UExEvVJKsva9JuKfC6rFcH2/oeLUsjqXJwdX3wxMtrZfpykainckra/N eVtuWFMD9SfcPmGliiVhPGpUCW+hLINx6rxGc9g7WfdYeKAMOPsrM2oeWwKJ4ArAvvih PYwuQ6FWcXjR1aJQi3lbP93dE+hVxiE53TQhai+/gPry+vvj7xIp8eiVK5YjRcWrEx67 zYeA== X-Gm-Message-State: AOAM530L6jYkwFGwBXYW6l+Wo2VPhPzQ/Q0O4FhpS8F4siQclJhn7ZnS yTdBCB1tOBOnlAZNx5KI02+1Q4ly+mIi X-Google-Smtp-Source: ABdhPJxcZ9biebm1fDKv+UMiqbVL5l0nCshM5eLfjTeBhNH2YYSYI90HGbAFPRYEaW9dglJFBj8tlcbiknXL X-Received: from luke.lon.corp.google.com ([2a00:79e0:d:210:b0e8:d460:758b:a0ae]) (user=qperret job=sendgmr) by 2002:a0c:e609:: with SMTP id z9mr9405599qvm.37.1628522692904; Mon, 09 Aug 2021 08:24:52 -0700 (PDT) Date: Mon, 9 Aug 2021 16:24:28 +0100 In-Reply-To: <20210809152448.1810400-1-qperret@google.com> Message-Id: <20210809152448.1810400-2-qperret@google.com> Mime-Version: 1.0 References: <20210809152448.1810400-1-qperret@google.com> X-Mailer: git-send-email 2.32.0.605.g8dce9f2422-goog Subject: [PATCH v4 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, qperret@google.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210809_082455_115915_582EC312 X-CRM114-Status: GOOD ( 11.70 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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__ */