swscale/aarch64: mark CPS kernel functions as indirect branch targets

Only the process functions are entered via an indirect _call_ from C.
The kernel functions and process_return are dispatched to by indirect
_branches_ instead (continuation-passing style design).

Make use of the recently added "jumpable" parameter to the function
macro in libavutil/aarch64/asm.S to fix these functions when BTI is
enabled.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
This commit is contained in:
Ramiro Polla
2026-03-31 17:33:28 +08:00
parent af443abe99
commit 53537f6cf5
4 changed files with 18 additions and 11 deletions
+3 -3
View File
@@ -298,7 +298,7 @@ static void asmgen_process(SwsAArch64Context *s, const SwsAArch64OpImplParams *p
aarch64_op_impl_func_name(func_name, sizeof(func_name), p);
rasm_func_begin(r, func_name, true);
rasm_func_begin(r, func_name, true, false);
/* Function prologue */
RasmOp saved_regs[MAX_SAVED_REGS];
@@ -341,7 +341,7 @@ static void asmgen_process_return(SwsAArch64Context *s, const SwsAArch64OpImplPa
aarch64_op_impl_func_name(func_name, sizeof(func_name), p);
rasm_func_begin(r, func_name, true);
rasm_func_begin(r, func_name, true, true);
/* Reset impl to first kernel. */
i_mov(r, s->impl, s->op1_impl); CMT("impl = op1_impl;");
@@ -1348,7 +1348,7 @@ static void asmgen_op_cps(SwsAArch64Context *s, const SwsAArch64OpImplParams *p)
char func_name[128];
aarch64_op_impl_func_name(func_name, sizeof(func_name), p);
rasm_func_begin(r, func_name, true);
rasm_func_begin(r, func_name, true, true);
/**
* Set up vector register dimensions and reshape all vectors
+8 -5
View File
@@ -152,13 +152,15 @@ RasmNode *rasm_add_label(RasmContext *rctx, int id)
return node;
}
RasmNode *rasm_add_func(RasmContext *rctx, int id, bool export)
RasmNode *rasm_add_func(RasmContext *rctx, int id, bool export,
bool jumpable)
{
RasmNode *node = add_node(rctx, RASM_NODE_FUNCTION);
if (node) {
av_assert0(id >= 0 && id < rctx->num_labels);
node->func.name = rctx->labels[id];
node->func.export = export;
node->func.name = rctx->labels[id];
node->func.export = export;
node->func.jumpable = jumpable;
}
return node;
}
@@ -204,7 +206,8 @@ RasmNode *rasm_set_current_node(RasmContext *rctx, RasmNode *node)
/*********************************************************************/
/* Top-level IR entries */
int rasm_func_begin(RasmContext *rctx, const char *name, bool export)
int rasm_func_begin(RasmContext *rctx, const char *name, bool export,
bool jumpable)
{
if (rctx->error)
return rctx->error;
@@ -223,7 +226,7 @@ int rasm_func_begin(RasmContext *rctx, const char *name, bool export)
int id = rasm_new_label(rctx, name);
rasm_set_current_node(rctx, NULL);
entry->start = rasm_add_func(rctx, id, export);
entry->start = rasm_add_func(rctx, id, export, jumpable);
entry->end = rasm_add_endfunc(rctx);
rasm_set_current_node(rctx, entry->start);
+5 -2
View File
@@ -133,6 +133,7 @@ typedef struct RasmNodeLabel {
typedef struct RasmNodeFunc {
char *name;
bool export;
bool jumpable;
} RasmNodeFunc;
typedef struct RasmNodeDirective {
@@ -200,7 +201,8 @@ RasmNode *rasm_add_comment(RasmContext *rctx, const char *comment);
RasmNode *rasm_add_commentf(RasmContext *rctx, char *s, size_t n,
const char *fmt, ...) av_printf_format(4, 5);
RasmNode *rasm_add_label(RasmContext *rctx, int id);
RasmNode *rasm_add_func(RasmContext *rctx, int id, bool export);
RasmNode *rasm_add_func(RasmContext *rctx, int id, bool export,
bool jumpable);
RasmNode *rasm_add_endfunc(RasmContext *rctx);
RasmNode *rasm_add_directive(RasmContext *rctx, const char *text);
@@ -208,7 +210,8 @@ RasmNode *rasm_get_current_node(RasmContext *rctx);
RasmNode *rasm_set_current_node(RasmContext *rctx, RasmNode *node);
/* Top-level IR entries */
int rasm_func_begin(RasmContext *rctx, const char *name, bool export);
int rasm_func_begin(RasmContext *rctx, const char *name, bool export,
bool jumpable);
/**
* Allocate a new label ID with the given name.
+2 -1
View File
@@ -402,7 +402,8 @@ static void print_node_function(const RasmContext *rctx,
FILE *fp, int64_t *pos, int64_t line_start,
const RasmNode *node)
{
pos_fprintf(fp, pos, "function %s, export=%d", node->func.name, node->func.export);
pos_fprintf(fp, pos, "function %s, export=%d, jumpable=%d",
node->func.name, node->func.export, node->func.jumpable);
}
/*********************************************************************/