[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [UNIKRAFT PATCH v2 3/3] lib/syscall_shim: Provide `uk_syscall6()`, `uk_syscall6_r()`



Reviewed-by: Gaulthier Gain <gaulthier.gain@xxxxxxxxx>

> On 21 Apr 2020, at 17:49, Simon Kuenzer <simon.kuenzer@xxxxxxxxx> wrote:
> 
> `uk_syscall6()` and `uk_syscall6_r()` are a variant of `uk_syscall()` and
> `uk_syscall_r()` that are not variadic.
> 
> Signed-off-by: Simon Kuenzer <simon.kuenzer@xxxxxxxxx>
> ---
> lib/syscall_shim/Makefile.uk                  | 13 +++++++
> lib/syscall_shim/{ => arch}/regmap_linuxabi.h |  0
> lib/syscall_shim/gen_uk_syscall6.awk          | 39 +++++++++++++++++++
> lib/syscall_shim/gen_uk_syscall6_r.awk        | 39 +++++++++++++++++++
> lib/syscall_shim/include/uk/syscall.h         |  4 ++
> lib/syscall_shim/uk_syscall6_r.c.in_end       | 18 +++++++++
> lib/syscall_shim/uk_syscall_r.c.in_end        | 18 ---------
> 7 files changed, 113 insertions(+), 18 deletions(-)
> rename lib/syscall_shim/{ => arch}/regmap_linuxabi.h (100%)
> create mode 100644 lib/syscall_shim/gen_uk_syscall6.awk
> create mode 100644 lib/syscall_shim/gen_uk_syscall6_r.awk
> create mode 100644 lib/syscall_shim/uk_syscall6_r.c.in_end
> 
> diff --git a/lib/syscall_shim/Makefile.uk b/lib/syscall_shim/Makefile.uk
> index ad4c8188..b758f830 100644
> --- a/lib/syscall_shim/Makefile.uk
> +++ b/lib/syscall_shim/Makefile.uk
> @@ -9,7 +9,9 @@ LIBSYSCALL_SHIM_PHONY_SRC_NEW := $(addsuffix .new, 
> $(LIBSYSCALL_SHIM_PHONY_SRC))
> 
> LIBSYSCALL_SHIM_GEN_SRC := 
> $(LIBSYSCALL_SHIM_INCLUDES_PATH)/provided_syscalls.h
> LIBSYSCALL_SHIM_GEN_SRC += $(LIBSYSCALL_SHIM_BUILD)/uk_syscall.c
> +LIBSYSCALL_SHIM_GEN_SRC += $(LIBSYSCALL_SHIM_BUILD)/uk_syscall6.c
> LIBSYSCALL_SHIM_GEN_SRC += $(LIBSYSCALL_SHIM_BUILD)/uk_syscall_r.c
> +LIBSYSCALL_SHIM_GEN_SRC += $(LIBSYSCALL_SHIM_BUILD)/uk_syscall6_r.c
> LIBSYSCALL_SHIM_GEN_SRC += $(LIBSYSCALL_SHIM_BUILD)/uk_syscall_r_fn.c
> LIBSYSCALL_SHIM_GEN_SRC += $(LIBSYSCALL_SHIM_BUILD)/uk_syscall_name.c
> LIBSYSCALL_SHIM_GEN_SRC += $(LIBSYSCALL_SHIM_BUILD)/uk_syscall_name_p.c
> @@ -48,6 +50,10 @@ $(LIBSYSCALL_SHIM_INCLUDES_PATH)/provided_syscalls.h: 
> $(LIBSYSCALL_SHIM_BASE)/ge
>               $(AWK) -F '-' -f  $(LIBSYSCALL_SHIM_BASE)/gen_provided.awk \
>               $(LIBSYSCALL_SHIM_BUILD)/provided_syscalls.h.in > $@)
> 
> +$(LIBSYSCALL_SHIM_BUILD)/uk_syscall6.c: 
> $(LIBSYSCALL_SHIM_BUILD)/provided_syscalls.h.in 
> $(LIBSYSCALL_SHIM_BASE)/gen_uk_syscall6.awk
> +     $(call build_cmd,GEN,libsyscall_shim,$(notdir $@), \
> +             $(AWK) -F '-' -f $(LIBSYSCALL_SHIM_BASE)/gen_uk_syscall6.awk $< 
> > $@)
> +
> $(LIBSYSCALL_SHIM_BUILD)/uk_syscall.c: 
> $(LIBSYSCALL_SHIM_BUILD)/provided_syscalls.h.in 
> $(LIBSYSCALL_SHIM_BASE)/gen_uk_syscall.awk 
> $(LIBSYSCALL_SHIM_BASE)/uk_syscall.c.in_end
>       $(call build_cmd,GEN,libsyscall_shim,$(notdir $@), \
>               $(AWK) -F '-' -f $(LIBSYSCALL_SHIM_BASE)/gen_uk_syscall.awk $< 
> > $@ && \
> @@ -58,6 +64,11 @@ $(LIBSYSCALL_SHIM_BUILD)/uk_syscall_r.c: 
> $(LIBSYSCALL_SHIM_BUILD)/provided_sysca
>               $(AWK) -F '-' -f $(LIBSYSCALL_SHIM_BASE)/gen_uk_syscall_r.awk 
> $< > $@ && \
>               cat $(LIBSYSCALL_SHIM_BASE)/uk_syscall_r.c.in_end >> $@)
> 
> +$(LIBSYSCALL_SHIM_BUILD)/uk_syscall6_r.c: 
> $(LIBSYSCALL_SHIM_BUILD)/provided_syscalls.h.in 
> $(LIBSYSCALL_SHIM_BASE)/gen_uk_syscall6_r.awk 
> $(LIBSYSCALL_SHIM_BASE)/uk_syscall6_r.c.in_end
> +     $(call build_cmd,GEN,libsyscall_shim,$(notdir $@), \
> +             $(AWK) -F '-' -f $(LIBSYSCALL_SHIM_BASE)/gen_uk_syscall6_r.awk 
> $< > $@ && \
> +             cat $(LIBSYSCALL_SHIM_BASE)/uk_syscall6_r.c.in_end >> $@)
> +
> $(LIBSYSCALL_SHIM_BUILD)/uk_syscall_r_fn.c: 
> $(LIBSYSCALL_SHIM_BUILD)/provided_syscalls.h.in 
> $(LIBSYSCALL_SHIM_BASE)/gen_uk_syscall_r_fn.awk
>       $(call build_cmd,GEN,libsyscall_shim,$(notdir $@), \
>               $(AWK) -F '-' -f 
> $(LIBSYSCALL_SHIM_BASE)/gen_uk_syscall_r_fn.awk $< > $@)
> @@ -93,7 +104,9 @@ CXXINCLUDES-y += -I$(LIBSYSCALL_SHIM_BASE)/include
> LIBSYSCALL_SHIM_CINCLUDES += -I$(LIBSYSCALL_SHIM_BASE)
> 
> LIBSYSCALL_SHIM_SRCS-y += $(LIBSYSCALL_SHIM_BUILD)/uk_syscall.c
> +LIBSYSCALL_SHIM_SRCS-y += $(LIBSYSCALL_SHIM_BUILD)/uk_syscall6.c
> LIBSYSCALL_SHIM_SRCS-y += $(LIBSYSCALL_SHIM_BUILD)/uk_syscall_r.c
> +LIBSYSCALL_SHIM_SRCS-y += $(LIBSYSCALL_SHIM_BUILD)/uk_syscall6_r.c
> LIBSYSCALL_SHIM_SRCS-y += $(LIBSYSCALL_SHIM_BUILD)/uk_syscall_r_fn.c
> LIBSYSCALL_SHIM_UK_SYSCALL_R_FN_FLAGS+=-Wno-cast-function-type
> LIBSYSCALL_SHIM_SRCS-y += $(LIBSYSCALL_SHIM_BUILD)/uk_syscall_name.c
> diff --git a/lib/syscall_shim/regmap_linuxabi.h 
> b/lib/syscall_shim/arch/regmap_linuxabi.h
> similarity index 100%
> rename from lib/syscall_shim/regmap_linuxabi.h
> rename to lib/syscall_shim/arch/regmap_linuxabi.h
> diff --git a/lib/syscall_shim/gen_uk_syscall6.awk 
> b/lib/syscall_shim/gen_uk_syscall6.awk
> new file mode 100644
> index 00000000..d6eae04e
> --- /dev/null
> +++ b/lib/syscall_shim/gen_uk_syscall6.awk
> @@ -0,0 +1,39 @@
> +BEGIN {
> +     max_args = 6
> +     print "/* Auto generated file. DO NOT EDIT */\n\n"
> +
> +     print "#include <uk/syscall.h>"
> +     print "#include <uk/print.h>\n"
> +
> +     printf "long uk_syscall6(long nr, "
> +     for (i = 1; i < max_args; i++)
> +             printf "long arg%d, ",i
> +     printf "long arg%d)\n{\n", max_args
> +
> +     for (i = 1; i <= max_args; i++)
> +             printf "\t(void) arg%d;\n", i
> +
> +     print "\n\tswitch (nr) {"
> +}
> +
> +
> +/[a-zA-Z0-9]+-[0-9]+/{
> +     name = $1
> +     sys_name = "SYS_" name
> +     args_nr = $2 + 0
> +     printf "\tcase %s:\n", sys_name;
> +     printf "\t\treturn uk_syscall_e_%s(", name;
> +     for (i = 1; i < args_nr; i++)
> +             printf("arg%d, ", i)
> +     if (args_nr > 0)
> +             printf("arg%d", args_nr)
> +     printf(");\n")
> +}
> +
> +END {
> +     printf "\tdefault:\n"
> +     printf "\t\tuk_pr_debug(\"syscall \\\"%%s\\\" is not available\\n\", 
> uk_syscall_name(nr));\n"
> +     printf "\t\terrno = -ENOSYS;\n"
> +     printf "\t\treturn -1;\n"
> +     printf "\t}\n}\n"
> +}
> diff --git a/lib/syscall_shim/gen_uk_syscall6_r.awk 
> b/lib/syscall_shim/gen_uk_syscall6_r.awk
> new file mode 100644
> index 00000000..d5f8c8ba
> --- /dev/null
> +++ b/lib/syscall_shim/gen_uk_syscall6_r.awk
> @@ -0,0 +1,39 @@
> +BEGIN {
> +     max_args = 6
> +     print "/* Auto generated file. DO NOT EDIT */\n\n"
> +
> +     print "#include <uk/syscall.h>"
> +     print "#include <uk/print.h>\n"
> +
> +     printf "long uk_syscall6_r(long nr, "
> +     for (i = 1; i < max_args; i++)
> +             printf "long arg%d, ",i
> +     printf "long arg%d)\n{\n", max_args
> +
> +     for (i = 1; i <= max_args; i++)
> +             printf "\t(void) arg%d;\n", i
> +
> +     print "\n\tswitch (nr) {"
> +}
> +
> +
> +/[a-zA-Z0-9]+-[0-9]+/{
> +     name = $1
> +     sys_name = "SYS_" name
> +     uk_syscall_r = "uk_syscall_r_" name
> +     args_nr = $2 + 0
> +     printf "\tcase %s:\n", sys_name;
> +     printf "\t\treturn %s(", uk_syscall_r;
> +     for (i = 1; i < args_nr; i++)
> +             printf("arg%d, ", i)
> +     if (args_nr > 0)
> +             printf("arg%d", args_nr)
> +     printf(");\n")
> +}
> +
> +END {
> +     printf "\tdefault:\n"
> +     printf "\t\tuk_pr_debug(\"syscall \\\"%%s\\\" is not available\\n\", 
> uk_syscall_name(nr));\n"
> +     printf "\t\treturn -ENOSYS;\n"
> +     printf "\t}\n}\n"
> +}
> diff --git a/lib/syscall_shim/include/uk/syscall.h 
> b/lib/syscall_shim/include/uk/syscall.h
> index 3d2e4e89..a3b79d41 100644
> --- a/lib/syscall_shim/include/uk/syscall.h
> +++ b/lib/syscall_shim/include/uk/syscall.h
> @@ -290,6 +290,8 @@ typedef long uk_syscall_arg_t;
> /* System call, returns -1 and sets errno on errors */
> long uk_syscall(long nr, ...);
> long uk_vsyscall(long nr, va_list arg);
> +long uk_syscall6(long nr, long arg1, long arg2, long arg3,
> +              long arg4, long arg5, long arg6);
> 
> /*
>  * Use this variant instead of `uk_syscall()` whenever the system call number
> @@ -302,6 +304,8 @@ long uk_vsyscall(long nr, va_list arg);
> /* Raw system call, returns negative codes on errors */
> long uk_syscall_r(long nr, ...);
> long uk_vsyscall_r(long nr, va_list arg);
> +long uk_syscall6_r(long nr, long arg1, long arg2, long arg3,
> +                long arg4, long arg5, long arg6);
> 
> /*
>  * Use this variant instead of `uk_syscall_r()` whenever the system call 
> number
> diff --git a/lib/syscall_shim/uk_syscall6_r.c.in_end 
> b/lib/syscall_shim/uk_syscall6_r.c.in_end
> new file mode 100644
> index 00000000..daa75d95
> --- /dev/null
> +++ b/lib/syscall_shim/uk_syscall6_r.c.in_end
> @@ -0,0 +1,18 @@
> +
> +#if CONFIG_LIBSYSCALL_SHIM_HANDLER
> +#include <uk/plat/syscall.h>
> +#include <uk/assert.h>
> +#include <arch/regmap_linuxabi.h>
> +
> +void ukplat_syscall_handler(struct __regs *r)
> +{
> +     UK_ASSERT(r);
> +
> +     uk_pr_debug("Binary system call request \"%s\" (%lu) at ip:%p 
> (arg0=0x%lx, arg1=0x%lx, ...)\n",
> +                 uk_syscall_name(r->rsyscall), r->rsyscall,
> +                 (void *) r->rip, r->rarg0, r->rarg1);
> +     r->rret0 = uk_syscall6_r(r->rsyscall,
> +                              r->rarg0, r->rarg1, r->rarg2,
> +                              r->rarg3, r->rarg4, r->rarg5);
> +}
> +#endif /* CONFIG_LIBSYSCALL_SHIM_HANDLER */
> diff --git a/lib/syscall_shim/uk_syscall_r.c.in_end 
> b/lib/syscall_shim/uk_syscall_r.c.in_end
> index 73ff755c..a09c473c 100644
> --- a/lib/syscall_shim/uk_syscall_r.c.in_end
> +++ b/lib/syscall_shim/uk_syscall_r.c.in_end
> @@ -9,21 +9,3 @@ long uk_syscall_r(long nr, ...)
>       va_end(ap);
>       return ret;
> }
> -
> -#if CONFIG_LIBSYSCALL_SHIM_HANDLER
> -#include <uk/plat/syscall.h>
> -#include <uk/assert.h>
> -#include <regmap_linuxabi.h>
> -
> -void ukplat_syscall_handler(struct __regs *r)
> -{
> -     UK_ASSERT(r);
> -
> -     uk_pr_debug("Binary system call request \"%s\" (%lu) at ip:%p 
> (arg0=0x%lx, arg1=0x%lx, ...)\n",
> -                 uk_syscall_name(r->rsyscall), r->rsyscall,
> -                 (void *) r->rip, r->rarg0, r->rarg1);
> -     r->rret0 = uk_syscall_r(r->rsyscall,
> -                             r->rarg0, r->rarg1, r->rarg2,
> -                             r->rarg3, r->rarg4, r->rarg5);
> -}
> -#endif /* CONFIG_LIBSYSCALL_SHIM_HANDLER */
> -- 
> 2.20.1
> 
> 




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.