Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp494022lqb; Wed, 29 May 2024 01:43:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVrr9Uti7BHtjVmnSAnPQpSZnGoiD3nbyZpihR9eweneUV+hL7J7hezbKiDrqSj0hFP8/I3tFNBh1iY/U8A0nmj/syJZSDeHZAoVXq+LQ== X-Google-Smtp-Source: AGHT+IGRElrmFGa8qvyaOeS+iC2mkpaNNaG/1Y5p/t+QwIBIUMivKf71Xm+t+YN2NFC6JQOoNIv+ X-Received: by 2002:a50:cb8d:0:b0:579:c8f7:567f with SMTP id 4fb4d7f45d1cf-579c8f75730mr8561154a12.42.1716972219327; Wed, 29 May 2024 01:43:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716972219; cv=pass; d=google.com; s=arc-20160816; b=LP0BZcrJtVHO6/N+CZsMwg8wIH7MGhk545UX54JKFRW4V1FhclmiZYfizDep14be2l 3TDCo5ohqGkaG1T/ym7CTa9LQt3q9XKPToPmytCetALCJZl+ZXAFryfHkSI9Lg7ARVMb XycPCjGNIF8pMaC4iLtdrXwWEnW9aho2fPzvNWP1gukoSdq25SYMmeM6C9cnZ6zA9PMe qW8Xx/rZm9hdYMPlvmgmzhOzKVPIOpfSBjVTTrXF6vs+Rzc/pYzg3K0WV4tpHpUIa3eJ Ae0IlNIXQzSc0iuvowSfQ5IxUnhLmZ58hmsOvjSXK9t16om51PyJLhhhd9SKBkjPx5KU k81A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=21X9UlHX+fPsujEUXeJTIFpAAcXsNqjBqq3kXV2CRnA=; fh=cDzgObpEUqFkc2dvEIaGTqwg1K/iGGXMvzMpzGqsyUk=; b=Dh2AIgwPOjZCsaFOoT1VkjIyeDONfQwqHhG+F5/1eXC0rMRpK7+ZBrP9I23aLkTSiP 5NlXharTHdu7KKPE+gxSJ//OTwtKINjL6ScvBePW3Ri8lv7Z3cqTyc1Y4DU5Abr1gpiN aSUvplyclCZA6HWwnHH4YY9vcXo0PdGsjhBCeQxp91hRXpUY9VwBaxh1UfLw95N3dF8D Hi73h90nZk1VffGboGgdTv5KpO48Q0O0JNRXxDfsp61V89013V0457D7nJ9b/Ti+Od5S IXyqu85UdL45K/C1crRkdLF8k26ssBPIkhRv7AMs6kzPpJgeTXc5juuujYK8Z9P5DLze QGUQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=cvMm7zbn; arc=pass (i=1 spf=pass spfdomain=mediatek.com dkim=pass dkdomain=mediatek.com dmarc=pass fromdomain=mediatek.com); spf=pass (google.com: domain of linux-kernel+bounces-193766-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193766-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5785233060fsi6053968a12.98.2024.05.29.01.43.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 01:43:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-193766-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=cvMm7zbn; arc=pass (i=1 spf=pass spfdomain=mediatek.com dkim=pass dkdomain=mediatek.com dmarc=pass fromdomain=mediatek.com); spf=pass (google.com: domain of linux-kernel+bounces-193766-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193766-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id B8D111F28D08 for ; Wed, 29 May 2024 08:43:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DF2CF16C440; Wed, 29 May 2024 08:42:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="cvMm7zbn" Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) (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 64B981667DB; Wed, 29 May 2024 08:42:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.61.82.184 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716972173; cv=none; b=JKskIn9SCCmaRSWWbIcjpC5j7AttqId+THbZ5OeeGiet6RSkSXrdkclYwK60yVwoZFUjhoq+sMK/PPTJ3eOxZcZKBw/TY5SJdyiqt55lhIlK9xagpJHoy4bb1hwLb0OKi/bDi14C0WZ5TNtZTdLO3V6IljSpIwWylDuwjeeO/24= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716972173; c=relaxed/simple; bh=jg1Jp8N6Tl94tpp4AHgxx8UuAEyR6RsgqHUvtxEbRg4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=f80zroNyVehbrN95WqXyLaW+pkJCgjEbsEvlUUUKRlGFla6q0HsLKq8xGmJxe/i7ymNiKjbphc7e6FyGZKYKZnXoWdqRuvlg5BJhomRNPliGMY/ka1pEYF6rVNzwCGUwzMqIT6EQTRet6akJn0t6RTWnV5coFEOBFtpbYMZdL5A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=cvMm7zbn; arc=none smtp.client-ip=210.61.82.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com X-UUID: 6aa850061d9711efbfff99f2466cf0b4-20240529 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=21X9UlHX+fPsujEUXeJTIFpAAcXsNqjBqq3kXV2CRnA=; b=cvMm7zbnjmcejupBjGP43TAJUHMcbPQil5pTdl/LWHkpnUxbQCbS6kP30NGioywxrm8eAfE4FcOmBNnlWyjPrjnIXPnC2nZWp9jFNrGEHXlIxFmPkniAs4itn/w5a11pW0bFdWyw7eRzIh3mGesMglX8p12r+3S1XwwBhVaGZ18=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.39,REQID:f297f757-15e9-444c-9530-18ee3cb1778b,IP:0,U RL:0,TC:0,Content:-25,EDM:-30,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACT ION:release,TS:-55 X-CID-META: VersionHash:393d96e,CLOUDID:231cf587-8d4f-477b-89d2-1e3bdbef96d1,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:2,IP:nil,UR L:11|1,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES: 1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_ULN,TF_CID_SPAM_SNR X-UUID: 6aa850061d9711efbfff99f2466cf0b4-20240529 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 16314301; Wed, 29 May 2024 16:42:43 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by MTKMBS14N1.mediatek.inc (172.21.101.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Wed, 29 May 2024 16:42:41 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Wed, 29 May 2024 16:42:41 +0800 From: Liju-clr Chen To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jonathan Corbet , "Catalin Marinas" , Will Deacon , "Steven Rostedt" , Masami Hiramatsu , Mathieu Desnoyers , Richard Cochran , Matthias Brugger , AngeloGioacchino Del Regno , Liju-clr Chen , Yingshiuan Pan , Ze-yu Wang CC: , , , , , , , David Bradil , Trilok Soni , Shawn Hsiao , PeiLun Suei , Chi-shen Yeh , Kevenny Hsieh , Liju-clr Chen Subject: [PATCH v11 12/21] virt: geniezone: Add memory region purpose for hypervisor Date: Wed, 29 May 2024 16:42:30 +0800 Message-ID: <20240529084239.11478-13-liju-clr.chen@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20240529084239.11478-1-liju-clr.chen@mediatek.com> References: <20240529084239.11478-1-liju-clr.chen@mediatek.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 X-TM-AS-Product-Ver: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-AS-Result: No-10--3.824400-8.000000 X-TMASE-MatchedRID: Bo0EIJTmAYww2a0RxGqSGyVypP66BP0QNNuh+5zmS68Cgjr7b0ytGZas fA8Y/RCF8B1Eq8wDKAEQzM3Grt8RghUBkTmMruyZhK8o4aoss8pKPIx+MJF9o99RlPzeVuQQpc2 xgJAY6Lr/EdEp4HtkngHGJy9aPQkxszLAY5oHhBDd+fuf9kcapoLFgHaE9Li9myiLZetSf8mfop 0ytGwvXiq2rl3dzGQ19+9ZqEp9FThLnv07eOR+FADAYkZXyNcIbd6xgOLRhrpgBPiGQ8jlcOwYV dkT7SkWWPeZyqTFSSOvAR+R87rVR56r4mzrm8D9E37uz0EXFfMXRoPmWO3jekxwdkPqCq7vDEyN +J8hd+jCS9WgDXVPCp6oP1a0mRIj X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--3.824400-8.000000 X-TMASE-Version: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-SNTS-SMTP: 4A0668940C8103318647D27F0CF410D4B8048F4C12FE9DF4285CF724B447C25D2000:8 X-MTK: N From: Yi-De Wu 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 | 10 ++++++++++ drivers/virt/geniezone/gzvm_vm.c | 7 +++++++ include/linux/soc/mediatek/gzvm_drv.h | 3 +++ 4 files changed, 22 insertions(+) diff --git a/arch/arm64/geniezone/gzvm_arch_common.h b/arch/arm64/geniezone/gzvm_arch_common.h index d4b49a4b283a..dabd11438e94 100644 --- a/arch/arm64/geniezone/gzvm_arch_common.h +++ b/arch/arm64/geniezone/gzvm_arch_common.h @@ -22,6 +22,7 @@ enum { GZVM_FUNC_PROBE = 12, GZVM_FUNC_ENABLE_CAP = 13, GZVM_FUNC_INFORM_EXIT = 14, + GZVM_FUNC_MEMREGION_PURPOSE = 15, NR_GZVM_FUNC, }; @@ -44,6 +45,7 @@ enum { #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_INFORM_EXIT GZVM_HCALL_ID(GZVM_FUNC_INFORM_EXIT) +#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 8690def2419f..c20a2ded2a4f 100644 --- a/arch/arm64/geniezone/vm.c +++ b/arch/arm64/geniezone/vm.c @@ -144,6 +144,16 @@ int gzvm_arch_destroy_vm(u16 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 6d666974fbf7..91f08dd72c63 100644 --- a/drivers/virt/geniezone/gzvm_vm.c +++ b/drivers/virt/geniezone/gzvm_vm.c @@ -105,6 +105,7 @@ static int gzvm_vm_ioctl_set_memory_region(struct gzvm *gzvm, struct gzvm_userspace_memory_region *mem) { + int ret; struct vm_area_struct *vma; struct gzvm_memslot *memslot; unsigned long size; @@ -128,6 +129,12 @@ gzvm_vm_ioctl_set_memory_region(struct gzvm *gzvm, memslot->vma = vma; memslot->flags = mem->flags; memslot->slot_id = mem->slot; + + ret = gzvm_arch_memregion_purpose(gzvm, mem); + if (ret) { + pr_err("Failed to config memory region for the specified purpose\n"); + return -EFAULT; + } return register_memslot_addr_range(gzvm, memslot); } diff --git a/include/linux/soc/mediatek/gzvm_drv.h b/include/linux/soc/mediatek/gzvm_drv.h index 096e72b76e5c..3c2b5d9071c6 100644 --- a/include/linux/soc/mediatek/gzvm_drv.h +++ b/include/linux/soc/mediatek/gzvm_drv.h @@ -179,6 +179,9 @@ void gzvm_drv_irqfd_exit(void); int gzvm_vm_irqfd_init(struct gzvm *gzvm); void gzvm_vm_irqfd_release(struct gzvm *gzvm); +int gzvm_arch_memregion_purpose(struct gzvm *gzvm, + struct gzvm_userspace_memory_region *mem); + int gzvm_init_ioeventfd(struct gzvm *gzvm); int gzvm_ioeventfd(struct gzvm *gzvm, struct gzvm_ioeventfd *args); bool gzvm_ioevent_write(struct gzvm_vcpu *vcpu, __u64 addr, int len, -- 2.18.0