Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1629824pxb; Thu, 4 Mar 2021 16:57:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJwcW44aQX5nHk5Mc3e4bfrplukOt4Oh5jxbNq9CCxrPcfceef1Zr4etxjCJ68MZTujsSroN X-Received: by 2002:a05:6602:2d04:: with SMTP id c4mr6047930iow.182.1614905823881; Thu, 04 Mar 2021 16:57:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614905823; cv=none; d=google.com; s=arc-20160816; b=EDUy8j10kDek2u/86ZuFyxYTw80JTHS8sw+ctxjO/gIwNqJGz0alIpqREL0XevdwAj p4jCWxAmxS9NkbX8aEJ9x0sDNuVAZko72i93f5jsLWC7TP9CxT6PM7oEWy9OUIiIT73K STzjdsIFFo2QfJjHw3x9rIPB2u43pcMme5Pi4i0MrKk5xGErtkdRIjulXuio1hngNIpC iqzAvP15+Xvk8RJ4/TOTDQr0M1UqCMsAHYL2lV9sWXbUhEGsWyKvNL9n2IR0v2+D3vK0 2rGf32cbkaEsGp24xoCbUUzROM7Fprxckg7k66X2HJa/DioiinCSbePXsCuJ0TeGq3U3 Poig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=wr1H+F1++VndbfWHfZ9UbxcG9leD3I7V2rZNW/hmJMI=; b=tNsR7fmzvIccu9P+0hB3AI6pPfb0fW3MY5p6woq6RGCGOOznuhR2LQJP+o1Mp383aW uiRvt6f16rmKzu74OTxOIujrpkxrrj7O+IHICgFZcp4ueL1IIvClT/kojU5gg5rf9KMb 7fEouj16NXkyremrjv2kWfxk5TBJU4sDKodiDR3ShYvuzusdKMz1MMLaE5XL5xUPaTQG LTyL0pqWxQcP2rucv3F8YPmflfCt3W1nOkhe9k2i9v4AjfD5dyg3hltGS6wVizVvSUMX P7tOOHd1wKcLxxjDpWe6/EzMCffpkNTgerPd55ObBzM0Wx1WlR9axh85C0XdYqWggVJw hleA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=U4gN8l38; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r9si696557ilb.68.2021.03.04.16.56.50; Thu, 04 Mar 2021 16:57:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=U4gN8l38; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236804AbhCDUEf (ORCPT + 99 others); Thu, 4 Mar 2021 15:04:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:50538 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238058AbhCDUEW (ORCPT ); Thu, 4 Mar 2021 15:04:22 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 352FE64F65; Thu, 4 Mar 2021 20:03:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614888221; bh=U98Si46P9QGICBUxtNMdo2gi+WMxJtL8qV9OiXNLz/g=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=U4gN8l38meTixs38uXpwshwzF5+yHfcTiLAS+WdCPLbxYXrlkbU8LnAcwsYLd8HZn FPczhctWD+SdQO4jwsx5UhtC2onXyL5dt/nrLzLpt4CMLx+RTCAMK++uqcogKDeaPe kqynj+Kb7qnAO7rJjCWuPASACOtt2/Q0m7aQSKKuBf5VvZxBh5Dl0DstNLJtBcMhJl 21a5SCZ83VWuZ/8+eOtKUadSKTbDPzJK7iIrYAKl2hRvY+CAmiz0wj7y+uiGLgn1VQ 62YQbH0sgziQWESXpm/kU5XlICQSWxeFyPeS71LfQ8uf82+/Qaj4Pco/qlfRx5dBff 2NqXoQCem14IA== Date: Thu, 4 Mar 2021 20:03:36 +0000 From: Will Deacon To: Quentin Perret Cc: catalin.marinas@arm.com, maz@kernel.org, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, android-kvm@google.com, linux-kernel@vger.kernel.org, kernel-team@android.com, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, tabba@google.com, mark.rutland@arm.com, dbrazdil@google.com, mate.toth-pal@arm.com, seanjc@google.com, robh+dt@kernel.org Subject: Re: [PATCH v3 27/32] KVM: arm64: Refactor stage2_map_set_prot_attr() Message-ID: <20210304200335.GG21950@willie-the-truck> References: <20210302150002.3685113-1-qperret@google.com> <20210302150002.3685113-28-qperret@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210302150002.3685113-28-qperret@google.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 02, 2021 at 02:59:57PM +0000, Quentin Perret wrote: > In order to ease its re-use in other code paths, refactor > stage2_map_set_prot_attr() to not depend on a stage2_map_data struct. > No functional change intended. > > Signed-off-by: Quentin Perret > --- > arch/arm64/kvm/hyp/pgtable.c | 19 ++++++++----------- > 1 file changed, 8 insertions(+), 11 deletions(-) > > diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c > index 8e7059fcfd40..8aa01a9e2603 100644 > --- a/arch/arm64/kvm/hyp/pgtable.c > +++ b/arch/arm64/kvm/hyp/pgtable.c > @@ -494,8 +494,7 @@ u64 kvm_get_vtcr(u64 mmfr0, u64 mmfr1, u32 phys_shift) > return vtcr; > } > > -static int stage2_map_set_prot_attr(enum kvm_pgtable_prot prot, > - struct stage2_map_data *data) > +static kvm_pte_t stage2_get_prot_attr(enum kvm_pgtable_prot prot) > { > bool device = prot & KVM_PGTABLE_PROT_DEVICE; > kvm_pte_t attr = device ? PAGE_S2_MEMATTR(DEVICE_nGnRE) : > @@ -504,15 +503,15 @@ static int stage2_map_set_prot_attr(enum kvm_pgtable_prot prot, > > if (prot & KVM_PGTABLE_PROT_NONE) { > if (prot != KVM_PGTABLE_PROT_NONE) > - return -EINVAL; > + return 0; Hmm, does the architecture actually say that having all these attributes as 0 is illegal? If not, I think it would be better to keep the int return code and replace the 'data' parameter with a pointer to a kvm_pte_t. Does that work? Will