From 4d5253258a3fe55a8130ae39ce60e276dba0882c Mon Sep 17 00:00:00 2001 From: meganz009 Date: Thu, 1 Jun 2023 23:10:15 +0800 Subject: [PATCH 1/5] Drivers: hv: vmbus: include header for get_irq_regs() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit 42e5ab6924b31025c97846b749ebe188ee4b5fdd upstream. On !RT the header file get_irq_regs() gets pulled in via other header files. On RT it does not and the build fails: drivers/hv/vmbus_drv.c:975 implicit declaration of function ‘get_irq_regs’ [-Werror=implicit-function-declaration] drivers/hv/hv.c:115 implicit declaration of function ‘get_irq_regs’ [-Werror=implicit-function-declaration] Add the header file for get_irq_regs() in a common header so it used by vmbus_drv.c by hv.c for their get_irq_regs() usage. Reported-by: Bernhard Landauer Reported-by: Ralf Ramsauer Signed-off-by: Sebastian Andrzej Siewior --- drivers/hv/hyperv_vmbus.h | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h index 87d3d7da78f8..1d2d8a4b837d 100644 --- a/drivers/hv/hyperv_vmbus.h +++ b/drivers/hv/hyperv_vmbus.h @@ -31,6 +31,7 @@ #include #include #include +#include #include "hv_trace.h" -- Gitee From dcf6c136d1d2df59c33dea53c98fdcf27c9c0165 Mon Sep 17 00:00:00 2001 From: meganz009 Date: Thu, 1 Jun 2023 23:11:36 +0800 Subject: [PATCH 2/5] percpu: include irqflags.h for raw_local_irq_save() commit bc0b4a3ef268cec82163752ddaa730d8ec193d7c upstream. The header percpu.h header file is using raw_local_irq_save() but does not include irqflags.h for its definition. It compiles because the header file is included via an other header file. On -RT the build fails because raw_local_irq_save() is not defined. Include irqflags.h in percpu.h. Signed-off-by: Sebastian Andrzej Siewior --- include/asm-generic/percpu.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/asm-generic/percpu.h b/include/asm-generic/percpu.h index 1817a8415a5e..942d64c0476e 100644 --- a/include/asm-generic/percpu.h +++ b/include/asm-generic/percpu.h @@ -5,6 +5,7 @@ #include #include #include +#include #ifdef CONFIG_SMP -- Gitee From 7eaa2ae9b7aa006a738714b07abdb96ca34ce151 Mon Sep 17 00:00:00 2001 From: meganz009 Date: Thu, 1 Jun 2023 23:12:23 +0800 Subject: [PATCH 3/5] efi: Allow efi=runtime commit da834999f8c566ac722fd157de36dd3f9335c2ad upstream. In case the option "efi=noruntime" is default at built-time, the user could overwrite its sate by `efi=runtime' and allow it again. Acked-by: Ard Biesheuvel Signed-off-by: Sebastian Andrzej Siewior --- drivers/firmware/efi/efi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 31c98f693ece..6f68a8b5cc52 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -114,6 +114,9 @@ static int __init parse_efi_cmdline(char *str) if (parse_option_str(str, "noruntime")) disable_runtime = true; + if (parse_option_str(str, "runtime")) + disable_runtime = false; + return 0; } early_param("efi", parse_efi_cmdline); -- Gitee From b79d1cb84186db7e82600631b95b1f504571f489 Mon Sep 17 00:00:00 2001 From: meganz009 Date: Thu, 1 Jun 2023 23:12:32 +0800 Subject: [PATCH 4/5] x86/efi: drop task_lock() from efi_switch_mm() commit d24d03df7b0c0b6a0975a373a815487a220ee93b upstream. efi_switch_mm() is a wrapper around switch_mm() which saves current's ->active_mm, sets the requests mm as ->active_mm and invokes switch_mm(). I don't think that task_lock() is required during that procedure. It protects ->mm which isn't changed here. It needs to be mentioned that during the whole procedure (switch to EFI's mm and back) the preemption needs to be disabled. A context switch at this point would reset the cr3 value based on current->mm. Also, this function may not be invoked at the same time on a different CPU because it would overwrite the efi_scratch.prev_mm information. Remove task_lock() and also update the comment to reflect it. Signed-off-by: Sebastian Andrzej Siewior --- arch/x86/platform/efi/efi_64.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c index dfc809b31c7c..3b7dd7064d04 100644 --- a/arch/x86/platform/efi/efi_64.c +++ b/arch/x86/platform/efi/efi_64.c @@ -622,18 +622,16 @@ void __init efi_dump_pagetable(void) /* * Makes the calling thread switch to/from efi_mm context. Can be used - * for SetVirtualAddressMap() i.e. current->active_mm == init_mm as well - * as during efi runtime calls i.e current->active_mm == current_mm. - * We are not mm_dropping()/mm_grabbing() any mm, because we are not - * losing/creating any references. + * in a kernel thread and user context. Preemption needs to remain disabled + * while the EFI-mm is borrowed. mmgrab()/mmdrop() is not used because the mm + * can not change under us. + * It should be ensured that there are no concurent calls to this function. */ void efi_switch_mm(struct mm_struct *mm) { - task_lock(current); efi_scratch.prev_mm = current->active_mm; current->active_mm = mm; switch_mm(efi_scratch.prev_mm, mm, NULL); - task_unlock(current); } #ifdef CONFIG_EFI_MIXED -- Gitee From 20a15c2573349b5a8d092f9e64e16339a5ecec2d Mon Sep 17 00:00:00 2001 From: meganz009 Date: Thu, 1 Jun 2023 23:12:48 +0800 Subject: [PATCH 5/5] arm64: KVM: compute_layout before altenates are applied commit 057073be1e10190ea715360a6fde5478df36b563 upstream. compute_layout() is invoked as part of an alternative fixup under stop_machine() and needs a sleeping lock as part of get_random_long(). Invoke compute_layout() before the alternatives are applied. Signed-off-by: Sebastian Andrzej Siewior --- arch/arm64/include/asm/alternative.h | 6 ++++++ arch/arm64/kernel/alternative.c | 1 + arch/arm64/kvm/va_layout.c | 7 +------ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/arch/arm64/include/asm/alternative.h b/arch/arm64/include/asm/alternative.h index b9f8d787eea9..7532f044d713 100644 --- a/arch/arm64/include/asm/alternative.h +++ b/arch/arm64/include/asm/alternative.h @@ -35,6 +35,12 @@ void apply_alternatives_module(void *start, size_t length); static inline void apply_alternatives_module(void *start, size_t length) { } #endif +#ifdef CONFIG_KVM_ARM_HOST +void kvm_compute_layout(void); +#else +static inline void kvm_compute_layout(void) { } +#endif + #define ALTINSTR_ENTRY(feature,cb) \ " .word 661b - .\n" /* label */ \ " .if " __stringify(cb) " == 0\n" \ diff --git a/arch/arm64/kernel/alternative.c b/arch/arm64/kernel/alternative.c index a9b467763153..8cd880c51764 100644 --- a/arch/arm64/kernel/alternative.c +++ b/arch/arm64/kernel/alternative.c @@ -249,6 +249,7 @@ static int __apply_alternatives_multi_stop(void *unused) void __init apply_alternatives_all(void) { /* better not try code patching on a live SMP system */ + kvm_compute_layout(); stop_machine(__apply_alternatives_multi_stop, NULL, cpu_online_mask); } diff --git a/arch/arm64/kvm/va_layout.c b/arch/arm64/kvm/va_layout.c index c712a7376bc1..792da0e125de 100644 --- a/arch/arm64/kvm/va_layout.c +++ b/arch/arm64/kvm/va_layout.c @@ -33,7 +33,7 @@ static u8 tag_lsb; static u64 tag_val; static u64 va_mask; -static void compute_layout(void) +__init void kvm_compute_layout(void) { phys_addr_t idmap_addr = __pa_symbol(__hyp_idmap_text_start); u64 hyp_va_msb; @@ -121,8 +121,6 @@ void __init kvm_update_va_mask(struct alt_instr *alt, BUG_ON(nr_inst != 5); - if (!has_vhe() && !va_mask) - compute_layout(); for (i = 0; i < nr_inst; i++) { u32 rd, rn, insn, oinsn; @@ -167,9 +165,6 @@ void kvm_patch_vector_branch(struct alt_instr *alt, return; } - if (!va_mask) - compute_layout(); - /* * Compute HYP VA by using the same computation as kern_hyp_va() */ -- Gitee