From bbd51f4b06ed088704e883b3153644af9b336e69 Mon Sep 17 00:00:00 2001 From: Adrian Mangeac Date: Wed, 17 Apr 2019 17:41:51 +0200 Subject: Add jailhouse related patches Change-Id: I7f7f4a17dddc512dd8c3d50e0606f2618ee7e23e Signed-off-by: Adrian Mangeac --- .../jailhouse/0001-export__hyp_stub_vectors.patch | 57 ++++++++ patches/jailhouse/0002-disable_uart1.patch | 13 ++ patches/jailhouse/jailhouse.scc | 5 + patches/jailhouse/jailhouse_0004.patch | 155 +++++++++++++++++++++ patches/jailhouse/jailhouse_0005.patch | 64 +++++++++ patches/jailhouse/jailhouse_0006.patch | 9 ++ 6 files changed, 303 insertions(+) create mode 100644 patches/jailhouse/0001-export__hyp_stub_vectors.patch create mode 100644 patches/jailhouse/0002-disable_uart1.patch create mode 100644 patches/jailhouse/jailhouse.scc create mode 100644 patches/jailhouse/jailhouse_0004.patch create mode 100644 patches/jailhouse/jailhouse_0005.patch create mode 100644 patches/jailhouse/jailhouse_0006.patch diff --git a/patches/jailhouse/0001-export__hyp_stub_vectors.patch b/patches/jailhouse/0001-export__hyp_stub_vectors.patch new file mode 100644 index 0000000..b58b522 --- /dev/null +++ b/patches/jailhouse/0001-export__hyp_stub_vectors.patch @@ -0,0 +1,57 @@ +From 90165e12a59df7e26bfb4cedd76a1def45cee5a9 Mon Sep 17 00:00:00 2001 +From: Ralf Ramsauer +Date: Wed, 7 Jun 2017 15:48:43 +0200 +Subject: [PATCH] arm, arm64: export __hyp_stub_vectors + +HVC_GET_VECTORS got removed. External hypervisors, like Jailhouse, need +this address when they are deactivated, in order to restore original +state. + +Signed-off-by: Ralf Ramsauer +Signed-off-by: Jan Kiszka +--- + arch/arm/kernel/hyp-stub.S | 2 ++ + arch/arm64/kernel/hyp-stub.S | 2 ++ + 2 files changed, 4 insertions(+) + +diff --git a/arch/arm/kernel/hyp-stub.S b/arch/arm/kernel/hyp-stub.S +index 60146e3..d34efc5 100644 +--- a/arch/arm/kernel/hyp-stub.S ++++ b/arch/arm/kernel/hyp-stub.S +@@ -19,6 +19,7 @@ + #include + #include + #include ++#include + #include + #include + +@@ -282,4 +283,5 @@ __hyp_stub_trap: W(b) __hyp_stub_do_trap + __hyp_stub_irq: W(b) . + __hyp_stub_fiq: W(b) . + ENDPROC(__hyp_stub_vectors) ++EXPORT_SYMBOL_GPL(__hyp_stub_vectors) + +diff --git a/arch/arm64/kernel/hyp-stub.S b/arch/arm64/kernel/hyp-stub.S +index e1261fb..061b32e 100644 +--- a/arch/arm64/kernel/hyp-stub.S ++++ b/arch/arm64/kernel/hyp-stub.S +@@ -21,6 +21,7 @@ + #include + #include + ++#include + #include + #include + #include +@@ -51,6 +52,7 @@ ENTRY(__hyp_stub_vectors) + ventry el1_fiq_invalid // FIQ 32-bit EL1 + ventry el1_error_invalid // Error 32-bit EL1 + ENDPROC(__hyp_stub_vectors) ++EXPORT_SYMBOL_GPL(__hyp_stub_vectors) + + .align 11 + +-- +2.1.4 + diff --git a/patches/jailhouse/0002-disable_uart1.patch b/patches/jailhouse/0002-disable_uart1.patch new file mode 100644 index 0000000..64eb5b9 --- /dev/null +++ b/patches/jailhouse/0002-disable_uart1.patch @@ -0,0 +1,13 @@ +diff --git a/arch/arm64/boot/dts/xilinx/zynqmp-zcu102-revA.dts b/arch/arm64/boot/dts/xilinx/zynqmp-zcu102-revA.dts +index 46ab349..e1d6739 100644 +--- a/arch/arm64/boot/dts/xilinx/zynqmp-zcu102-revA.dts ++++ b/arch/arm64/boot/dts/xilinx/zynqmp-zcu102-revA.dts +@@ -913,7 +913,7 @@ drivers/hwmon/pmbus/Makefile:11:obj-$(CONFIG_SENSORS_MAX20751) += max20751.o + }; + + &uart1 { +- status = "okay"; ++ status = "disabled"; /* Disable so that jailhouse inmate can use it. */ + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_uart1_default>; + }; diff --git a/patches/jailhouse/jailhouse.scc b/patches/jailhouse/jailhouse.scc new file mode 100644 index 0000000..11db4ae --- /dev/null +++ b/patches/jailhouse/jailhouse.scc @@ -0,0 +1,5 @@ +patch 0001-export__hyp_stub_vectors.patch +patch 0002-disable_uart1.patch +patch jailhouse_0004.patch +patch jailhouse_0005.patch +patch jailhouse_0006.patch diff --git a/patches/jailhouse/jailhouse_0004.patch b/patches/jailhouse/jailhouse_0004.patch new file mode 100644 index 0000000..be612ff --- /dev/null +++ b/patches/jailhouse/jailhouse_0004.patch @@ -0,0 +1,155 @@ +From 8ba0c10a0b7fd44efe2e17462bb39732498b6d9b Mon Sep 17 00:00:00 2001 +From: Jan Kiszka +Date: Sun, 11 Sep 2016 23:30:04 +0200 +Subject: [PATCH] jailhouse: Add simple debug console via the hypervisor + +Jailhouse allows explicitly configured cells to write character-wise +messages to the hypervisor debug console. Make use of this for a +platform-agnostic boot diagnosis channel, specifically for non-root +cells. It also comes with earlycon support. + +Signed-off-by: Jan Kiszka +--- + drivers/virt/Kconfig | 11 +++++ + drivers/virt/Makefile | 1 + + drivers/virt/jailhouse_dbgcon.c | 99 +++++++++++++++++++++++++++++++++++++++++ + 3 files changed, 111 insertions(+) + create mode 100644 drivers/virt/jailhouse_dbgcon.c + +diff --git a/drivers/virt/Kconfig b/drivers/virt/Kconfig +index 99ebdde..baf04bb 100644 +--- a/drivers/virt/Kconfig ++++ b/drivers/virt/Kconfig +@@ -30,4 +30,15 @@ config FSL_HV_MANAGER + 4) A kernel interface for receiving callbacks when a managed + partition shuts down. + ++config JAILHOUSE_DBGCON ++ tristate "Jailhouse console driver" ++ depends on X86 || ARM || ARM64 ++ help ++ The Jailhouse hypervisor provides a simple write-only console for ++ debugging the bootstrap process of its cells. This driver registers ++ a console with the kernel to make use of it. ++ ++ Note that Jailhouse has to be configured to permit a cell the usage ++ of the console interface. ++ + endif +diff --git a/drivers/virt/Makefile b/drivers/virt/Makefile +index c47f04d..abd4baa 100644 +--- a/drivers/virt/Makefile ++++ b/drivers/virt/Makefile +@@ -3,3 +3,4 @@ + # + + obj-$(CONFIG_FSL_HV_MANAGER) += fsl_hypervisor.o ++obj-$(CONFIG_JAILHOUSE_DBGCON) += jailhouse_dbgcon.o +diff --git a/drivers/virt/jailhouse_dbgcon.c b/drivers/virt/jailhouse_dbgcon.c +new file mode 100644 +index 0000000..5a8a8fb +--- /dev/null ++++ b/drivers/virt/jailhouse_dbgcon.c +@@ -0,0 +1,99 @@ ++/* ++ * Console driver for running over the Jailhouse partitioning hypervisor ++ * ++ * Copyright (c) Siemens AG, 2016 ++ * ++ * Authors: ++ * Jan Kiszka ++ * ++ * This work is licensed under the terms of the GNU GPL, version 2. See ++ * the COPYING file in the top-level directory. ++ */ ++ ++#include ++#include ++#include ++#ifdef CONFIG_X86 ++#include ++#endif ++#ifdef CONFIG_ARM ++#include ++#endif ++ ++#define JAILHOUSE_HC_DEBUG_CONSOLE_PUTC 8 ++ ++static void hypervisor_putc(char c) ++{ ++#if defined(CONFIG_X86) ++ int result; ++ ++ asm volatile( ++ ALTERNATIVE(".byte 0x0f,0x01,0xc1", ".byte 0x0f,0x01,0xd9", ++ X86_FEATURE_VMMCALL) ++ : "=a" (result) ++ : "a" (JAILHOUSE_HC_DEBUG_CONSOLE_PUTC), "D" (c) ++ : "memory"); ++#elif defined(CONFIG_ARM) ++ register u32 num_res asm("r0") = JAILHOUSE_HC_DEBUG_CONSOLE_PUTC; ++ register u32 arg1 asm("r1") = c; ++ ++ asm volatile( ++ __HVC(0x4a48) ++ : "=r" (num_res) ++ : "r" (num_res), "r" (arg1) ++ : "memory"); ++#elif defined(CONFIG_ARM64) ++ register u64 num_res asm("x0") = JAILHOUSE_HC_DEBUG_CONSOLE_PUTC; ++ register u64 arg1 asm("x1") = c; ++ ++ asm volatile( ++ "hvc #0x4a48\n\t" ++ : "=r" (num_res) ++ : "r" (num_res), "r" (arg1) ++ : "memory"); ++#endif ++} ++ ++static void jailhouse_dbgcon_write(struct console *con, const char *s, ++ unsigned count) ++{ ++ while (count > 0) { ++ hypervisor_putc(*s); ++ count--; ++ s++; ++ } ++} ++ ++static int __init early_jailhouse_dbgcon_setup(struct earlycon_device *device, ++ const char *options) ++{ ++ device->con->write = jailhouse_dbgcon_write; ++ return 0; ++} ++ ++EARLYCON_DECLARE(jailhouse, early_jailhouse_dbgcon_setup); ++ ++static struct console jailhouse_dbgcon = { ++ .name = "jailhouse", ++ .write = jailhouse_dbgcon_write, ++ .flags = CON_PRINTBUFFER | CON_ANYTIME, ++ .index = -1, ++}; ++ ++static int __init jailhouse_dbgcon_init(void) ++{ ++ register_console(&jailhouse_dbgcon); ++ return 0; ++} ++ ++static void __exit jailhouse_dbgcon_exit(void) ++{ ++ unregister_console(&jailhouse_dbgcon); ++} ++ ++module_init(jailhouse_dbgcon_init); ++module_exit(jailhouse_dbgcon_exit); ++ ++MODULE_LICENSE("GPL v2"); ++MODULE_DESCRIPTION("Jailhouse debug console driver"); ++MODULE_AUTHOR("Jan Kiszka "); +-- +2.1.4 + diff --git a/patches/jailhouse/jailhouse_0005.patch b/patches/jailhouse/jailhouse_0005.patch new file mode 100644 index 0000000..cafff2b --- /dev/null +++ b/patches/jailhouse/jailhouse_0005.patch @@ -0,0 +1,64 @@ +From d921eb56b4b0516a0bd46e9337c3deb773146faf Mon Sep 17 00:00:00 2001 +From: Jan Kiszka +Date: Tue, 21 Jun 2016 19:58:08 +0200 +Subject: [PATCH] pci: Add support for unbinding the generic PCI host + controller + +Particularly useful when working in virtual environments where the +controller may come and go, but possibly not only there. + +NOTE: leaks memory, see lkml thread! +--- + drivers/pci/host/pci-host-common.c | 13 +++++++++++++ + drivers/pci/host/pci-host-generic.c | 1 + + include/linux/pci-ecam.h | 1 + + 3 files changed, 15 insertions(+) + +diff --git a/drivers/pci/host/pci-host-common.c b/drivers/pci/host/pci-host-common.c +index 44a47d4..e0da836 100644 +--- a/drivers/pci/host/pci-host-common.c ++++ b/drivers/pci/host/pci-host-common.c +@@ -176,5 +176,18 @@ int pci_host_common_probe(struct platform_device *pdev, + } + + pci_bus_add_devices(bus); ++ platform_set_drvdata(pdev, bus); ++ return 0; ++} ++ ++int pci_host_common_remove(struct platform_device *pdev) ++{ ++ struct pci_bus *bus = platform_get_drvdata(pdev); ++ ++ pci_lock_rescan_remove(); ++ pci_stop_root_bus(bus); ++ pci_remove_root_bus(bus); ++ pci_unlock_rescan_remove(); ++ + return 0; + } +diff --git a/drivers/pci/host/pci-host-generic.c b/drivers/pci/host/pci-host-generic.c +index 7d709a7..b35057e 100644 +--- a/drivers/pci/host/pci-host-generic.c ++++ b/drivers/pci/host/pci-host-generic.c +@@ -63,5 +63,6 @@ static struct platform_driver gen_pci_driver = { + .suppress_bind_attrs = true, + }, + .probe = gen_pci_probe, ++ .remove = pci_host_common_remove, + }; + builtin_platform_driver(gen_pci_driver); +diff --git a/include/linux/pci-ecam.h b/include/linux/pci-ecam.h +index 809c2f1..36c9ddb 100644 +--- a/include/linux/pci-ecam.h ++++ b/include/linux/pci-ecam.h +@@ -73,5 +73,6 @@ extern struct pci_ecam_ops xgene_v2_pcie_ecam_ops; /* APM X-Gene PCIe v2.x */ + /* for DT-based PCI controllers that support ECAM */ + int pci_host_common_probe(struct platform_device *pdev, + struct pci_ecam_ops *ops); ++int pci_host_common_remove(struct platform_device *pdev); + #endif + #endif +-- +2.1.4 + diff --git a/patches/jailhouse/jailhouse_0006.patch b/patches/jailhouse/jailhouse_0006.patch new file mode 100644 index 0000000..8f0bbaf --- /dev/null +++ b/patches/jailhouse/jailhouse_0006.patch @@ -0,0 +1,9 @@ +diff --git a/lib/ioremap.c b/lib/ioremap.c +index b808a39..e486ef9 100644 +--- a/lib/ioremap.c ++++ b/lib/ioremap.c +@@ -179,3 +179,4 @@ int ioremap_page_range(unsigned long addr, + + return err; + } ++EXPORT_SYMBOL_GPL(ioremap_page_range); -- cgit v1.2.3-54-g00ecf