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 14DADC74A5B for ; Thu, 16 Mar 2023 23:43:27 +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=Cpo09OpxUCCjYPqF3rheFXyWktjhUYP9cVD34/UcclM=; b=b5GJMa4q1aPqAR XQhYDxxA7QgeUGSGJ0MWvchjUsvnsqS27s6Anbv8yBvyKlwtmy2P0EtHC5efBJS3LPoBi8ahEv7rx oLS9r7S1coLa/IlOI/mrQmzYFnlF+PPhtf+0eebJcvK+xvq/nfgicVkw+JpFmXYykAOvGQ68Absya fUMOwh7UHZVDmrbFbSeikLYgtUqtYtTwPZIURXhWinXSBgj1YAhni7xhwQrOkmhJ5IZxAD7W0vfHt w0xaj9rHnGwJxNp4OTRuQvyUbxukyXtLnJ7WJuIoNWhYUNsE6D1FVaKM5DAmWTFO6MEi6gXLsogM3 P+uElYqLB3v9hpcw/aFg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pcxEo-000LLY-1z; Thu, 16 Mar 2023 23:42:26 +0000 Received: from out-50.mta1.migadu.com ([95.215.58.50]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pcxEk-000LKr-2E for linux-arm-kernel@lists.infradead.org; Thu, 16 Mar 2023 23:42:24 +0000 Date: Thu, 16 Mar 2023 23:42:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1679010137; 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=Z9wFXHFTqY0qDRcH43pszZPbHt+9ze46oN5dD5scERM=; b=LtNgIIiFchLoDQZMYIjfVErlc53+gEFMCv31zVbKG+w/WX/9cNgUJtNhJsaE+oGs4zhs9Y Xmejd3PTagnQcaBzhRVlOhhT9fNC5mNMCSe6dDDiK5yOIT3LggZ4EJY7B3QDQzi5qpwu0c oTpCCSGaN7OezLzUDYGEL35c1tuTeAs= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Marc Zyngier Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, James Morse , Suzuki K Poulose , Zenghui Yu , Ard Biesheuvel , Will Deacon , Quentin Perret , Sean Christopherson , David Matlack , stable@vger.kernel.org Subject: Re: [PATCH v2 1/2] KVM: arm64: Disable interrupts while walking userspace PTs Message-ID: References: <20230316174546.3777507-1-maz@kernel.org> <20230316174546.3777507-2-maz@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230316174546.3777507-2-maz@kernel.org> X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230316_164223_310260_79FF83BC X-CRM114-Status: GOOD ( 16.94 ) 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 Marc, On Thu, Mar 16, 2023 at 05:45:45PM +0000, Marc Zyngier wrote: > We walk the userspace PTs to discover what mapping size was > used there. However, this can race against the userspace tables > being freed, and we end-up in the weeds. > > Thankfully, the mm code is being generous and will IPI us when > doing so. So let's implement our part of the bargain and disable > interrupts around the walk. This ensures that nothing terrible > happens during that time. > > We still need to handle the removal of the page tables before > the walk. For that, allow get_user_mapping_size() to return an > error, and make sure this error can be propagated all the way > to the the exit handler. > > Signed-off-by: Marc Zyngier > Cc: stable@vger.kernel.org Looks good. I've squashed in this meaningless diff to make use of an existing helper. diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index e95593736ae3..3b9d4d24c361 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -691,7 +691,7 @@ static int get_user_mapping_size(struct kvm *kvm, u64 addr) return -EFAULT; /* Oops, the userspace PTs are gone... Replay the fault */ - if (!(pte & PTE_VALID)) + if (!kvm_pte_valid(pte)) return -EAGAIN; return BIT(ARM64_HW_PGTABLE_LEVEL_SHIFT(level)); -- Thanks, Oliver _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel