Re: [PATCH v12 00/11] Application Data Integrity feature introduced by SPARC M7

2018-03-19 Thread Khalid Aziz
On 03/18/2018 09:08 AM, David Miller wrote: In uapi/asm/auxvec.h you conditionalize the ADI aux vectors on CONFIG_SPARC64. That's not correct, you should never control user facing definitions based upon kernel configuration. Also, both 32-bit and 64-bit applications running on ADI capable machi

Re: [PATCH v12 10/11] sparc64: Add support for ADI (Application Data Integrity)

2018-03-05 Thread Khalid Aziz
On 03/05/2018 02:31 PM, Dave Hansen wrote: On 03/05/2018 01:14 PM, Khalid Aziz wrote: Are you suggesting that vma returned by find_vma() could be split or merged underneath me if I do not hold mmap_sem and thus make the flag check invalid? If so, that is a good point. This part does make me

Re: [PATCH v12 10/11] sparc64: Add support for ADI (Application Data Integrity)

2018-03-05 Thread Khalid Aziz
On 03/05/2018 02:26 PM, Dave Hansen wrote: On 02/21/2018 09:15 AM, Khalid Aziz wrote: +tag_storage_desc_t *alloc_tag_store(struct mm_struct *mm, + struct vm_area_struct *vma, + unsigned long addr) ... + tags = kzalloc

Re: [PATCH v12 10/11] sparc64: Add support for ADI (Application Data Integrity)

2018-03-05 Thread Khalid Aziz
On 03/05/2018 12:22 PM, Dave Hansen wrote: On 02/21/2018 09:15 AM, Khalid Aziz wrote: +#define arch_validate_prot(prot, addr) sparc_validate_prot(prot, addr) +static inline int sparc_validate_prot(unsigned long prot, unsigned long addr) +{ + if (prot & ~(PROT_READ | PROT_WRITE | PROT_

[PATCH v13 10/11] sparc64: Add support for ADI (Application Data Integrity)

2018-02-23 Thread Khalid Aziz
for any task. A task must explicitly enable ADI on a memory range and set version tag for ADI to be effective for the task. Signed-off-by: Khalid Aziz Cc: Khalid Aziz Reviewed-by: Anthony Yznaga --- v13: - Fixed a build error for AMD GPU DRM driver on sparc reported by kbuild

Re: [PATCH v12 10/11] sparc64: Add support for ADI (Application Data Integrity)

2018-02-23 Thread Khalid Aziz
On 02/23/2018 11:57 AM, David Miller wrote: From: Khalid Aziz Date: Fri, 23 Feb 2018 11:51:25 -0700 On 02/22/2018 07:50 PM, kbuild test robot wrote: Hi Khalid, I love your patch! Yet something to improve: [auto build test ERROR on sparc-next/master] [also build test ERROR on v4.16-rc2

Re: [PATCH v12 10/11] sparc64: Add support for ADI (Application Data Integrity)

2018-02-23 Thread Khalid Aziz
help improve the system] url: https://github.com/0day-ci/linux/commits/Khalid-Aziz/Application-Data-Integrity-feature-introduced-by-SPARC-M7/20180223-071725 base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-next.git master config: sparc64-allyesconfig (attached as .config

[PATCH v12 10/11] sparc64: Add support for ADI (Application Data Integrity)

2018-02-21 Thread Khalid Aziz
for any task. A task must explicitly enable ADI on a memory range and set version tag for ADI to be effective for the task. Signed-off-by: Khalid Aziz Cc: Khalid Aziz Reviewed-by: Anthony Yznaga --- v10: - Added code to return from kernel path to set PSTATE.mcde if kernel

[PATCH v12 00/11] Application Data Integrity feature introduced by SPARC M7

2018-02-21 Thread Khalid Aziz
children that read from ADI enabled pages shared with parent and other children and write to them as well forcing COW. - Khalid Aziz (11): signals, sparc: Add signal codes for ADI violations mm, swap: Add infrastructure for saving page metadata on swap sparc64: Add support for AD

Re: [PATCH v11 00/10] Application Data Integrity feature introduced by SPARC M7

2018-02-07 Thread Khalid Aziz
On 02/07/2018 12:38 AM, ebied...@xmission.com wrote: Khalid Aziz writes: On 02/01/2018 07:29 PM, ebied...@xmission.com wrote: Khalid Aziz writes: V11 changes: This series is same as v10 and was simply rebased on 4.15 kernel. Can mm maintainers please review patches 2, 7, 8 and 9 which are

Re: [PATCH v11 00/10] Application Data Integrity feature introduced by SPARC M7

2018-02-02 Thread Khalid Aziz
On 02/01/2018 07:29 PM, ebied...@xmission.com wrote: Khalid Aziz writes: V11 changes: This series is same as v10 and was simply rebased on 4.15 kernel. Can mm maintainers please review patches 2, 7, 8 and 9 which are arch independent, and include/linux/mm.h and mm/ksm.c changes in patch 10

[PATCH v11 10/10] sparc64: Add support for ADI (Application Data Integrity)

2018-02-01 Thread Khalid Aziz
for any task. A task must explicitly enable ADI on a memory range and set version tag for ADI to be effective for the task. Signed-off-by: Khalid Aziz Cc: Khalid Aziz Reviewed-by: Anthony Yznaga --- v10: - Added code to return from kernel path to set PSTATE.mcde if kernel

[PATCH v11 00/10] Application Data Integrity feature introduced by SPARC M7

2018-02-01 Thread Khalid Aziz
een two nodes every few seconds over an hour long run. Verified page migration through /proc//numa_maps. - Tested COW support using test that forks children that read from ADI enabled pages shared with parent and other children and write to them as well forcing COW. - Khalid Aziz (

[PATCH v10 00/10] Application Data Integrity feature introduced by SPARC M7

2017-11-15 Thread Khalid Aziz
nodes every few seconds over an hour long run. Verified page migration through /proc//numa_maps. - Tested COW support using test that forks children that read from ADI enabled pages shared with parent and other children and write to them as well forcing COW. - Khalid Aziz (10):

[PATCH v10 10/10] sparc64: Add support for ADI (Application Data Integrity)

2017-11-15 Thread Khalid Aziz
for any task. A task must explicitly enable ADI on a memory range and set version tag for ADI to be effective for the task. Signed-off-by: Khalid Aziz Cc: Khalid Aziz --- v10: - Added code to return from kernel path to set PSTATE.mcde if kernel continues execution in another

[PATCH v9 10/10] sparc64: Add support for ADI (Application Data Integrity)

2017-10-20 Thread Khalid Aziz
for any task. A task must explicitly enable ADI on a memory range and set version tag for ADI to be effective for the task. Signed-off-by: Khalid Aziz Cc: Khalid Aziz --- v9: - Added code to migrate ADI tags to copy_highpage() to ensure tags get copied on page migration

[PATCH v9 00/10] Application Data Integrity feature introduced by SPARC M7

2017-10-20 Thread Khalid Aziz
ite to them as well forcing COW. - Khalid Aziz (10): signals, sparc: Add signal codes for ADI violations mm, swap: Add infrastructure for saving page metadata as well on swap sparc64: Add support for ADI register fields, ASIs and traps sparc64: Add HV fault type handlers for ADI related

Re: [PATCH v8 9/9] sparc64: Add support for ADI (Application Data Integrity)

2017-10-13 Thread Khalid Aziz
On 10/13/2017 08:14 AM, Khalid Aziz wrote: On 10/12/2017 02:27 PM, Anthony Yznaga wrote: On Oct 12, 2017, at 7:44 AM, Khalid Aziz wrote: On 10/06/2017 04:12 PM, Anthony Yznaga wrote: On Sep 25, 2017, at 9:49 AM, Khalid Aziz wrote: This patch extends mprotect to enable ADI (TSTATE.mcde

Re: [PATCH v8 9/9] sparc64: Add support for ADI (Application Data Integrity)

2017-10-13 Thread Khalid Aziz
On 10/12/2017 02:27 PM, Anthony Yznaga wrote: On Oct 12, 2017, at 7:44 AM, Khalid Aziz wrote: On 10/06/2017 04:12 PM, Anthony Yznaga wrote: On Sep 25, 2017, at 9:49 AM, Khalid Aziz wrote: This patch extends mprotect to enable ADI (TSTATE.mcde), enable/disable MCD (Memory Corruption

Re: [PATCH v8 9/9] sparc64: Add support for ADI (Application Data Integrity)

2017-10-12 Thread Khalid Aziz
Hi Anthony, Please quote only the relevant parts of the patch with comments. That makes it much easier to find the comments. On 10/06/2017 04:12 PM, Anthony Yznaga wrote: On Sep 25, 2017, at 9:49 AM, Khalid Aziz wrote: This patch extends mprotect to enable ADI (TSTATE.mcde), enable

[PATCH v8 0/9] Application Data Integrity feature introduced by SPARC M7

2017-09-25 Thread Khalid Aziz
ldren and write to them as well forcing COW. - Khalid Aziz (9): signals, sparc: Add signal codes for ADI violations mm, swap: Add infrastructure for saving page metadata as well on swap sparc64: Add support for ADI register fields, ASIs and traps sparc64: Add HV fault type handlers

[PATCH v8 9/9] sparc64: Add support for ADI (Application Data Integrity)

2017-09-25 Thread Khalid Aziz
for any task. A task must explicitly enable ADI on a memory range and set version tag for ADI to be effective for the task. Signed-off-by: Khalid Aziz Cc: Khalid Aziz --- v8: - Added note to doc about non-faulting loads not triggering ADI tag mismatch and more details on special

Re: [PATCH v7 9/9] sparc64: Add support for ADI (Application Data Integrity)

2017-09-06 Thread Khalid Aziz
On 09/04/2017 10:25 AM, Pavel Machek wrote: Hi! ADI is a new feature supported on SPARC M7 and newer processors to allow hardware to catch rogue accesses to memory. ADI is supported for data fetches only and not instruction fetches. An app can enable ADI on its data pages, set version tags on t

Re: [PATCH v7 9/9] sparc64: Add support for ADI (Application Data Integrity)

2017-08-31 Thread Khalid Aziz
On 08/30/2017 06:09 PM, David Miller wrote: From: Khalid Aziz Date: Wed, 30 Aug 2017 17:23:37 -0600 That is an interesting idea. This would enable TSTATE_MCDE on all threads of a process as soon as one thread enables it. If we consider the case where the parent creates a shared memory area

Re: [PATCH v7 9/9] sparc64: Add support for ADI (Application Data Integrity)

2017-08-30 Thread Khalid Aziz
On 08/30/2017 04:38 PM, David Miller wrote: From: Khalid Aziz Date: Wed, 30 Aug 2017 16:27:54 -0600 +#define arch_calc_vm_prot_bits(prot, pkey) sparc_calc_vm_prot_bits(prot) +static inline unsigned long sparc_calc_vm_prot_bits(unsigned long prot) +{ + if (prot & PROT

Re: [PATCH v7 9/9] sparc64: Add support for ADI (Application Data Integrity)

2017-08-30 Thread Khalid Aziz
Hi Anthony, Thanks for taking the time to provide feedback. My comments inline below. On 08/25/2017 04:31 PM, Anthony Yznaga wrote: On Aug 9, 2017, at 2:26 PM, Khalid Aziz wrote: ..deleted.. +provided by the hypervisor to the kernel. Kernel returns the value of +ADI block size to

Re: [PATCH v7 9/9] sparc64: Add support for ADI (Application Data Integrity)

2017-08-16 Thread Khalid Aziz
On 08/15/2017 10:58 PM, David Miller wrote: From: Khalid Aziz Date: Wed, 9 Aug 2017 15:26:02 -0600 +void adi_restore_tags(struct mm_struct *mm, struct vm_area_struct *vma, + unsigned long addr, pte_t pte) +{ ... + tag = tag_start(addr, tag_desc); + paddr

[PATCH v7 9/9] sparc64: Add support for ADI (Application Data Integrity)

2017-08-09 Thread Khalid Aziz
for any task. A task must explicitly enable ADI on a memory range and set version tag for ADI to be effective for the task. Signed-off-by: Khalid Aziz Cc: Khalid Aziz --- v7: - Enhanced arch_validate_prot() to enable ADI only on writable addresses backed by physical RAM

[PATCH v7 0/9] Application Data Integrity feature introduced by SPARC M7

2017-08-09 Thread Khalid Aziz
Verified page migration through /proc//numa_maps. - Tested COW support using test that forks children that read from ADI enabled pages shared with parent and other children and write to them as well forcing COW. - Khalid Aziz (9): signals, sparc: Add signal codes for ADI vio

Re: [PATCH v6 4/4] sparc64: Add support for ADI (Application Data Integrity)

2017-03-07 Thread Khalid Aziz
On 03/06/2017 06:25 PM, Anthony Yznaga wrote: > >> On Mar 6, 2017, at 4:31 PM, Khalid Aziz wrote: >> >> On 03/06/2017 05:13 PM, Anthony Yznaga wrote: >>> >>>> On Feb 28, 2017, at 10:35 AM, Khalid Aziz wrote: >>>> >>>> diff -

Re: [PATCH v6 4/4] sparc64: Add support for ADI (Application Data Integrity)

2017-03-06 Thread Khalid Aziz
On 03/06/2017 05:13 PM, Anthony Yznaga wrote: On Feb 28, 2017, at 10:35 AM, Khalid Aziz wrote: diff --git a/arch/sparc/kernel/etrap_64.S b/arch/sparc/kernel/etrap_64.S index 1276ca2..7be33bf 100644 --- a/arch/sparc/kernel/etrap_64.S +++ b/arch/sparc/kernel/etrap_64.S @@ -132,7 +132,33

[PATCH v6 0/4] Application Data Integrity feature introduced by SPARC M7

2017-02-28 Thread Khalid Aziz
race conditions as well in the solution for second issue that will need to be evaluated and addressed. --- Khalid Aziz (4): signals, sparc: Add signal codes for ADI violations mm: Add functions to support extra actions on swap in/out sparc64: Add support for ADI register fields, ASIs and tr

[PATCH v6 4/4] sparc64: Add support for ADI (Application Data Integrity)

2017-02-28 Thread Khalid Aziz
page for the tag to survive swap and migration. Swap swupport infrastructure in this patch allows for this capability to be expanded to store/restore more than one tag per page in future. Signed-off-by: Khalid Aziz Cc: Khalid Aziz --- v6: - Eliminated instructions to read and write PSTATE

Re: [PATCH v5 4/4] sparc64: Add support for ADI (Application Data Integrity)

2017-01-31 Thread Khalid Aziz
On 01/30/2017 03:15 PM, David Miller wrote: From: Khalid Aziz Date: Wed, 25 Jan 2017 12:57:16 -0700 +static inline void enable_adi(void) +{ ... + __asm__ __volatile__( + "rdpr %%pstate, %%g1\n\t" + "or %%g1, %0, %%g1\n\t" +

Re: [PATCH v5 4/4] sparc64: Add support for ADI (Application Data Integrity)

2017-01-25 Thread Khalid Aziz
On 01/25/2017 03:50 PM, Rob Gardner wrote: On 01/25/2017 03:20 PM, Khalid Aziz wrote: On 01/25/2017 03:00 PM, Rob Gardner wrote: On 01/25/2017 12:57 PM, Khalid Aziz wrote: @@ -157,6 +158,24 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write, pgd_t *pgdp

Re: [PATCH v5 4/4] sparc64: Add support for ADI (Application Data Integrity)

2017-01-25 Thread Khalid Aziz
On 01/25/2017 03:00 PM, Rob Gardner wrote: On 01/25/2017 12:57 PM, Khalid Aziz wrote: @@ -157,6 +158,24 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write, pgd_t *pgdp; int nr = 0; +#ifdef CONFIG_SPARC64 +if (adi_capable()) { +long addr = start

[PATCH v5 0/4] Application Data Integrity feature introduced by SPARC M7

2017-01-25 Thread Khalid Aziz
e mmap'd read-only to crash if it changes ADI tags without coordinating the change with other processes. These ideas need to be explored more before implementing a fix. There are potential race conditions as well in the solution for second issue that will need to be evaluated and addressed.

[PATCH v5 4/4] sparc64: Add support for ADI (Application Data Integrity)

2017-01-25 Thread Khalid Aziz
page for the tag to survive swap and migration. Swap swupport infrastructure in this patch allows for this capability to be expanded to store/restore more than one tag per page in future. Signed-off-by: Khalid Aziz Cc: Khalid Aziz --- v5: - Fixed indentation issues and instrcuctions in

Re: [PATCH v4 4/4] sparc64: Add support for ADI (Application Data Integrity)

2017-01-17 Thread Khalid Aziz
On 01/16/2017 09:39 PM, David Miller wrote: From: Khalid Aziz Date: Wed, 11 Jan 2017 09:12:54 -0700 diff --git a/arch/sparc/kernel/mdesc.c b/arch/sparc/kernel/mdesc.c index 8a6982d..68b03bf 100644 --- a/arch/sparc/kernel/mdesc.c +++ b/arch/sparc/kernel/mdesc.c @@ -20,6 +20,7 @@ #include

Re: [PATCH v4 0/4] Application Data Integrity feature introduced by SPARC M7

2017-01-17 Thread Khalid Aziz
On 01/16/2017 09:47 PM, David Miller wrote: From: Dave Hansen Date: Wed, 11 Jan 2017 10:13:54 -0800 For memory shared by two different processes, do they have to agree on what the tags are, or can they differ? Whoever allocates the memory (does the mmap()+mprotect() or whatever), decides on

Re: [PATCH v4 4/4] sparc64: Add support for ADI (Application Data Integrity)

2017-01-17 Thread Khalid Aziz
On 01/17/2017 12:42 PM, David Miller wrote: From: Khalid Aziz Date: Tue, 17 Jan 2017 12:32:46 -0700 On 01/16/2017 09:39 PM, David Miller wrote: From: Khalid Aziz Date: Wed, 11 Jan 2017 09:12:54 -0700 + __asm__ __volatile__( + ".word 0xa143800

Re: [PATCH v4 4/4] sparc64: Add support for ADI (Application Data Integrity)

2017-01-17 Thread Khalid Aziz
On 01/16/2017 09:39 PM, David Miller wrote: From: Khalid Aziz Date: Wed, 11 Jan 2017 09:12:54 -0700 + __asm__ __volatile__( + ".word 0xa1438000\n\t"/* rd %mcdper, %l0 */ Just use "rd %%asr14, %0" this way you don't have t

Re: [PATCH v4 0/4] Application Data Integrity feature introduced by SPARC M7

2017-01-13 Thread Khalid Aziz
On 01/13/2017 08:29 AM, Rob Gardner wrote: On 01/13/2017 07:48 AM, Khalid Aziz wrote: On 01/12/2017 06:31 PM, Rob Gardner wrote: On 01/12/2017 05:22 PM, Khalid Aziz wrote: On 01/12/2017 10:53 AM, Dave Hansen wrote: On 01/12/2017 08:50 AM, Khalid Aziz wrote: 2. Any shared page that has ADI

Re: [PATCH v4 0/4] Application Data Integrity feature introduced by SPARC M7

2017-01-13 Thread Khalid Aziz
On 01/12/2017 06:31 PM, Rob Gardner wrote: On 01/12/2017 05:22 PM, Khalid Aziz wrote: On 01/12/2017 10:53 AM, Dave Hansen wrote: On 01/12/2017 08:50 AM, Khalid Aziz wrote: 2. Any shared page that has ADI protection enabled on it, must stay ADI protected across all processes sharing it. Is

Re: [PATCH v4 0/4] Application Data Integrity feature introduced by SPARC M7

2017-01-12 Thread Khalid Aziz
On 01/12/2017 10:53 AM, Dave Hansen wrote: On 01/12/2017 08:50 AM, Khalid Aziz wrote: 2. Any shared page that has ADI protection enabled on it, must stay ADI protected across all processes sharing it. Is that true? What happens if a page with ADI tags set is accessed via a PTE without the

Re: [PATCH v4 0/4] Application Data Integrity feature introduced by SPARC M7

2017-01-12 Thread Khalid Aziz
On 01/11/2017 05:49 PM, Dave Hansen wrote: On 01/11/2017 04:22 PM, Khalid Aziz wrote: ... All of the tag coordination can happen in userspace. Once a process sets a tag on a physical page mapped in its address space, another process that has mapped the same physical page in its address space

Re: [PATCH v4 0/4] Application Data Integrity feature introduced by SPARC M7

2017-01-11 Thread Khalid Aziz
On 01/11/2017 12:11 PM, Dave Hansen wrote: On 01/11/2017 10:50 AM, Khalid Aziz wrote: On 01/11/2017 11:13 AM, Dave Hansen wrote: On 01/11/2017 08:56 AM, Khalid Aziz wrote: For memory shared by two different processes, do they have to agree on what the tags are, or can they differ? The two

Re: [PATCH v4 0/4] Application Data Integrity feature introduced by SPARC M7

2017-01-11 Thread Khalid Aziz
On 01/11/2017 11:13 AM, Dave Hansen wrote: On 01/11/2017 08:56 AM, Khalid Aziz wrote: On 01/11/2017 09:33 AM, Dave Hansen wrote: On 01/11/2017 08:12 AM, Khalid Aziz wrote: A userspace task enables ADI through mprotect(). This patch series adds a page protection bit PROT_ADI and a

Re: [PATCH v4 0/4] Application Data Integrity feature introduced by SPARC M7

2017-01-11 Thread Khalid Aziz
On 01/11/2017 09:33 AM, Dave Hansen wrote: On 01/11/2017 08:12 AM, Khalid Aziz wrote: A userspace task enables ADI through mprotect(). This patch series adds a page protection bit PROT_ADI and a corresponding VMA flag VM_SPARC_ADI. VM_SPARC_ADI is used to trigger setting TTE.mcd bit in the

[PATCH v4 4/4] sparc64: Add support for ADI (Application Data Integrity)

2017-01-11 Thread Khalid Aziz
page for the tag to survive swap and migration. Swap swupport infrastructure in this patch allows for this capability to be expanded to store/restore more than one tag per page in future. Signed-off-by: Khalid Aziz Cc: Khalid Aziz --- v2: - Fixed a build error v3: - Removed

[PATCH v4 0/4] Application Data Integrity feature introduced by SPARC M7

2017-01-11 Thread Khalid Aziz
ugh multiple hour long runs of this test. - Tested page migration with malloc and shm by migrating data pages of active ADI test process using migratepages, back and forth between two nodes every few seconds over an hour long run. Verified page migration through /proc//numa_maps. --- Kha

Re: [RFC PATCH v3] sparc64: Add support for Application Data Integrity (ADI)

2017-01-06 Thread Khalid Aziz
On 01/06/2017 10:54 AM, Rob Gardner wrote: On 01/06/2017 09:10 AM, Khalid Aziz wrote: On 01/06/2017 10:02 AM, David Miller wrote: From: Dave Hansen Date: Fri, 6 Jan 2017 08:55:03 -0800 Actually, that reminds me... How does your code interface with ksm? Or is there no interaction needed

Re: [RFC PATCH v3] sparc64: Add support for Application Data Integrity (ADI)

2017-01-06 Thread Khalid Aziz
On 01/06/2017 10:02 AM, David Miller wrote: From: Dave Hansen Date: Fri, 6 Jan 2017 08:55:03 -0800 Actually, that reminds me... How does your code interface with ksm? Or is there no interaction needed since you're always working on virtual addresses? This reminds me, I consider this featur

Re: [RFC PATCH v3] sparc64: Add support for Application Data Integrity (ADI)

2017-01-06 Thread Khalid Aziz
On 01/06/2017 09:55 AM, Dave Hansen wrote: On 01/06/2017 08:22 AM, Khalid Aziz wrote: On 01/06/2017 08:36 AM, Dave Hansen wrote: On 01/06/2017 07:32 AM, Khalid Aziz wrote: I agree with you on simplicity first. Subpage granularity is complex, but the architecture allows for subpage granularity

Re: [RFC PATCH v3] sparc64: Add support for Application Data Integrity (ADI)

2017-01-06 Thread Khalid Aziz
On 01/06/2017 08:36 AM, Dave Hansen wrote: On 01/06/2017 07:32 AM, Khalid Aziz wrote: I agree with you on simplicity first. Subpage granularity is complex, but the architecture allows for subpage granularity. Maybe the right approach is to support this at page granularity first for swappable

Re: [RFC PATCH v3] sparc64: Add support for Application Data Integrity (ADI)

2017-01-06 Thread Khalid Aziz
On 01/06/2017 02:19 AM, Michal Hocko wrote: On Thu 05-01-17 13:30:10, Khalid Aziz wrote: [...] It is very tempting to restrict tags to PAGE_SIZE granularity since it makes code noticeably simpler and that is indeed going to be the majority of cases. Sooner or later somebody would want to use

Re: [RFC PATCH v3] sparc64: Add support for Application Data Integrity (ADI)

2017-01-05 Thread Khalid Aziz
On 01/05/2017 12:22 PM, Dave Hansen wrote: On 01/04/2017 04:26 PM, Khalid Aziz wrote: ... No, we do not have space to stuff PAGE_SIZE/64 version tags in swap pte. There is enough space for just one tag per page. DaveM had suggested doing this since the usual case is for a task to set one tag

Re: [RFC PATCH v3] sparc64: Add support for Application Data Integrity (ADI)

2017-01-05 Thread Khalid Aziz
On 01/05/2017 02:37 AM, Jerome Marchand wrote: On 01/04/2017 11:46 PM, Khalid Aziz wrote: ADI is a new feature supported on sparc M7 and newer processors to allow hardware to catch rogue accesses to memory. ADI is supported for data fetches only and not instruction fetches. An app can enable

Re: [RFC PATCH v3] sparc64: Add support for Application Data Integrity (ADI)

2017-01-04 Thread Khalid Aziz
On 01/04/2017 05:14 PM, Dave Hansen wrote: On 01/04/2017 04:05 PM, Rob Gardner wrote: What if two different small pages have different tags and khugepaged comes along and tries to collapse them? Will the page be split if a user attempts to set two different tags inside two different small-page

Re: [RFC PATCH v3] sparc64: Add support for Application Data Integrity (ADI)

2017-01-04 Thread Khalid Aziz
On 01/04/2017 04:49 PM, Dave Hansen wrote: On 01/04/2017 03:44 PM, Rob Gardner wrote: On 01/04/2017 03:40 PM, Dave Hansen wrote: On 01/04/2017 03:35 PM, Rob Gardner wrote: Tags are not cleared at all when memory is freed, but rather, lazily (and automatically) cleared when memory is allocated.

Re: [RFC PATCH v3] sparc64: Add support for Application Data Integrity (ADI)

2017-01-04 Thread Khalid Aziz
On 01/04/2017 04:31 PM, Dave Hansen wrote: One other high-level comment: It would be nice to see the arch-independent and x86 portions broken out and explained in their own right, even if they're small patches. It's a bit cruel to make us scroll through a thousand lines of sparc code to see the

Re: [RFC PATCH v3] sparc64: Add support for Application Data Integrity (ADI)

2017-01-04 Thread Khalid Aziz
On 01/04/2017 04:27 PM, Dave Hansen wrote: On 01/04/2017 02:46 PM, Khalid Aziz wrote: This patch extends mprotect to enable ADI (TSTATE.mcde), enable/disable MCD (Memory Corruption Detection) on selected memory ranges, enable TTE.mcd in PTEs, return ADI parameters to userspace and save/restore

[RFC PATCH v3] sparc64: Add support for Application Data Integrity (ADI)

2017-01-04 Thread Khalid Aziz
must explicitly enable ADI on a memory range and set version tag for ADI to be effective for the task. Signed-off-by: Khalid Aziz Cc: Khalid Aziz --- v2: - Fixed a build error v3: - Removed CONFIG_SPARC_ADI - Replaced prctl commands with mprotect - Added auxiliary

Re: [PATCH v2] sparc64: Add support for Application Data Integrity (ADI)

2016-03-08 Thread Khalid Aziz
On 03/08/2016 01:27 PM, David Miller wrote: From: Khalid Aziz Date: Tue, 8 Mar 2016 13:16:11 -0700 On 03/08/2016 12:57 PM, David Miller wrote: From: Khalid Aziz Date: Mon, 7 Mar 2016 14:06:43 -0700 Good questions. Isn't set of valid VAs already constrained by VA_BITS (set to 44 in

Re: [PATCH v2] sparc64: Add support for Application Data Integrity (ADI)

2016-03-08 Thread Khalid Aziz
On 03/08/2016 12:57 PM, David Miller wrote: From: Khalid Aziz Date: Mon, 7 Mar 2016 14:06:43 -0700 Good questions. Isn't set of valid VAs already constrained by VA_BITS (set to 44 in arch/sparc/include/asm/processor_64.h)? As I see it we are already not using the top 4 bits. Please corre

Re: [PATCH v2] sparc64: Add support for Application Data Integrity (ADI)

2016-03-07 Thread Khalid Aziz
On 03/07/2016 12:16 PM, David Miller wrote: From: Khalid Aziz Date: Mon, 7 Mar 2016 11:24:54 -0700 Tags can be cleared by user by setting tag to 0. Tags are automatically cleared by the hardware when the mapping for a virtual address is removed from TSB (which is why swappable pages are a

Re: [PATCH v2] sparc64: Add support for Application Data Integrity (ADI)

2016-03-07 Thread Khalid Aziz
On 03/07/2016 04:12 PM, Rob Gardner wrote: On 03/07/2016 01:33 PM, Khalid Aziz wrote: That is a possibility but limited in scope. An address range covered by a single TTE can have large number of tags. Version tags are set on cacheline. In extreme case, one could set a tag for each set of 64

Re: [PATCH v2] sparc64: Add support for Application Data Integrity (ADI)

2016-03-07 Thread Khalid Aziz
On 03/07/2016 02:34 PM, David Miller wrote: From: Khalid Aziz Date: Mon, 7 Mar 2016 14:27:09 -0700 I agree with your point of view. PSTATE.mcde and TTE.mcd are set in response to request from userspace. If userspace asked for them to be set, they already know but it was the database guys that

Re: [PATCH v2] sparc64: Add support for Application Data Integrity (ADI)

2016-03-07 Thread Khalid Aziz
On 03/07/2016 12:16 PM, David Miller wrote: From: Khalid Aziz Date: Mon, 7 Mar 2016 11:24:54 -0700 Tags can be cleared by user by setting tag to 0. Tags are automatically cleared by the hardware when the mapping for a virtual address is removed from TSB (which is why swappable pages are a

Re: [PATCH v2] sparc64: Add support for Application Data Integrity (ADI)

2016-03-07 Thread Khalid Aziz
On 03/07/2016 12:09 PM, David Miller wrote: From: Khalid Aziz Date: Mon, 7 Mar 2016 11:04:38 -0700 On 03/07/2016 09:56 AM, David Miller wrote: From: Khalid Aziz Date: Mon, 7 Mar 2016 08:07:53 -0700 PR_GET_SPARC_ADICAPS Put this into a new ELF auxiliary vector entry via ARCH_DLINFO. So

Re: [PATCH v2] sparc64: Add support for Application Data Integrity (ADI)

2016-03-07 Thread Khalid Aziz
On 03/07/2016 01:58 PM, David Miller wrote: From: Khalid Aziz Date: Mon, 7 Mar 2016 13:41:39 -0700 Shared data may not always be backed by a file. My understanding is one of the use cases is for in-memory databases. This shared space could also be used to hand off transactions in flight to

Re: [PATCH v2] sparc64: Add support for Application Data Integrity (ADI)

2016-03-07 Thread Khalid Aziz
On 03/07/2016 10:46 AM, Dave Hansen wrote: On 03/07/2016 08:06 AM, Khalid Aziz wrote: Top 4-bits of sparc64 virtual address are used for version tag only when a process has its PSTATE.mcde bit set and it is accessing a memory region that has ADI enabled on it (TTE.mcd set) and a version tag was

Re: [PATCH v2] sparc64: Add support for Application Data Integrity (ADI)

2016-03-07 Thread Khalid Aziz
On 03/07/2016 12:54 PM, Andy Lutomirski wrote: On Mon, Mar 7, 2016 at 11:44 AM, Khalid Aziz wrote: Consider this scenario: 1. Process A creates a shm and attaches to it. 2. Process A fills shm with data it wants to share with only known processes. It enables ADI and sets tags on the shm. 3

Re: [PATCH v2] sparc64: Add support for Application Data Integrity (ADI)

2016-03-07 Thread Khalid Aziz
On 03/07/2016 11:49 AM, Andy Lutomirski wrote: On Mon, Mar 7, 2016 at 10:22 AM, Khalid Aziz wrote: No, it changes the tag associated with the virtual address for the caller. Physical page backing this virtual address is unaffected. Tag checking is done for virtual addresses. The one

Re: [PATCH v2] sparc64: Add support for Application Data Integrity (ADI)

2016-03-07 Thread Khalid Aziz
On 03/07/2016 12:22 PM, David Miller wrote: Khalid, maybe you should share notes with the folks working on x86 protection keys. Good idea. Sparc ADI feature is indeed similar to x86 protection keys sounds like. Thanks, Khalid -- To unsubscribe from this list: send the line "unsubscribe linu

Re: [PATCH v2] sparc64: Add support for Application Data Integrity (ADI)

2016-03-07 Thread Khalid Aziz
On 03/07/2016 11:12 AM, Dave Hansen wrote: On 03/07/2016 09:53 AM, Andy Lutomirski wrote: Also, what am I missing? Tying these tags to the physical page seems like a poor design to me. This seems really awkward to use. Yeah, can you describe the structures that store these things? Surely th

Re: [PATCH v2] sparc64: Add support for Application Data Integrity (ADI)

2016-03-07 Thread Khalid Aziz
On 03/07/2016 11:09 AM, Rob Gardner wrote: On 03/07/2016 10:04 AM, Khalid Aziz wrote: On 03/07/2016 09:56 AM, David Miller wrote: From: Khalid Aziz Date: Mon, 7 Mar 2016 08:07:53 -0700 PR_GET_SPARC_ADICAPS Put this into a new ELF auxiliary vector entry via ARCH_DLINFO. So now all that&#

Re: [PATCH v2] sparc64: Add support for Application Data Integrity (ADI)

2016-03-07 Thread Khalid Aziz
On 03/07/2016 11:08 AM, Andy Lutomirski wrote: On Mon, Mar 7, 2016 at 10:04 AM, Khalid Aziz wrote: On 03/07/2016 09:56 AM, David Miller wrote: From: Khalid Aziz Date: Mon, 7 Mar 2016 08:07:53 -0700 PR_GET_SPARC_ADICAPS Put this into a new ELF auxiliary vector entry via ARCH_DLINFO. So

Re: [PATCH v2] sparc64: Add support for Application Data Integrity (ADI)

2016-03-07 Thread Khalid Aziz
On 03/07/2016 10:35 AM, Dave Hansen wrote: On 03/02/2016 12:39 PM, Khalid Aziz wrote: +long enable_sparc_adi(unsigned long addr, unsigned long len) +{ + unsigned long end, pagemask; + int error; + struct vm_area_struct *vma, *vma2; + struct mm_struct *mm; + + if

Re: [PATCH v2] sparc64: Add support for Application Data Integrity (ADI)

2016-03-07 Thread Khalid Aziz
On 03/07/2016 09:56 AM, David Miller wrote: From: Khalid Aziz Date: Mon, 7 Mar 2016 08:07:53 -0700 PR_GET_SPARC_ADICAPS Put this into a new ELF auxiliary vector entry via ARCH_DLINFO. So now all that's left is supposedly the TAG stuff, please explain that to me so I can direct you t

Re: [PATCH v2] sparc64: Add support for Application Data Integrity (ADI)

2016-03-07 Thread Khalid Aziz
On 03/07/2016 09:45 AM, David Miller wrote: From: Khalid Aziz Date: Mon, 7 Mar 2016 08:07:53 -0700 I can remove CONFIG_SPARC_ADI. It does mean this code will be built into 32-bit kernels as well but it will be inactive code. The code should be built only into obj-$(CONFIG_SPARC64) just like

Re: [PATCH v2] sparc64: Add support for Application Data Integrity (ADI)

2016-03-07 Thread Khalid Aziz
On 03/07/2016 08:43 AM, Andy Lutomirski wrote: On Mon, Mar 7, 2016 at 7:30 AM, Rob Gardner wrote: On 03/07/2016 07:07 AM, Khalid Aziz wrote: On 03/05/2016 09:07 PM, David Miller wrote: From: Khalid Aziz Date: Wed, 2 Mar 2016 13:39:37 -0700 In this first implementation I am

Re: [PATCH v2] sparc64: Add support for Application Data Integrity (ADI)

2016-03-07 Thread Khalid Aziz
On 03/07/2016 08:30 AM, Rob Gardner wrote: On 03/07/2016 07:07 AM, Khalid Aziz wrote: On 03/05/2016 09:07 PM, David Miller wrote: From: Khalid Aziz Date: Wed, 2 Mar 2016 13:39:37 -0700 In this first implementation I am enabling ADI for hugepages only since these pages are

Re: [PATCH v2] sparc64: Add support for Application Data Integrity (ADI)

2016-03-07 Thread Khalid Aziz
On 03/05/2016 09:07 PM, David Miller wrote: From: Khalid Aziz Date: Wed, 2 Mar 2016 13:39:37 -0700 In this first implementation I am enabling ADI for hugepages only since these pages are locked in memory and hence avoid the issue of saving and restoring tags

Re: [PATCH] sparc64: Add support for Application Data Integrity (ADI)

2016-03-03 Thread Khalid Aziz
On 03/03/2016 03:26 PM, Julian Calaby wrote: Hi Khalid, On Fri, Mar 4, 2016 at 4:42 AM, Khalid Aziz wrote: On 03/02/2016 06:33 PM, Julian Calaby wrote: Hi Khalid, A couple of other comments: On Thu, Mar 3, 2016 at 5:54 AM, Khalid Aziz wrote: Enable Application Data Integrity (ADI

Re: [PATCH] sparc64: Add support for Application Data Integrity (ADI)

2016-03-03 Thread Khalid Aziz
On 03/02/2016 06:33 PM, Julian Calaby wrote: Hi Khalid, A couple of other comments: On Thu, Mar 3, 2016 at 5:54 AM, Khalid Aziz wrote: Enable Application Data Integrity (ADI) support in the sparc kernel for applications to use ADI in userspace. ADI is a new feature supported on sparc M7 and

Re: [PATCH v2] sparc64: Add support for Application Data Integrity (ADI)

2016-03-03 Thread Khalid Aziz
On 03/02/2016 05:48 PM, Julian Calaby wrote: Hi Khalid, On Thu, Mar 3, 2016 at 11:25 AM, Khalid Aziz wrote: Thanks, Julian! I really appreciate your feedback. No problem! My comments below. On 03/02/2016 04:08 PM, Julian Calaby wrote: Hi Khalid, On Thu, Mar 3, 2016 at 7:39 AM, Khalid

Re: [PATCH v2] sparc64: Add support for Application Data Integrity (ADI)

2016-03-02 Thread Khalid Aziz
Thanks, Julian! I really appreciate your feedback. My comments below. On 03/02/2016 04:08 PM, Julian Calaby wrote: Hi Khalid, On Thu, Mar 3, 2016 at 7:39 AM, Khalid Aziz wrote: Enable Application Data Integrity (ADI) support in the sparc kernel for applications to use ADI in userspace. ADI

[PATCH v2] sparc64: Add support for Application Data Integrity (ADI)

2016-03-02 Thread Khalid Aziz
(TSTATE.mcde), turn MCD on on a memory range and set version tag for ADI to be effective for the task. This patch adds support for ADI for hugepages only. Addresses passed into system calls must be non-ADI tagged addresses. Signed-off-by: Khalid Aziz --- NOTES: ADI is a new feature added to M7 processor to

Re: [PATCH] sparc64: Add support for Application Data Integrity (ADI)

2016-03-02 Thread Khalid Aziz
://github.com/0day-ci/linux/commits/Khalid-Aziz/sparc64-Add-support-for-Application-Data-Integrity-ADI/20160303-025709 base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc.git master config: sparc64-allnoconfig (attached as .config) reproduce: wget https://git.kernel.org/cgit/linux

[PATCH] sparc64: Add support for Application Data Integrity (ADI)

2016-03-02 Thread Khalid Aziz
(TSTATE.mcde), turn MCD on on a memory range and set version tag for ADI to be effective for the task. This patch adds support for ADI for hugepages only. Addresses passed into system calls must be non-ADI tagged addresses. Signed-off-by: Khalid Aziz --- NOTES: ADI is a new feature added to M7 processor to