From: Carsten Haitzler <carsten.haitzler(a)arm.com>
This series starts to enable purecap support for drm ioctls. This
series enables all the libdrm tests (tested and working). You will
also need the purecap libdrm port as well to complement this.
Carsten Haitzler (3):
drm: Fix copy to/from user so that caps trasnport in the region
drm: Fix purecap vblank handling
drm: fix up purecap handling of all iotcls in libdrm test tools
drivers/gpu/drm/drm_atomic_uapi.c | 3 +-
drivers/gpu/drm/drm_connector.c | 107 +++++++++++++++++++------
drivers/gpu/drm/drm_file.c | 2 +-
drivers/gpu/drm/drm_internal.h | 4 +
drivers/gpu/drm/drm_ioc32.c | 8 +-
drivers/gpu/drm/drm_ioctl.c | 20 ++---
drivers/gpu/drm/drm_mode_config.c | 126 +++++++++++++++++++++---------
drivers/gpu/drm/drm_mode_object.c | 37 ++++++++-
drivers/gpu/drm/drm_plane.c | 88 +++++++++++++++++----
drivers/gpu/drm/drm_property.c | 87 ++++++++++++++++++---
drivers/gpu/drm/drm_vblank.c | 46 ++++++++---
include/drm/drm_drv.h | 9 +++
include/drm/drm_vblank.h | 23 ++++++
include/uapi/drm/drm.h | 6 +-
include/uapi/drm/drm_mode.h | 34 ++++----
tools/include/uapi/drm/drm.h | 4 +-
16 files changed, 458 insertions(+), 146 deletions(-)
--
2.25.1
In PCuABI, we need compat_ptr() to create a valid capability from an
arbitrary compat pointer, to enable uaccess to the underlying
memory. However, if the compat pointer is clearly an invalid
address, it is preferable to return a null-derived (invalid)
capability. This is especially true when the address is null: we
clearly want to return the null capability in that case.
This should be a non-functional change (uaccess would fail anyway
due to the absence of underlying mapping), but it avoids some
confusion when debugging compat64 handling (and reduces the creation
of capabilities).
Signed-off-by: Kevin Brodsky <kevin.brodsky(a)arm.com>
---
Review branch:
https://git.morello-project.org/kbrodsky-arm/linux/-/commits/morello/null_c…
arch/arm64/include/asm/compat.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/include/asm/compat.h b/arch/arm64/include/asm/compat.h
index 4556bed1704f..acf5487985b5 100644
--- a/arch/arm64/include/asm/compat.h
+++ b/arch/arm64/include/asm/compat.h
@@ -93,7 +93,9 @@ static inline void __user *compat_ptr(compat_uptr_t uptr)
* TODO [Morello] - this should be done using the current user DDC, not
* the root user capability.
*/
- return (void __user *)cheri_address_set(cheri_user_root_allperms_cap, uptr);
+ return likely(uptr >= PAGE_SIZE && uptr < TASK_SIZE_MAX) ?
+ (void __user *)cheri_address_set(cheri_user_root_allperms_cap, uptr) :
+ as_user_ptr(uptr);
}
#define compat_ptr(uptr) compat_ptr(uptr)
#endif
--
2.43.0
Hi,
This is a small series adding various firmware-related options to the
Morello defconfig. These options work out of the box in PCuABI (no
build or runtime issue).
Patch 1 is useful to inspect the EFI configuration on a live system, and
is used by tools like bootctl (systemd-boot).
Patch 2 enables the DPU to be successfully probed when using the
firmware-provided device tree (part of upstream TF-A), as it relies on
the DPU clock being provided by SCMI. This should be useful for
controlling other functionalities as well (e.g. power management).
Review branch:
https://git.morello-project.org/kbrodsky-arm/linux/-/commits/morello/defcon…
Thanks,
Kevin
Kevin Brodsky (2):
arm64: morello: Enable EFIVAR_FS in defconfig
arm64: morello: Enable SCMI in defconfig
arch/arm64/configs/morello_transitional_pcuabi_defconfig | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
--
2.43.0
These definitions were needed to build arch/arm64/kernel/ptrace.c
with CONFIG_COMPAT64 a long time ago, before "arm64: ptrace: Support
compat64". This is not the case any more, however since
"fs/compat_binfmt_elf: Align compat64 with compat32" we do need to
define compat_elf_gregset_t to keep linux/elfcore-compat.h happy.
This is the correct approach and there is no plan to change it, so
let's remove the outdated TODO.
Signed-off-by: Kevin Brodsky <kevin.brodsky(a)arm.com>
---
arch/arm64/include/asm/elf.h | 5 -----
1 file changed, 5 deletions(-)
diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h
index b54070e80867..63f6f50599e6 100644
--- a/arch/arm64/include/asm/elf.h
+++ b/arch/arm64/include/asm/elf.h
@@ -209,11 +209,6 @@ extern int purecap_setup_additional_pages(struct linux_binprm *bprm,
#define compat_elf_check_arch(x) ((x)->e_machine == EM_AARCH64 && \
!((x)->e_flags & EF_AARCH64_CHERI_PURECAP))
-/*
- * TODO [PCuABI]: Redefine below macros and typedefs to let ptrace pick them
- * and build. These redefinitions are not permanent and might not be required if
- * the ptrace is modified for complete COMPAT64 support.
- */
#define COMPAT_ELF_NGREG ELF_NGREG
typedef unsigned long compat_elf_greg_t;
typedef compat_elf_greg_t compat_elf_gregset_t[COMPAT_ELF_NGREG];
--
2.43.0
Hi,
This small series aligns the kernel with the latest release of Morello
Clang (1.7). Patch 1 removes a warning when building kselftests, while
patch 2 simplifies pieces of inline assembly that are not specific to
PCuABI, by making use of a relaxation in asm constraints.
Review branch:
https://git.morello-project.org/kbrodsky-arm/linux/-/commits/morello%2Flate…
Thanks,
Kevin
Kevin Brodsky (2):
kselftests/arm64: morello: Drop +c64 from -march
arm64: Switch to standard asm constraints for capabilities
arch/arm64/include/asm/futex.h | 23 ++++++++-----------
arch/arm64/include/asm/uaccess.h | 14 ++++-------
arch/arm64/include/asm/vdso/gettimeofday.h | 15 ++++--------
.../testing/selftests/arm64/morello/Makefile | 2 +-
4 files changed, 18 insertions(+), 36 deletions(-)
--
2.43.0
Hi,
This series of patches enables the use of the Wireguard VPN and all
assocaited tools required for running wireguard-tools' test script.
Wireguard's test script (netns.sh) runs to completion using purecap compiled:
wireguard-tools, iproute2, iputils (ping/ping6), iptables, nftables,
libnftnl, libmnl, libelf, argp-standalone, musl-obstack, fts,
libjansson.
Packages used in netns.sh currently not tested in purecap:
ncat, iperf3.
The bulk of the changes required are additions to the kernel config,
with a fix for a bug found in iptables.
There is an alignment issue at the user/kernel boundary in xtables with
capabilities, encountered in the macro XT_ALIGN, used in the function
xt_check_target (with the resulting message indicating size of
(kernel) and (user) not matching). This bug occurs when running certain
iptables commands in the test script. e.g.
iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -d 10.0.0.0/24 -j SNAT
--to 10.0.0.1
This is my first patch to the kernel so please forgive me if anything
is drastically wrong. I have tried to follow the format of others on here...
Cheers,
Joshua Lant
Joshua Lant (2):
morello: enable wireguard kernel config
xtables: fix alignment issue
.../morello_transitional_pcuabi_defconfig | 23 +++++++++++++++++++
include/uapi/linux/netfilter/x_tables.h | 1 +
2 files changed, 24 insertions(+)
--
2.25.1
A previous patch which introduced support for capabilities in the
MMC_IOC_{MULTI_}CMD ioctls also hard-coded the ioctl values to
maintain compatibility with non-PCuABI ioctl handlers such as those
found in block.c.
This patch therefore removes the hard-coding of these ioctl values,
and enforces compatibility by accounting for the change in values
if the ioctl handler is running in compat64.
Signed-off-by: Akram Ahmad <Akram.Ahmad(a)arm.com>
---
drivers/mmc/core/block.c | 21 +++++++++++++++++++++
include/uapi/linux/mmc/ioctl.h | 21 +++++++++------------
2 files changed, 30 insertions(+), 12 deletions(-)
diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index 17a1d24bdaed..acb7f3a9b31a 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -76,6 +76,15 @@ MODULE_ALIAS("mmc:block");
#define MMC_EXTRACT_INDEX_FROM_ARG(x) ((x & 0x00FF0000) >> 16)
#define MMC_EXTRACT_VALUE_FROM_ARG(x) ((x & 0x0000FF00) >> 8)
+/*
+ * The compat_mmc_ioc_{multi_}cmd structs have different sizes in PCuABI and in
+ * compat64, which affects the expected MMC_IOC_{MULTI_}CMD ioctl values. The
+ * following ioctl values reflect the sizes of the compat64 structs defined in
+ * this file.
+ */
+#define COMPAT64_MMC_IOC_CMD _IOWR(MMC_BLOCK_MAJOR, 0, struct compat_mmc_ioc_cmd)
+#define COMPAT64_MMC_IOC_MULTI_CMD _IOWR(MMC_BLOCK_MAJOR, 1, struct compat_mmc_ioc_multi_cmd)
+
static DEFINE_MUTEX(block_mutex);
/*
@@ -858,6 +867,9 @@ static int mmc_blk_ioctl(struct block_device *bdev, blk_mode_t mode,
int ret;
switch (cmd) {
+ case COMPAT64_MMC_IOC_CMD:
+ if (!in_compat64_syscall())
+ return -EINVAL;
case MMC_IOC_CMD:
ret = mmc_blk_check_blkdev(bdev);
if (ret)
@@ -870,6 +882,9 @@ static int mmc_blk_ioctl(struct block_device *bdev, blk_mode_t mode,
NULL);
mmc_blk_put(md);
return ret;
+ case COMPAT64_MMC_IOC_MULTI_CMD:
+ if (!in_compat64_syscall())
+ return -EINVAL;
case MMC_IOC_MULTI_CMD:
ret = mmc_blk_check_blkdev(bdev);
if (ret)
@@ -2678,11 +2693,17 @@ static long mmc_rpmb_ioctl(struct file *filp, unsigned int cmd,
int ret;
switch (cmd) {
+ case COMPAT64_MMC_IOC_CMD:
+ if (!in_compat64_syscall())
+ return -EINVAL;
case MMC_IOC_CMD:
ret = mmc_blk_ioctl_cmd(rpmb->md,
(struct mmc_ioc_cmd __user *)arg,
rpmb);
break;
+ case COMPAT64_MMC_IOC_MULTI_CMD:
+ if (!in_compat64_syscall())
+ return -EINVAL;
case MMC_IOC_MULTI_CMD:
ret = mmc_blk_ioctl_multi_cmd(rpmb->md,
(struct mmc_ioc_multi_cmd __user *)arg,
diff --git a/include/uapi/linux/mmc/ioctl.h b/include/uapi/linux/mmc/ioctl.h
index 9d34bfc49198..e99d932268c6 100644
--- a/include/uapi/linux/mmc/ioctl.h
+++ b/include/uapi/linux/mmc/ioctl.h
@@ -67,26 +67,23 @@ struct mmc_ioc_multi_cmd {
/*
* The size of struct mmc_ioc_cmd changes in PCuABI due to the use of
* __kernel_uintptr_t, which in turn modifies the command value for this
- * ioctl. It is therefore necessary to hard-code the value for the ioctl
- * using the size of the struct that is expected in any ABI other than
- * PCuABI, to ensure that the value for MMC_IOC_CMD is unchanged. The
- * original definition is as follows:
- *
- * #define MMC_IOC_CMD _IOWR(MMC_BLOCK_MAJOR, 0, struct mmc_ioc_cmd)
+ * ioctl. As this command value is not hard-coded to represent the original
+ * size of the struct, any ioctl handlers in compat64 must handle this change
+ * in values instead.
*/
-#define MMC_IOC_CMD _IOC(_IOC_READ|_IOC_WRITE, MMC_BLOCK_MAJOR, 0, 72)
+#define MMC_IOC_CMD _IOWR(MMC_BLOCK_MAJOR, 0, struct mmc_ioc_cmd)
+
/*
* MMC_IOC_MULTI_CMD: Used to send an array of MMC commands described by
* the structure mmc_ioc_multi_cmd. The MMC driver will issue all
* commands in array in sequence to card.
*
* Note: the size of struct mmc_ioc_multi_cmd changes in PCuABI, due to the
- * increased alignment of struct mmc_ioc_cmd. For that reason, its value needs
- * to be hard-coded too. Original definition:
- *
- * #define MMC_IOC_MULTI_CMD _IOWR(MMC_BLOCK_MAJOR, 1, struct mmc_ioc_multi_cmd)
+ * increased alignment of struct mmc_ioc_cmd. Similarly to MMC_IOC_CMD, any
+ * ioctl handlers must account for this change when running in compat64.
*/
-#define MMC_IOC_MULTI_CMD _IOC(_IOC_READ|_IOC_WRITE, MMC_BLOCK_MAJOR, 1, 8)
+#define MMC_IOC_MULTI_CMD _IOWR(MMC_BLOCK_MAJOR, 1, struct mmc_ioc_multi_cmd)
+
/*
* Since this ioctl is only meant to enhance (and not replace) normal access
* to the mmc bus device, an upper data transfer limit of MMC_IOC_MAX_BYTES
--
2.34.1
A few tests currently create temporary files in / to obtain an fd
for testing further syscalls. This is suboptimal as these files may
be used for other purposes, they are not deleted after the tests are
run, and we should generally avoid creating files at the root.
We could create files in /tmp instead, with some naming pattern à la
mkstemp(), but it turns out there is an even simpler solution.
open() can be passed O_TMPFILE to create an unnamed file under a
given directory. The file disappears once the fd is closed, so there
can be no leftover. This approach is used to implement tmpfile() in
glibc, if available.
On the model of tmpfile(), add a new helper tmpfd() in
freestanding.h and make use of it in the tests that need a temporary
fd, replacing the hardcoded files. We try to create the unnamed file
under /tmp if it exists, as /tmp should be writable by any user,
while / may not be writable at all.
Signed-off-by: Kevin Brodsky <kevin.brodsky(a)arm.com>
---
v1..v2:
* Replaced open_file() with tmpfd() in the new uaccess tests.
* Attempt to create the unnamed file under /tmp first, to avoid
requiring write access to /.
Review branch:
https://git.morello-project.org/kbrodsky-arm/linux/-/commits/morello/kselft…
.../selftests/arm64/morello/freestanding.h | 19 +++++++++++++++++++
tools/testing/selftests/arm64/morello/mmap.c | 4 +---
.../selftests/arm64/morello/read_write.c | 7 ++-----
.../testing/selftests/arm64/morello/uaccess.c | 13 +------------
4 files changed, 23 insertions(+), 20 deletions(-)
diff --git a/tools/testing/selftests/arm64/morello/freestanding.h b/tools/testing/selftests/arm64/morello/freestanding.h
index 8dab905d2b54..0969b518bad2 100644
--- a/tools/testing/selftests/arm64/morello/freestanding.h
+++ b/tools/testing/selftests/arm64/morello/freestanding.h
@@ -8,6 +8,8 @@
#include <stdint.h>
#include <stddef.h>
#include <asm/unistd.h>
+#include <linux/errno.h>
+#include <linux/fcntl.h>
#include <linux/posix_types.h>
#include <linux/resource.h>
#include <linux/signal.h>
@@ -229,4 +231,21 @@ static inline int waitpid(pid_t pid, int *wstatus, int options)
return syscall(__NR_wait4, pid, wstatus, options, 0);
}
+/*
+ * Creates a new temporary file and returns an fd to it. The file has no name
+ * (see open(2) regarding O_TMPFILE) and is deleted when the fd is closed.
+ */
+static inline int tmpfd(void)
+{
+ int fd;
+
+ /* First try /tmp, fall back to / if it doesn't exist */
+ fd = syscall(__NR_openat, 0, "/tmp", O_TMPFILE | O_RDWR, 0666);
+ if (fd == -ENOENT)
+ fd = syscall(__NR_openat, 0, "/", O_TMPFILE | O_RDWR, 0666);
+
+ ASSERT_GE(fd, 0);
+ return fd;
+}
+
#endif
diff --git a/tools/testing/selftests/arm64/morello/mmap.c b/tools/testing/selftests/arm64/morello/mmap.c
index 62fc14d14d46..618eb221d0ae 100644
--- a/tools/testing/selftests/arm64/morello/mmap.c
+++ b/tools/testing/selftests/arm64/morello/mmap.c
@@ -7,7 +7,6 @@
#include <linux/mman.h>
#include <linux/errno.h>
#include <linux/fs.h>
-#include <linux/fcntl.h>
#include <cheriintrin.h>
#include "freestanding.h"
@@ -65,13 +64,12 @@ void syscall_mmap2(void)
{
const char msg[] = "foo";
unsigned int msg_len = sizeof(msg); /* No need for the terminator */
- const char *sample_file = "/limbo.dat";
void *addr;
int fd;
int retval;
/* create a sample file to map onto with mmap */
- fd = syscall(__NR_openat, 0, sample_file, O_RDWR | O_CREAT, FILE_PERM);
+ fd = tmpfd();
ASSERT_GE(fd, 0);
diff --git a/tools/testing/selftests/arm64/morello/read_write.c b/tools/testing/selftests/arm64/morello/read_write.c
index a68b5efeb5ab..6425c8449baa 100644
--- a/tools/testing/selftests/arm64/morello/read_write.c
+++ b/tools/testing/selftests/arm64/morello/read_write.c
@@ -7,7 +7,6 @@
#include <linux/fs.h>
#include <linux/stat.h>
#include <linux/uio.h>
-#include <asm/fcntl.h>
#include <asm/unistd.h>
#include "freestanding.h"
@@ -26,8 +25,6 @@ static const char w_vec_msg2[VEC_MSG_LEN] = " is vector\n";
static char r_vec_msg1[VEC_MSG_LEN];
static char r_vec_msg2[VEC_MSG_LEN];
-static const char file[] = "/check_cap.txt";
-
static const struct iovec w_iovec[VEC_MSG_NUM] = {
{.iov_base = (char *) w_vec_msg1, .iov_len = VEC_MSG_LEN},
{.iov_base = (char *) w_vec_msg2, .iov_len = VEC_MSG_LEN},
@@ -58,8 +55,8 @@ TEST(test_writev)
TEST(test_open)
{
- fd = syscall(__NR_openat, 0, file, O_RDWR | O_CREAT, 0666);
- ASSERT_LE(1, fd) TH_LOG("open failed");
+ /* tmpfd() asserts that the openat syscall succeeds */
+ fd = tmpfd();
}
TEST(test_read)
diff --git a/tools/testing/selftests/arm64/morello/uaccess.c b/tools/testing/selftests/arm64/morello/uaccess.c
index a1667d9b6bfc..7a48a35c67c5 100644
--- a/tools/testing/selftests/arm64/morello/uaccess.c
+++ b/tools/testing/selftests/arm64/morello/uaccess.c
@@ -5,11 +5,8 @@
#include <stddef.h>
#include <stdbool.h>
-#include <asm/fcntl.h>
-#include <asm-generic/errno-base.h>
#include <cheriintrin.h>
#include <linux/errno.h>
-#include <linux/fs.h>
#include <linux/futex.h>
#include <linux/mman.h>
#include <linux/signal.h>
@@ -22,14 +19,11 @@
#define MSG_LEN 16
-static const char file[] = "/my_file.txt";
-
static inline int fsopen(const char *string)
{
return syscall(__NR_fsopen, string);
}
-
static inline int futex_wake_op(uint32_t *uaddr, uint32_t *uaddr2, uint32_t val3)
{
return syscall(__NR_futex, uaddr, FUTEX_WAKE_OP, 1, 1,
@@ -48,11 +42,6 @@ static int getsockname(int socket, struct sockaddr *sockaddr, int *socklen)
return syscall(__NR_getsockname, socket, sockaddr, socklen);
}
-static int open_file(void)
-{
- return syscall(__NR_openat, 0, file, O_RDWR | O_CREAT, 0666);
-}
-
static inline int preadv(int fd, struct iovec *iov, int iovcnt)
{
return syscall(__NR_preadv, fd, iov, iovcnt, 0);
@@ -181,7 +170,7 @@ TEST(test_explicit_iov_iter)
int iovcnt = sizeof(iov) / sizeof(struct iovec);
int fd;
- fd = open_file();
+ fd = tmpfd();
ASSERT_NE(fd, -1);
iov[0].iov_base = (void *)write_buf0;
--
2.43.0
Hello all,
Many of the Morello helper functions are implemented in assembly due
to historical reasons. This patch series aims to translate the helpers into
C functions to improve their readability, introducing additional helpers
where necessary such as to access capability-based system registers. The
newly translated helpers are defined directly in morello.c.
This patch series also removes the now empty morello.S file, and updates
the Makefile accordingly. It also tidies up definitions of assembly-only
values, removing these where necessary.
V1 -> V2:
- Minor adjustments to improve code readability
- Correction to cheri_cap_build usage
- Remove duplicate calls to read_cap_sysreg
V1 separates the patch series into two patches; one to add the register
helpers, and another to translate the assembly helpers (and tidy up). V1
also corrects the more complicated helpers, whilst removing unnecessary
casts and finally implementing some feedback for improving code clarity.
The review branch is accessible here:
https://git.morello-project.org/arkamnite/linux/-/commits/morello%2Farm64_v2
The related issue is here:
https://git.morello-project.org/morello/kernel/linux/-/issues/61
Many thanks,
Akram
Akram Ahmad (2):
arm64: morello: add {read, write}_cap_sysreg helpers
arm64: morello: rewrite Morello helpers in C
arch/arm64/include/asm/assembler.h | 10 --
arch/arm64/include/asm/morello.h | 7 +-
arch/arm64/include/asm/sysreg.h | 14 ++
arch/arm64/kernel/asm-offsets.c | 8 --
arch/arm64/kernel/morello.c | 150 ++++++++++++++++++---
arch/arm64/lib/Makefile | 3 +-
arch/arm64/lib/morello.S | 205 -----------------------------
7 files changed, 152 insertions(+), 245 deletions(-)
delete mode 100644 arch/arm64/lib/morello.S
--
2.34.1