From: ard.biesheuvel@linaro.org (Ard Biesheuvel)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/4] efi/arm64: unmap the kernel while executing UEFI services
Date: Thu, 25 Jan 2018 10:31:31 +0000 [thread overview]
Message-ID: <20180125103131.19168-5-ard.biesheuvel@linaro.org> (raw)
In-Reply-To: <20180125103131.19168-1-ard.biesheuvel@linaro.org>
Now that all UEFI runtime service wrappers ensure that byref
arguments are moved into the UEFI marshalling buffer (which
is not part of the kernel mapping), we can proceed and unmap
the kernel while UEFI runtime service calls are in progress.
This is done by setting the EPD1 bit and flushing the TLB of
the local CPU. This makes it independent of KPTI or whether
non-global mappings are being used.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
arch/arm64/kernel/efi-rt-wrapper.S | 22 ++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/arch/arm64/kernel/efi-rt-wrapper.S b/arch/arm64/kernel/efi-rt-wrapper.S
index 09e77e5edd94..70af90ef914c 100644
--- a/arch/arm64/kernel/efi-rt-wrapper.S
+++ b/arch/arm64/kernel/efi-rt-wrapper.S
@@ -9,6 +9,24 @@
#include <linux/linkage.h>
#include <asm/efi.h>
+ .macro sepd1, reg
+ mrs \reg, tcr_el1 // read Translation Control Reg
+ orr \reg, \reg, #1 << 23 // set EPD1 bit
+ msr tcr_el1, \reg // write back TCR
+ isb
+ tlbi vmalle1
+ dsb nsh
+ .endm
+
+ .macro cepd1, reg
+ mrs \reg, tcr_el1 // read Translation Control Reg
+ bic \reg, \reg, #1 << 23 // clear EPD1 bit
+ msr tcr_el1, \reg // write back TCR
+ isb
+ tlbi vmalle1
+ dsb nsh
+ .endm
+
.section ".rodata", "a"
.align PAGE_SHIFT
ENTRY(__efi_rt_asm_wrapper)
@@ -27,6 +45,7 @@ ENTRY(__efi_rt_asm_wrapper)
adr x1, __efi_rt_vectors
msr vbar_el1, x1
isb
+ sepd1 x1
/*
* We are lucky enough that no EFI runtime services take more than
@@ -46,6 +65,7 @@ ENTRY(__efi_rt_asm_wrapper)
ldr x1, 2f
msr vbar_el1, x1
isb
+ cepd1 x1
ldp x1, x2, [sp, #16]
cmp x2, x18
@@ -63,6 +83,7 @@ ENDPROC(__efi_rt_asm_wrapper)
.align 7
.Lv\@ : stp x29, x30, [sp, #-16]! // preserve x29 and x30
mrs x29, elr_el1 // preserve ELR
+ cepd1 x30
adr x30, .Lret // take return address
msr elr_el1, x30 // set ELR to return address
ldr x30, 2b // take address of 'vectors'
@@ -76,6 +97,7 @@ ENDPROC(__efi_rt_asm_wrapper)
adr x30, __efi_rt_vectors
msr vbar_el1, x30
isb
+ sepd1 x30
ldp x29, x30, [sp], #16
eret
--
2.11.0
next prev parent reply other threads:[~2018-01-25 10:31 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-25 10:31 [PATCH 0/4] efi/arm64: unmap the kernel during runtime service calls Ard Biesheuvel
2018-01-25 10:31 ` [PATCH 1/4] efi: arm64: Check whether x18 is preserved by runtime services calls Ard Biesheuvel
2018-01-26 15:05 ` Will Deacon
2018-01-25 10:31 ` [PATCH 2/4] efi/arm64: map the stack and entry wrapper into the UEFI page tables Ard Biesheuvel
2018-01-26 16:57 ` Will Deacon
2018-01-26 17:03 ` Ard Biesheuvel
2018-01-26 17:09 ` Will Deacon
2018-01-25 10:31 ` [PATCH 3/4] efi/arm64: marshall runtime services arguments via buffer in TTBR0 Ard Biesheuvel
2018-01-25 10:31 ` Ard Biesheuvel [this message]
2018-01-26 17:05 ` [PATCH 4/4] efi/arm64: unmap the kernel while executing UEFI services Will Deacon
2018-01-26 17:06 ` Ard Biesheuvel
2018-01-26 17:10 ` Will Deacon
2018-01-29 14:51 ` [PATCH 0/4] efi/arm64: unmap the kernel during runtime service calls Jeffrey Hugo
2018-01-29 14:55 ` Ard Biesheuvel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180125103131.19168-5-ard.biesheuvel@linaro.org \
--to=ard.biesheuvel@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).