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 X-Spam-Level: X-Spam-Status: No, score=-10.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable 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 05C40C433E0 for ; Fri, 12 Mar 2021 11:19:47 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 8D17F64F09 for ; Fri, 12 Mar 2021 11:19:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8D17F64F09 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; 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=+F9+BeF7JEzt1fgNdk7Wxwp8pPC81IZh0qT/AMrwB2Y=; b=lrFXEQ1TMzxv+bR+byvNH6M5q CeK8kDQQL/bObZNr6CZUnWFSjL1mv2EIGOs9tTmwz915zgqePjn9wOtz0r0B5ic0dg/MRcwTMWza+ sLhEevT4l1j/A/IeZXQZC67PlrXA/B7K8b++pmBA5bJtJKfcCMbqrYH1pTi6Tf+dAWqicF4KWxXHR iMjwddT1CCE6zwKMv3Q6R7EGa2Ppw9MOEl1cM6hBC17yaXJev/loY0rIt7V8xNTlF4pkBdx18ADI4 KZk9uca5dKEObNYiBPASqrLIq7jB7VcUvNtH7Dk7GfqgwjzQAKF+Y2+WA4LoPoIeDE2zxiLJyytJ+ Lrs0iK1Zw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lKfoC-00BHAA-K9; Fri, 12 Mar 2021 11:18:20 +0000 Received: from mail.kernel.org ([198.145.29.99]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lKfo5-00BH8q-EZ for linux-arm-kernel@lists.infradead.org; Fri, 12 Mar 2021 11:18:17 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4EB0864F09; Fri, 12 Mar 2021 11:18:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1615547891; bh=4M8/d1QtvNV0W22nnWX2De2qfNZVr8K7C/taDssa2Ss=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=hvgY2ixxwgnMDRs6DayZDJfXR1VG+agFl/c5ryWLihtPZrXyiAITc3Z3DhwjhWKSr QixZ+cIFSfVRHu4wj4bqnJGhgTgoxG5Q0jiA/zFwgGZIAd9kbttdxrXMz+h8rc8DLf MDeAFCrDlcWQpHH4KXEY+shjNwnrtMK00t5f1QibG3Md/5LlHoA1oaIwqvgMnuJWJq uqmgObMsd6Ue5uqdFkktT4ksgWSGaYa+dit8HiN9xOqjsbTRGwR40tCGNsgeSqNRyX XKYql/ytfOCaQm3wnG3kpztMyXHP3ok0WEpLpAMsOBbBGibTvIk9DztGVRjgRRV51L JBSXW6eZQ3BHg== Date: Fri, 12 Mar 2021 11:18:05 +0000 From: Will Deacon To: Quentin Perret Cc: catalin.marinas@arm.com, maz@kernel.org, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, android-kvm@google.com, linux-kernel@vger.kernel.org, kernel-team@android.com, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, tabba@google.com, mark.rutland@arm.com, dbrazdil@google.com, mate.toth-pal@arm.com, seanjc@google.com, robh+dt@kernel.org, ardb@kernel.org Subject: Re: [PATCH v4 28/34] KVM: arm64: Use page-table to track page ownership Message-ID: <20210312111804.GB32208@willie-the-truck> References: <20210310175751.3320106-1-qperret@google.com> <20210310175751.3320106-29-qperret@google.com> <20210311183834.GC31378@willie-the-truck> <20210312093205.GB32016@willie-the-truck> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210312_111814_499095_B5280977 X-CRM114-Status: GOOD ( 28.78 ) 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 Fri, Mar 12, 2021 at 10:13:26AM +0000, Quentin Perret wrote: > On Friday 12 Mar 2021 at 09:32:06 (+0000), Will Deacon wrote: > > I'm not saying to use the VMID directly, just that allocating half of the > > pte feels a bit OTT given that the state of things after this patch series > > is that we're using exactly 1 bit. > > Right, and that was the reason for the PROT_NONE approach in the > previous version, but we agreed it'd be worth generalizing to allow for > future use-cases :-) Yeah, just generalising to 32 bits feels like going too far! I dunno, make it a u8 for now, or define the hypervisor owner ID as 1 and reject owners greater than that? We can easily extend it later. > > > > > @@ -517,28 +543,36 @@ static int stage2_map_walker_try_leaf(u64 addr, u64 end, u32 level, > > > > > if (!kvm_block_mapping_supported(addr, end, phys, level)) > > > > > return -E2BIG; > > > > > > > > > > - new = kvm_init_valid_leaf_pte(phys, data->attr, level); > > > > > - if (kvm_pte_valid(old)) { > > > > > + if (kvm_pte_valid(data->attr)) > > > > > > > > This feels like a bit of a hack to me: the 'attr' field in stage2_map_data > > > > is intended to correspond directly to the lower/upper attributes of the > > > > descriptor as per the architecture, so tagging the valid bit in there is > > > > pretty grotty. However, I can see the significant advantage in being able > > > > to re-use the stage2_map_walker functionality, so about instead of nobbling > > > > attr, you set phys to something invalid instead, e.g.: > > > > > > > > #define KVM_PHYS_SET_OWNER (-1ULL) > > > > > > That'll confuse kvm_block_mapping_supported() and friends I think, at > > > least in their current form. If you _really_ don't like this, maybe we > > > could have an extra 'flags' field in stage2_map_data? > > > > I was pondering this last night and I thought of two ways to do it: > > > > 1. Add a 'bool valid' and then stick the owner and the phys in a union. > > (yes, you'll need to update the block mapping checks to look at the > > valid flag) > > Right, though that is also used for the hyp s1 which doesn't use any of > this ATM. That shouldn't be too bad to change, I'll have a look. Oh, I meant stick the bool in the stage2_map_data so that should be limited to the stage2 path. Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel