mbox series

[v6,00/31] target-arm: Implement ARMv8.5-MemTag, user mode

Message ID 20210210000223.884088-1-richard.henderson@linaro.org (mailing list archive)
Headers show
Series target-arm: Implement ARMv8.5-MemTag, user mode | expand

Message

Richard Henderson Feb. 10, 2021, 12:01 a.m. UTC
Changes for v6:
  * Drop the change to probe_access.  The cpu_untagged_addr function
    isn't correct, since that's specifically for syscalls.  The uses
    of probe_access in target/arm/ are already done with clean addresses.
  * Move unlock_user comparison change from p19 to p18.

The only unreviewed patch is 19.


r~


Richard Henderson (31):
  tcg: Introduce target-specific page data for user-only
  linux-user: Introduce PAGE_ANON
  exec: Use uintptr_t for guest_base
  exec: Use uintptr_t in cpu_ldst.h
  exec: Improve types for guest_addr_valid
  linux-user: Check for overflow in access_ok
  linux-user: Tidy VERIFY_READ/VERIFY_WRITE
  bsd-user: Tidy VERIFY_READ/VERIFY_WRITE
  linux-user: Do not use guest_addr_valid for h2g_valid
  linux-user: Fix guest_addr_valid vs reserved_va
  exec: Introduce cpu_untagged_addr
  exec: Use cpu_untagged_addr in g2h; split out g2h_untagged
  linux-user: Explicitly untag memory management syscalls
  linux-user: Use guest_range_valid in access_ok
  exec: Rename guest_{addr,range}_valid to *_untagged
  linux-user: Use cpu_untagged_addr in access_ok; split out *_untagged
  linux-user: Move lock_user et al out of line
  linux-user: Fix types in uaccess.c
  linux-user: Handle tags in lock_user/unlock_user
  linux-user/aarch64: Implement PR_TAGGED_ADDR_ENABLE
  target/arm: Improve gen_top_byte_ignore
  target/arm: Use the proper TBI settings for linux-user
  linux-user/aarch64: Implement PR_MTE_TCF and PR_MTE_TAG
  linux-user/aarch64: Implement PROT_MTE
  target/arm: Split out syndrome.h from internals.h
  linux-user/aarch64: Pass syndrome to EXC_*_ABORT
  linux-user/aarch64: Signal SEGV_MTESERR for sync tag check fault
  linux-user/aarch64: Signal SEGV_MTEAERR for async tag check error
  target/arm: Add allocation tag storage for user mode
  target/arm: Enable MTE for user-only
  tests/tcg/aarch64: Add mte smoke tests

 bsd-user/qemu.h                     |   9 +-
 include/exec/cpu-all.h              |  47 ++++-
 include/exec/cpu_ldst.h             |  39 ++--
 include/exec/exec-all.h             |   2 +-
 linux-user/aarch64/target_signal.h  |   3 +
 linux-user/aarch64/target_syscall.h |  13 ++
 linux-user/qemu.h                   |  76 +++-----
 linux-user/syscall_defs.h           |   1 +
 target/arm/cpu-param.h              |   3 +
 target/arm/cpu.h                    |  32 ++++
 target/arm/internals.h              | 249 +------------------------
 target/arm/syndrome.h               | 273 ++++++++++++++++++++++++++++
 tests/tcg/aarch64/mte.h             |  60 ++++++
 accel/tcg/translate-all.c           |  32 +++-
 accel/tcg/user-exec.c               |  51 +++---
 bsd-user/main.c                     |   4 +-
 linux-user/aarch64/cpu_loop.c       |  38 +++-
 linux-user/elfload.c                |  18 +-
 linux-user/flatload.c               |   2 +-
 linux-user/hppa/cpu_loop.c          |  39 ++--
 linux-user/i386/cpu_loop.c          |   6 +-
 linux-user/i386/signal.c            |   5 +-
 linux-user/main.c                   |   4 +-
 linux-user/mmap.c                   |  86 +++++----
 linux-user/ppc/signal.c             |   4 +-
 linux-user/syscall.c                | 165 +++++++++++++----
 linux-user/uaccess.c                |  82 +++++++--
 target/arm/cpu.c                    |  25 ++-
 target/arm/helper-a64.c             |   4 +-
 target/arm/mte_helper.c             |  39 +++-
 target/arm/tlb_helper.c             |  15 +-
 target/arm/translate-a64.c          |  25 +--
 target/hppa/op_helper.c             |   2 +-
 target/i386/tcg/mem_helper.c        |   2 +-
 target/s390x/mem_helper.c           |   4 +-
 tests/tcg/aarch64/mte-1.c           |  28 +++
 tests/tcg/aarch64/mte-2.c           |  45 +++++
 tests/tcg/aarch64/mte-3.c           |  51 ++++++
 tests/tcg/aarch64/mte-4.c           |  45 +++++
 tests/tcg/aarch64/pauth-2.c         |   1 -
 tests/tcg/aarch64/Makefile.target   |   6 +
 tests/tcg/configure.sh              |   4 +
 42 files changed, 1122 insertions(+), 517 deletions(-)
 create mode 100644 target/arm/syndrome.h
 create mode 100644 tests/tcg/aarch64/mte.h
 create mode 100644 tests/tcg/aarch64/mte-1.c
 create mode 100644 tests/tcg/aarch64/mte-2.c
 create mode 100644 tests/tcg/aarch64/mte-3.c
 create mode 100644 tests/tcg/aarch64/mte-4.c

Comments

Peter Maydell Feb. 11, 2021, 10:44 a.m. UTC | #1
On Wed, 10 Feb 2021 at 00:02, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> Changes for v6:
>   * Drop the change to probe_access.  The cpu_untagged_addr function
>     isn't correct, since that's specifically for syscalls.  The uses
>     of probe_access in target/arm/ are already done with clean addresses.
>   * Move unlock_user comparison change from p19 to p18.
>
> The only unreviewed patch is 19.
>
>



Applied to target-arm.next, thanks.

-- PMM
no-reply@patchew.org Feb. 11, 2021, 11:10 a.m. UTC | #2
Patchew URL: https://patchew.org/QEMU/20210210000223.884088-1-richard.henderson@linaro.org/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Type: series
Message-id: 20210210000223.884088-1-richard.henderson@linaro.org
Subject: [PATCH v6 00/31] target-arm: Implement ARMv8.5-MemTag, user mode

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 * [new tag]         patchew/20210210095128.22732-1-mreitz@redhat.com -> patchew/20210210095128.22732-1-mreitz@redhat.com
Switched to a new branch 'test'
91d86c7 tests/tcg/aarch64: Add mte smoke tests
48e16b2 target/arm: Enable MTE for user-only
ebcd8a2 target/arm: Add allocation tag storage for user mode
6b20dad linux-user/aarch64: Signal SEGV_MTEAERR for async tag check error
a05a11b linux-user/aarch64: Signal SEGV_MTESERR for sync tag check fault
9fe7fab linux-user/aarch64: Pass syndrome to EXC_*_ABORT
8838427 target/arm: Split out syndrome.h from internals.h
f21440f linux-user/aarch64: Implement PROT_MTE
054d513 linux-user/aarch64: Implement PR_MTE_TCF and PR_MTE_TAG
6c13999 target/arm: Use the proper TBI settings for linux-user
636304b target/arm: Improve gen_top_byte_ignore
9a1539f linux-user/aarch64: Implement PR_TAGGED_ADDR_ENABLE
817c31c linux-user: Handle tags in lock_user/unlock_user
9ffb98f linux-user: Fix types in uaccess.c
0be35ad linux-user: Move lock_user et al out of line
9d88b12 linux-user: Use cpu_untagged_addr in access_ok; split out *_untagged
0c5bc6b exec: Rename guest_{addr,range}_valid to *_untagged
8bc3138 linux-user: Use guest_range_valid in access_ok
ff34f7c linux-user: Explicitly untag memory management syscalls
565097e exec: Use cpu_untagged_addr in g2h; split out g2h_untagged
127ec93 exec: Introduce cpu_untagged_addr
c1b01b2 linux-user: Fix guest_addr_valid vs reserved_va
1565993 linux-user: Do not use guest_addr_valid for h2g_valid
d00800d bsd-user: Tidy VERIFY_READ/VERIFY_WRITE
8bb8051 linux-user: Tidy VERIFY_READ/VERIFY_WRITE
ba83587 linux-user: Check for overflow in access_ok
49a9250 exec: Improve types for guest_addr_valid
83751bc exec: Use uintptr_t in cpu_ldst.h
0a20c92 exec: Use uintptr_t for guest_base
cac35fc linux-user: Introduce PAGE_ANON
713adc1 tcg: Introduce target-specific page data for user-only

=== OUTPUT BEGIN ===
1/31 Checking commit 713adc154c33 (tcg: Introduce target-specific page data for user-only)
2/31 Checking commit cac35fc3dac1 (linux-user: Introduce PAGE_ANON)
3/31 Checking commit 0a20c926cb91 (exec: Use uintptr_t for guest_base)
4/31 Checking commit 83751bcf1f0e (exec: Use uintptr_t in cpu_ldst.h)
5/31 Checking commit 49a9250416f0 (exec: Improve types for guest_addr_valid)
6/31 Checking commit ba83587c0f90 (linux-user: Check for overflow in access_ok)
7/31 Checking commit 8bb80517610e (linux-user: Tidy VERIFY_READ/VERIFY_WRITE)
8/31 Checking commit d00800da0c9b (bsd-user: Tidy VERIFY_READ/VERIFY_WRITE)
9/31 Checking commit 1565993ac642 (linux-user: Do not use guest_addr_valid for h2g_valid)
10/31 Checking commit c1b01b269613 (linux-user: Fix guest_addr_valid vs reserved_va)
11/31 Checking commit 127ec935269b (exec: Introduce cpu_untagged_addr)
12/31 Checking commit 565097eb4013 (exec: Use cpu_untagged_addr in g2h; split out g2h_untagged)
ERROR: braces {} are necessary for all arms of this statement
#536: FILE: linux-user/mmap.c:222:
+        if (pread(fd, g2h_untagged(start), end - start, offset) == -1)
[...]

ERROR: braces {} are necessary for all arms of this statement
#698: FILE: linux-user/qemu.h:669:
+    if (host_ptr == g2h_untagged(guest_addr))
[...]

total: 2 errors, 0 warnings, 814 lines checked

Patch 12/31 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

13/31 Checking commit ff34f7ca4b37 (linux-user: Explicitly untag memory management syscalls)
14/31 Checking commit 8bc313809b4f (linux-user: Use guest_range_valid in access_ok)
15/31 Checking commit 0c5bc6ba5fce (exec: Rename guest_{addr,range}_valid to *_untagged)
16/31 Checking commit 9d88b1201b11 (linux-user: Use cpu_untagged_addr in access_ok; split out *_untagged)
ERROR: braces {} are necessary for all arms of this statement
#32: FILE: linux-user/elfload.c:3503:
+    if (!access_ok_untagged(VERIFY_READ, vma->vma_start, TARGET_PAGE_SIZE))
[...]

total: 1 errors, 0 warnings, 108 lines checked

Patch 16/31 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

17/31 Checking commit 0be35ad67551 (linux-user: Move lock_user et al out of line)
ERROR: externs should be avoided in .c files
#117: FILE: linux-user/uaccess.c:29:
+void unlock_user(void *host_ptr, abi_ulong guest_addr, long len);

total: 1 errors, 0 warnings, 115 lines checked

Patch 17/31 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

18/31 Checking commit 9ffb98f407f0 (linux-user: Fix types in uaccess.c)
ERROR: externs should be avoided in .c files
#88: FILE: linux-user/uaccess.c:29:
+void unlock_user(void *host_ptr, abi_ulong guest_addr, size_t len);

total: 1 errors, 0 warnings, 150 lines checked

Patch 18/31 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

19/31 Checking commit 817c31c2eafa (linux-user: Handle tags in lock_user/unlock_user)
20/31 Checking commit 9a1539f22fa4 (linux-user/aarch64: Implement PR_TAGGED_ADDR_ENABLE)
21/31 Checking commit 636304beb493 (target/arm: Improve gen_top_byte_ignore)
22/31 Checking commit 6c13999a0de8 (target/arm: Use the proper TBI settings for linux-user)
23/31 Checking commit 054d51332920 (linux-user/aarch64: Implement PR_MTE_TCF and PR_MTE_TAG)
24/31 Checking commit f21440f02de9 (linux-user/aarch64: Implement PROT_MTE)
25/31 Checking commit 8838427ff8cc (target/arm: Split out syndrome.h from internals.h)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#282: 
new file mode 100644

total: 0 errors, 1 warnings, 530 lines checked

Patch 25/31 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
26/31 Checking commit 9fe7fabd17a9 (linux-user/aarch64: Pass syndrome to EXC_*_ABORT)
27/31 Checking commit a05a11bb87c3 (linux-user/aarch64: Signal SEGV_MTESERR for sync tag check fault)
28/31 Checking commit 6b20dad8c3e5 (linux-user/aarch64: Signal SEGV_MTEAERR for async tag check error)
29/31 Checking commit ebcd8a2c8781 (target/arm: Add allocation tag storage for user mode)
30/31 Checking commit 48e16b2aa7eb (target/arm: Enable MTE for user-only)
31/31 Checking commit 91d86c7a2491 (tests/tcg/aarch64: Add mte smoke tests)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#38: 
new file mode 100644

ERROR: trailing statements should be on next line
#177: FILE: tests/tcg/aarch64/mte-3.c:50:
+    while (1);

ERROR: braces {} are necessary for all arms of this statement
#177: FILE: tests/tcg/aarch64/mte-3.c:50:
+    while (1);
[...]

ERROR: use qemu_real_host_page_size instead of getpagesize()
#215: FILE: tests/tcg/aarch64/mte-4.c:31:
+    size_t size = getpagesize() * 4;

total: 3 errors, 1 warnings, 251 lines checked

Patch 31/31 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

=== OUTPUT END ===

Test command exited with code: 1


The full log is available at
http://patchew.org/logs/20210210000223.884088-1-richard.henderson@linaro.org/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com
Peter Maydell Feb. 11, 2021, 7:46 p.m. UTC | #3
On Thu, 11 Feb 2021 at 10:44, Peter Maydell <peter.maydell@linaro.org> wrote:
>
> On Wed, 10 Feb 2021 at 00:02, Richard Henderson
> <richard.henderson@linaro.org> wrote:
> >
> > Changes for v6:
> >   * Drop the change to probe_access.  The cpu_untagged_addr function
> >     isn't correct, since that's specifically for syscalls.  The uses
> >     of probe_access in target/arm/ are already done with clean addresses.
> >   * Move unlock_user comparison change from p19 to p18.
> >
> > The only unreviewed patch is 19.

> Applied to target-arm.next, thanks.

...dropped again, it breaks bsd-user:


NetBSD:

In file included from ../src/bsd-user/strace.c:25:0:
../src/bsd-user/qemu.h: In function 'lock_user':
../src/bsd-user/qemu.h:365:16: warning: passing argument 1 of 'g2h'
makes pointer from integer without a cast [-Wint-conversion]
     return g2h(guest_addr);
                ^~~~~~~~~~
In file included from ../src/bsd-user/qemu.h:22:0,
                 from ../src/bsd-user/strace.c:25:
/home/qemu/qemu-test.aZ6xMm/src/include/exec/cpu_ldst.h:85:21: note:
expected 'CPUState * {aka struct CPUState *}' but argument is of type
'abi_ulong {aka unsigned int}'
 static inline void *g2h(CPUState *cs, abi_ptr x)
                     ^~~
In file included from ../src/bsd-user/strace.c:25:0:
../src/bsd-user/qemu.h:365:12: error: too few arguments to function 'g2h'
     return g2h(guest_addr);
            ^~~
In file included from ../src/bsd-user/qemu.h:22:0,
                 from ../src/bsd-user/strace.c:25:
/home/qemu/qemu-test.aZ6xMm/src/include/exec/cpu_ldst.h:85:21: note:
declared here
 static inline void *g2h(CPUState *cs, abi_ptr x)
                     ^~~
In file included from ../src/bsd-user/strace.c:25:0:
../src/bsd-user/qemu.h:367:1: warning: control reaches end of non-void
function [-Wreturn-type]
 }
 ^

FreeBSD:

In file included from ../src/bsd-user/main.c:29:
../src/bsd-user/qemu.h:365:26: error: too few arguments to function
call, expected 2, have 1
    return g2h(guest_addr);
           ~~~           ^
/usr/home/qemu/qemu-test.FJ7zNo/src/include/exec/cpu_ldst.h:85:1:
note: 'g2h' declared here
static inline void *g2h(CPUState *cs, abi_ptr x)
^
../src/bsd-user/main.c:1058:34: error: too few arguments to function
call, expected 2, have 1
    idt_table = g2h(env->idt.base);
                ~~~              ^
/usr/home/qemu/qemu-test.FJ7zNo/src/include/exec/cpu_ldst.h:85:1:
note: 'g2h' declared here
static inline void *g2h(CPUState *cs, abi_ptr x)
^
../src/bsd-user/main.c:1088:38: error: too few arguments to function
call, expected 2, have 1
        gdt_table = g2h(env->gdt.base);
                    ~~~              ^
/usr/home/qemu/qemu-test.FJ7zNo/src/include/exec/cpu_ldst.h:85:1:
note: 'g2h' declared here
static inline void *g2h(CPUState *cs, abi_ptr x)
^

And also

../src/accel/tcg/translate-all.c:2812:41: warning: shift count >=
width of type [-Wshift-count-overflow]
        assert(start < ((target_ulong)1 << L1_MAP_ADDR_SPACE_BITS));
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:56:21: note: expanded from macro 'assert'
#define assert(e)       ((e) ? (void)0 : __assert(__func__, __FILE__, \
                          ^


OpenBSD:

In file included from ../src/cpu.c:30:
../src/bsd-user/qemu.h:365:26: error: too few arguments to function
call, expected 2, have 1
    return g2h(guest_addr);
           ~~~           ^
/home/qemu/qemu-test.UlUP2w/src/include/exec/cpu_ldst.h:85:1: note:
'g2h' declared here
static inline void *g2h(CPUState *cs, abi_ptr x)
^


thanks
-- PMM