Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp2313529pxy; Tue, 3 Aug 2021 03:22:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVi2Eg8tUPgPIPyTXX3lkoOJNuCuU/M/l9tZ9DSdI3mneNqlIw49OC0J2A8GAGvqzfSSWK X-Received: by 2002:a5e:c912:: with SMTP id z18mr159462iol.9.1627986137125; Tue, 03 Aug 2021 03:22:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627986137; cv=none; d=google.com; s=arc-20160816; b=QifHU/M39TWIvEdykE0vuibnDhpDkTH5wCqseYioY2gkbrq07SIe0RgNeWG9+3ROal y0QWnYWa5IM7iY2Nkbg8y6KqdTndRTuzmJQ7Vp+Ooh454LNuVWi2L/iPmRLl64wcIkAR 7YEBFPmb9c9P/mV0EOXn0L+8HM32FvGoGcuktLKPprN5BP63ioClLdpjfAse8S5+4Vz8 0/6l/L+vtsclFHLbaUFpb39o71cgkBkx9p3605zgBfrN4DsdQM/RNInVdCs/bMrBHa8z iqBHOoMu1B7C3PzYNL0zoV2vl7z03bM60ovrBtRGM2c4KrQ1ELKCBZ0KbyN/gBMPZQdB TQ4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=BH6VSubQLcCEeiXp46qRZOXRNaTnzvfumnh86E0J8aM=; b=ToIiHPXK1UWPVUlbNgtbHCV3vdGOmJY0i+CfGU4GwT60nEAstXAHPyzA8s6OwcFq+H mYAA3droZXWRwlt+YMRDwaJHOr11vFP/P76TZUypOLvk4sih+CN8NEQzjf16mjldIwK0 rt+ryULEp4WQ46tvCIE+ROz6X5UOgz6xiNOFYHHU1ovsEvbZTgWQePnEOweJ56qk09RG +ZBpxurTZWkxMIrddP46cqrnbb6PtVVO3HC3ULnzXUt+x1fxp9Myk+/6OnyJQ8ZEDT5i yWOskRpJ41mtPftrsWt+y+GhrALPxNwzlLvfTFZ7eMZmMQu8d0v6riTdFpvaywZEZpZS xEpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="NQYGJM/X"; 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 b15si15848662ilv.151.2021.08.03.03.22.02; Tue, 03 Aug 2021 03:22:17 -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="NQYGJM/X"; 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 S235341AbhHCKUR (ORCPT + 99 others); Tue, 3 Aug 2021 06:20:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235143AbhHCKUQ (ORCPT ); Tue, 3 Aug 2021 06:20:16 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8047AC06175F for ; Tue, 3 Aug 2021 03:20:05 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id b13so13858723wrs.3 for ; Tue, 03 Aug 2021 03:20:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=BH6VSubQLcCEeiXp46qRZOXRNaTnzvfumnh86E0J8aM=; b=NQYGJM/XzsrAJWy8BNxS7s5O7GkQgGVRYjx+8M/j9wHLNhSSVCVnmOw51NtulDRnRA YCrgVK54gw85K3GHJCd3kW0jmE48JlVl28VXS9mK9YrBDrotXYSyUcT+NhBO+eMx71sQ 8KmrjMkyKg0DgnEJfodsW3C/yzAu4Y9E1ZOaW1AycJiMWXRAhJt2GqL22/BTK42XNN1m EfTqLZ5rwAO1wGEkJz4bWP/rrNEq64U+FN9ar5keUt3upGBQWHWvJ5K5Zph3vhV+fgQu grHCCISsAfzFD4PmL3Hhv8XvH+7cI0Sd117guye40xRgVwI2ospt3iM5xcn81EcjojHw VVcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=BH6VSubQLcCEeiXp46qRZOXRNaTnzvfumnh86E0J8aM=; b=PGVoAleV/GKTAD/UY0i2JIkNUScjqzAiEUGmYc8rdm/8uAlL0dlzvJ9ZuZ9YohM6TA wzHvZ5LtTCzUGXIdlDKHpDMRHF1orzff8+5GBBIQEC0AzWNqJaExZSF+uKe5lfASiaJc ZPbzvzu7B1yity+tH1KaZYEEhuITEiMpijpWWhs9fhhaSge9G61X7ELIL5IYQMMfIg7R m1IXiUbDJCz+mO2XpzrhEsKQVSUtPRPy4zvfWputzqs7PucB8ifveMuiY0yvJb2VdRxd poDQ+ST1fA2J6GY3jtyyXSmeg6m12JWwI5DNqgclVmLd9KsrawlSNOAxve2hDbroq6AY oYaw== X-Gm-Message-State: AOAM532bBFuzTowxsFMiUMPTt6Gg2KY2fwsMmnEabQl4BvdtIPHzykfc 5JUixCGMgkxYy+iUxmdWjiLOoA== X-Received: by 2002:a5d:6589:: with SMTP id q9mr22819763wru.284.1627986004001; Tue, 03 Aug 2021 03:20:04 -0700 (PDT) Received: from google.com ([2a00:79e0:d:210:754:7d1b:7303:129a]) by smtp.gmail.com with ESMTPSA id e3sm14173327wrw.51.2021.08.03.03.20.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Aug 2021 03:20:03 -0700 (PDT) Date: Tue, 3 Aug 2021 11:20:00 +0100 From: Quentin Perret To: Fuad Tabba Cc: maz@kernel.org, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, ardb@kernel.org, qwandor@google.com, dbrazdil@google.com, kernel-team@android.com Subject: Re: [PATCH v3 13/21] KVM: arm64: Expose host stage-2 manipulation helpers Message-ID: References: <20210729132818.4091769-1-qperret@google.com> <20210729132818.4091769-14-qperret@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Monday 02 Aug 2021 at 13:13:20 (+0200), Fuad Tabba wrote: > Hi Quentin, > > On Thu, Jul 29, 2021 at 3:28 PM Quentin Perret wrote: > > > > We will need to manipulate the host stage-2 page-table from outside > > mem_protect.c soon. Introduce two functions allowing this, and make > > them usable to users of mem_protect.h. > > > > Signed-off-by: Quentin Perret > > --- > > arch/arm64/kvm/hyp/include/nvhe/mem_protect.h | 2 ++ > > arch/arm64/kvm/hyp/nvhe/mem_protect.c | 17 ++++++++++++++++- > > 2 files changed, 18 insertions(+), 1 deletion(-) > > > > diff --git a/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h b/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h > > index ae355bfd8c01..47c2a0c51612 100644 > > --- a/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h > > +++ b/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h > > @@ -49,6 +49,8 @@ extern struct host_kvm host_kvm; > > int __pkvm_prot_finalize(void); > > int __pkvm_mark_hyp(phys_addr_t start, phys_addr_t end); > > > > +int host_stage2_idmap_locked(u64 start, u64 end, enum kvm_pgtable_prot prot); > > +int host_stage2_set_owner_locked(u64 start, u64 end, u8 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 70c57d2c3024..a7f6134789e0 100644 > > --- a/arch/arm64/kvm/hyp/nvhe/mem_protect.c > > +++ b/arch/arm64/kvm/hyp/nvhe/mem_protect.c > > @@ -272,6 +272,21 @@ static int host_stage2_adjust_range(u64 addr, struct kvm_mem_range *range) > > return 0; > > } > > > > +int host_stage2_idmap_locked(u64 start, u64 end, enum kvm_pgtable_prot prot) > > +{ > > + hyp_assert_lock_held(&host_kvm.lock); > > + > > + return host_stage2_try(__host_stage2_idmap, start, end, prot); > > +} > > + > > +int host_stage2_set_owner_locked(u64 start, u64 end, u8 owner_id) > > +{ > > + hyp_assert_lock_held(&host_kvm.lock); > > + > > + return host_stage2_try(kvm_pgtable_stage2_set_owner, &host_kvm.pgt, > > + start, end - start, &host_s2_pool, owner_id); > > +} > > This is a potential issue elsewhere as well, but all functions in > kvm_pgtable.h, including kvm_pgtable_stage2_set_owner, specify an > address range via address and size. The two you have introduced here > take a start and an end. I'm not sure if making these two consistent > with the ones in kvm_pgtable.h would be good, or would just complicate > things in other places. Good point, and it looks like specifying these two with start-size parameters would simplify the callers a tiny bit as well, so I'll fold that in v4. Thanks, Quentin