From patchwork Wed Oct 13 15:58:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Perret X-Patchwork-Id: 12556269 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08320C433F5 for ; Wed, 13 Oct 2021 16:06:03 +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 C83C161168 for ; Wed, 13 Oct 2021 16:06:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C83C161168 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=jtLhiVFje8ZdoDkXPcdhw4i4VYkgjLuYOIVRLR3Uc1g=; b=1GSp3ofx872pF/iaQYFQqopgrw 3VUCwzahQEL2btg+Q488x9tjCoCFpvSgnSJ81RtY+DiCbEkjpmj0JNaz/uZzRVZQi6SPS5ThD+i3M tBKUCKH0l6E3QASL80W8rD7Cj3kMmNn5Zx6PcBXqE6I0HXRGxNAUieAeDbmWq92437TH9/oxkDeTC murorasCoaZyroHTJYY1eQCQ+gtQOT5YmUi9JuPTUC6A1rSF15es7YdHRwtshUsXDlkClupkHpR83 XqkfBpwVik8AK8BMonX5yGqYzDu2hQO+L29V5Dg7fCgDRY2SAM2/Mm440LhIl8R9HqFDdrXJB+Wuz 6N4MF9mA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1magjm-00HVeF-83; Wed, 13 Oct 2021 16:04:15 +0000 Received: from mail-wr1-x449.google.com ([2a00:1450:4864:20::449]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1magel-00HTQl-SA for linux-arm-kernel@lists.infradead.org; Wed, 13 Oct 2021 15:59:07 +0000 Received: by mail-wr1-x449.google.com with SMTP id 10-20020a5d47aa000000b001610cbda93dso2310036wrb.23 for ; Wed, 13 Oct 2021 08:59:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=jY5Bguf6FHbyrvp9n+fOCeNfdUoUza19VDS/XHTNadE=; b=a2bOxgesO4qShM9iZUtwxpNLNxvAtISKgoXG58VYG79ZxfXEvlG4txY+QkZoEO33fr k8oSCXYH8GFser7sVBGps8Vjd1hFlXGn5Ts0CCcl2YJqxk3xdJFxAIsh+rBQxP2SkpQQ q347qvkPHogVXKP8Z/gA0OMQ6RXw4b7Pj69mipXSocgiJn7uu/wVPB7Ljf7jnX5yMZdN 5FKtQ19TMmETiAtK1UX8oROSHR0BqOCK12jCUhWEAqJJ9V5EaIC1BevZLvOQtIxRv/we 3alhXG4rLviir9mjCOgr2Z2d38wDI2PSOWjG2Wb6omWVPHFuxiTwi3WQoexeHeTBEv+V rfPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=jY5Bguf6FHbyrvp9n+fOCeNfdUoUza19VDS/XHTNadE=; b=upsXcqKaJRWz3lOPFHV9zndnvLJjm/cOhjdXBfdfcvRh4GHPsT0LG9L5GacLzj/ScE M3Mo0HvO9r78/TKly9COUeKkt79D4GA17phAIOGEvnui+1qr812AVzt81QBBZtro7EW5 6Fsb9q8l/h0ALUPe/sTMuhlb70HUmRdJLf+0mAxI5uAgcw9cnaRtSGg1k5I+/GnpmOCR eA2VdxPQbwZ0UnpEYijV/VTYP2HJW9+pchu1OXHZlPYpoqXQDGW09/bsHMNy6ZMj/ILJ kBVdvnWO6VdOfLga/C4xOAYH86Rvd3Lqyh7Z9tjRkJQiiTVoNwfMZE29jdOeZbWAMUim /HIg== X-Gm-Message-State: AOAM5308y59Z5h7aUh335SZIeduIAkmZm+oBToXZTGLpASj4Ic1mQpyi l3r1Qt38NhTdZQiyuo1O9r2/q3GO8GHx X-Google-Smtp-Source: ABdhPJxV4HY2vWNYpk4jg87UJ31CTmQTVWpbTKB1UxegDt8PV1t1yvNzHY7X12YOZjtv1MWET7xESBbrbphK X-Received: from luke.lon.corp.google.com ([2a00:79e0:d:210:65b5:73d3:1558:b9ae]) (user=qperret job=sendgmr) by 2002:adf:a31d:: with SMTP id c29mr40005842wrb.381.1634140741873; Wed, 13 Oct 2021 08:59:01 -0700 (PDT) Date: Wed, 13 Oct 2021 16:58:27 +0100 In-Reply-To: <20211013155831.943476-1-qperret@google.com> Message-Id: <20211013155831.943476-13-qperret@google.com> Mime-Version: 1.0 References: <20211013155831.943476-1-qperret@google.com> X-Mailer: git-send-email 2.33.0.882.g93a45727a2-goog Subject: [PATCH 12/16] KVM: arm64: Move hyp refcount helpers to header files From: Quentin Perret To: Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Catalin Marinas , Will Deacon , Fuad Tabba , David Brazdil Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, kernel-team@android.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211013_085903_973116_4C2E24AF X-CRM114-Status: GOOD ( 11.00 ) 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 We will soon need to touch the hyp_page refcount from outside page_alloc.c in nVHE protected mode, so move the relevant helpers into a header file. Signed-off-by: Quentin Perret --- arch/arm64/kvm/hyp/include/nvhe/memory.h | 18 ++++++++++++++++++ arch/arm64/kvm/hyp/nvhe/page_alloc.c | 18 ------------------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/arch/arm64/kvm/hyp/include/nvhe/memory.h b/arch/arm64/kvm/hyp/include/nvhe/memory.h index 592b7edb3edb..e77783be0f3f 100644 --- a/arch/arm64/kvm/hyp/include/nvhe/memory.h +++ b/arch/arm64/kvm/hyp/include/nvhe/memory.h @@ -12,6 +12,24 @@ struct hyp_page { unsigned short order; }; +static inline void hyp_page_ref_inc(struct hyp_page *p) +{ + BUG_ON(p->refcount == USHRT_MAX); + p->refcount++; +} + +static inline int hyp_page_ref_dec_and_test(struct hyp_page *p) +{ + p->refcount--; + return (p->refcount == 0); +} + +static inline void hyp_set_page_refcounted(struct hyp_page *p) +{ + BUG_ON(p->refcount); + p->refcount = 1; +} + extern u64 __hyp_vmemmap; #define hyp_vmemmap ((struct hyp_page *)__hyp_vmemmap) diff --git a/arch/arm64/kvm/hyp/nvhe/page_alloc.c b/arch/arm64/kvm/hyp/nvhe/page_alloc.c index 38accc2e23e3..0d977169ed08 100644 --- a/arch/arm64/kvm/hyp/nvhe/page_alloc.c +++ b/arch/arm64/kvm/hyp/nvhe/page_alloc.c @@ -144,24 +144,6 @@ static struct hyp_page *__hyp_extract_page(struct hyp_pool *pool, return p; } -static inline void hyp_page_ref_inc(struct hyp_page *p) -{ - BUG_ON(p->refcount == USHRT_MAX); - p->refcount++; -} - -static inline int hyp_page_ref_dec_and_test(struct hyp_page *p) -{ - p->refcount--; - return (p->refcount == 0); -} - -static inline void hyp_set_page_refcounted(struct hyp_page *p) -{ - BUG_ON(p->refcount); - p->refcount = 1; -} - static void __hyp_put_page(struct hyp_pool *pool, struct hyp_page *p) { if (hyp_page_ref_dec_and_test(p))