Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4798013rdb; Tue, 12 Dec 2023 09:32:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IEjzciEUd8dQpeVHgBaF4VtlWTuc2jc5iWKF7EziDKO9LDgS25Je9Jy2+vPJ5Hzlai3iyWv X-Received: by 2002:a17:902:db01:b0:1d3:44ad:215a with SMTP id m1-20020a170902db0100b001d344ad215amr614342plx.85.1702402341858; Tue, 12 Dec 2023 09:32:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702402341; cv=none; d=google.com; s=arc-20160816; b=VKzrIn7tLwFD0dZCZ3eDDLNjmZEkl2S/tg9emmGW85gieLRhFt9M5Bj3mJ9ZSKZUgg EgZnyMF1wLpO11jUK6RwovvzxQZp20p9833EZFc9z19AUVlXxbhz7P3SdQeWxCGqDchw kxjGUM9a12tJ2SSn7xrjwqGj1N+FUyX0RSts2IXgLHX0w1a6axCDJ+vUHBYbHBHUogmg B2vxgbz2yAF2QLlI9M4htwT/ffpKi9EJ4IOXsIX6/6JoNKGT8sHooEMCX1c3KQDA3Z8S MiTtzQ6pmmYmy9tFXFtu1ZcNeSURDuA1alowNNrpjxjZ+MgqFoyNWlFy84brDVfBcqnr 4CIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=kOPYTeT/Bd53F5cs8I1ekw4aizD+hP16cgFcdY+O5Mo=; fh=WhxzlHWRn4+iJ51THhMoC5frG09B2KaLaG2tLbMOG2g=; b=PB+Xn3wB+X52kUX1CbXbqEJH4ZR93hRBLBny5dSEPXndhVLnEBR4Ph3kSMukoVAQF6 lCQd2hv0NyXU6cZKfBjDo8G1ML1n3SwANewOSqrTubqQW0PtB55S9AqZMKuF8hOgqVnj AZAVJFkouUa3mJu2xVVjCTFZSKOTzCZImRf4K4ND1wS7wfafZleffhZOrjWko9NByJR9 wPodxYArhaI0qKNi0E9LMgEOU9+HqdV40MzmSrRWMnbZnzbWNp23f5vAKv+6crAx1WIc pfN6/pAz/WKDuWRmu8Hh+lQ2lLSPFVbu1rN2vxOwr11igUCP0yuVCwXB/6ewW+uPfKeE +nvA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id k4-20020a170902c40400b001d2ea8c47e3si7904367plk.628.2023.12.12.09.32.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 09:32:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id A1A59801B33C; Tue, 12 Dec 2023 09:32:19 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376558AbjLLRcC (ORCPT + 99 others); Tue, 12 Dec 2023 12:32:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232933AbjLLRcA (ORCPT ); Tue, 12 Dec 2023 12:32:00 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31B818E for ; Tue, 12 Dec 2023 09:32:07 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95A85C433C7; Tue, 12 Dec 2023 17:32:01 +0000 (UTC) Date: Tue, 12 Dec 2023 17:31:59 +0000 From: Catalin Marinas To: ankita@nvidia.com Cc: jgg@nvidia.com, maz@kernel.org, oliver.upton@linux.dev, suzuki.poulose@arm.com, yuzenghui@huawei.com, will@kernel.org, alex.williamson@redhat.com, kevin.tian@intel.com, yi.l.liu@intel.com, ardb@kernel.org, akpm@linux-foundation.org, gshan@redhat.com, linux-mm@kvack.org, lpieralisi@kernel.org, aniketa@nvidia.com, cjia@nvidia.com, kwankhede@nvidia.com, targupta@nvidia.com, vsethi@nvidia.com, acurrid@nvidia.com, apopple@nvidia.com, jhubbard@nvidia.com, danw@nvidia.com, mochs@nvidia.com, kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v3 1/2] kvm: arm64: introduce new flag for non-cacheable IO memory Message-ID: References: <20231208164709.23101-1-ankita@nvidia.com> <20231208164709.23101-2-ankita@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231208164709.23101-2-ankita@nvidia.com> X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Tue, 12 Dec 2023 09:32:19 -0800 (PST) On Fri, Dec 08, 2023 at 10:17:08PM +0530, ankita@nvidia.com wrote: > diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c > index c651df904fe3..d4835d553c61 100644 > --- a/arch/arm64/kvm/hyp/pgtable.c > +++ b/arch/arm64/kvm/hyp/pgtable.c > @@ -718,10 +718,17 @@ static int stage2_set_prot_attr(struct kvm_pgtable *pgt, enum kvm_pgtable_prot p > kvm_pte_t *ptep) > { > bool device = prot & KVM_PGTABLE_PROT_DEVICE; > - kvm_pte_t attr = device ? KVM_S2_MEMATTR(pgt, DEVICE_nGnRE) : > - KVM_S2_MEMATTR(pgt, NORMAL); > + bool normal_nc = prot & KVM_PGTABLE_PROT_NORMAL_NC; > + kvm_pte_t attr; > u32 sh = KVM_PTE_LEAF_ATTR_LO_S2_SH_IS; > > + if (device) > + attr = KVM_S2_MEMATTR(pgt, DEVICE_nGnRE); > + else if (normal_nc) > + attr = KVM_S2_MEMATTR(pgt, NORMAL_NC); > + else > + attr = KVM_S2_MEMATTR(pgt, NORMAL); As Will said, maybe a WARN_ON_ONCE(device && normal_nc). It would fall back to device which I think is fine. Reviewed-by: Catalin Marinas