Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions Documentation/devicetree/bindings/bao/bao,io-dispatcher.yaml
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>;
};
82 changes: 82 additions & 0 deletions Documentation/devicetree/bindings/bao/bao,ipcshmem.yaml
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>;
};
2 changes: 2 additions & 0 deletions Documentation/devicetree/bindings/vendor-prefixes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ patternProperties:
description: Shenzhen AZW Technology Co., Ltd.
"^baikal,.*":
description: BAIKAL ELECTRONICS, JSC
"^bao,.*":
description: Bao Hypervisor
"^bananapi,.*":
description: BIPAI KEJI LIMITED
"^beacon,.*":
Expand Down
2 changes: 2 additions & 0 deletions Documentation/userspace-api/ioctl/ioctl-number.rst
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,8 @@ Code Seq# Include File Comments
<mailto:luzmaximilian@gmail.com>
0xA5 20-2F linux/surface_aggregator/dtx.h Microsoft Surface DTX driver
<mailto:luzmaximilian@gmail.com>
0xA6 all uapi/linux/bao.h Bao hypervisor
<mailto:info@bao-project.org>
0xAA 00-3F linux/uapi/linux/userfaultfd.h
0xAB 00-1F linux/nbd.h
0xAC 00-1F linux/raw.h
Expand Down
13 changes: 13 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -4321,6 +4321,19 @@ F: drivers/video/backlight/
F: include/linux/backlight.h
F: include/linux/pwm_backlight.h

BAO HYPERVISOR
M: José Martins <jose@osyx.tech>
M: David Cerdeira <davidmcerdeira@osyx.tech>
M: João Peixoto <joaopeixoto@osyx.tech>
S: Maintained
F: Documentation/devicetree/bindings/bao/
F: arch/arm/include/asm/bao.h
F: arch/arm64/include/asm/bao.h
F: arch/riscv/include/asm/bao.h
F: drivers/virt/bao
F: include/linux/bao.h
F: include/uapi/linux/bao.h

BARCO P50 GPIO DRIVER
M: Santosh Kumar Yadav <santoshkumar.yadav@barco.com>
M: Peter Korsgaard <peter.korsgaard@barco.com>
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
VERSION = 6
PATCHLEVEL = 19
SUBLEVEL = 0
EXTRAVERSION = -rc1
EXTRAVERSION = -rc2
NAME = Baby Opossum Posse

# *DOCUMENTATION*
Expand Down
60 changes: 60 additions & 0 deletions arch/arm/include/asm/bao.h
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 */
60 changes: 60 additions & 0 deletions arch/arm64/include/asm/bao.h
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 */
60 changes: 60 additions & 0 deletions arch/riscv/include/asm/bao.h
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 */
2 changes: 2 additions & 0 deletions drivers/virt/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ source "drivers/virt/nitro_enclaves/Kconfig"

source "drivers/virt/acrn/Kconfig"

source "drivers/virt/bao/Kconfig"

endif

source "drivers/virt/coco/Kconfig"
Loading