Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp251268rdb; Mon, 29 Jan 2024 00:33:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IEZLac0qs+YOWzKC7GZD1oaTisNlYk9gW/VsoMyL5RahWEMXsyNQojukXubVWWUJs9aMJjn X-Received: by 2002:a17:906:c0cb:b0:a2d:60a:2ae9 with SMTP id bn11-20020a170906c0cb00b00a2d060a2ae9mr4024958ejb.52.1706517237933; Mon, 29 Jan 2024 00:33:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706517237; cv=pass; d=google.com; s=arc-20160816; b=xOujqYO/oT/IK8W8vPg0XBggOf87HF1IdrbO/4IZIj/RvOGoOgUtQBtaWaMXWMhxP2 fke3VMilyEHY9p1GeLhTag95Zi+I084CvB1GS4/dzJWnPsoHizISpoBwFPyCeOg+xohr 6sdi5a5Jqw8h5PtSxpBq8r7Mu+QWK8NQ5g3x6k2dXSjpStnpQiq8PfPnMS23wP5YmdsJ OU2qVMtlS2ZEJDR6t6RwF6d50hMENRjR+3P9WTdAz9LTFxNp3OmN8G0Lq8cJkhWxMIKo O+T4/Hco0aIEX6Xg1QidRUCeL6HAozHNtPVQr3iORfHyWCVo6RDvjeYS2KNLdWI5jHVz lecg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=Rnb2WCy9EMT6IEMBrEmGBdkJCYJjdl/KP7SLYCfe+X0=; fh=hH5L/ld0CjFhRvhMbGDzE2BAF3OQ89jjQIXHqlUV0cw=; b=g8HMOE0fELU/vUJJn7rnBcwx6k/pREpt8sdDka/y717tk0UJBP9YNWtr9ULjGB7gUL ZDx3/EG/oOAbYzM8+qukjW906tedu7f4EPmuJJZifEoUtTB34gm7Cb+f8VhRoAYPeHb6 H0joIE+FFBZw/3Rm31jZdlrIG9NwkxtQGW5TTRx7Cr0+nVkUwa1jcji3GvON6aMYlV66 4t9zQlpYOe2QH2q4onJyPc5/VTQZosK+s3kryV30OmfOQt8Lw3Np5gnQQ7zWS8BeJtSw dVYOqt04f8u8wIoWzbJMaHtze261ZmG6xgcUDJvR3AVprtu89WAhuO8EB1i+lDfL2TF3 Ah7A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=q+uO6Chd; 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-42354-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42354-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 l8-20020a170906230800b00a35b8beaf92si730882eja.80.2024.01.29.00.33.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 00:33:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42354-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=q+uO6Chd; 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-42354-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42354-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 828531F23C13 for ; Mon, 29 Jan 2024 08:33:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D4A2054FAC; Mon, 29 Jan 2024 08:33:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="q+uO6Chd" Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) (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 95C695467C; Mon, 29 Jan 2024 08:33:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=60.244.123.138 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706517194; cv=none; b=RGNzxTRqoCH4eAfIo6YAg+HsSnHMdTSHWht2IpMcdao6H3uEsY0eMZ1vDbXRdoJbaALg80cmRPm39hG9jmAqAt41dEkqk7MNMUXv/UbaUZKReo0wx4CncdDUF5kA8tAr5hZthaMmu6XPRWQh3uRVL0F+CuZufhxNcqQGqn0SsHw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706517194; c=relaxed/simple; bh=+0SKvVKgXHrkL1mceNd+9UP0JOnQYE2L8R1xqCmAh5A=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=Fn5Wl+0Cz7GmiZVdb9IhtTfwjEnraHpv43MajmUoQQWKbScm3Igt9HPv9yJyJyS078VpySgXjhadigD6eBhDgaMtKAoacu7LW5nneLMtbi5KTDoApzPgK7o/WHLyPAA73nkKJpg5bk4x5jpBDg8DImy7mGY8za7NsTO3RN9v5tA= 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=q+uO6Chd; arc=none smtp.client-ip=60.244.123.138 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: 06bbe37abe8111ee9e680517dc993faa-20240129 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=Rnb2WCy9EMT6IEMBrEmGBdkJCYJjdl/KP7SLYCfe+X0=; b=q+uO6ChdFIHt4mcwUKq1RGk7omnGayAaYV5/Ew5sWSLCfG3oPlK5TG1KJipxOFDLfD3jRyOKMc0401DMp9nDgsxghEyJUrMBxriHZtVeBpCm36F+ZtDpTH7PPvneMUiuC/DWZ8LmRd6ukfgGMC45/C7qCdhBPIoHzd8JijowfFk=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.36,REQID:fb3040b7-1875-40b6-89c5-99b8c24cb78d,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-25 X-CID-META: VersionHash:6e16cf4,CLOUDID:79185e83-8d4f-477b-89d2-1e3bdbef96d1,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL: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 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_ULS X-UUID: 06bbe37abe8111ee9e680517dc993faa-20240129 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 523109377; Mon, 29 Jan 2024 16:33:06 +0800 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) by mtkmbs11n2.mediatek.inc (172.21.101.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Mon, 29 Jan 2024 16:33:05 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs13n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Mon, 29 Jan 2024 16:33:05 +0800 From: Yi-De Wu To: Yingshiuan Pan , Ze-Yu Wang , Yi-De Wu , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jonathan Corbet , Catalin Marinas , Will Deacon , Richard Cochran , Matthias Brugger , AngeloGioacchino Del Regno CC: , , , , , , David Bradil , Trilok Soni , My Chuang , Shawn Hsiao , PeiLun Suei , Liju Chen , Willix Yeh , Kevenny Hsieh Subject: [PATCH v9 00/21] GenieZone hypervisor drivers Date: Mon, 29 Jan 2024 16:32:41 +0800 Message-ID: <20240129083302.26044-1-yi-de.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 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="UTF-8" Content-Transfer-Encoding: 8bit X-MTK: N This series is based on linux-next, tag: next-20240125. GenieZone hypervisor(gzvm) is a type-1 hypervisor that supports various virtual machine types and provides security features such as TEE-like scenarios and secure boot. It can create guest VMs for security use cases and has virtualization capabilities for both platform and interrupt. Although the hypervisor can be booted independently, it requires the assistance of GenieZone hypervisor kernel driver(gzvm-ko) to leverage the ability of Linux kernel for vCPU scheduling, memory management, inter-VM communication and virtio backend support. Changes in v9: - Add gzvm_vm_allocate_guest_page function for demand paging support and protected VM memory performance optimization - Fix coding style from viewer suggestion and checking tools. Changes in v8: https://lore.kernel.org/all/20231228105147.13752-1-yi-de.wu@mediatek.com/ - Add reasons for using dt solution in dt-bindings. - Add locks for memory pin/unpin and relinquish operations. - Add VM memory stats in debugfs. - Add tracing support for hypercall and vcpu exit reasons. - Enable PTP for timing synchronization between host and guests. - Optimize memory performance for protected VMs. - Refactor wording and titles in documentation. Changes in v7: https://lore.kernel.org/all/20231116152756.4250-1-yi-de.wu@mediatek.com/ - Rebase these patches to the Linux 6.7-rc1 release. - Refactor patches 1 to 15 to improve coding style while ensuring they do not violate the majority of the changes made in v6 - Provide individual VM memory statistics within debugfs in patch 16. - Add tracing support for hyper call and vcpu exit_reason. Changes in v6: https://lore.kernel.org/all/20230919111210.19615-1-yi-de.wu@mediatek.com/ - Rebase based on kernel 6.6-rc1 - Keep dt solution and leave the reasons in the commit message - Remove arch/arm64/include/uapi/asm/gzvm_arch.h due to simplicity - Remove resampler in drivers/virt/geniezone/gzvm_irqfd.c due to defeature for now - Remove PPI in arch/arm64/geniezone/vgic.c - Refactor vm related components into 3 smaller patches, namely adding vm support, setting user memory region and checking vm capability - Refactor vcpu and vm component to remove unnecessary ARM prefix - Add demand paging to fix crash on destroying memory page, acclerate on booting and support ballooning deflate - Add memory pin/unpin memory mechanism to support protected VM - Add block-based demand paging for performance concern - Response to reviewers and fix coding style accordingly Changes in v5: https://lore.kernel.org/all/20230727080005.14474-1-yi-de.wu@mediatek.com/ - Add dt solution back for device initialization - Add GZVM_EXIT_GZ reason for gzvm_vcpu_run() - Add patch for guest page fault handler - Add patch for supporitng pin/unpin memory - Remove unused enum members, namely GZVM_FUNC_GET_REGS and GZVM_FUNC_SET_REGS - Use dev_debug() for debugging when platform device is available, and use pr_debug() otherwise - Response to reviewers and fix bugs accordingly Changes in v4: https://lore.kernel.org/all/20230609085214.31071-1-yi-de.wu@mediatek.com/ - Add macro to set VM as protected without triggering pvmfw in AVF. - Add support to pass dtb config to hypervisor. - Add support for virtual timer. - Add UAPI to pass memory region metadata to hypervisor. - Define our own macros for ARM's interrupt number - Elaborate more on GenieZone hyperivsor in documentation - Fix coding style. - Implement our own module for coverting ipa to pa - Modify the way of initializing device from dt to a more discoverable way - Move refactoring changes into indepedent patches. Changes in v3: https://lore.kernel.org/all/20230512080405.12043-1-yi-de.wu@mediatek.com/ - Refactor: separate arch/arm64/geniezone/gzvm_arch.c into vm.c/vcpu.c/vgic.c - Remove redundant functions - Fix reviewer's comments Changes in v2: https://lore.kernel.org/all/20230428103622.18291-1-yi-de.wu@mediatek.com/ - Refactor: move to drivers/virt/geniezone - Refactor: decouple arch-dependent and arch-independent - Check pending signal before entering guest context - Fix reviewer's comments Initial Commit in v1: https://lore.kernel.org/all/20230413090735.4182-1-yi-de.wu@mediatek.com/ Yi-De Wu (21): virt: geniezone: enable gzvm-ko in defconfig docs: geniezone: Introduce GenieZone hypervisor dt-bindings: hypervisor: Add MediaTek GenieZone hypervisor virt: geniezone: Add GenieZone hypervisor driver virt: geniezone: Add vm support virt: geniezone: Add set_user_memory_region for vm virt: geniezone: Add vm capability check virt: geniezone: Optimize performance of protected VM memory virt: geniezone: Add vcpu support virt: geniezone: Add irqchip support for virtual interrupt injection virt: geniezone: Add irqfd support virt: geniezone: Add ioeventfd support virt: geniezone: Add memory region support virt: geniezone: Add dtb config support virt: geniezone: Add demand paging support virt: geniezone: Add block-based demand paging support virt: geniezone: Add memory pin/unpin support virt: geniezone: Add memory relinquish support virt: geniezone: Provide individual VM memory statistics within debugfs virt: geniezone: Add tracing support for hyp call and vcpu exit_reason virt: geniezone: Enable PTP for synchronizing time between host and guest VMs .../hypervisor/mediatek,geniezone-hyp.yaml | 31 + Documentation/virt/geniezone/introduction.rst | 87 +++ Documentation/virt/index.rst | 1 + MAINTAINERS | 11 + arch/arm64/Kbuild | 1 + arch/arm64/configs/defconfig | 2 + arch/arm64/geniezone/Makefile | 9 + arch/arm64/geniezone/gzvm_arch_common.h | 122 ++++ arch/arm64/geniezone/hvc.c | 73 +++ arch/arm64/geniezone/vcpu.c | 80 +++ arch/arm64/geniezone/vgic.c | 50 ++ arch/arm64/geniezone/vm.c | 432 +++++++++++++ drivers/virt/Kconfig | 2 + drivers/virt/geniezone/Kconfig | 16 + drivers/virt/geniezone/Makefile | 12 + drivers/virt/geniezone/gzvm_common.h | 12 + drivers/virt/geniezone/gzvm_exception.c | 61 ++ drivers/virt/geniezone/gzvm_ioeventfd.c | 276 ++++++++ drivers/virt/geniezone/gzvm_irqfd.c | 382 +++++++++++ drivers/virt/geniezone/gzvm_main.c | 153 +++++ drivers/virt/geniezone/gzvm_mmu.c | 308 +++++++++ drivers/virt/geniezone/gzvm_vcpu.c | 284 ++++++++ drivers/virt/geniezone/gzvm_vm.c | 608 ++++++++++++++++++ include/linux/gzvm_drv.h | 224 +++++++ include/trace/events/geniezone.h | 54 ++ include/uapi/linux/gzvm.h | 396 ++++++++++++ 26 files changed, 3687 insertions(+) create mode 100644 Documentation/devicetree/bindings/hypervisor/mediatek,geniezone-hyp.yaml create mode 100644 Documentation/virt/geniezone/introduction.rst create mode 100644 arch/arm64/geniezone/Makefile create mode 100644 arch/arm64/geniezone/gzvm_arch_common.h create mode 100644 arch/arm64/geniezone/hvc.c create mode 100644 arch/arm64/geniezone/vcpu.c create mode 100644 arch/arm64/geniezone/vgic.c create mode 100644 arch/arm64/geniezone/vm.c create mode 100644 drivers/virt/geniezone/Kconfig create mode 100644 drivers/virt/geniezone/Makefile create mode 100644 drivers/virt/geniezone/gzvm_common.h create mode 100644 drivers/virt/geniezone/gzvm_exception.c create mode 100644 drivers/virt/geniezone/gzvm_ioeventfd.c create mode 100644 drivers/virt/geniezone/gzvm_irqfd.c create mode 100644 drivers/virt/geniezone/gzvm_main.c create mode 100644 drivers/virt/geniezone/gzvm_mmu.c create mode 100644 drivers/virt/geniezone/gzvm_vcpu.c create mode 100644 drivers/virt/geniezone/gzvm_vm.c create mode 100644 include/linux/gzvm_drv.h create mode 100644 include/trace/events/geniezone.h create mode 100644 include/uapi/linux/gzvm.h -- 2.18.0