From 704f8b0a032ef3629ca45b383fbde9f7950b0430 Mon Sep 17 00:00:00 2001 From: Murali Nalajala Date: Thu, 3 Dec 2020 15:27:33 -0800 Subject: [PATCH 1/2] haven: ctrl: add debugfs interface to control hyp uart Hyp uart is disabled default today in ABL. Provide debugfs interface to users when they want to enable hyp uart to debug hypervisor and VM issues. Change-Id: I5e2c0501ed309a65c9dff1304b2e88e0d58917ae Signed-off-by: Murali Nalajala --- drivers/virt/haven/hh_ctrl.c | 84 +++++++++++++++++++++++++----------- 1 file changed, 59 insertions(+), 25 deletions(-) diff --git a/drivers/virt/haven/hh_ctrl.c b/drivers/virt/haven/hh_ctrl.c index c019bf411282..bdc288544ee4 100644 --- a/drivers/virt/haven/hh_ctrl.c +++ b/drivers/virt/haven/hh_ctrl.c @@ -15,9 +15,6 @@ #include #include -#define QC_HYP_SMCCC_UART_DISABLE \ - ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, ARM_SMCCC_SMC_32, \ - ARM_SMCCC_OWNER_VENDOR_HYPERVISOR, 0x0) #define QC_HYP_SMCCC_CALL_UID \ ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, ARM_SMCCC_SMC_32, \ ARM_SMCCC_OWNER_VENDOR_HYPERVISOR, 0xff01) @@ -48,27 +45,6 @@ static bool qc_hyp_calls; static struct hh_hcall_hyp_identify_resp haven_api; -static bool disable_uart; - -#if !defined(CONFIG_HH_DISABLE_UART) -static int __init setup_nohyp_uart(char *arg) -{ - disable_uart = true; - return 0; -} -early_param("nohyp_uart", setup_nohyp_uart); -#endif - -static void hh_disable_uart(void) -{ -#if defined(CONFIG_HH_DISABLE_UART) - disable_uart = true; -#endif - if (disable_uart) { - pr_info("Haven: disabling HYP UART\n"); - arm_smccc_1_1_smc(QC_HYP_SMCCC_UART_DISABLE, NULL); - } -} static ssize_t type_show(struct kobject *kobj, struct kobj_attribute *attr, char *buffer) @@ -119,7 +95,44 @@ static void __exit hh_sysfs_unregister(void) } #if defined(CONFIG_DEBUG_FS) + +#define QC_HYP_SMCCC_UART_DISABLE \ + ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, ARM_SMCCC_SMC_32, \ + ARM_SMCCC_OWNER_VENDOR_HYPERVISOR, 0x0) +#define QC_HYP_SMCCC_UART_ENABLE \ + ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, ARM_SMCCC_SMC_32, \ + ARM_SMCCC_OWNER_VENDOR_HYPERVISOR, 0x1) +#define ENABLE 1 +#define DISABLE 0 + static struct dentry *hh_dbgfs_dir; +static int hyp_uart_enable; + +static void hh_control_hyp_uart(int val) +{ + switch (val) { + case ENABLE: + if (!hyp_uart_enable) { + hyp_uart_enable = val; + pr_info("Haven: enabling HYP UART\n"); + arm_smccc_1_1_smc(QC_HYP_SMCCC_UART_ENABLE, NULL); + } else { + pr_info("Haven: HYP UART already enabled\n"); + } + break; + case DISABLE: + if (hyp_uart_enable) { + hyp_uart_enable = val; + pr_info("Haven: disabling HYP UART\n"); + arm_smccc_1_1_smc(QC_HYP_SMCCC_UART_DISABLE, NULL); + } else { + pr_info("Haven: HYP UART already disabled\n"); + } + break; + default: + pr_info("Haven: supported values disable(0)/enable(1)\n"); + } +} static int hh_dbgfs_trace_class_set(void *data, u64 val) { @@ -137,6 +150,18 @@ static int hh_dbgfs_trace_class_get(void *data, u64 *val) return hh_remap_error(hh_hcall_trace_update_class_flags(0, 0, val)); } +static int hh_dbgfs_hyp_uart_set(void *data, u64 val) +{ + hh_control_hyp_uart(val); + return 0; +} + +static int hh_dbgfs_hyp_uart_get(void *data, u64 *val) +{ + *val = hyp_uart_enable; + return 0; +} + DEFINE_DEBUGFS_ATTRIBUTE(hh_dbgfs_trace_class_set_fops, hh_dbgfs_trace_class_get, hh_dbgfs_trace_class_set, @@ -147,6 +172,11 @@ DEFINE_DEBUGFS_ATTRIBUTE(hh_dbgfs_trace_class_clear_fops, hh_dbgfs_trace_class_clear, "0x%llx\n"); +DEFINE_DEBUGFS_ATTRIBUTE(hh_dbgfs_hyp_uart_ctrl_fops, + hh_dbgfs_hyp_uart_get, + hh_dbgfs_hyp_uart_set, + "0x%llx\n"); + static int __init hh_dbgfs_register(void) { struct dentry *dentry; @@ -165,6 +195,11 @@ static int __init hh_dbgfs_register(void) NULL, &hh_dbgfs_trace_class_clear_fops); if (IS_ERR(dentry)) return PTR_ERR(dentry); + + dentry = debugfs_create_file("hyp_uart_ctrl", 0600, hh_dbgfs_dir, + NULL, &hh_dbgfs_hyp_uart_ctrl_fops); + if (IS_ERR(dentry)) + return PTR_ERR(dentry); } return 0; @@ -204,7 +239,6 @@ static int __init hh_ctrl_init(void) qc_hyp_calls = true; if (qc_hyp_calls) { - hh_disable_uart(); ret = hh_sysfs_register(); if (ret) return ret; From feb739798587369cff48a8a50a7a465681338cc1 Mon Sep 17 00:00:00 2001 From: Murali Nalajala Date: Thu, 3 Dec 2020 17:19:56 -0800 Subject: [PATCH 2/2] haven: remove config to disable hyp uart Hyp uart is default disabled from ABL now. There is no need of CONFIG_HH_DISABLE_UART option anymore. Hyp uart now can be controlled using DEBUG_FS interface. Change-Id: Ie1a0986399d30b89bf62468a23633994c8d6b11b Signed-off-by: Murali Nalajala --- arch/arm64/configs/vendor/genericarmv8-64_defconfig | 1 - arch/arm64/configs/vendor/lahaina_consolidate.config | 1 - drivers/virt/haven/Kconfig | 11 ----------- 3 files changed, 13 deletions(-) diff --git a/arch/arm64/configs/vendor/genericarmv8-64_defconfig b/arch/arm64/configs/vendor/genericarmv8-64_defconfig index 22da3d46d77e..2f3424e04bc4 100644 --- a/arch/arm64/configs/vendor/genericarmv8-64_defconfig +++ b/arch/arm64/configs/vendor/genericarmv8-64_defconfig @@ -213,7 +213,6 @@ CONFIG_MSM_GPI_DMA_DEBUG=y CONFIG_VIRT_DRIVERS=y CONFIG_HAVEN_DRIVERS=y CONFIG_HH_CTRL=y -# CONFIG_HH_DISABLE_UART is not set CONFIG_HH_MSGQ=y CONFIG_HH_RM_DRV=y CONFIG_HH_DBL=y diff --git a/arch/arm64/configs/vendor/lahaina_consolidate.config b/arch/arm64/configs/vendor/lahaina_consolidate.config index 42fb0ad5458e..0a227034bc4d 100644 --- a/arch/arm64/configs/vendor/lahaina_consolidate.config +++ b/arch/arm64/configs/vendor/lahaina_consolidate.config @@ -50,7 +50,6 @@ CONFIG_DEBUG_PANIC_ON_OOM=y CONFIG_USB_F_FS_IPC_LOGGING=y CONFIG_DYNAMIC_DEBUG=y CONFIG_QTI_PMIC_GLINK_CLIENT_DEBUG=y -# CONFIG_HH_DISABLE_UART is not set CONFIG_DEBUG_MODULE_LOAD_INFO=y CONFIG_QCOM_MINIDUMP_FTRACE=y CONFIG_QCOM_MINIDUMP_PANIC_DUMP=y diff --git a/drivers/virt/haven/Kconfig b/drivers/virt/haven/Kconfig index fdb017f5995f..b67c71ffd000 100644 --- a/drivers/virt/haven/Kconfig +++ b/drivers/virt/haven/Kconfig @@ -25,17 +25,6 @@ config HH_CTRL hypervisor debug features. See Documentation/ABI/testing/sysfs-hypervisor-haven for more details. -if HH_CTRL -config HH_DISABLE_UART - bool "Disable Haven UART print during kernel boot" - default y - help - The hypervisor UART driver is enabled at boot, - however its use may conflict with use of the - Linux driver. This config requests Haven to - disable its UART driver. -endif - config HH_MSGQ tristate "Haven Message Queue driver" help