From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A4CDDC636CD for ; Tue, 7 Feb 2023 12:23:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=36KSAbTg1CCZYw6UZSiartnOkCi2+lIGQp/4tLO8UWs=; b=ubwaGTFYga0+oA WcyBwOI1epnesCs1idfjNbWxpNDziGAlJW6mrjPtLUGOocW1DfuCjoVrTTY39RhLfEsdVC1xUuMwg 4CZd5xTuNyjrKeZtf0cyLDv3VKAgZsJWfVJjYncEcTkoC6ENkZahkbUFHxXGjwPsGhiWwvVh+YEbd 1te8mriE3mrWUff8FCN25Jq+kTW9DBHwePtlLVo0rWE0JLcxaKTWEU9HVrXw9HoWlV3KYTcN2hIo9 mj5mnYobkC2NvSpxwHNFfpk9aMB0S663fhWwTRqhToNIJ7jdj+eRbgxTPzrSppdb/RUQL9RwVISy7 9B0/STll8BR3qNBWSj6g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pPMzY-00C4mL-1G; Tue, 07 Feb 2023 12:22:32 +0000 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pPMzV-00C4ld-CZ for linux-arm-kernel@lists.infradead.org; Tue, 07 Feb 2023 12:22:30 +0000 Received: by mail-wm1-x32b.google.com with SMTP id bg13-20020a05600c3c8d00b003d9712b29d2so13044571wmb.2 for ; Tue, 07 Feb 2023 04:22:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; 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=U4270KcmhwHObRXxbA6duIgRVQX8U4dTBfwyE3BlZU4=; b=EfsjtE0KTvihG8YYYBF4VD2b0uiK8ecgj2vKvntsbMhJtsIWIWTNFruWmUDCBV0WEc VQDl6xb7KdZkw38DeQ8M+SSeZRo+0J9h2v4/upBxP7QwLEZUKbapi2zytKGiA2RGdOOb 2Klp0gnA6W6S4g7RlzFUd3oppk3kB8e3j8kAeU6hH7nVKCbC5Qxb5BZ7HWp7xFfQtMPu dkZoL+hM6iKa/MQ7Wd2k01p6bwHhf52rITtpKo5YJaHhptjGckMCR13YDVtJb1Dy5Yhu QknexDea1iqpEt0GIbPb0WNuyzkHOaMsjgQy0yPQGKNeF5wANoFWK7IIeeJHnNfXt4GB blDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=U4270KcmhwHObRXxbA6duIgRVQX8U4dTBfwyE3BlZU4=; b=pd91Aq9f/4gA6pcSI9EBX3W4MZssIS/W4SX30SS06Y1HQkRRJCaZu4I1ZVoduy0hbD m/r2WiEeg2WO3z6C8ywAyGQZ5RRNL2feNV25xm+kwLOOuUFXRa54j9KX/rrt16m3MNUV HA/03XyT+MPP+LYavA8borAtjz3B00ok/MHdSjdUSghQttFyhc1W7de7bze3Ttisluv8 +CdXlCntiD56D4hcR93LxNHsc2TLyfe5bkkR343eCvDymduVf/tlwKMMHQrjeJPZAD/u 7uyyMy+BQjTvrOBEcqMoYZxNZk1sqtB9OLPJyySeqWHeWYw1x627huLYTMR9q2YbqwIy IAAw== X-Gm-Message-State: AO0yUKVpRrkn0lEn+MSNWmagkPKMppFQftRUpfIWRjbHM2O7tN9fFmua ddQnfHZkBp3onu/tYJ1MilBJCA== X-Google-Smtp-Source: AK7set/3HW35lwoBV8fAb2W9wTUyuQE7iLTrg1JNxyIV1kCvHLvpXKVcMLTI0ZrBnoT7/ByKLVuOnQ== X-Received: by 2002:a05:600c:3b88:b0:3df:f3ce:be48 with SMTP id n8-20020a05600c3b8800b003dff3cebe48mr113836wms.7.1675772545732; Tue, 07 Feb 2023 04:22:25 -0800 (PST) Received: from google.com (44.232.78.34.bc.googleusercontent.com. [34.78.232.44]) by smtp.gmail.com with ESMTPSA id p12-20020a5d48cc000000b00241fab5a296sm11013595wrs.40.2023.02.07.04.22.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 04:22:25 -0800 (PST) Date: Tue, 7 Feb 2023 12:22:13 +0000 From: Mostafa Saleh To: Jean-Philippe Brucker Cc: maz@kernel.org, catalin.marinas@arm.com, will@kernel.org, joro@8bytes.org, robin.murphy@arm.com, james.morse@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, yuzenghui@huawei.com, dbrazdil@google.com, ryan.roberts@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, iommu@lists.linux.dev Subject: Re: [RFC PATCH 09/45] KVM: arm64: pkvm: Add pkvm_create_hyp_device_mapping() Message-ID: References: <20230201125328.2186498-1-jean-philippe@linaro.org> <20230201125328.2186498-10-jean-philippe@linaro.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230201125328.2186498-10-jean-philippe@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230207_042229_446665_C532DAA4 X-CRM114-Status: GOOD ( 22.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Jean, On Wed, Feb 01, 2023 at 12:52:53PM +0000, Jean-Philippe Brucker wrote: > Add a function to map a MMIO region in the hypervisor and remove it from > the host. Hypervisor device drivers use this to reserve their regions > during setup. > > Signed-off-by: Jean-Philippe Brucker > --- > arch/arm64/kvm/hyp/include/nvhe/mm.h | 1 + > arch/arm64/kvm/hyp/nvhe/setup.c | 17 +++++++++++++++++ > 2 files changed, 18 insertions(+) > > diff --git a/arch/arm64/kvm/hyp/include/nvhe/mm.h b/arch/arm64/kvm/hyp/include/nvhe/mm.h > index d5ec972b5c1e..84db840f2057 100644 > --- a/arch/arm64/kvm/hyp/include/nvhe/mm.h > +++ b/arch/arm64/kvm/hyp/include/nvhe/mm.h > @@ -27,5 +27,6 @@ int __pkvm_create_private_mapping(phys_addr_t phys, size_t size, > enum kvm_pgtable_prot prot, > unsigned long *haddr); > int pkvm_alloc_private_va_range(size_t size, unsigned long *haddr); > +int pkvm_create_hyp_device_mapping(u64 base, u64 size, void __iomem *haddr); > > #endif /* __KVM_HYP_MM_H */ > diff --git a/arch/arm64/kvm/hyp/nvhe/setup.c b/arch/arm64/kvm/hyp/nvhe/setup.c > index 629e74c46b35..de7d60c3c20b 100644 > --- a/arch/arm64/kvm/hyp/nvhe/setup.c > +++ b/arch/arm64/kvm/hyp/nvhe/setup.c > @@ -259,6 +259,23 @@ static int fix_host_ownership(void) > return 0; > } > > +/* Map the MMIO region into the hypervisor and remove it from host */ > +int pkvm_create_hyp_device_mapping(u64 base, u64 size, void __iomem *haddr) > +{ > + int ret; > + > + ret = __pkvm_create_private_mapping(base, size, PAGE_HYP_DEVICE, haddr); > + if (ret) > + return ret; > + > + /* lock not needed during setup */ > + ret = host_stage2_set_owner_locked(base, size, PKVM_ID_HYP); > + if (ret) > + return ret; > + Do we need to unmap in case of errors from host_stage2_set_owner_locked? > + return ret; > +} > + > static int fix_hyp_pgtable_refcnt(void) > { > struct kvm_pgtable_walker walker = { > -- > 2.39.0 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel