Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5196627rwd; Mon, 12 Jun 2023 01:09:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6rjrBmTtEDyhVPCbHt97KrQ9wmu9bQHGv1I10ucl8YaWFb8o82EBQZlCKp/uW9u/zA2UeT X-Received: by 2002:a17:907:2da5:b0:96f:4225:9009 with SMTP id gt37-20020a1709072da500b0096f42259009mr9505240ejc.0.1686557366013; Mon, 12 Jun 2023 01:09:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686557366; cv=none; d=google.com; s=arc-20160816; b=iywM3+7dLeHTXKi9Buf03Q3kYoyVXNGDA360rKnsqbIl+WnD40NWLvd8dn/4UhH0qw 9rPzG8pufjaQCR6z5X64oKhqruclHvfqaMCKCeAd91Jhit8S4HaCiGpgKm/Mc6+yBlql e+Yfd5gdGP4gPeG1hIFNEDK/z5owklF8j4wGuzIczZsUH7AZsE0FgYdxZcREWsZrL4aE A4JMYGnyXerucYaEl7EhAPIIOkoL489rLVpJ4tYZhHUUm4mA53Z5Orno7TQ8mHxFTC3X Tj79dh2u8DKdK6jNNK23QUDbze3fKCO/IajjYONdR9Xd6SqVraocIyTUC0DshIN2kyR2 dCQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=kyEYGpiUXUwEO++brD6pSMhp0UMkXw14uE+6J5CxDfo=; b=NRMHxV7XV/hwEWUzQ++FqBZKpgox8dBSt0OfGIt+Qx5fq4fKsA+j8JwzGfnnp9YSjM HoBqAWe9kVwth9KF/k32G4O7Aa3/ctjcOnWrX5u338HShAW2eQEGWnCCK18+Tq7/iuL9 bNUh2h4uNKRDxxC9v7/vXrHilr4Tb/ZHTctyFcxxDMhWe1NzXyFv6lwT5u4aVVUPPVeg 4bxDYM08Z1JSosi3Vki+2lT693E5Atxjc6gSIPqXSk4V3jB9OvJCpeFY/axW2Fl3kmRc dP+aGPeMMSbfiHmi/uKKYj0X0cxUMeBWZfipZzkfsmANZCn3lkpe+HdnXxaSQCHRcher yW1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="E/iy+iVF"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f13-20020a170906560d00b0096a919994desi4960029ejq.731.2023.06.12.01.09.01; Mon, 12 Jun 2023 01:09:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="E/iy+iVF"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229476AbjFLIDm (ORCPT + 99 others); Mon, 12 Jun 2023 04:03:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230287AbjFLID1 (ORCPT ); Mon, 12 Jun 2023 04:03:27 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF0814225; Mon, 12 Jun 2023 01:01:37 -0700 (PDT) Received: from [IPV6:2001:b07:2ed:14ed:c5f8:7372:f042:90a2] (unknown [IPv6:2001:b07:2ed:14ed:c5f8:7372:f042:90a2]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madras.collabora.co.uk (Postfix) with ESMTPSA id 507D966056AA; Mon, 12 Jun 2023 09:01:34 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1686556895; bh=isC+sRbNV9BUr83pa0sHnpd0Kls5ayI8Qkm4CZ8u4Pw=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=E/iy+iVFGvPWHCoINGvQF2uRuHCfw5+XDUVGvhCyITBMUFcLi3mSNdsa4neq52Rnq s5OsYHI9ROLaP5Fqlm9tS1ITnFzYSX112HS5iBrTRQLwlVLSt9mVYjUH84lgBKU58m IO6wbSokB33nReRXAv1rjcnEO7CoRirFIOlQm9L0mXg/y8MJ7gwVKG/DRoGHNpTVBr r+zT8qTQg92tLrpzjZmXjAaRitht6sdvm6oZj/1UfSBsp8uJDl3NWVUgIhb0IAkSEi ouQpgNztTBgr98V1R89cjyPdgvKQA62PS1zKs+ygquKeCuM+5/VWouWOIKYrT1/igV HOcUaBRrfpEUw== Message-ID: <92b1c382-7428-5428-c8b1-e252ad3f81c1@collabora.com> Date: Mon, 12 Jun 2023 10:01:31 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.2 Subject: Re: [PATCH v4 7/9] virt: geniezone: Add memory region support To: Yi-De Wu , Yingshiuan Pan , Ze-Yu Wang , Jonathan Corbet , Catalin Marinas , Will Deacon , Arnd Bergmann , Matthias Brugger Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arch@vger.kernel.org, linux-mediatek@lists.infradead.org, Krzysztof Kozlowski , Rob Herring , Conor Dooley , Conor Dooley , Trilok Soni , David Bradil , Jade Shih , Miles Chen , Ivan Tseng , My Chuang , Shawn Hsiao , PeiLun Suei , Liju Chen , Willix Yeh References: <20230609085214.31071-1-yi-de.wu@mediatek.com> <20230609085214.31071-8-yi-de.wu@mediatek.com> Content-Language: en-US From: AngeloGioacchino Del Regno In-Reply-To: <20230609085214.31071-8-yi-de.wu@mediatek.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Il 09/06/23 10:52, Yi-De Wu ha scritto: > From: "Jerry Wang" > > Hypervisor might need to know the precise purpose of each memory > region, so that it can provide specific memory protection. We add a new > uapi to pass address and size of a memory region and its purpose. > > Signed-off-by: Jerry Wang > Signed-off-by: Liju-clr Chen > Signed-off-by: Yi-De Wu > --- > arch/arm64/geniezone/gzvm_arch_common.h | 2 ++ > arch/arm64/geniezone/vm.c | 9 +++++++++ > drivers/virt/geniezone/gzvm_vm.c | 1 + > include/linux/gzvm_drv.h | 2 ++ > 4 files changed, 14 insertions(+) > > diff --git a/arch/arm64/geniezone/gzvm_arch_common.h b/arch/arm64/geniezone/gzvm_arch_common.h > index 5affa28b935a..5cfeb4df84c5 100644 > --- a/arch/arm64/geniezone/gzvm_arch_common.h > +++ b/arch/arm64/geniezone/gzvm_arch_common.h > @@ -23,6 +23,7 @@ enum { > GZVM_FUNC_CREATE_DEVICE, > GZVM_FUNC_PROBE, > GZVM_FUNC_ENABLE_CAP, > + GZVM_FUNC_MEMREGION_PURPOSE, > NR_GZVM_FUNC > }; > > @@ -46,6 +47,7 @@ enum { > #define MT_HVC_GZVM_CREATE_DEVICE GZVM_HCALL_ID(GZVM_FUNC_CREATE_DEVICE) > #define MT_HVC_GZVM_PROBE GZVM_HCALL_ID(GZVM_FUNC_PROBE) > #define MT_HVC_GZVM_ENABLE_CAP GZVM_HCALL_ID(GZVM_FUNC_ENABLE_CAP) > +#define MT_HVC_GZVM_MEMREGION_PURPOSE GZVM_HCALL_ID(GZVM_FUNC_MEMREGION_PURPOSE) > #define GIC_V3_NR_LRS 16 > > /** > diff --git a/arch/arm64/geniezone/vm.c b/arch/arm64/geniezone/vm.c > index 9f1f14f71b99..e19a66d6a75d 100644 > --- a/arch/arm64/geniezone/vm.c > +++ b/arch/arm64/geniezone/vm.c > @@ -97,6 +97,15 @@ int gzvm_arch_destroy_vm(gzvm_id_t vm_id) > 0, 0, &res); > } > > +int gzvm_arch_memregion_purpose(struct gzvm *gzvm, struct gzvm_userspace_memory_region *mem) > +{ > + struct arm_smccc_res res; > + > + return gzvm_hypcall_wrapper(MT_HVC_GZVM_MEMREGION_PURPOSE, gzvm->vm_id, > + mem->guest_phys_addr, mem->memory_size, > + mem->flags, 0, 0, 0, &res); > +} > + > static int gzvm_vm_arch_enable_cap(struct gzvm *gzvm, struct gzvm_enable_cap *cap, > struct arm_smccc_res *res) > { > diff --git a/drivers/virt/geniezone/gzvm_vm.c b/drivers/virt/geniezone/gzvm_vm.c > index ba5412acfa7d..3b1cb715ef34 100644 > --- a/drivers/virt/geniezone/gzvm_vm.c > +++ b/drivers/virt/geniezone/gzvm_vm.c > @@ -248,6 +248,7 @@ gzvm_vm_ioctl_set_memory_region(struct gzvm *gzvm, > memslot->vma = vma; > memslot->flags = mem->flags; > memslot->slot_id = mem->slot; > + gzvm_arch_memregion_purpose(gzvm, mem); ret = gzvm_arch_memregion_purpose(...) if (ret) ...... > return register_memslot_addr_range(gzvm, memslot); > } > Regards, Angelo