Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp973632lqs; Wed, 6 Mar 2024 02:24:38 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVOyCjw1SbHcAgkB/Af9LuiUhWpltIVSEmrCp5rtQWINAxD2qyAbAzoX5GK64cRAg4mx6hvNkvcWg2EaYC4GTMThjDyDYL91sjkU4qHUA== X-Google-Smtp-Source: AGHT+IEiFZk+A9DkLB7Q19m3BRF0MtwEle3i3Pgq4lPmHcOTkwGzEK2bJNzxmrA2G09t9uQVsJfB X-Received: by 2002:a05:6808:2a70:b0:3c2:18a7:dd70 with SMTP id fu16-20020a0568082a7000b003c218a7dd70mr1864388oib.55.1709720678501; Wed, 06 Mar 2024 02:24:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709720678; cv=pass; d=google.com; s=arc-20160816; b=CkoFmMHUKqft+Cjqp6te2Mwat4G4/SkLw/Vg47C2ruB9iqonV4Frd2xAWhtfe0mnAc xPczOPKoj4Gr8a1U6Rnxm/sy2y+S21BYwHusZ/wPkj7BRC2hpfiNvgnToZHB7LtXHYM9 eaaanPmnZuYPOkpPr36XGSaCT2bB2pyvrt6SptNXFyzIp4D1LEEd0fOadB32AjzyuNDy rf7JL072VPs2XZQmN0M9e8oZW4gCaMSRXjwDg4HTYDFqUUzpDgR8QhIP6w666VlwOC7k oMmqekJ4GWVaxbQA6rT7Iaq5wm9hK8pLsQn2JG4TQSURPmEReeBlH5XAdfemdTxu78FQ uBKw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:references:in-reply-to:subject:cc:to:from:message-id :date:dkim-signature; bh=C/bzD+MNAqknziU5uI13cNKPCx1HbgrO4Qb2MkFWsVQ=; fh=1eSe69I6ov78NotZhgTWo+4O50awDL2VFdHg/O8MtSs=; b=ShhfE1jvsdW/wJFd+gBf4lr/wHm2v3oP5u2s9hNx9TsTOUVt0mPrjhk7w6bguZt5lI 5Quo9ROpWgIu3lyXLyd1y44Ss2hI/MxXeWdQV0nG+jCBWBVDcRGxHJO/JereYtWxmM2C fraUKX2fni8xFOuwNizsu0bQuNnpkEPGcOuMk9B1tCTnqPANtXv44O3pL24A7h0szRdl 0J2J28vuxblx8q21cTLAxTTXBzYHbqpm7XpGui9BG75LFanEwWAeNMhSRUXRDZbm8EVw MIhdZxPiH8Wa62SMaX2OiqjpFsrn1ab8S+AgfIUhgRowG2vkt2wTIGi8jkJQgx4Kxfsm 68Lg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ueLaVv6j; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-93744-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93744-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id z23-20020a63e557000000b005cdc2cc9a1dsi11957059pgj.699.2024.03.06.02.24.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 02:24:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-93744-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ueLaVv6j; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-93744-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93744-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 29AFD291248 for ; Wed, 6 Mar 2024 10:24:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BF091604BD; Wed, 6 Mar 2024 10:23:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ueLaVv6j" 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 E08255FB97; Wed, 6 Mar 2024 10:23:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709720596; cv=none; b=ELz69MVcypGpdvLzcs3uds/FTtOPR1Httq363dFnBpIuLPKP0LQa2YvT8eofYKZWb3sNu9KN/fCNoeCSm8uc8dIVxdzG1G4svSUSvO+80zC5o6wAqZxWWk4gv2yLvY28ssU+72nYrZPBEBaFmrep9gQsFwVWJVrM8i6xyf3f/dI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709720596; c=relaxed/simple; bh=am4CcjtfeE6MF8q/1whJHcAa25zNF3wSJWqj4Zqk1f4=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=NfLRmwYlbvLEKGzXvIlql8GRVTr9Qagpq0I7KTBMgOjrJ7V+7xst0xUk7z3VU0V5LdGNY7TDzF4YK8RF3GXs1RIzQ2tsVASZo2wSgVdakjElv0YNm8CpSOHve9tvUEeI/KBfDSvIrZ+J04etA/HYHmMa8+HkBlW2oYluYoxDEms= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ueLaVv6j; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7588BC433F1; Wed, 6 Mar 2024 10:23:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709720595; bh=am4CcjtfeE6MF8q/1whJHcAa25zNF3wSJWqj4Zqk1f4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ueLaVv6jN+9gmHWC9HJSXlPkO3zBqGQkVkmk4H6l6wL+0uH1q8fgvL5TKOX4mwQGD xUDvjXWw54+HQOPN1o3ogBucCVvNElTccBebf5nGZAmcljYk7T/TejzPxGBRbtT+mT 1xYqXL7qOWXDATgBWYa3GXnvH20Iw9cKwkc/CT0zIxTEunhrGnoufYA3j4g1D2QyxT 2lHGuVq3jaHDZ7I2k4WDeBIV3mh5n5G6j8ohMt+si0C3vpgjuoBIgv4d35X10Em9/G sX7OvecAGfJlZTF5LqBKU9f9VVfD03pp1R5a4C8+Onm+dVQ3C1Y2PzNaev3QAymtw8 jSSixnvi/xDuA== Received: from ip-185-104-136-29.ptr.icomera.net ([185.104.136.29] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rhoQa-009tYJ-P6; Wed, 06 Mar 2024 10:23:13 +0000 Date: Wed, 06 Mar 2024 10:23:03 +0000 Message-ID: <877cifr75k.wl-maz@kernel.org> From: Marc Zyngier To: Ganapatrao Kulkarni Cc: kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, oliver.upton@linux.dev, darren@os.amperecomputing.com, d.scott.phillips@amperecomputing.com Subject: Re: [RFC PATCH] kvm: nv: Optimize the unmapping of shadow S2-MMU tables. In-Reply-To: <2911d04d-a785-4d60-9a8d-be0d2cec21de@os.amperecomputing.com> References: <20240305054606.13261-1-gankulkarni@os.amperecomputing.com> <86sf150w4t.wl-maz@kernel.org> <6685c3a6-2017-4bc2-ad26-d11949097050@os.amperecomputing.com> <86r0go201z.wl-maz@kernel.org> <2911d04d-a785-4d60-9a8d-be0d2cec21de@os.amperecomputing.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.104.136.29 X-SA-Exim-Rcpt-To: gankulkarni@os.amperecomputing.com, kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, oliver.upton@linux.dev, darren@os.amperecomputing.com, d.scott.phillips@amperecomputing.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Tue, 05 Mar 2024 18:33:27 +0000, Ganapatrao Kulkarni wrote: > > >>>> index 61bdd8798f83..3948681426a0 100644 > >>>> --- a/arch/arm64/kvm/mmu.c > >>>> +++ b/arch/arm64/kvm/mmu.c > >>>> @@ -1695,6 +1695,13 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, > >>>> memcache, > >>>> KVM_PGTABLE_WALK_HANDLE_FAULT | > >>>> KVM_PGTABLE_WALK_SHARED); > >>>> + if ((nested || kvm_is_l1_using_shadow_s2(vcpu)) && !ret) { > >>> > >>> I don't understand this condition. If nested is non-NULL, it's because > >>> we're using a shadow S2. So why the additional condition? > >> > >> No, nested is set only for L2, for L1 it is not. > >> To handle L1 shadow S2 case, I have added this condition. > > > > But there is *no shadow* for L1 at all. The only way to get a shadow > > is to be outside of the EL2(&0) translation regime. El2(&0) itself is > > always backed by the canonical S2. By definition, L1 does not run with > > a S2 it is in control of. No S2, no shadow. > > Shadow, I mean nested_mmus[0] which is used(first consumer of the > S2-MMU array) while L1 booting till it switches to NV2. Please fix your terminology: - if someone is using *any* of the nested_mmus[], then it is an L2. It may come from the same guest binary, but it doesn't change that it has changed translation regime to EL1&0. So by definition, it is an L2. Yes, booting a Linux guest at EL2 involve both an L1 (the EL2 part) *and* an L2 (the EL1 part). - I don't understand 'till it switches to NV2'. Do you mean EL2? > As per my tracing, the nested_mmus[0] is used for L1 after first ERET > trap while L1 is booting and switches back to canonical S2, when it is > moved to NV2. > > In this window, if the pages are unmapped, we need to unmap from the > nested_mmus[0] table. Well, we need to unmap things from all shadow PTs that target the same PA. Index 0 isn't special. Thanks, M. -- Without deviation from the norm, progress is not possible.