From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A244222D5D for ; Thu, 19 Dec 2024 11:23:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734607390; cv=none; b=TB4cv+Mj1Op1RsemqzecVuuaW5ladJ1OlbqsrnYWOVFbcWESEfDeJxZB3YyGZ2TgkzeXoO9zJYSC42zlzNioEgu13GPeoxJc+3B9ojERwdSOuaYrVz10uL9uD5B4k3MZk4GxBZUIOfscTiBofTgrjkPZkjpU1bVwlsAHlcAWPLU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734607390; c=relaxed/simple; bh=4zgfT7Xg+JQmuyr3IdhaXo3BVOo4fRBTlxoKmbMDBiE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=eVHcyW3mctNfKd0zklslfvCVCozgnK00Aag+QGz/EPZrWQezLjGkBSObSHPojP4RS07aMZUU4aOoRlobuLhjAj4YJvx25q8BBe3eUfWENsfWIN9FAULv+434dA742kju5HDh4LPLqH7/kEU03+NYEIJoETi29SrRMiVNy5Vupiw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Tgpc0ilJ; arc=none smtp.client-ip=209.85.218.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Tgpc0ilJ" Received: by mail-ej1-f51.google.com with SMTP id a640c23a62f3a-aa692211331so126786366b.1 for ; Thu, 19 Dec 2024 03:23:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1734607387; x=1735212187; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=MNoCLTk5PLrDllVxHnAKqOI/0xe6p3W8/JGr5L06//I=; b=Tgpc0ilJIfPOzsNSGEMTh57iJLNgOLfHCxOAPzFiVShEFIvKCs05kXDYBz8VeXqrKn vHQxcpOK7ptwb9f6nU+HrOdnH56Tg0MxCFIbzaQec1RYEywmppQnKNg7cZWaSER5qbt0 9Ciek8cv68lP2UDP2Ziet95MVfKHK9vzpd2hDZFwK1t3SXz4jE/L03HhsbLm9jIDOmoJ /FLlg3SVghRRzVFQ22KAgbXhwtssFG577jhuck9zt/CmFluhDRrqvtvj69TlvkU9e6ja xOL7MiyKI0eJ95n0MRKZIOqkgnnuQd3daakuYfJ533aVsiTjcOFbhRuedMseyIcVyrks BKTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734607387; x=1735212187; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=MNoCLTk5PLrDllVxHnAKqOI/0xe6p3W8/JGr5L06//I=; b=rLjj/1lnESvvIyNvaUNufg5IymX12P1nAALFFder3LHZhHODjTsCJZNgfOLzPTlGDy d+dmZ8mjVaguWjIw2+CfSXmPbGdTs8U6aS+aAtTVcOhYKdLEbRpqeU8LJsPIniXdv8ut 2jFRar204R68NJD77C/unlal3glWadqrdbjm3lWh9At3NhUAOgJi10vUY5hdxtpPRcNw 2RclwgZ/xIej3Qpc6G9mgQzCK3XNIjMnVH9C5Pma/uTM+zSkWegAAUtUb+qqlR55xk3O d4bQ5cZUZynbPc5Y8g8OHXl446N/YHXnHh7RwGbNFh5tfx5DnC1MpvDO0LDDOkublvnH FySg== X-Forwarded-Encrypted: i=1; AJvYcCW8fO/zPapc+h4jTqtNCWQF62vJUj9Kgwf3ecOtX5jYSlg8LKjGs+gjrxUPD8dbZUvcpBQUUAd7dtssBes=@vger.kernel.org X-Gm-Message-State: AOJu0YxhSaB9aZwDVUz7QGdpZgld+NgNRo1wP5AwIPIhHA9MF7P7BW0J 8gHVTqcPzdJK0hEzdxRXYJ2M18dPhkZ6nIvqg2gpFIyM/6kcl930wYo8Gdoh9w== X-Gm-Gg: ASbGncsteU+ofFJkKlg0J1CdCbYVpJzsOwpsCsLkew7YQ1Q5b/pbf8/FkFRoBIMEXQK SOXoVrVM+GabUI6F4IiIh3Xx9vLwW2k5H624CG0chCMLc7jx1XE5Iqu2/N+MXM5F3pJW+A8uu9C v4d60lIDboRR+kxfwHrV4MKCLHMa0CPeGfTHgP2QvLMnqgzFHjaEe/YNGVTNc65m49d/CI4GBvL 7vDI6F6r0J5XD2J2OznYrWniwVgza4omvnaAHKK5MdNrCf8NFGJPidI6rv1tOiEURq2ijKq1kTZ 27fqS1oyUpLRiX4= X-Google-Smtp-Source: AGHT+IGBbkrBT1+E3hcflKVgebxmfU7Se8YKjT9HtDdCtUo3a97FGuUSH0zyshOzjTlEgkesB5a4qg== X-Received: by 2002:a17:907:9615:b0:a9a:6c41:50a8 with SMTP id a640c23a62f3a-aac08155183mr234984166b.17.1734607387303; Thu, 19 Dec 2024 03:23:07 -0800 (PST) Received: from google.com (61.134.90.34.bc.googleusercontent.com. [34.90.134.61]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aac0e82f31bsm54976666b.1.2024.12.19.03.23.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2024 03:23:06 -0800 (PST) Date: Thu, 19 Dec 2024 11:23:04 +0000 From: Quentin Perret To: Mostafa Saleh Cc: iommu@lists.linux.dev, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, will@kernel.org, maz@kernel.org, oliver.upton@linux.dev, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, robdclark@gmail.com, joro@8bytes.org, robin.murphy@arm.com, jean-philippe@linaro.org, jgg@ziepe.ca, nicolinc@nvidia.com, vdonnefort@google.com, tabba@google.com, danielmentz@google.com, tzukui@google.com Subject: Re: [RFC PATCH v2 12/58] KVM: arm64: Add __pkvm_{use, unuse}_dma() Message-ID: References: <20241212180423.1578358-1-smostafa@google.com> <20241212180423.1578358-13-smostafa@google.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: <20241212180423.1578358-13-smostafa@google.com> On Thursday 12 Dec 2024 at 18:03:36 (+0000), Mostafa Saleh wrote: > +int __pkvm_host_unuse_dma(phys_addr_t phys_addr, size_t size) > +{ > + int i; > + size_t nr_pages = size >> PAGE_SHIFT; > + > + if (WARN_ON(!PAGE_ALIGNED(phys_addr | size))) > + return -EINVAL; > + > + host_lock_component(); > + if (!range_is_memory(phys_addr, phys_addr + size)) > + goto out_ret; Nit: I think you can do this out of the critical section -- the memblock list is guaranteed stable by construction. > + /* > + * We end up here after the caller successfully unmapped the page from > + * the IOMMU table. Which means that a ref is held, the page is shared > + * in the host s2, there can be no failure. > + */ > + for (i = 0; i < nr_pages; i++) > + __pkvm_host_unuse_dma_page(phys_addr + i * PAGE_SIZE); > + > +out_ret: > + host_unlock_component(); > + return 0; > +} > + > int __pkvm_host_share_guest(u64 pfn, u64 gfn, struct pkvm_hyp_vcpu *vcpu, > enum kvm_pgtable_prot prot) > { > -- > 2.47.0.338.g60cca15819-goog >