forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Add Bao IPC and I/O dispatcher drivers #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
joaopeixoto13
wants to merge
9
commits into
master
Choose a base branch
from
virt/bao
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e1f82d6
scripts: coccicheck: filter *.cocci files by MODE
5a1cf38
Coccinelle: pm_runtime: Fix typo in report message
toblux 6ae12b6
Linux 6.19-rc2
torvalds 458e188
dt-bindings: Add Bao IPC shared memory driver binding
fe1aa8b
virt: bao: Add Bao IPC shared memory driver
592494b
dt-bindings: Add Bao I/O dispatcher driver binding
c1f9bcd
virt: bao: Add Bao I/O dispatcher driver
43c1ad1
virt: bao: Move BAO_IPCSHMEM_HYPERCALL_ID to common header
c4ec09b
MAINTAINERS: Add entries for Bao hypervisor drivers, headers, and DT …
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
75 changes: 75 additions & 0 deletions
75
Documentation/devicetree/bindings/bao/bao,io-dispatcher.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| # SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause | ||
| %YAML 1.2 | ||
| --- | ||
| $id: http://devicetree.org/schemas/bao/bao,io-dispatcher.yaml# | ||
| $schema: http://devicetree.org/meta-schemas/core.yaml# | ||
|
|
||
| title: Bao I/O Dispatcher Device | ||
|
|
||
| maintainers: | ||
| - João Peixoto <joaopeixoto@osyx.tech> | ||
| - José Martins <jose@osyx.tech> | ||
| - David Cerdeira <davidmcerdeira@osyx.tech> | ||
|
|
||
| description: | | ||
| I/O Dispatcher device for Bao hypervisor guests that run virtualized | ||
| devices (e.g., VirtIO). | ||
|
|
||
| This device is only required in backend VMs, which are responsible for | ||
| performing the actual I/O operations on physical hardware. Frontend | ||
| VMs, which only consume I/O services, do not require this device. | ||
|
|
||
| The I/O Dispatcher provides access to one or more backend devices. | ||
| Each backend device is associated with a contiguous shared-memory | ||
| region used to exchange I/O buffers with the respective frontend | ||
| driver, and an interrupt used by the Bao hypervisor to notify the | ||
| backend VM of pending I/O requests. | ||
|
|
||
| properties: | ||
| compatible: | ||
| const: bao,io-dispatcher | ||
|
|
||
| reg: | ||
| description: | | ||
| Contiguous memory-mapped regions for each VirtIO backend device | ||
| managed by the I/O Dispatcher. | ||
|
|
||
| Each region is used to exchange I/O buffers between the backend | ||
| and frontend devices. A single region corresponds to one | ||
| backend device. | ||
| minItems: 1 | ||
| maxItems: 64 | ||
|
|
||
| interrupts: | ||
| description: | | ||
| Interrupts associated with the VirtIO backend devices. | ||
|
|
||
| Each interrupt corresponds to a backend device and is used | ||
| by the Bao hypervisor to notify the backend VM of pending | ||
| I/O requests from the associated frontend driver. | ||
| minItems: 1 | ||
| maxItems: 64 | ||
|
|
||
| required: | ||
| - compatible | ||
| - reg | ||
| - interrupts | ||
|
|
||
| additionalProperties: false | ||
|
|
||
| examples: | ||
| - | | ||
| bao-io-dispatcher@50000000 { | ||
| compatible = "bao,io-dispatcher"; | ||
| reg = <0x0 0x50000000 0x0 0x01000000 | ||
| 0x0 0x51000000 0x0 0x01000000 | ||
| 0x0 0x52000000 0x0 0x01000000 | ||
| 0x0 0x53000000 0x0 0x01000000 | ||
| 0x0 0x54000000 0x0 0x01000000>; | ||
| interrupts = <0x0 0x08 0x1 | ||
| 0x0 0x09 0x1 | ||
| 0x0 0x0a 0x1 | ||
| 0x0 0x0b 0x1 | ||
| 0x0 0x0c 0x1>; | ||
| interrupt-parent = <&gic>; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| # SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause | ||
| %YAML 1.2 | ||
| --- | ||
| $id: http://devicetree.org/schemas/bao/bao,ipcshmem.yaml# | ||
| $schema: http://devicetree.org/meta-schemas/core.yaml# | ||
|
|
||
| title: Bao IPC Shared Memory Device | ||
|
|
||
| maintainers: | ||
| - José Martins <jose@osyx.tech> | ||
| - David Cerdeira <davidmcerdeira@osyx.tech> | ||
| - João Peixoto <joaopeixoto@osyx.tech> | ||
|
|
||
| description: | | ||
| Shared memory based communication device for Bao hypervisor guests. | ||
|
|
||
| The device describes a set of shared-memory regions used for | ||
| communication between Bao guests. Each guest instantiating this | ||
| device uses one region for reading data produced by a peer guest | ||
| and another region for writing data consumed by that peer. | ||
|
|
||
| properties: | ||
| compatible: | ||
| const: bao,ipcshmem | ||
|
|
||
| reg: | ||
| description: | ||
| Shared memory region used for IPC. | ||
| minItems: 2 | ||
| maxItems: 2 | ||
|
|
||
| read-channel: | ||
| description: | | ||
| Shared-memory sub-region that this guest reads from. | ||
|
|
||
| This region is written by the peer Bao guest and read by the | ||
| guest instantiating this device. | ||
|
|
||
| Consists of two cells: | ||
| - offset into the shared-memory region defined by `reg` | ||
| - size in bytes | ||
| $ref: /schemas/types.yaml#/definitions/uint32-array | ||
| minItems: 2 | ||
| maxItems: 2 | ||
|
|
||
| write-channel: | ||
| description: | | ||
| Shared-memory sub-region that this guest writes to. | ||
|
|
||
| This region is written by the guest instantiating this device and | ||
| read by the peer Bao guest. | ||
|
|
||
| Consists of two cells: | ||
| - offset into the shared-memory region defined by `reg` | ||
| - size in bytes | ||
| $ref: /schemas/types.yaml#/definitions/uint32-array | ||
| minItems: 2 | ||
| maxItems: 2 | ||
|
|
||
| id: | ||
| description: | ||
| Driver instance ID. | ||
| $ref: /schemas/types.yaml#/definitions/uint32 | ||
|
|
||
| required: | ||
| - compatible | ||
| - reg | ||
| - read-channel | ||
| - write-channel | ||
| - id | ||
|
|
||
| additionalProperties: false | ||
|
|
||
| examples: | ||
| - | | ||
| bao-ipc@f0000000 { | ||
| compatible = "bao,ipcshmem"; | ||
| reg = <0x0 0xf0000000 0x0 0x00010000>; | ||
| read-channel = <0x0 0x2000>; | ||
| write-channel = <0x2000 0x2000>; | ||
| id = <0>; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| /* SPDX-License-Identifier: GPL-2.0 */ | ||
| /* | ||
| * Bao Hypervisor Hypercall Interface | ||
| * | ||
| * Copyright (c) Bao Project and Contributors. All rights reserved. | ||
| * | ||
| * Authors: | ||
| * João Peixoto <joaopeixoto@osyx.tech> | ||
| * José Martins <jose@osyx.tech> | ||
| * David Cerdeira <davidmcerdeira@osyx.tech> | ||
| */ | ||
|
|
||
| #ifndef __ASM_ARM_BAO_H | ||
| #define __ASM_ARM_BAO_H | ||
|
|
||
| #include <linux/arm-smccc.h> | ||
| #include <linux/bao.h> | ||
|
|
||
| static inline unsigned long bao_ipcshmem_hypercall(unsigned long ipcshmem_id) | ||
| { | ||
| struct arm_smccc_res res; | ||
|
|
||
| arm_smccc_hvc(ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, ARM_SMCCC_SMC_32, | ||
| ARM_SMCCC_OWNER_VENDOR_HYP, | ||
| BAO_IPCSHMEM_HYPERCALL_ID), | ||
| ipcshmem_id, 0, 0, 0, 0, 0, 0, &res); | ||
|
|
||
| return res.a0; | ||
| } | ||
|
|
||
| static inline unsigned long | ||
| bao_remio_hypercall(struct bao_remio_hypercall_ctx *ctx) | ||
| { | ||
| register int r0 asm("r0") = | ||
| ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, ARM_SMCCC_SMC_32, | ||
| ARM_SMCCC_OWNER_VENDOR_HYP, BAO_REMIO_HYPERCALL_ID); | ||
| register u32 r1 asm("r1") = ctx->dm_id; | ||
| register u32 r2 asm("r2") = ctx->addr; | ||
| register u32 r3 asm("r3") = ctx->op; | ||
| register u32 r4 asm("r4") = ctx->value; | ||
| register u32 r5 asm("r5") = ctx->request_id; | ||
| register u32 r6 asm("r6") = 0; | ||
|
|
||
| asm volatile("hvc 0\n\t" | ||
| : "=r"(r0), "=r"(r1), "=r"(r2), "=r"(r3), "=r"(r4), | ||
| "=r"(r5), "=r"(r6) | ||
| : "r"(r0), "r"(r1), "r"(r2), "r"(r3), "r"(r4), "r"(r5) | ||
| : "memory"); | ||
|
|
||
| ctx->addr = r1; | ||
| ctx->op = r2; | ||
| ctx->value = r3; | ||
| ctx->access_width = r4; | ||
| ctx->request_id = r5; | ||
| ctx->npend_req = r6; | ||
|
|
||
| return r0; | ||
| } | ||
|
|
||
| #endif /* __ASM_ARM_BAO_H */ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| /* SPDX-License-Identifier: GPL-2.0 */ | ||
| /* | ||
| * Bao Hypervisor Hypercall Interface | ||
| * | ||
| * Copyright (c) Bao Project and Contributors. All rights reserved. | ||
| * | ||
| * Authors: | ||
| * João Peixoto <joaopeixoto@osyx.tech> | ||
| * José Martins <jose@osyx.tech> | ||
| * David Cerdeira <davidmcerdeira@osyx.tech> | ||
| */ | ||
|
|
||
| #ifndef __ASM_ARM64_BAO_H | ||
| #define __ASM_ARM64_BAO_H | ||
|
|
||
| #include <linux/arm-smccc.h> | ||
| #include <linux/bao.h> | ||
|
|
||
| static inline unsigned long bao_ipcshmem_hypercall(unsigned long ipcshmem_id) | ||
| { | ||
| struct arm_smccc_res res; | ||
|
|
||
| arm_smccc_hvc(ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, ARM_SMCCC_SMC_64, | ||
| ARM_SMCCC_OWNER_VENDOR_HYP, | ||
| BAO_IPCSHMEM_HYPERCALL_ID), | ||
| ipcshmem_id, 0, 0, 0, 0, 0, 0, &res); | ||
|
|
||
| return res.a0; | ||
| } | ||
|
|
||
| static inline unsigned long | ||
| bao_remio_hypercall(struct bao_remio_hypercall_ctx *ctx) | ||
| { | ||
| register int x0 asm("x0") = | ||
| ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, ARM_SMCCC_SMC_64, | ||
| ARM_SMCCC_OWNER_VENDOR_HYP, BAO_REMIO_HYPERCALL_ID); | ||
| register u64 x1 asm("x1") = ctx->dm_id; | ||
| register u64 x2 asm("x2") = ctx->addr; | ||
| register u64 x3 asm("x3") = ctx->op; | ||
| register u64 x4 asm("x4") = ctx->value; | ||
| register u64 x5 asm("x5") = ctx->request_id; | ||
| register u64 x6 asm("x6") = 0; | ||
|
|
||
| asm volatile("hvc 0\n\t" | ||
| : "=r"(x0), "=r"(x1), "=r"(x2), "=r"(x3), "=r"(x4), | ||
| "=r"(x5), "=r"(x6) | ||
| : "r"(x0), "r"(x1), "r"(x2), "r"(x3), "r"(x4), "r"(x5) | ||
| : "memory"); | ||
|
|
||
| ctx->addr = x1; | ||
| ctx->op = x2; | ||
| ctx->value = x3; | ||
| ctx->access_width = x4; | ||
| ctx->request_id = x5; | ||
| ctx->npend_req = x6; | ||
|
|
||
| return x0; | ||
| } | ||
|
|
||
| #endif /* __ASM_ARM64_BAO_H */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| /* SPDX-License-Identifier: GPL-2.0 */ | ||
| /* | ||
| * Bao Hypervisor Hypercall Interface | ||
| * | ||
| * Copyright (c) Bao Project and Contributors. All rights reserved. | ||
| * | ||
| * Authors: | ||
| * João Peixoto <joaopeixoto@osyx.tech> | ||
| * José Martins <jose@osyx.tech> | ||
| * David Cerdeira <davidmcerdeira@osyx.tech> | ||
| */ | ||
|
|
||
| #ifndef __ASM_RISCV_BAO_H | ||
| #define __ASM_RISCV_BAO_H | ||
|
|
||
| #include <asm/sbi.h> | ||
| #include <linux/bao.h> | ||
|
|
||
| #define BAO_SBI_EXT_ID 0x08000ba0 | ||
|
|
||
| static inline unsigned long bao_ipcshmem_hypercall(unsigned long ipcshmem_id) | ||
| { | ||
| struct sbiret ret; | ||
|
|
||
| ret = sbi_ecall(BAO_SBI_EXT_ID, BAO_IPCSHMEM_HYPERCALL_ID, ipcshmem_id, | ||
| 0, 0, 0, 0, 0); | ||
|
|
||
| return ret.error; | ||
| } | ||
|
|
||
| static inline unsigned long | ||
| bao_remio_hypercall(struct bao_remio_hypercall_ctx *ctx) | ||
| { | ||
| register uintptr_t a0 asm("a0") = (uintptr_t)(ctx->dm_id); | ||
| register uintptr_t a1 asm("a1") = (uintptr_t)(ctx->addr); | ||
| register uintptr_t a2 asm("a2") = (uintptr_t)(ctx->op); | ||
| register uintptr_t a3 asm("a3") = (uintptr_t)(ctx->value); | ||
| register uintptr_t a4 asm("a4") = (uintptr_t)(ctx->request_id); | ||
| register uintptr_t a5 asm("a5") = (uintptr_t)(0); | ||
| register uintptr_t a6 asm("a6") = (uintptr_t)(BAO_REMIO_HYPERCALL_ID); | ||
| register uintptr_t a7 asm("a7") = (uintptr_t)(0x08000ba0); | ||
|
|
||
| asm volatile("ecall" | ||
| : "+r"(a0), "+r"(a1), "+r"(a2), "+r"(a3), "+r"(a4), | ||
| "+r"(a5), "+r"(a6), "+r"(a7) | ||
| : "r"(a0), "r"(a1), "r"(a2), "r"(a3), "r"(a4), "r"(a5), | ||
| "r"(a6), "r"(a7) | ||
| : "memory"); | ||
|
|
||
| ctx->addr = a2; | ||
| ctx->op = a3; | ||
| ctx->value = a4; | ||
| ctx->access_width = a5; | ||
| ctx->request_id = a6; | ||
| ctx->npend_req = a7; | ||
|
|
||
| return a0; | ||
| } | ||
|
|
||
| #endif /* __ASM_RISCV_BAO_H */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.