From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC5BF810 for ; Fri, 17 Mar 2023 09:03:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61E38C433D2; Fri, 17 Mar 2023 09:03:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679043832; bh=RrbCxRQbeYh+QHF+SQ74FvWDUfJeosjdXICD/8hIBR0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=LkYEb5vLxw9Pnphh2sN+xstLaO1E8fOa8cuAwYfKL+3NIAbTObJvfmjcAmjQxqsLv CpvtLKj8vbYdaViupwyXxgujt12LuBAPg5UqqBCDENNXHSy39O1FUnYM+OLdAzckNm dL1a/HcC1vCJMyVbsfN3z++Kq23lYYBA/pR2M3DYLYD7O7Sl9T7YF0tkODYBkzj3N1 1Opcm/BJ6MIvr7POaOJkskIrG3uo7r0W9kCN9PQ/o7kvOYvORZh/ow5aiFWGhvh5UW /14GSRz/beCTNJqYdPSe5m6GCrz7lERRSVF8HdtSpfEIdD/w5azEMBJfQC/7XW4nOh szugRJkAY8v3A== Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pd606-000tA9-51; Fri, 17 Mar 2023 09:03:50 +0000 Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Fri, 17 Mar 2023 09:03:50 +0000 From: Marc Zyngier To: Oliver Upton 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 In-Reply-To: References: <20230316174546.3777507-1-maz@kernel.org> <20230316174546.3777507-2-maz@kernel.org> User-Agent: Roundcube Webmail/1.4.13 Message-ID: <760caa64691576b728c224bbbfdd18a4@kernel.org> X-Sender: maz@kernel.org Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: oliver.upton@linux.dev, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, ardb@kernel.org, will@kernel.org, qperret@google.com, seanjc@google.com, dmatlack@google.com, stable@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On 2023-03-16 23:42, Oliver Upton wrote: > 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; Sure, LGTM. Thanks, M. -- Jazz is not dead. It just smells funny...