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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 1F872C433EF for ; Tue, 15 Feb 2022 12:14:17 +0000 (UTC) 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=69mfG6oKphDug+J+p0xnbabb0RiLaNcY7g6qfuiKs+M=; b=n+K2Srq4sJpXUU tr11VhkmsDVnd1xGABFEka7RBpD+FtV9BH6OvPHvFzmp4ZYRwq23BDEqYRjE0pT2HLXRkNHO/Clyj 2W4V3Tyyo1JD++iXdZ0rkSDwAb5g3UJ+mXEoLFdJXjp7Vj2WWrYXp45QHwW7gZRnEG2VetNdJoaGE TXV1VP/j3WyZFClSo8FeYtatcGY11I5VnbE03GRCCvKVnw40vuPNCdM18vsPZ3ZwUDJj/txsgEW++ +w3C14laoMzNrRwGY/ioh1FWpeVY2OsEQXv+cu/PrBjP/5beN1vEJDLPFSNtiA/tNEKbYAzXK0dTW cTSoi8ErM8LV4Q7MqWfg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nJwhn-002f6K-RY; Tue, 15 Feb 2022 12:13:15 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nJwhk-002f5l-KK for linux-arm-kernel@lists.infradead.org; Tue, 15 Feb 2022 12:13:14 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id F39CC1480; Tue, 15 Feb 2022 04:13:10 -0800 (PST) Received: from monolith.localdoman (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4E48A3F718; Tue, 15 Feb 2022 04:13:09 -0800 (PST) Date: Tue, 15 Feb 2022 12:13:23 +0000 From: Alexandru Elisei To: Marc Zyngier Cc: Reiji Watanabe , James Morse , Suzuki K Poulose , Linux ARM , kvmarm@lists.cs.columbia.edu, Will Deacon , Mark Rutland Subject: Re: [RFC PATCH v5 02/38] KVM: arm64: Add lock/unlock memslot user API Message-ID: References: <20211117153842.302159-1-alexandru.elisei@arm.com> <20211117153842.302159-3-alexandru.elisei@arm.com> <87ee4449t9.wl-maz@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <87ee4449t9.wl-maz@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220215_041312_732700_B65F6275 X-CRM114-Status: GOOD ( 22.77 ) 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 Hi, On Tue, Feb 15, 2022 at 12:02:26PM +0000, Marc Zyngier wrote: > On Tue, 15 Feb 2022 11:03:59 +0000, > Alexandru Elisei wrote: > > > > > If a memslot with read/write permission is locked with read only, > > > and then unlocked, can userspace expect stage 2 mapping for the > > > memslot to be updated with read/write ? > > > > Locking a memslot with the read flag would map the memory described by the > > memslot with read permissions at stage 2. When the memslot is unlocked, KVM > > won't touch the stage 2 entries. > > > > When the memslot is unlocked, the pages (as in, struct page) backing the VM > > memory as described by the memslot are unpinned. Then the host's MM subsystem > > can treat the memory like any other pages (make them old, new, unmap them, do > > nothing, etc), and the MMU notifier will take care of updating the stage 2 > > entries as necessary. > > > > I guess I should have been more precise in the description. I'll > > change "causes the memory pinned when locking the memslot specified > > in args[0] to be unpinned" to something that clearly states that the > > memory in the host that backs the memslot is unpinned. > > > > > Can userspace delete the memslot that is locked (without unlocking) ? > > > > No, it cannot. > > > > > If so, userspace can expect the corresponding range to be implicitly > > > unlocked, correct ? > > > > Userspace must explicitely unlock the memslot before deleting it. I want > > userspace to be explicit in its intent. > > Does it get in the way of making this robust wrt userspace being > killed (or terminating without unlock first)? Patch #8 ("KVM: arm64: Unlock memslots after stage 2 tables are freed") teaches kvm_arch_flush_shadow_all() to unlock all locked memslots. Thanks, Alex > > M. > > -- > Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel