Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp260823rdb; Thu, 8 Feb 2024 05:26:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IF10Z5cAhW1dSxspDLIbjAiaisMfMK8Bz6Sx4LK0jfKDMq+1Ald4criXli4ixy3/9DneDzb X-Received: by 2002:ac8:5c83:0:b0:42c:11a1:8fe4 with SMTP id r3-20020ac85c83000000b0042c11a18fe4mr9220880qta.3.1707398787030; Thu, 08 Feb 2024 05:26:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707398787; cv=pass; d=google.com; s=arc-20160816; b=if/BkzDR6J5wNerZUY7C2ZgwDI4aahzV48Qb2VQeevRZ0HnaBXtDIz557YhVVcT2bG 8rA5SXPlryF8uE3ZPMWJU5FonaGEflLpW/QxfwN0r0f6iIceo6tv+10aotpUTbnL2xuY iUWiGgOuLHa2G/DnY3xTP43aahT6B7l1tHqaoCi0LsOXFPRLR1nu8X/5k8dd/URWbUmf LA5OjAoApMcGxLGJc5MurOt4s0HzJdZM2OI2wnzdUc1xf4l7cqYDe/ubxNBmZF3SShuE Ko/ITN3hp06oZa7ShC2A1FJR/04ahYY7rWjqY4m4NZ5GDrI37rmza/e0Ze4Bzb9n0ESD H9yA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:dkim-signature:date; bh=7lGdYQhRSSfN0dykRkya8P4upBClWyVoqhyocRgWZ8E=; fh=saxLGRHHM4HXPkae2eSmtzEsRfDOVRo2WywQJAxKKhg=; b=qO7VB20LmIJ4SBUumb83k1b2MoBmczQ8v5ysJ/QAIMnwO35bYi449SGDy5EcYbA3d+ x5UPKN1yzjhlzGBUT7E/dM9dTPl0Pn09GN6BMuirOJGHC2m0DCvssAaVGspEclFJug9j SQnC3XtAiH35rO78OWUi0KZYQh/4P0z4aXDt435Iuf3knqyYEUFLIPBlxgN2/4+ZKv5Z STEL5v91Fqe5xzUVa9QqUVQPubX/9y82xdrNQ9DE1o2lJsrZvivSpW+0+bAw+4OsNu24 8SMfgVVJZKCgwHfZ3cRTF+Rc0pk87CYInZ88T9Cx6x2SupNgu5tNsXbI0GrjUQQiroLI vusw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Tvi1paTT; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-58152-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58152-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev X-Forwarded-Encrypted: i=2; AJvYcCW2lYa74Lc4nnONj1eeYbTd8zfJivcNcTGynystzciLvOzclcgR3rVqjBnrYz6qPd9jo0nlGh+1OGWnfBwRpElE+XMFKDjAnbLKgH1pBA== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id m6-20020a05622a118600b0042c49ed6a54si1491573qtk.407.2024.02.08.05.26.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 05:26:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58152-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Tvi1paTT; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-58152-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58152-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 9149D1C27942 for ; Thu, 8 Feb 2024 13:25:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5A12E77F0A; Thu, 8 Feb 2024 13:25:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Tvi1paTT" Received: from out-186.mta1.migadu.com (out-186.mta1.migadu.com [95.215.58.186]) (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 8086E76416 for ; Thu, 8 Feb 2024 13:25:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.186 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707398709; cv=none; b=k7sjPqWx8+19O/mdxPY5UmlpqZwC4Sx0Tsc5Bwr9Yhg4PPy5QplXPcu7QEBkZuOBQRdNAw4doNfNZ8MYxmhgrKG6NuulKn/Pe9zwuQxpsS/2ObZGqGRY3IItmVh1ECTVIxqUSji3j328MCnOjNoZ9Qy1oxkZrS4kgBz56/pYa4s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707398709; c=relaxed/simple; bh=zDFq8JwWXF7RSRVmF1+WH9VzX61GkH5t4YUYqcHQ/1Q=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=dzlXhnFKgGGYA3CK0mOUzLnFLG3hNqysT6S/shJbnN+HGX14mIb5Ed17iHrNF/W2qeS6ViG9vvUf2ggfe0KkiG37DdvZGniNv/bMwJQlaVjJxYIMDyf7NZatWMb9OPLbhIpOZFs4xOevZeerZU32N/MSsBORJfxuq189U8OqEpM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=Tvi1paTT; arc=none smtp.client-ip=95.215.58.186 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Date: Thu, 8 Feb 2024 13:24:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1707398704; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=7lGdYQhRSSfN0dykRkya8P4upBClWyVoqhyocRgWZ8E=; b=Tvi1paTTnVNkLWQ4FgCp0lp4590qKyU+DMW/1tenbAuA71NOiHdT0sIcFrHjZZt6+qnifI OGwMwmpbvxHwN3YvP4Eb1gWO9mMevwVbdsnC658WCysAX7SkPT2Rjxj3cs1498TfKkffbf f0PZpFefakmGx/dYyp3yTn8u6VLlMLg= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Catalin Marinas Cc: ankita@nvidia.com, jgg@nvidia.com, maz@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, reinette.chatre@intel.com, surenb@google.com, stefanha@redhat.com, brauner@kernel.org, will@kernel.org, mark.rutland@arm.com, alex.williamson@redhat.com, kevin.tian@intel.com, yi.l.liu@intel.com, ardb@kernel.org, akpm@linux-foundation.org, andreyknvl@gmail.com, wangjinchao@xfusion.com, gshan@redhat.com, ricarkol@google.com, linux-mm@kvack.org, lpieralisi@kernel.org, rananta@google.com, ryan.roberts@arm.com, 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, kvmarm@lists.linux.dev, mochs@nvidia.com, zhiw@nvidia.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v6 1/4] kvm: arm64: introduce new flag for non-cacheable IO memory Message-ID: References: <20240207204652.22954-1-ankita@nvidia.com> <20240207204652.22954-2-ankita@nvidia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT On Thu, Feb 08, 2024 at 01:00:59PM +0000, Catalin Marinas wrote: > On Thu, Feb 08, 2024 at 02:16:49AM +0530, ankita@nvidia.com wrote: > > diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c > > index c651df904fe3..2a893724ee9b 100644 > > --- a/arch/arm64/kvm/hyp/pgtable.c > > +++ b/arch/arm64/kvm/hyp/pgtable.c > > @@ -717,15 +717,28 @@ void kvm_tlb_flush_vmid_range(struct kvm_s2_mmu *mmu, > > static int stage2_set_prot_attr(struct kvm_pgtable *pgt, enum kvm_pgtable_prot prot, > > 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); > > + kvm_pte_t attr; > > u32 sh = KVM_PTE_LEAF_ATTR_LO_S2_SH_IS; > > > > + switch (prot & (KVM_PGTABLE_PROT_DEVICE | > > + KVM_PGTABLE_PROT_NORMAL_NC)) { > > + case 0: > > + attr = KVM_S2_MEMATTR(pgt, NORMAL); > > + break; > > + case KVM_PGTABLE_PROT_DEVICE: > > + if (prot & KVM_PGTABLE_PROT_X) > > + return -EINVAL; > > + attr = KVM_S2_MEMATTR(pgt, DEVICE_nGnRE); > > + break; > > + case KVM_PGTABLE_PROT_NORMAL_NC: > > + attr = KVM_S2_MEMATTR(pgt, NORMAL_NC); > > + break; > > Does it make sense to allow executable here as well? I don't think it's > harmful but not sure there's a use-case for it either. Ah, we should just return EINVAL for that too. I get that the memory attribute itself is not problematic, but since we're only using this thing for MMIO it'd be a rather massive bug in KVM... We reject attempts to do this earlier in user_mem_abort(). If, for some reason, we wanted to do Normal-NC actual memory then we would need to make sure that KVM does the appropriate cache maintenance at map / unmap. -- Thanks, Oliver