Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F177459886
D43307.1794464522.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
3 KB
Referenced Files
None
Subscribers
None
D43307.1794464522.diff
View Options
diff --git a/sys/arm64/arm64/exec_machdep.c b/sys/arm64/arm64/exec_machdep.c
--- a/sys/arm64/arm64/exec_machdep.c
+++ b/sys/arm64/arm64/exec_machdep.c
@@ -570,6 +570,7 @@
sys_sigreturn(struct thread *td, struct sigreturn_args *uap)
{
struct arm64_reg_context ctx;
+ struct pcb *pcb;
ucontext_t uc;
vm_offset_t addr;
int error;
@@ -581,6 +582,7 @@
/* Read any register contexts we find */
if (uc.uc_mcontext.mc_ptr != 0) {
addr = uc.uc_mcontext.mc_ptr;
+ pcb = td->td_pcb;
done = false;
do {
@@ -588,6 +590,28 @@
return (EFAULT);
switch(ctx.ctx_id) {
+ case ARM64_CTX_SVE: {
+ struct sve_context sve_ctx;
+ size_t buf_size;
+
+ if (pcb->pcb_svesaved == NULL)
+ return (EINVAL);
+
+ buf_size = sve_buf_size(td);
+ /* Check the size is valid */
+ if (ctx.ctx_size !=
+ (sizeof(sve_ctx) + buf_size))
+ return (EINVAL);
+
+ memset(pcb->pcb_svesaved, 0,
+ sve_max_buf_size());
+
+ /* Copy the SVE registers from userspace */
+ if (copyin((void *)(addr + sizeof(sve_ctx)),
+ pcb->pcb_svesaved, buf_size) != 0)
+ return (EINVAL);
+ break;
+ }
case ARM64_CTX_END:
done = true;
break;
@@ -603,6 +627,13 @@
if (error != 0)
return (error);
+ /*
+ * Sync the VFP and SVE registers. To be backwards compatible we
+ * use the VFP registers to restore the lower bits of the SVE
+ * register it aliases.
+ */
+ vfp_to_sve_sync(td);
+
/* Restore signal mask. */
kern_sigprocmask(td, SIG_SETMASK, &uc.uc_sigmask, NULL, 0);
@@ -628,9 +659,47 @@
return (true);
}
+static bool
+sendsig_ctx_sve(struct thread *td, vm_offset_t *addrp)
+{
+ struct sve_context ctx;
+ struct pcb *pcb;
+ size_t buf_size;
+ vm_offset_t ctx_addr;
+
+ pcb = td->td_pcb;
+ /* Do nothing if sve hasn't started */
+ if (pcb->pcb_svesaved == NULL)
+ return (true);
+
+ MPASS(pcb->pcb_svesaved != NULL);
+
+ buf_size = sve_buf_size(td);
+
+ /* Address for the full context */
+ *addrp -= sizeof(ctx) + buf_size;
+ ctx_addr = *addrp;
+
+ memset(&ctx, 0, sizeof(ctx));
+ ctx.sve_ctx.ctx_id = ARM64_CTX_SVE;
+ ctx.sve_ctx.ctx_size = sizeof(ctx) + buf_size;
+ ctx.sve_vector_len = pcb->pcb_sve_len;
+ ctx.sve_flags = 0;
+
+ /* Copy out the header and data */
+ if (copyout(&ctx, (void *)ctx_addr, sizeof(ctx)) != 0)
+ return (false);
+ if (copyout(pcb->pcb_svesaved, (void *)(ctx_addr + sizeof(ctx)),
+ buf_size) != 0)
+ return (false);
+
+ return (true);
+}
+
typedef bool(*ctx_func)(struct thread *, vm_offset_t *);
static const ctx_func ctx_funcs[] = {
sendsig_ctx_end, /* Must be first to end the linked list */
+ sendsig_ctx_sve,
NULL,
};
diff --git a/sys/arm64/include/ucontext.h b/sys/arm64/include/ucontext.h
--- a/sys/arm64/include/ucontext.h
+++ b/sys/arm64/include/ucontext.h
@@ -62,6 +62,14 @@
};
#define ARM64_CTX_END 0xa5a5a5a5
+#define ARM64_CTX_SVE 0x00657673
+
+struct sve_context {
+ struct arm64_reg_context sve_ctx;
+ __uint16_t sve_vector_len;
+ __uint16_t sve_flags;
+ __uint16_t sve_reserved[2];
+};
struct __mcontext {
struct gpregs mc_gpregs;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 12, 6:22 AM (13 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41672446
Default Alt Text
D43307.1794464522.diff (3 KB)
Attached To
Mode
D43307: arm64: Add the SVE registers to the signal frame
Attached
Detach File
Event Timeline