Re: [PATCH 1/2] x86/traps: call cond_local_irq_disable before returning from exc_general_protection and math_error

2021-04-09 Thread Alexandre Chartre
+-- 1 file changed, 2 insertions(+), 2 deletions(-) Reviewed-by: Alexandre Chartre And it is probably worth adding a 'Fixes:' tag: Fixes: 334872a09198 ("x86/traps: Attempt to fixup exceptions in vDSO before signaling") alex.

[PATCH] x86/alternatives: check int3 breakpoint physical addresses

2019-01-25 Thread Alexandre Chartre
addresses. Signed-off-by: Alexandre Chartre Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: H. Peter Anvin Cc: Josh Poimboeuf Cc: x...@kernel.org --- This is a potential issue and I don't know if it can be triggered with the current kernel: is there any code mapped to m

Re: [for-stable-4.19 PATCH 1/2] vmlinux.lds.h: Create section for protection against instrumentation

2021-03-19 Thread Alexandre Chartre
instrumentation markers are only active when CONFIG_DEBUG_ENTRY is enabled as the end marker emits a NOP to prevent the compiler from merging the annotation points. This means the objtool verification requires a kernel compiled with this option. Signed-off-by: Thomas Gleixner Reviewed-by: Alexandre

Re: [PATCH 2/2] arch/x86: arch/sparc: tools/perf: fix typos in comments

2021-04-09 Thread Alexandre Chartre
++-- 4 files changed, 5 insertions(+), 5 deletions(-) Reviewed-by: Alexandre Chartre alex.

Re: [RFC][PATCH v2 12/21] x86/pti: Use PTI stack instead of trampoline stack

2020-11-17 Thread Alexandre Chartre
On 11/16/20 7:34 PM, Andy Lutomirski wrote: On Mon, Nov 16, 2020 at 10:10 AM Alexandre Chartre wrote: On 11/16/20 5:57 PM, Andy Lutomirski wrote: On Mon, Nov 16, 2020 at 6:47 AM Alexandre Chartre wrote: When entering the kernel from userland, use the per-task PTI stack instead of the

Re: [RFC][PATCH v2 12/21] x86/pti: Use PTI stack instead of trampoline stack

2020-11-17 Thread Alexandre Chartre
On 11/17/20 4:52 PM, Andy Lutomirski wrote: On Tue, Nov 17, 2020 at 7:07 AM Alexandre Chartre wrote: On 11/16/20 7:34 PM, Andy Lutomirski wrote: On Mon, Nov 16, 2020 at 10:10 AM Alexandre Chartre wrote: On 11/16/20 5:57 PM, Andy Lutomirski wrote: On Mon, Nov 16, 2020 at 6:47 AM

Re: [RFC][PATCH v2 00/21] x86/pti: Defer CR3 switch to C code

2020-11-17 Thread Alexandre Chartre
On 11/17/20 5:55 PM, Borislav Petkov wrote: On Tue, Nov 17, 2020 at 08:56:23AM +0100, Alexandre Chartre wrote: The main goal of ASI is to provide KVM address space isolation to mitigate guest-to-host speculative attacks like L1TF or MDS. Because the current L1TF and MDS mitigations are

Re: [RFC][PATCH v2 00/21] x86/pti: Defer CR3 switch to C code

2020-11-17 Thread Alexandre Chartre
On 11/17/20 6:07 PM, Borislav Petkov wrote: On Tue, Nov 17, 2020 at 09:19:01AM +0100, Alexandre Chartre wrote: We are not reversing PTI, we are extending it. You're reversing it in the sense that you're mapping more kernel memory into the user page table than what is mapped

Re: [RFC][PATCH v2 00/21] x86/pti: Defer CR3 switch to C code

2020-11-17 Thread Alexandre Chartre
On 11/17/20 7:28 PM, Borislav Petkov wrote: On Tue, Nov 17, 2020 at 07:12:07PM +0100, Alexandre Chartre wrote: Yes. L1TF/MDS allow some inter cpu-thread attacks which are not mitigated at the moment. In particular, this allows a guest VM to attack another guest VM or the host kernel running

Re: [RFC][PATCH v2 00/21] x86/pti: Defer CR3 switch to C code

2020-11-17 Thread Alexandre Chartre
On 11/17/20 10:23 PM, Borislav Petkov wrote: On Tue, Nov 17, 2020 at 08:02:51PM +0100, Alexandre Chartre wrote: No. This prevents the guest VM from gathering data from the host kernel on the same cpu-thread. But there's no mitigation for a guest VM running on a cpu-thread attacking an

Re: [RFC][PATCH v2 00/21] x86/pti: Defer CR3 switch to C code

2020-11-17 Thread Alexandre Chartre
On 11/17/20 10:26 PM, Borislav Petkov wrote: On Tue, Nov 17, 2020 at 07:12:07PM +0100, Alexandre Chartre wrote: Some benchmarks are available, in particular from phoronix: What I was expecting was benchmarks *you* have run which show that perf penalty, not something one can find quickly on

Re: [RFC][PATCH v2 00/21] x86/pti: Defer CR3 switch to C code

2020-11-18 Thread Alexandre Chartre
On 11/18/20 10:30 AM, David Laight wrote: From: Alexandre Chartre Sent: 18 November 2020 07:42 On 11/17/20 10:26 PM, Borislav Petkov wrote: On Tue, Nov 17, 2020 at 07:12:07PM +0100, Alexandre Chartre wrote: Some benchmarks are available, in particular from phoronix: What I was expecting

Re: [RFC][PATCH v2 00/21] x86/pti: Defer CR3 switch to C code

2020-11-18 Thread Alexandre Chartre
On 11/18/20 2:22 PM, David Laight wrote: From: Alexandre Chartre Sent: 18 November 2020 10:30 ... Correct, this RFC is not changing the overhead. However, it is a step forward for being able to execute some selected syscalls or interrupt handlers without switching to the kernel page-table

Re: [RFC][PATCH v2 00/21] x86/pti: Defer CR3 switch to C code

2020-11-18 Thread Alexandre Chartre
On 11/18/20 12:29 PM, Borislav Petkov wrote: On Wed, Nov 18, 2020 at 08:41:42AM +0100, Alexandre Chartre wrote: Well, it looks like I wrongfully assume that KPTI was a well known performance overhead since it was introduced (because it adds extra page-table switches), but you are right I

Re: [RFC][PATCH v2 12/21] x86/pti: Use PTI stack instead of trampoline stack

2020-11-19 Thread Alexandre Chartre
On 11/19/20 2:49 AM, Andy Lutomirski wrote: On Tue, Nov 17, 2020 at 8:59 AM Alexandre Chartre wrote: On 11/17/20 4:52 PM, Andy Lutomirski wrote: On Tue, Nov 17, 2020 at 7:07 AM Alexandre Chartre wrote: On 11/16/20 7:34 PM, Andy Lutomirski wrote: On Mon, Nov 16, 2020 at 10:10 AM

Re: [RFC][PATCH v2 12/21] x86/pti: Use PTI stack instead of trampoline stack

2020-11-19 Thread Alexandre Chartre
On 11/19/20 9:05 AM, Alexandre Chartre wrote: When entering the kernel from userland, use the per-task PTI stack instead of the per-cpu trampoline stack. Like the trampoline stack, the PTI stack is mapped both in the kernel and in the user page-table. Using a per-task stack which is mapped

Re: [RFC][PATCH v2 12/21] x86/pti: Use PTI stack instead of trampoline stack

2020-11-19 Thread Alexandre Chartre
On 11/19/20 5:06 PM, Andy Lutomirski wrote: On Thu, Nov 19, 2020 at 4:06 AM Alexandre Chartre wrote: On 11/19/20 9:05 AM, Alexandre Chartre wrote: When entering the kernel from userland, use the per-task PTI stack instead of the per-cpu trampoline stack. Like the trampoline stack, the PTI

Re: [RFC][PATCH v2 12/21] x86/pti: Use PTI stack instead of trampoline stack

2020-11-19 Thread Alexandre Chartre
On 11/19/20 8:10 PM, Thomas Gleixner wrote: On Mon, Nov 16 2020 at 19:10, Alexandre Chartre wrote: On 11/16/20 5:57 PM, Andy Lutomirski wrote: On Mon, Nov 16, 2020 at 6:47 AM Alexandre Chartre wrote: When executing more code in the kernel, we are likely to reach a point where we need to

Re: [PATCH] x86/alternatives: check int3 breakpoint physical addresses

2019-02-11 Thread Alexandre Chartre
On 02/10/2019 10:23 PM, Thomas Gleixner wrote: On Fri, 25 Jan 2019, Alexandre Chartre wrote: Note that this issue has been observed and reproduced with a custom kernel with some code mapped to different virtual addresses and using jump labels As jump labels use text_poke_bp(), crashes were

Re: [PATCH] x86/alternatives: check int3 breakpoint physical addresses

2019-02-11 Thread Alexandre Chartre
On 02/11/2019 10:15 AM, Thomas Gleixner wrote: On Mon, 11 Feb 2019, Alexandre Chartre wrote: On 02/10/2019 10:23 PM, Thomas Gleixner wrote: On Fri, 25 Jan 2019, Alexandre Chartre wrote: Note that this issue has been observed and reproduced with a custom kernel with some code mapped to

Re: [RFC v2 00/27] Kernel Address Space Isolation

2019-08-22 Thread Alexandre Chartre
, 2019 at 02:17:20PM +0200, Alexandre Chartre wrote: On 7/12/19 1:44 PM, Peter Zijlstra wrote: AFAIK3 this wants/needs to be combined with core-scheduling to be useful, but not a single mention of that is anywhere. No. This is actually an alternative to core-scheduling. Eventually, ASI will kick

[RFC v4][PATCH part-1 2/7] mm/asi: ASI entry/exit interface

2020-05-04 Thread Alexandre Chartre
ASI session structure (struct asi_session). Signed-off-by: Alexandre Chartre --- arch/x86/include/asm/asi.h | 4 ++ arch/x86/include/asm/asi_session.h | 17 ++ arch/x86/include/asm/mmu_context.h | 19 ++- arch/x86/include/asm/tlbflush.h| 12 arch/x86/mm/asi.c

[RFC v4][PATCH part-1 0/7] ASI - Part I (ASI Infrastructure and PTI)

2020-05-04 Thread Alexandre Chartre
.char...@oracle.com [4] Core Scheduling - https://lwn.net/Articles/803652 [5] Page Table Isolation (PTI) - https://www.kernel.org/doc/html/latest/x86/pti.html Thanks, alex. ----- Alexandre Chartre (7): mm/x86: Introduce kernel Address Space Isolation (ASI) mm/asi: ASI entry/exit interface mm/asi: Im

[RFC v4][PATCH part-1 5/7] mm/asi: Exit/enter ASI when task enters/exits scheduler

2020-05-04 Thread Alexandre Chartre
Exit ASI as soon as a task is entering the scheduler (__schedule()), otherwise ASI will likely quick fault, for example when accessing run queues. The task will return to ASI when it is scheduled again. Signed-off-by: Alexandre Chartre --- arch/x86/include/asm/asi.h | 3 ++ arch/x86/mm/asi.c

[RFC v4][PATCH part-1 3/7] mm/asi: Improve TLB flushing when switching to an ASI pagetable

2020-05-04 Thread Alexandre Chartre
ave a new generation of the same ASI pagetable, then the TLB needs to be flushed. This behavior is similar to the context tracking done when switching mm. Signed-off-by: Alexandre Chartre --- arch/x86/include/asm/asi.h | 23 +++ arch/x86/mm/asi.c

[RFC v4][PATCH part-1 4/7] mm/asi: Interrupt ASI on interrupt/exception/NMI

2020-05-04 Thread Alexandre Chartre
: Alexandre Chartre --- arch/x86/entry/calling.h | 26 +- arch/x86/entry/entry_64.S | 22 ++ arch/x86/include/asm/asi.h | 122 + arch/x86/include/asm/asi_session.h | 7 ++ arch/x86/include/asm/mmu_context.h | 3 +- arch/x86/kernel/asm

[RFC v4][PATCH part-1 6/7] mm/asi: ASI fault handler

2020-05-04 Thread Alexandre Chartre
aborted then the location and address of the fault can be logged and optionally include a stack trace. Signed-off-by: Alexandre Chartre --- arch/x86/include/asm/asi.h | 42 - arch/x86/mm/asi.c | 95 ++ arch/x86/mm/fault.c| 20

[RFC v4][PATCH part-1 1/7] mm/x86: Introduce kernel Address Space Isolation (ASI)

2020-05-04 Thread Alexandre Chartre
type and a pagetable. Signed-off-by: Alexandre Chartre --- arch/x86/include/asm/asi.h | 88 ++ arch/x86/mm/Makefile | 1 + arch/x86/mm/asi.c | 60 ++ security/Kconfig | 10 + 4 files changed, 159 insertions

[RFC v4][PATCH part-1 7/7] mm/asi: Implement PTI with ASI

2020-05-04 Thread Alexandre Chartre
re returning to userland. Signed-off-by: Alexandre Chartre --- arch/x86/entry/calling.h| 13 - arch/x86/entry/common.c | 29 - arch/x86/entry/entry_64.S | 6 ++ arch/x86/include/asm/asi.h | 9 + arch/x86/include/asm/

[RFC v4][PATCH part-2 01/13] mm/x86: Introduce decorated page-table (dpt)

2020-05-04 Thread Alexandre Chartre
references to another page-table. Signed-off-by: Alexandre Chartre --- arch/x86/include/asm/dpt.h | 23 + arch/x86/mm/Makefile | 2 +- arch/x86/mm/dpt.c | 67 ++ 3 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 arch

[RFC v4][PATCH part-2 05/13] mm/dpt: Add decorated page-table entry set functions

2020-05-04 Thread Alexandre Chartre
Add wrappers around the page table entry (pgd/p4d/pud/pmd) set functions which check that an existing entry is not being overwritten. Signed-off-by: Alexandre Chartre --- arch/x86/mm/dpt.c | 126 ++ 1 file changed, 126 insertions(+) diff --git a/arch

[RFC v4][PATCH part-2 04/13] mm/dpt: Add decorated page-table entry allocation functions

2020-05-04 Thread Alexandre Chartre
Add functions to allocate p4d/pud/pmd/pte pages for an decorated page-table and keep track of them. Signed-off-by: Alexandre Chartre --- arch/x86/mm/dpt.c | 110 ++ 1 file changed, 110 insertions(+) diff --git a/arch/x86/mm/dpt.c b/arch/x86/mm/dpt.c

[RFC v4][PATCH part-2 03/13] mm/dpt: Add decorated page-table entry offset functions

2020-05-04 Thread Alexandre Chartre
Add wrappers around the p4d/pud/pmd/pte offset kernel functions which ensure that page-table pointers are in the specified decorated page-table. Signed-off-by: Alexandre Chartre --- arch/x86/mm/dpt.c | 66 +++ 1 file changed, 66 insertions(+) diff

[RFC v4][PATCH part-2 06/13] mm/dpt: Functions to populate a decorated page-table from a VA range

2020-05-04 Thread Alexandre Chartre
level (PGD, P4D, PUD PMD, PTE) at which the copy should be done. Also functions don't rely on mm or vma, and they don't alter the source page-table even if an entry is bad. Finally, the VA range start and size don't need to be page-aligned. Signed-off-by: Alexandre Chartre --- arch/

[RFC v4][PATCH part-2 08/13] mm/dpt: Keep track of VA ranges mapped in a decorated page-table

2020-05-04 Thread Alexandre Chartre
Add functions to keep track of VA ranges mapped in a decorated page-table. This will be used when unmapping to ensure the same range is unmapped, at the same page-table level. This will also be used to handle mapping and unmapping of overlapping VA ranges. Signed-off-by: Alexandre Chartre

[RFC v4][PATCH part-2 07/13] mm/dpt: Helper functions to map module into a decorated page-table

2020-05-04 Thread Alexandre Chartre
Add helper functions to easily map a module into a decorated page-table. Signed-off-by: Alexandre Chartre --- arch/x86/include/asm/dpt.h | 21 + 1 file changed, 21 insertions(+) diff --git a/arch/x86/include/asm/dpt.h b/arch/x86/include/asm/dpt.h index 85d2c5051acb

[RFC v4][PATCH part-2 00/13] ASI - Part II (Decorated Page-Table)

2020-05-04 Thread Alexandre Chartre
part III) and later by KVM ASI. Decorated page-table is independent of ASI, and can potentially be used anywhere a page-table is needed. Thanks, alex. - Alexandre Chartre (13): mm/x86: Introduce decorated page-table (dpt) mm/dpt: Track buffers allocated for a decorated page-table mm/dpt

[RFC v4][PATCH part-2 10/13] mm/dpt: Function to copy page-table entries for percpu buffer

2020-05-04 Thread Alexandre Chartre
Provide functions to copy page-table entries from the kernel page-table to a decorated page-table for a percpu buffer. A percpu buffer have a different VA range for each cpu and all them have to be copied. Signed-off-by: Alexandre Chartre --- arch/x86/include/asm/dpt.h | 6 ++ arch/x86/mm

[RFC v4][PATCH part-2 09/13] mm/dpt: Functions to clear decorated page-table entries for a VA range

2020-05-04 Thread Alexandre Chartre
another page table is not modified by mistake. As information (address, size, page-table level) about VA ranges mapped to the decorated page-table is tracked, clearing is done with just specifying the start address of the range. Signed-off-by: Alexandre Chartre --- arch/x86/include/asm/dpt.h

[RFC v4][PATCH part-2 13/13] mm/asi: Function to init decorated page-table with ASI core mappings

2020-05-04 Thread Alexandre Chartre
-by: Alexandre Chartre --- arch/x86/include/asm/asi.h | 2 ++ arch/x86/mm/asi.c | 57 ++ 2 files changed, 59 insertions(+) diff --git a/arch/x86/include/asm/asi.h b/arch/x86/include/asm/asi.h index ac0594d4f549..eafed750e07f 100644 --- a/arch/x86

[RFC v4][PATCH part-2 11/13] mm/dpt: Add decorated page-table remap function

2020-05-04 Thread Alexandre Chartre
: Alexandre Chartre --- arch/x86/include/asm/dpt.h | 1 + arch/x86/mm/dpt.c | 25 + 2 files changed, 26 insertions(+) diff --git a/arch/x86/include/asm/dpt.h b/arch/x86/include/asm/dpt.h index fd8c1b84ffe2..3234ba968d80 100644 --- a/arch/x86/include/asm/dpt.h +++ b/arch

[RFC v4][PATCH part-2 02/13] mm/dpt: Track buffers allocated for a decorated page-table

2020-05-04 Thread Alexandre Chartre
not parts of the kernel page table referenced from the page-table. To do so, we will keep track of buffers when building the page-table. Signed-off-by: Alexandre Chartre --- arch/x86/include/asm/dpt.h | 21 ++ arch/x86/mm/dpt.c | 82 ++ 2 files

[RFC v4][PATCH part-3 08/14] asidrv: Sequence to test scheduling in/out with ASI

2020-05-04 Thread Alexandre Chartre
Add a sequence to test if an ASI remains active after it is scheduled out and then scheduled back in. Signed-off-by: Alexandre Chartre --- drivers/staging/asi/asidrv.c | 98 drivers/staging/asi/asidrv.h | 2 + 2 files changed, 100 insertions(+) diff --git

[RFC v4][PATCH part-3 14/14] asidrv/asicmd: Add options to manage ASI mapped VA ranges

2020-05-04 Thread Alexandre Chartre
Add options to the asicmd CLI to list, add and clear ASI mapped VA ranges. Signed-off-by: Alexandre Chartre --- drivers/staging/asi/asicmd.c | 243 +++ 1 file changed, 243 insertions(+) diff --git a/drivers/staging/asi/asicmd.c b/drivers/staging/asi/asicmd.c

[RFC v4][PATCH part-3 02/14] asidrv: Introduce the ASI driver

2020-05-04 Thread Alexandre Chartre
Introduce the infrastructure for the ASI driver. This driver is meant for testing ASI. It creates a test ASI, and will allow to run some test sequences on this ASI. Signed-off-by: Alexandre Chartre --- drivers/staging/asi/Makefile | 7 ++ drivers/staging/asi/asidrv.c | 129

[RFC v4][PATCH part-2 12/13] mm/dpt: Handle decorated page-table mapped range leaks and overlaps

2020-05-04 Thread Alexandre Chartre
. Also data effectively mapped can overlap with an already mapped buffer. This is not an issue when mapping data but, when unmapping, make sure data from another buffer don't get unmapped as a side effect. Signed-off-by: Alexandre Chartre --- arch/x86/include/asm/dpt.h | 1 + arch/x86/mm/

[RFC v4][PATCH part-3 07/14] asidrv: Sequence to test interrupt+NMI on ASI

2020-05-04 Thread Alexandre Chartre
Add a sequence to test if an ASI remains active after receiving an interrupt which is itself interrupted by an NMI. Signed-off-by: Alexandre Chartre --- drivers/staging/asi/asidrv.c | 62 +++- drivers/staging/asi/asidrv.h | 1 + 2 files changed, 62 insertions

[RFC v4][PATCH part-3 03/14] asidrv: Introduce the ASIDRV_IOCTL_RUN_SEQUENCE ioctl

2020-05-04 Thread Alexandre Chartre
ASI; - ASIDRV_SEQ_PRINTK calls printk while running with ASI. Signed-off-by: Alexandre Chartre --- drivers/staging/asi/asidrv.c | 248 +++ drivers/staging/asi/asidrv.h | 29 2 files changed, 277 insertions(+) create mode 100644 drivers/staging/asi/asidrv.h

[RFC v4][PATCH part-3 11/14] asidrv/asicmd: Introduce the asicmd command

2020-05-04 Thread Alexandre Chartre
The asicmd command is a userland CLI to interact with the ASI driver (asidrv), in particular it provides an interface for running ASI test sequences. Signed-off-by: Alexandre Chartre --- drivers/staging/asi/Makefile | 6 ++ drivers/staging/asi/asicmd.c | 120

[RFC v4][PATCH part-3 06/14] asidrv: Sequence to test NMI on ASI

2020-05-04 Thread Alexandre Chartre
Add a sequence to test if an ASI remains active after receiving an NMI. Signed-off-by: Alexandre Chartre --- drivers/staging/asi/asidrv.c | 116 ++- drivers/staging/asi/asidrv.h | 4 ++ 2 files changed, 118 insertions(+), 2 deletions(-) diff --git a/drivers

[RFC v4][PATCH part-3 12/14] asidrv/asicmd: Add more test sequences for testing ASI

2020-05-04 Thread Alexandre Chartre
Add more options to the asicmd command to test access to map or unmapped memory buffer, interrupt, NMI, scheduling while using ASI. Signed-off-by: Alexandre Chartre --- drivers/staging/asi/asicmd.c | 14 ++ 1 file changed, 14 insertions(+) diff --git a/drivers/staging/asi/asicmd.c

[RFC v4][PATCH part-3 01/14] mm/asi: Define the test ASI type

2020-05-04 Thread Alexandre Chartre
Define the test ASI type which can be used for testing or experimenting ASI. Signed-off-by: Alexandre Chartre --- arch/x86/include/asm/asi.h | 2 ++ arch/x86/mm/asi.c | 1 + drivers/staging/Makefile | 1 + 3 files changed, 4 insertions(+) diff --git a/arch/x86/include/asm/asi.h b

[RFC v4][PATCH part-3 00/14] ASI - Part III (ASI Test Driver and CLI)

2020-05-04 Thread Alexandre Chartre
AILED - unexpected ASI state # ./asicmd fault ADDRESS COUNT SYMBOL 0x811081f3 1 log_store.constprop.27+0x1f3/0x280 We still see a new fault but at a difference address (this time because cpu_number is not mapped). - Alexandre Chartre (14): mm/asi: Define the test ASI type

[RFC v4][PATCH part-3 05/14] asidrv: Sequence to test interrupt on ASI

2020-05-04 Thread Alexandre Chartre
Add a sequence to test if an ASI remains active after receiving an interrupt. Signed-off-by: Alexandre Chartre --- drivers/staging/asi/asidrv.c | 144 +-- drivers/staging/asi/asidrv.h | 5 ++ 2 files changed, 144 insertions(+), 5 deletions(-) diff --git a

[RFC v4][PATCH part-3 04/14] asidrv: Sequence to test ASI access to mapped/unmapped memory

2020-05-04 Thread Alexandre Chartre
Add a sequence to test if ASI exit or not when accessing a mapped or unmapped memory buffer. Signed-off-by: Alexandre Chartre --- drivers/staging/asi/asidrv.c | 70 drivers/staging/asi/asidrv.h | 3 ++ 2 files changed, 73 insertions(+) diff --git a/drivers

[RFC v4][PATCH part-3 13/14] asidrv/asicmd: Add options to manage ASI page faults

2020-05-04 Thread Alexandre Chartre
Add options to the asicmd CLI to list and clear ASI page faults. Also add an option to enable/disable displaying stack trace on ASI page fault. Signed-off-by: Alexandre Chartre --- drivers/staging/asi/asicmd.c | 68 ++-- 1 file changed, 65 insertions(+), 3

[RFC v4][PATCH part-3 09/14] asidrv: Add ioctls to manage ASI page faults

2020-05-04 Thread Alexandre Chartre
Add ioctls to list and clear ASI page faults. Also add an ioctl to display or not stack trace on ASI page fault. Signed-off-by: Alexandre Chartre --- drivers/staging/asi/asidrv.c | 88 drivers/staging/asi/asidrv.h | 32 + 2 files changed, 120

[RFC v4][PATCH part-3 10/14] asidrv: Add ioctls to manage ASI mapped VA ranges

2020-05-04 Thread Alexandre Chartre
Add ioctls to list, add, clear ASI mapped VA ranges. Signed-off-by: Alexandre Chartre --- drivers/staging/asi/asidrv.c | 138 +++ drivers/staging/asi/asidrv.h | 26 +++ 2 files changed, 164 insertions(+) diff --git a/drivers/staging/asi/asidrv.c b/drivers

Re: [PATCH] x86/alternatives: check int3 breakpoint physical addresses

2019-02-21 Thread Alexandre Chartre
On 02/11/2019 10:57 AM, Alexandre Chartre wrote: On 02/11/2019 10:15 AM, Thomas Gleixner wrote: On Mon, 11 Feb 2019, Alexandre Chartre wrote: On 02/10/2019 10:23 PM, Thomas Gleixner wrote: On Fri, 25 Jan 2019, Alexandre Chartre wrote: Note that this issue has been observed and reproduced

Re: [PATCH v3 5/6] x86/alternative: Use a single access in text_poke() where possible

2019-01-15 Thread Alexandre Chartre
On 01/11/2019 05:57 PM, Josh Poimboeuf wrote: On Fri, Jan 11, 2019 at 05:46:36PM +0100, Alexandre Chartre wrote: On 01/11/2019 04:28 PM, Josh Poimboeuf wrote: On Fri, Jan 11, 2019 at 01:10:52PM +0100, Alexandre Chartre wrote: To avoid any issue with live patching the call instruction

Re: [PATCH v3 5/6] x86/alternative: Use a single access in text_poke() where possible

2019-01-15 Thread Alexandre Chartre
On 01/15/2019 05:19 PM, Steven Rostedt wrote: On Tue, 15 Jan 2019 12:10:19 +0100 Alexandre Chartre wrote: Thinking more about it (and I've probably missed something or I am just being totally stupid because this seems way too simple), can't we just replace the "call"

[RFC KVM 00/27] KVM Address Space Isolation

2019-05-13 Thread Alexandre Chartre
e handled using the full kernel address space. Thanks, alex. --- Alexandre Chartre (18): kvm/isolation: function to track buffers allocated for the KVM page table kvm/isolation: add KVM page table entry free functions kvm/isolation: add KVM page table entry offset functions kvm/isolation:

[RFC KVM 02/27] KVM: x86: Introduce address_space_isolation module parameter

2019-05-13 Thread Alexandre Chartre
performance hit which some users will not want to take for security gain. Signed-off-by: Liran Alon Signed-off-by: Alexandre Chartre --- arch/x86/kvm/Makefile|2 +- arch/x86/kvm/isolation.c | 26 ++ 2 files changed, 27 insertions(+), 1 deletions(-) create mode

[RFC KVM 03/27] KVM: x86: Introduce KVM separate virtual address space

2019-05-13 Thread Alexandre Chartre
-off-by: Liran Alon Signed-off-by: Alexandre Chartre --- arch/x86/kvm/isolation.c | 95 ++ arch/x86/kvm/isolation.h |8 arch/x86/kvm/x86.c | 10 - 3 files changed, 112 insertions(+), 1 deletions(-) create mode 100644 arch/x86/kvm

[RFC KVM 07/27] KVM: x86: Switch to host address space when may access sensitive data

2019-05-13 Thread Alexandre Chartre
(kvm_write_guest_virt_system() can pull in tons of pages) 4) On return to userspace (e.g. QEMU) 5) On prelog of IRQ handlers Signed-off-by: Liran Alon Signed-off-by: Alexandre Chartre --- arch/x86/kvm/isolation.c |7 ++- arch/x86/kvm/isolation.h |3 +++ arch/x86/kvm/mmu.c |3

[RFC KVM 08/27] KVM: x86: Optimize branches which checks if address space isolation enabled

2019-05-13 Thread Alexandre Chartre
From: Liran Alon As every entry to guest checks if should switch from host_mm to kvm_mm, these branches is at very hot path. Optimize them by using static_branch. Signed-off-by: Liran Alon Signed-off-by: Alexandre Chartre --- arch/x86/kvm/isolation.c | 11 --- arch/x86/kvm

[RFC KVM 11/27] kvm/isolation: add KVM page table entry offset functions

2019-05-13 Thread Alexandre Chartre
These functions are wrappers are the p4d/pud/pmd/pte offset functions which ensure that page table pointers are in the KVM page table. Signed-off-by: Alexandre Chartre --- arch/x86/kvm/isolation.c | 61 ++ 1 files changed, 61 insertions(+), 0

[RFC KVM 10/27] kvm/isolation: add KVM page table entry free functions

2019-05-13 Thread Alexandre Chartre
These functions are wrappers around the p4d/pud/pmd/pte free function which can be used with any pointer in the directory. Signed-off-by: Alexandre Chartre --- arch/x86/kvm/isolation.c | 26 ++ 1 files changed, 26 insertions(+), 0 deletions(-) diff --git a/arch/x86

[RFC KVM 04/27] KVM: x86: Switch to KVM address space on entry to guest

2019-05-13 Thread Alexandre Chartre
#VMExit handlers still run with full host address space. However, this introduces the entry points and places for switching. Next commits will change switch to happen only when necessary. Signed-off-by: Liran Alon Signed-off-by: Alexandre Chartre --- arch/x86/kvm/isolation.c | 20

[RFC KVM 15/27] kvm/isolation: keep track of VA range mapped in KVM address space

2019-05-13 Thread Alexandre Chartre
This will be used when we have to clear mappings to ensure the same range is cleared at the same page table level it was copied. Signed-off-by: Alexandre Chartre --- arch/x86/kvm/isolation.c | 86 - 1 files changed, 84 insertions(+), 2 deletions

[RFC KVM 12/27] kvm/isolation: add KVM page table entry allocation functions

2019-05-13 Thread Alexandre Chartre
These functions allocate p4d/pud/pmd/pte pages and ensure that pages are in the KVM page table. Signed-off-by: Alexandre Chartre --- arch/x86/kvm/isolation.c | 94 ++ 1 files changed, 94 insertions(+), 0 deletions(-) diff --git a/arch/x86/kvm

[RFC KVM 13/27] kvm/isolation: add KVM page table entry set functions

2019-05-13 Thread Alexandre Chartre
Add wrappers around the page table entry (pgd/p4d/pud/pmd) set function to check that an existing entry is not being overwritten. Signed-off-by: Alexandre Chartre --- arch/x86/kvm/isolation.c | 107 ++ 1 files changed, 107 insertions(+), 0 deletions

[RFC KVM 16/27] kvm/isolation: functions to clear page table entries for a VA range

2019-05-13 Thread Alexandre Chartre
the kernel page table isn't mistakenly modified. Information (address, size, page table level) about address ranges mapped to the KVM page table is tracked, so mapping clearing is done with just specified the start address of the range. Signed-off-by: Alexandre Chartre --- arch/x86/kvm/isolat

[RFC KVM 19/27] kvm/isolation: initialize the KVM page table with core mappings

2019-05-13 Thread Alexandre Chartre
The KVM page table is initialized with adding core memory mappings: the kernel text, the per-cpu memory, the kvm module, the cpu_entry_area, %esp fixup stacks, IRQ stacks. Signed-off-by: Alexandre Chartre --- arch/x86/kernel/cpu/common.c |2 + arch/x86/kvm/isolation.c | 131

[RFC KVM 20/27] kvm/isolation: initialize the KVM page table with vmx specific data

2019-05-13 Thread Alexandre Chartre
In addition of core memory mappings, the KVM page table has to be initialized with vmx specific data. Signed-off-by: Alexandre Chartre --- arch/x86/kvm/vmx/vmx.c | 19 +++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx

[RFC KVM 22/27] kvm/isolation: initialize the KVM page table with vmx cpu data

2019-05-13 Thread Alexandre Chartre
Map vmx cpu to the KVM address space when a vmx cpu is created, and unmap when it is freed. Signed-off-by: Alexandre Chartre --- arch/x86/kvm/vmx/vmx.c | 65 1 files changed, 65 insertions(+), 0 deletions(-) diff --git a/arch/x86/kvm/vmx/vmx.c

[RFC KVM 25/27] kvm/isolation: implement actual KVM isolation enter/exit

2019-05-13 Thread Alexandre Chartre
From: Liran Alon KVM isolation enter/exit is done by switching between the KVM address space and the kernel address space. Signed-off-by: Liran Alon Signed-off-by: Alexandre Chartre --- arch/x86/kvm/isolation.c | 30 -- arch/x86/mm/tlb.c|1 + include

[RFC KVM 21/27] kvm/isolation: initialize the KVM page table with vmx VM data

2019-05-13 Thread Alexandre Chartre
Map VM data, in particular the kvm structure data. Signed-off-by: Alexandre Chartre --- arch/x86/kvm/isolation.c | 17 + arch/x86/kvm/isolation.h |2 ++ arch/x86/kvm/vmx/vmx.c | 31 ++- arch/x86/kvm/x86.c | 12 include

[RFC KVM 06/27] KVM: x86: Exit KVM isolation on IRQ entry

2019-05-13 Thread Alexandre Chartre
instead of KVM isolated address space. Signed-off-by: Liran Alon Signed-off-by: Alexandre Chartre --- arch/x86/include/asm/apic.h|4 ++-- arch/x86/include/asm/hardirq.h | 10 ++ arch/x86/kernel/smp.c |2 +- arch/x86/platform/uv/tlb_uv.c |2 +- 4 files changed

[RFC KVM 09/27] kvm/isolation: function to track buffers allocated for the KVM page table

2019-05-13 Thread Alexandre Chartre
table. To do so, we will keep track of buffers when building the KVM page table. Signed-off-by: Alexandre Chartre --- arch/x86/kvm/isolation.c | 119 ++ 1 files changed, 119 insertions(+), 0 deletions(-) diff --git a/arch/x86/kvm/isolation.c b/arch

[RFC KVM 18/27] kvm/isolation: function to copy page table entries for percpu buffer

2019-05-13 Thread Alexandre Chartre
percpu buffer. Signed-off-by: Alexandre Chartre --- arch/x86/kvm/isolation.c | 34 ++ arch/x86/kvm/isolation.h |2 ++ 2 files changed, 36 insertions(+), 0 deletions(-) diff --git a/arch/x86/kvm/isolation.c b/arch/x86/kvm/isolation.c index 539e287..2052abf

[RFC KVM 17/27] kvm/isolation: improve mapping copy when mapping is already present

2019-05-13 Thread Alexandre Chartre
mapped range, then remap the entire larger map. Signed-off-by: Alexandre Chartre --- arch/x86/kvm/isolation.c | 67 +++--- 1 files changed, 63 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/isolation.c b/arch/x86/kvm/isolation.c index e494a15

[RFC KVM 14/27] kvm/isolation: functions to copy page table entries for a VA range

2019-05-13 Thread Alexandre Chartre
page table. Signed-off-by: Alexandre Chartre --- arch/x86/kvm/isolation.c | 229 ++ arch/x86/kvm/isolation.h |1 + 2 files changed, 230 insertions(+), 0 deletions(-) diff --git a/arch/x86/kvm/isolation.c b/arch/x86/kvm/isolation.c index b681e4

[RFC KVM 24/27] kvm/isolation: KVM page fault handler

2019-05-13 Thread Alexandre Chartre
. The fault will still be reported but without the stack trace. Signed-off-by: Alexandre Chartre --- arch/x86/kernel/dumpstack.c |1 + arch/x86/kvm/isolation.c| 202 +++ arch/x86/mm/fault.c | 12 +++ 3 files changed, 215 insertions(+), 0 dele

[RFC KVM 23/27] kvm/isolation: initialize the KVM page table with the vcpu tasks

2019-05-13 Thread Alexandre Chartre
task and vcpu. This should eventually be improved to be independent of any task/vcpu mapping. Also check that the task effectively entering the KVM address space is mapped. Signed-off-by: Alexandre Chartre --- arch/x86/kvm/isolation.c | 182 ++ arch/x8

[RFC KVM 26/27] kvm/isolation: initialize the KVM page table with KVM memslots

2019-05-13 Thread Alexandre Chartre
KVM memslots can change after they have been created so new memslots have to be mapped when they are created. TODO: we currently don't unmapped old memslots, they should be unmapped when they are freed. Signed-off-by: Alexandre Chartre --- arch/x86/kvm/isolation.c |

[RFC KVM 05/27] KVM: x86: Add handler to exit kvm isolation

2019-05-13 Thread Alexandre Chartre
From: Liran Alon Interrupt handlers will need this handler to switch from the KVM address space back to the kernel address space on their prelog. Signed-off-by: Liran Alon Signed-off-by: Alexandre Chartre --- arch/x86/include/asm/irq.h |1 + arch/x86/kernel/irq.c | 11

[RFC KVM 27/27] kvm/isolation: initialize the KVM page table with KVM buses

2019-05-13 Thread Alexandre Chartre
KVM buses can change after they have been created so new buses have to be mapped when they are created. Signed-off-by: Alexandre Chartre --- arch/x86/kvm/isolation.c | 37 + arch/x86/kvm/isolation.h |1 + arch/x86/kvm/x86.c | 13

[RFC KVM 01/27] kernel: Export memory-management symbols required for KVM address space isolation

2019-05-13 Thread Alexandre Chartre
From: Liran Alon Export symbols needed to create, manage, populate and switch a mm from a kernel module (kvm in this case). This is a hacky way for now to start. This should be changed to some suitable memory-management API. Signed-off-by: Liran Alon Signed-off-by: Alexandre Chartre

Re: [RFC KVM 02/27] KVM: x86: Introduce address_space_isolation module parameter

2019-05-13 Thread Alexandre Chartre
On 5/13/19 5:46 PM, Andy Lutomirski wrote: On Mon, May 13, 2019 at 7:39 AM Alexandre Chartre wrote: From: Liran Alon Add the address_space_isolation parameter to the kvm module. When set to true, KVM #VMExit handlers run in isolated address space which maps only KVM required code and

Re: [RFC KVM 03/27] KVM: x86: Introduce KVM separate virtual address space

2019-05-13 Thread Alexandre Chartre
On 5/13/19 5:45 PM, Andy Lutomirski wrote: On Mon, May 13, 2019 at 7:39 AM Alexandre Chartre wrote: From: Liran Alon Create a separate mm for KVM that will be active when KVM #VMExit handlers run. Up until the point which we architectully need to access host (or other VM) sensitive data

Re: [RFC KVM 05/27] KVM: x86: Add handler to exit kvm isolation

2019-05-13 Thread Alexandre Chartre
On 5/13/19 5:49 PM, Andy Lutomirski wrote: On Mon, May 13, 2019 at 7:39 AM Alexandre Chartre wrote: From: Liran Alon Interrupt handlers will need this handler to switch from the KVM address space back to the kernel address space on their prelog. This patch doesn't appear to do any

Re: [RFC KVM 24/27] kvm/isolation: KVM page fault handler

2019-05-13 Thread Alexandre Chartre
On 5/13/19 6:02 PM, Andy Lutomirski wrote: On Mon, May 13, 2019 at 7:39 AM Alexandre Chartre wrote: The KVM page fault handler handles page fault occurring while using the KVM address space by switching to the kernel address space and retrying the access (except if the fault occurs while

Re: [RFC KVM 06/27] KVM: x86: Exit KVM isolation on IRQ entry

2019-05-13 Thread Alexandre Chartre
On 5/13/19 5:51 PM, Andy Lutomirski wrote: On Mon, May 13, 2019 at 7:39 AM Alexandre Chartre wrote: From: Liran Alon Next commits will change most of KVM #VMExit handlers to run in KVM isolated address space. Any interrupt handler raised during execution in KVM address space needs to

Re: [RFC KVM 19/27] kvm/isolation: initialize the KVM page table with core mappings

2019-05-13 Thread Alexandre Chartre
On 5/13/19 5:50 PM, Dave Hansen wrote: + /* +* Copy the mapping for all the kernel text. We copy at the PMD +* level since the PUD is shared with the module mapping space. +*/ + rv = kvm_copy_mapping((void *)__START_KERNEL_map, KERNEL_IMAGE_SIZE, +

Re: [RFC KVM 19/27] kvm/isolation: initialize the KVM page table with core mappings

2019-05-13 Thread Alexandre Chartre
On 5/13/19 6:00 PM, Andy Lutomirski wrote: On Mon, May 13, 2019 at 8:50 AM Dave Hansen wrote: + /* + * Copy the mapping for all the kernel text. We copy at the PMD + * level since the PUD is shared with the module mapping space. + */ + rv = kvm_copy_mapping((void *)_

Re: [RFC KVM 06/27] KVM: x86: Exit KVM isolation on IRQ entry

2019-05-14 Thread Alexandre Chartre
On 5/14/19 9:07 AM, Peter Zijlstra wrote: On Mon, May 13, 2019 at 11:13:34AM -0700, Andy Lutomirski wrote: On Mon, May 13, 2019 at 9:28 AM Alexandre Chartre wrote: Actually, I am not sure this is effectively useful because the IRQ handler is probably faulting before it tries to exit

Re: [RFC KVM 18/27] kvm/isolation: function to copy page table entries for percpu buffer

2019-05-14 Thread Alexandre Chartre
On 5/14/19 9:09 AM, Peter Zijlstra wrote: On Mon, May 13, 2019 at 11:18:41AM -0700, Andy Lutomirski wrote: On Mon, May 13, 2019 at 7:39 AM Alexandre Chartre wrote: pcpu_base_addr is already mapped to the KVM address space, but this represents the first percpu chunk. To access a per-cpu

Re: [RFC KVM 00/27] KVM Address Space Isolation

2019-05-14 Thread Alexandre Chartre
On 5/13/19 11:08 PM, Liran Alon wrote: On 13 May 2019, at 21:17, Andy Lutomirski wrote: I expect that the KVM address space can eventually be expanded to include the ioctl syscall entries. By doing so, and also adding the KVM page table to the process userland page table (which should be

Re: [RFC KVM 18/27] kvm/isolation: function to copy page table entries for percpu buffer

2019-05-14 Thread Alexandre Chartre
On 5/14/19 10:34 AM, Andy Lutomirski wrote: On May 14, 2019, at 1:25 AM, Alexandre Chartre wrote: On 5/14/19 9:09 AM, Peter Zijlstra wrote: On Mon, May 13, 2019 at 11:18:41AM -0700, Andy Lutomirski wrote: On Mon, May 13, 2019 at 7:39 AM Alexandre Chartre wrote: pcpu_base_addr is

  1   2   3   >