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... 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 33BC4C74A5B for ; Fri, 17 Mar 2023 09:04:49 +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-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-ID:References:In-Reply-To:Subject:Cc:To:From :Date:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=7KZUejyrkbkNcDOZp0PZCClqsJZ5elm2orhn1g17r0U=; b=usdNjNfwcnjGPP07/D0Vsd8Mqg T8LvYqyGy3BqDDXySPRNA/R2V0sVO9Mb+JSaoetHHgIw+3miKGQweo64WuoI5CDnwcEfbU7dXR5kX r3U2KXD1z4K+yggLVvVNr/UWqy6JEZPiOkJULWJWO1jfmat1x/AOwwU4GTFWrHEPqmETl4XCH8EQy 6bGo5U2SpUdYIeUEUHLNMum1MGCX/5sM4mhtGRN73mI+ROQ+KYOlutERXMl7Vf9vfbFJDNj31LjV6 6Tf3bqEcInmvvA2pFnWUSPMZ4mZ2xINryMtPci2RoFi6Q+ZrKcEl5F++UjD12a428KcJ3TOzWlEsM TJq+ntJg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pd60F-001e0l-1c; Fri, 17 Mar 2023 09:03:59 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pd60B-001dyf-15 for linux-arm-kernel@lists.infradead.org; Fri, 17 Mar 2023 09:03:57 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id BAA79B824EE; Fri, 17 Mar 2023 09:03:53 +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 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230317_020355_677328_351ACF70 X-CRM114-Status: GOOD ( 19.79 ) 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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... _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel