From mboxrd@z Thu Jan 1 00:00:00 1970 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 B8752C433EF for ; Wed, 6 Oct 2021 11:24:20 +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 83AD96109F for ; Wed, 6 Oct 2021 11:24:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 83AD96109F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=CWtTgnuU0MwJbkANJGbGO6QSwz6bq4kxQ2zwf3t/DPw=; b=vE8eKvVh7KegVR kzlxb1ijQTMUr+N4dCwWDGHOsPSeetZV8D0PhQP/eMZPw0V8rou/rKK/7C+gzeYfOf1vwehGkuVoY YnCokL8IP7WwxcGjYrTHv9dl7rQk0SLyCTv7d/ElD14mUxCv97SfE5ExfTdjDS1JSmBAGNM5Bf57M GcOe96MjyLuf8Il1DN6ZpaPfy1USKDhvFnDVSftFvQiWSfGSfOoFYcp/GDPxuqiDgT/FXI3A42NKk gK6uzq/uffq5b8xf0pNHxVMSbnO7aaIoqhLGgDFvn9XNdPfj2Ip9ANuQ39JMx7hCGbHZxUNU01W35 rBwrn2Npod7SIlvXvg2w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mY50J-00E4M4-EM; Wed, 06 Oct 2021 11:22:31 +0000 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mY50G-00E4LR-2U for linux-arm-kernel@lists.infradead.org; Wed, 06 Oct 2021 11:22:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633519347; 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: in-reply-to:in-reply-to:references:references; bh=jWX5sU8D1+Ly4mm1f35q3sYrq7WIwVRiVd8SgiHRgOs=; b=JJozpYtc+lht4K+GR9dJN5iVdGpxBjbKn7W+xoieRxxQ8phKA4tZS2P8GEffRp5wvYpdCU SxZhMU+0m/ogneH6G953wzBOFfdZS4zdZbfYmzmV+0y3bbjtJiuxBF6cAZTYXDdA26zSeS 9AR6TvwvluTsM0a+vcwiYZgNpBinv8g= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-253-E6JfbeL6Pemjf1BFEbWIXw-1; Wed, 06 Oct 2021 07:22:26 -0400 X-MC-Unique: E6JfbeL6Pemjf1BFEbWIXw-1 Received: by mail-ed1-f72.google.com with SMTP id r11-20020aa7cfcb000000b003d4fbd652b9so289584edy.14 for ; Wed, 06 Oct 2021 04:22:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=jWX5sU8D1+Ly4mm1f35q3sYrq7WIwVRiVd8SgiHRgOs=; b=jv45/nq2XkXLVpHLGHN+ew/rqIOHxwjBE8cBH5jXxDaB/J4s2p7hs55iLn6+wn8TOV uxfHFK9I1p02FH53mOcu4/R9fze8jqWXKUFCp06sj73KMZiLopneY/1P3i7VlHvmeqW/ q3SbjtQc7LNkTNGJrn4nCv9FZnAeciUh5jCMKKs20D996Fpe6Mf4HjuWm42PBy26a1Dl QwrWYZ1WSfSHwPm8oMCsM2KTDYKLdvZUWUHO3WF/L4DtEsA0ZXcI6wAhTinlKwA1KbXd rpMP3bzzR7064RGSkfLOcVMkOUph/9I3IKjvdmjuF4sv1Mxhx31Kk4+D2xjjRKFVEsFk pkVg== X-Gm-Message-State: AOAM5337tXHhivE8yjvphm/9tjntiZxVBA3kspSsqRjKsBmU7Hk9gS0v yDyAaydgNhvqCbYtdCRUFMaSu2iTmQVstSvL5pFaGdaaB/0AZZIzHDC3RHmwDzufGnLUdLYAR9l 8qzIx5nWwpSP7UKU6WrpUudoZwcLVBdD+7sg= X-Received: by 2002:a17:906:4f82:: with SMTP id o2mr31730765eju.10.1633519344814; Wed, 06 Oct 2021 04:22:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwIBjVZ1NUXsGTtniMInafdYKeFUjjcDRuQOp+LY5ONfLP3y1FH0sVTnhS2J3YnXmmsoLjhGg== X-Received: by 2002:a17:906:4f82:: with SMTP id o2mr31730745eju.10.1633519344572; Wed, 06 Oct 2021 04:22:24 -0700 (PDT) Received: from gator.home (cst2-174-28.cust.vodafone.cz. [31.30.174.28]) by smtp.gmail.com with ESMTPSA id u4sm1158745edj.33.2021.10.06.04.22.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Oct 2021 04:22:24 -0700 (PDT) Date: Wed, 6 Oct 2021 13:22:22 +0200 From: Andrew Jones To: Marc Zyngier Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, will@kernel.org, qperret@google.com, dbrazdil@google.com, Steven Price , Fuad Tabba , Srivatsa Vaddagiri , Shanker R Donthineni , James Morse , Suzuki K Poulose , Alexandru Elisei , kernel-team@android.com Subject: Re: [PATCH v2 03/16] KVM: arm64: Turn kvm_pgtable_stage2_set_owner into kvm_pgtable_stage2_annotate Message-ID: <20211006112222.ahfhtkhamdi3svm5@gator.home> References: <20211004174849.2831548-1-maz@kernel.org> <20211004174849.2831548-4-maz@kernel.org> <20211006110211.y6kzmjlzgardmwif@gator.home> MIME-Version: 1.0 In-Reply-To: <20211006110211.y6kzmjlzgardmwif@gator.home> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=drjones@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211006_042228_214061_A36CD1DC X-CRM114-Status: GOOD ( 25.83 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Oct 06, 2021 at 01:02:11PM +0200, Andrew Jones wrote: > On Mon, Oct 04, 2021 at 06:48:36PM +0100, Marc Zyngier wrote: > > kvm_pgtable_stage2_set_owner() could be generalised into a way > > to store up to 63 bits in the page tables, as long as we don't > > set bit 0. > > > > Let's just do that. > > > > Signed-off-by: Marc Zyngier > > --- > > arch/arm64/include/asm/kvm_pgtable.h | 12 ++++++----- > > arch/arm64/kvm/hyp/include/nvhe/mem_protect.h | 2 +- > > arch/arm64/kvm/hyp/nvhe/mem_protect.c | 11 ++++------ > > arch/arm64/kvm/hyp/nvhe/setup.c | 10 +++++++++- > > arch/arm64/kvm/hyp/pgtable.c | 20 ++++++------------- > > 5 files changed, 27 insertions(+), 28 deletions(-) > > > > diff --git a/arch/arm64/include/asm/kvm_pgtable.h b/arch/arm64/include/asm/kvm_pgtable.h > > index 027783829584..d4d3ae0b5edb 100644 > > --- a/arch/arm64/include/asm/kvm_pgtable.h > > +++ b/arch/arm64/include/asm/kvm_pgtable.h > > @@ -329,14 +329,16 @@ int kvm_pgtable_stage2_map(struct kvm_pgtable *pgt, u64 addr, u64 size, > > void *mc); > > > > /** > > - * kvm_pgtable_stage2_set_owner() - Unmap and annotate pages in the IPA space to > > - * track ownership. > > + * kvm_pgtable_stage2_annotate() - Unmap and annotate pages in the IPA space > > + * to track ownership (and more). > > * @pgt: Page-table structure initialised by kvm_pgtable_stage2_init*(). > > * @addr: Base intermediate physical address to annotate. > > * @size: Size of the annotated range. > > * @mc: Cache of pre-allocated and zeroed memory from which to allocate > > * page-table pages. > > - * @owner_id: Unique identifier for the owner of the page. > > + * @annotation: A 63 bit value that will be stored in the page tables. > > + * @annotation[0] must be 0, and @annotation[63:1] is stored > > + * in the page tables. > > * > > * By default, all page-tables are owned by identifier 0. This function can be > > * used to mark portions of the IPA space as owned by other entities. When a > > @@ -345,8 +347,8 @@ int kvm_pgtable_stage2_map(struct kvm_pgtable *pgt, u64 addr, u64 size, > > * > > * Return: 0 on success, negative error code on failure. > > */ > > -int kvm_pgtable_stage2_set_owner(struct kvm_pgtable *pgt, u64 addr, u64 size, > > - void *mc, u8 owner_id); > > +int kvm_pgtable_stage2_annotate(struct kvm_pgtable *pgt, u64 addr, u64 size, > > + void *mc, kvm_pte_t annotation); > > > > /** > > * kvm_pgtable_stage2_unmap() - Remove a mapping from a guest stage-2 page-table. > > diff --git a/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h b/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h > > index b58c910babaf..9d2ca173ea9a 100644 > > --- a/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h > > +++ b/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h > > @@ -53,7 +53,7 @@ int __pkvm_host_share_hyp(u64 pfn); > > > > bool addr_is_memory(phys_addr_t phys); > > int host_stage2_idmap_locked(phys_addr_t addr, u64 size, enum kvm_pgtable_prot prot); > > -int host_stage2_set_owner_locked(phys_addr_t addr, u64 size, u8 owner_id); > > +int host_stage2_annotate_locked(phys_addr_t addr, u64 size, kvm_pte_t owner_id); > > int kvm_host_prepare_stage2(void *pgt_pool_base); > > void handle_host_mem_abort(struct kvm_cpu_context *host_ctxt); > > > > diff --git a/arch/arm64/kvm/hyp/nvhe/mem_protect.c b/arch/arm64/kvm/hyp/nvhe/mem_protect.c > > index bacd493a4eac..8cd0c3bdb911 100644 > > --- a/arch/arm64/kvm/hyp/nvhe/mem_protect.c > > +++ b/arch/arm64/kvm/hyp/nvhe/mem_protect.c > > @@ -286,17 +286,14 @@ static int host_stage2_adjust_range(u64 addr, struct kvm_mem_range *range) > > int host_stage2_idmap_locked(phys_addr_t addr, u64 size, > > enum kvm_pgtable_prot prot) > > { > > - hyp_assert_lock_held(&host_kvm.lock); > > - > > return host_stage2_try(__host_stage2_idmap, addr, addr + size, prot); > > } > > > > -int host_stage2_set_owner_locked(phys_addr_t addr, u64 size, u8 owner_id) > > +int host_stage2_annotate_locked(phys_addr_t addr, u64 size, > > + kvm_pte_t annotation) > > { > > - hyp_assert_lock_held(&host_kvm.lock); > > Hi Marc, > > Why are the lock asserts getting dropped? Ah, I see. host_stage2_try already has the same assert. Reviewed-by: Andrew Jones Thanks, drew _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel