From patchwork Tue Oct 11 00:08:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elliot Berman X-Patchwork-Id: 13003437 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 27744C433F5 for ; Tue, 11 Oct 2022 00:10:46 +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:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=mwxWJ50P9iF/ODUfrqB+iRzco3HISzIBd2UzNkoa5MU=; b=EqAZpxhA7jAMEu z5PWbBlXofjpWHdNFG3MbmyJx1vFWocz6Mlv0pVdN9AfMN2F8LWLP+IN3xAhvQFMlSoAg+sauX6ci 8G4GvcCX10KGw7OJbTOjINAXQnWNyzD2oGhnkmdaI5cG7I7GgLphevC5VpJiIWPlyyTbasa7tVALi M1RmjOItkW5Va2X/n2PjMbqkVqyigdPr3CzXJRvwXjYQv/hWF5lFZOqM1snxxhX9VdpkK2wAoLH18 bgMmJHjPV2H+rB2dQP2vGu/3XRgXtnAyFQV8UIJexGEKuNUCz5XU03JyaZ6VZvu868+V7KK03b20W Gbghsis0iUrA1WO+J6XQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oi2pR-002gs5-87; Tue, 11 Oct 2022 00:09:01 +0000 Received: from alexa-out-sd-02.qualcomm.com ([199.106.114.39]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oi2pO-002gqj-4b for linux-arm-kernel@lists.infradead.org; Tue, 11 Oct 2022 00:09:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1665446938; x=1696982938; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=ipbw/+e2Oo3eMCZOjD0tMoR/u4y/sSabGgMZR3hs0LY=; b=x1gGnHNQqPNlli1N1ia3fWKmChpTiu1SBLfUVtj1slG132TP7tVWsZ/H jzEwSxnpVeH2cy3n3YNj+Yzt7gM+Il+F8G+G+vZgHIgJzpNQFcFqgW8Vv eb8l3bz8zFBHVC3i9ifLJjSiYRQ0vGrb++NTYr4EClg1td7wobgHHR/o7 c=; Received: from unknown (HELO ironmsg04-sd.qualcomm.com) ([10.53.140.144]) by alexa-out-sd-02.qualcomm.com with ESMTP; 10 Oct 2022 17:08:54 -0700 X-QCInternal: smtphost Received: from nasanex01b.na.qualcomm.com ([10.46.141.250]) by ironmsg04-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Oct 2022 17:08:54 -0700 Received: from hu-eberman-lv.qualcomm.com (10.49.16.6) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Mon, 10 Oct 2022 17:08:53 -0700 From: Elliot Berman To: Bjorn Andersson CC: Elliot Berman , Murali Nalajala , Trilok Soni , "Srivatsa Vaddagiri" , Carl van Schaik , Prakruthi Deepak Heragu , Andy Gross , Dmitry Baryshkov , Jassi Brar , , Mark Rutland , Lorenzo Pieralisi , Sudeep Holla , Marc Zyngier , Rob Herring , Krzysztof Kozlowski , Jonathan Corbet , "Will Deacon" , Catalin Marinas , "Arnd Bergmann" , Greg Kroah-Hartman , , , , Subject: [PATCH v5 00/13] Drivers for gunyah hypervisor Date: Mon, 10 Oct 2022 17:08:27 -0700 Message-ID: <20221011000840.289033-1-quic_eberman@quicinc.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01b.na.qualcomm.com (10.47.209.197) To nasanex01b.na.qualcomm.com (10.46.141.250) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221010_170858_251013_10005E61 X-CRM114-Status: GOOD ( 16.85 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Gunyah is a Type-1 hypervisor independent of any high-level OS kernel, and runs in a higher CPU privilege level. It does not depend on any lower-privileged OS kernel/code for its core functionality. This increases its security and can support a much smaller trusted computing base than a Type-2 hypervisor. Gunyah is an open source hypervisor. The source repo is available at https://github.com/quic/gunyah-hypervisor. The diagram below shows the architecture. :: VM A VM B +-----+ +-----+ | +-----+ +-----+ +-----+ | | | | | | | | | | | EL0 | APP | | APP | | | APP | | APP | | APP | | | | | | | | | | | | +-----+ +-----+ | +-----+ +-----+ +-----+ ---------------------|------------------------- +--------------+ | +----------------------+ | | | | | EL1 | Linux Kernel | | |Linux kernel/Other OS | ... | | | | | +--------------+ | +----------------------+ --------hvc/smc------|------hvc/smc------------ +----------------------------------------+ | | EL2 | Gunyah Hypervisor | | | +----------------------------------------+ Gunyah provides these following features. - Threads and Scheduling: The scheduler schedules virtual CPUs (VCPUs) on physical CPUs and enables time-sharing of the CPUs. - Memory Management: Gunyah tracks memory ownership and use of all memory under its control. Memory partitioning between VMs is a fundamental security feature. - Interrupt Virtualization: All interrupts are handled in the hypervisor and routed to the assigned VM. - Inter-VM Communication: There are several different mechanisms provided for communicating between VMs. - Device Virtualization: Para-virtualization of devices is supported using inter-VM communication. Low level system features and devices such as interrupt controllers are supported with emulation where required. This series adds the basic framework for detecting that Linux is running under Gunyah as a virtual machine, communication with the Gunyah Resource Manager, and a tty driver to demonstrate end-to-end use case of communicating with RM. Presently, the TTY driver is only capable of behaving as a loopback device: data sent to ttyGH0 shows up in ttyGH1 and vice versa. More Gunyah consoles can be exposed as Linux learns about other VMs running in Gunyah. In a future series, I'll introduce a Gunyah VM loader which can load and run VMs. This loader will follow the design philosophy of the /dev/kvm. Changes in v5: - Dropped sysfs nodes - Switch from aux bus to Gunyah RM bus for the subdevices - Cleaning up RM console Changes in v4: https://lore.kernel.org/all/20220928195633.2348848-1-quic_eberman@quicinc.com/ - Tidied up documentation throughout based on questions/feedback received - Switched message queue implementation to use mailboxes - Renamed "gunyah_device" as "gunyah_resource" Changes in v3: https://lore.kernel.org/all/20220811214107.1074343-1-quic_eberman@quicinc.com/ - /Maintained/Supported/ in MAINTAINERS - Tidied up documentation throughout based on questions/feedback received - Moved hypercalls into arch/arm64/gunyah/; following hyper-v's implementation - Drop opaque typedefs - Move sysfs nodes under /sys/hypervisor/gunyah/ - Moved Gunyah console driver to drivers/tty/ - Reworked gunyah_device design to drop the Gunyah bus. Changes in v2: https://lore.kernel.org/all/20220801211240.597859-1-quic_eberman@quicinc.com/ - DT bindings clean up - Switch hypercalls to follow SMCCC v1: https://lore.kernel.org/all/20220223233729.1571114-1-quic_eberman@quicinc.com/ Elliot Berman (13): docs: gunyah: Introduce Gunyah Hypervisor dt-bindings: Add binding for gunyah hypervisor gunyah: Common types and error codes for Gunyah hypercalls arm64: smccc: Include alternative-macros.h virt: gunyah: Add hypercalls to identify Gunyah virt: gunyah: Identify hypervisor version mailbox: Allow direct registration to a channel virt: gunyah: msgq: Add hypercalls to send and receive messages mailbox: Add Gunyah message queue mailbox gunyah: rsc_mgr: Add resource manager RPC core gunyah: rsc_mgr: Add RPC for console services gunyah: rsc_mgr: Add subdevices bus tty: gunyah: Add tty console driver for RM Console Services .../bindings/firmware/gunyah-hypervisor.yaml | 87 +++ Documentation/virt/gunyah/index.rst | 114 ++++ Documentation/virt/gunyah/message-queue.rst | 54 ++ Documentation/virt/index.rst | 1 + MAINTAINERS | 15 + arch/arm64/Kbuild | 1 + arch/arm64/gunyah/Makefile | 2 + arch/arm64/gunyah/hypercall.c | 104 +++ drivers/mailbox/Kconfig | 10 + drivers/mailbox/Makefile | 2 + drivers/mailbox/gunyah-msgq.c | 254 +++++++ drivers/mailbox/mailbox.c | 96 ++- drivers/tty/Kconfig | 8 + drivers/tty/Makefile | 1 + drivers/tty/gunyah_console.c | 439 ++++++++++++ drivers/virt/Kconfig | 1 + drivers/virt/Makefile | 1 + drivers/virt/gunyah/Kconfig | 29 + drivers/virt/gunyah/Makefile | 5 + drivers/virt/gunyah/gunyah.c | 41 ++ drivers/virt/gunyah/rsc_mgr.c | 644 ++++++++++++++++++ drivers/virt/gunyah/rsc_mgr.h | 66 ++ drivers/virt/gunyah/rsc_mgr_bus.c | 84 +++ drivers/virt/gunyah/rsc_mgr_rpc.c | 126 ++++ include/asm-generic/gunyah.h | 118 ++++ include/linux/arm-smccc.h | 1 + include/linux/gunyah.h | 67 ++ include/linux/gunyah_rsc_mgr.h | 64 ++ include/linux/mailbox_client.h | 1 + include/linux/mod_devicetable.h | 8 + scripts/mod/devicetable-offsets.c | 3 + scripts/mod/file2alias.c | 10 + 32 files changed, 2429 insertions(+), 28 deletions(-) create mode 100644 Documentation/devicetree/bindings/firmware/gunyah-hypervisor.yaml create mode 100644 Documentation/virt/gunyah/index.rst create mode 100644 Documentation/virt/gunyah/message-queue.rst create mode 100644 arch/arm64/gunyah/Makefile create mode 100644 arch/arm64/gunyah/hypercall.c create mode 100644 drivers/mailbox/gunyah-msgq.c create mode 100644 drivers/tty/gunyah_console.c create mode 100644 drivers/virt/gunyah/Kconfig create mode 100644 drivers/virt/gunyah/Makefile create mode 100644 drivers/virt/gunyah/gunyah.c create mode 100644 drivers/virt/gunyah/rsc_mgr.c create mode 100644 drivers/virt/gunyah/rsc_mgr.h create mode 100644 drivers/virt/gunyah/rsc_mgr_bus.c create mode 100644 drivers/virt/gunyah/rsc_mgr_rpc.c create mode 100644 include/asm-generic/gunyah.h create mode 100644 include/linux/gunyah.h create mode 100644 include/linux/gunyah_rsc_mgr.h base-commit: 4fe89d07dcc2804c8b562f6c7896a45643d34b2f