Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2773569rdh; Wed, 27 Sep 2023 12:13:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE0FZST0jCEpBeLE8MK0atXebSMhXG0wabc0YVFN5yKsI707EJNZuq0v4sWG53gjIMI2YQQ X-Received: by 2002:a17:90a:6504:b0:274:4161:b9dc with SMTP id i4-20020a17090a650400b002744161b9dcmr2686209pjj.31.1695841994439; Wed, 27 Sep 2023 12:13:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695841994; cv=none; d=google.com; s=arc-20160816; b=zvYk1nLZ3PIGYtPM4QdEPPZp4z1BI8CO6lpnphQpohTk0Kz0qriOcw28Vvulmyvcdc wrp0LJYCFVjvZmTo/d4/luGtCv2Cld/TDIskdUunMoF8FL81wzBmR4ibWid7A2mSA9wb p+xKJwoNxZCIY+wT/gi6zMznU8JGPBqLcIfdkuxHfvIU3+siOmCZv5ub4R9WceIVXrg6 ddYTS7euwEsMcKL/xLk8QvmMWjYgjqS4dM8zbEVwZANYVyEJYxPBypTRLwEIWF8kxAM1 uS/ifjQCXT1dvgaSssFB7ea4v2Wef/O0Q8PuNbvsmn0W/fXNtT/ZSa19UnyEvmSUNPN2 mRoQ== 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:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=LxbnVeeBsmxebuYPX9n5F7ayQvPWmM0quJncxxttJX8=; fh=yikR9HT1wx5LLj7DvfR9kbE/RatD/mnQgNUS++qRsJM=; b=oGaNvmeMowZiS+/Oi5MwZ9CdKT16dTN+kl+BF67ZYKScmAxRxQyskYfSLb+2s/vzi1 WSbunGWNz9idxIS9G4ll9oO98LKFxIJ1pwDuNqlw+Ky3MH8a233U5ZD6Y76LLMaTHrxc tv8PqnsRMGE4Xn771TRo6UapcpnKxbosFUCF9VTGcD98vVpaeXCusUqm6B0D0Oih3yRw A8esDFX0XjHV8d0joNHoSFSLY9HnQov9Yxk08upI9Y8KX6o6nyfzFp3w74n1i1mlXLfW otBQ1mlkhr7PgWBy3elXnLRlRo+iBcahiozX8dBDIC2ECwLhnbEzgDjc773OS9LGjgHU vR6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=cORnPyxn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id m8-20020a17090a4d8800b00274e2ba0ca6si17815277pjh.134.2023.09.27.12.13.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 12:13:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=cORnPyxn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id A2E8880CBF32; Wed, 27 Sep 2023 04:26:57 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231492AbjI0L0i (ORCPT + 99 others); Wed, 27 Sep 2023 07:26:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231516AbjI0L0J (ORCPT ); Wed, 27 Sep 2023 07:26:09 -0400 Received: from mail-wr1-x44a.google.com (mail-wr1-x44a.google.com [IPv6:2a00:1450:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 652AECC9 for ; Wed, 27 Sep 2023 04:26:01 -0700 (PDT) Received: by mail-wr1-x44a.google.com with SMTP id ffacd0b85a97d-32323283257so5369910f8f.2 for ; Wed, 27 Sep 2023 04:26:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695813960; x=1696418760; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=LxbnVeeBsmxebuYPX9n5F7ayQvPWmM0quJncxxttJX8=; b=cORnPyxnYUUDBEx8bFQsUJFhOFPxcisp5LuuwGrzGxDZYmQlbYb2sp29gySnKTpzqQ WZAE3x0kIcTFCrbRRXEZpeprCNaPrvHa7Kul4Vlh+gKKdp3fWzrgMpXWlvuEHJ9cK8rb GXH6Ax6RiiOXxZ3nKhGbEA4K+GWp4B192o2hrNfUzNvBiLCi7lb+RKzQP4jXcwhX7MSX aqQ7CLQeH4tvYIJVKoOeo3x4SJvALRIFNWc45igJw/gNCOZr9ntfV8yfbBoE4WRdIvcn k+lFfUzez+fx27EcTC3HD4D3YNruPFxaA2J7rISMCOKn5lNr75xWf48hmpySDJrDR+Hl HBHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695813960; x=1696418760; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=LxbnVeeBsmxebuYPX9n5F7ayQvPWmM0quJncxxttJX8=; b=C/7XUlqw6PKK4BITEeJVBMKHD+sCeyWT5XMnXPs4Gi0ypQJLPjwnTLHKWXXSkRhDGk bMp3Fg4O14vSI4+VB9hk7NqCU6IzADiLDlY/YeN0xxk8yd5weAzvr+NjHP3DB90llQbE dYtsCzWOEtRvE8nVMcTQouKgj2Yl2h9PRfXRTmaosg4U9fLtvJC5xby0sIbiOYcat1ZM b1UH7Ew8XdZYpgHoEHF/8aA54h+sDl0p6vHJ/9n+0DOdQS2hVS9gF6wzHckz+mQKRQEc pOJFO6TLD53dkV0mS813Ya/6ahUVR9CoMA8vkgLZf4mYYRZtt2Kg2MyXu6W0PHNPzWNS wudQ== X-Gm-Message-State: AOJu0Yws4SWiteOGieqTK0XUF05mVKbzEcARqsBM95m4P0cFEmNl1V/A QHp7aO+kSeDY3mw5BokU8KZlolwABqkYGp7j1jAKXU99SdUVQKTUm846ppHMO0rBSVVLrWeSRDo YXOjcY/T155RJ1qoneP/MpHGsUQVTJs0qLYvcjP5h7oNBhR0UDdwfAG4sklD72MzyB4CR5TE+7R YDCiRfZBefEw== X-Received: from seb.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:31bd]) (user=sebastianene job=sendgmr) by 2002:adf:ed84:0:b0:317:6e79:423c with SMTP id c4-20020adfed84000000b003176e79423cmr7347wro.3.1695813959676; Wed, 27 Sep 2023 04:25:59 -0700 (PDT) Date: Wed, 27 Sep 2023 11:25:16 +0000 In-Reply-To: <20230927112517.2631674-1-sebastianene@google.com> Mime-Version: 1.0 References: <20230927112517.2631674-1-sebastianene@google.com> X-Mailer: git-send-email 2.42.0.515.g380fc7ccd1-goog Message-ID: <20230927112517.2631674-11-sebastianene@google.com> Subject: [PATCH 10/11] arm64: ptdump: Interpret pKVM ownership annotations From: Sebastian Ene To: linux-kernel@vger.kernel.org Cc: kernel-team@android.com, will@kernel.org, ryan.roberts@arm.com, mark.rutland@arm.com, maz@kernel.org, vdonnefort@google.com, Sebastian Ene Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 27 Sep 2023 04:26:57 -0700 (PDT) Add support for interpretting pKVM invalid stage-2 descriptors that hold ownership information. We use these descriptors to keep track of the memory donations from the host side. Signed-off-by: Sebastian Ene --- arch/arm64/include/asm/kvm_pgtable.h | 7 +++++++ arch/arm64/kvm/hyp/include/nvhe/mem_protect.h | 7 ------- arch/arm64/mm/ptdump.c | 10 ++++++++++ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/arch/arm64/include/asm/kvm_pgtable.h b/arch/arm64/include/asm/kvm_pgtable.h index 913f34d75b29..938baffa7d4d 100644 --- a/arch/arm64/include/asm/kvm_pgtable.h +++ b/arch/arm64/include/asm/kvm_pgtable.h @@ -87,6 +87,13 @@ typedef u64 kvm_pte_t; */ #define KVM_INVALID_PTE_LOCKED BIT(10) +/* This corresponds to page-table locking order */ +enum pkvm_component_id { + PKVM_ID_HOST, + PKVM_ID_HYP, + PKVM_ID_FFA, +}; + static inline bool kvm_pte_valid(kvm_pte_t pte) { return pte & KVM_PTE_VALID; diff --git a/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h b/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h index 9cfb35d68850..cc2c439ffe75 100644 --- a/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h +++ b/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h @@ -53,13 +53,6 @@ struct host_mmu { }; extern struct host_mmu host_mmu; -/* This corresponds to page-table locking order */ -enum pkvm_component_id { - PKVM_ID_HOST, - PKVM_ID_HYP, - PKVM_ID_FFA, -}; - extern unsigned long hyp_nr_cpus; int __pkvm_prot_finalize(void); diff --git a/arch/arm64/mm/ptdump.c b/arch/arm64/mm/ptdump.c index 964758d5e76d..45ff4ebae01a 100644 --- a/arch/arm64/mm/ptdump.c +++ b/arch/arm64/mm/ptdump.c @@ -272,6 +272,16 @@ static const struct prot_bits stage2_pte_bits[] = { .val = PTE_S2_MEMATTR(MT_S2_FWB_NORMAL) | PTE_VALID, .set = "MEM/NORMAL FWB", .feature_on = is_fwb_enabled, + }, { + .mask = KVM_INVALID_PTE_OWNER_MASK | PTE_VALID, + .val = FIELD_PREP_CONST(KVM_INVALID_PTE_OWNER_MASK, + PKVM_ID_HYP), + .set = "HYP", + }, { + .mask = KVM_INVALID_PTE_OWNER_MASK | PTE_VALID, + .val = FIELD_PREP_CONST(KVM_INVALID_PTE_OWNER_MASK, + PKVM_ID_FFA), + .set = "FF-A", }, { .mask = KVM_PGTABLE_PROT_SW0, .val = KVM_PGTABLE_PROT_SW0, -- 2.42.0.515.g380fc7ccd1-goog