Message ID | 20220308194704.14061-13-fnu.vikram@xilinx.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | dynamic node programming using overlay dtbo | expand |
> > diff --git a/tools/libs/ctrl/Makefile b/tools/libs/ctrl/Makefile > index ef7362327f..848a8737c7 100644 > --- a/tools/libs/ctrl/Makefile > +++ b/tools/libs/ctrl/Makefile > @@ -3,6 +3,7 @@ include $(XEN_ROOT)/tools/Rules.mk > > SRCS-y += xc_altp2m.c > SRCS-y += xc_cpupool.c > +SRCS-y += xc_overlay.c I think these entries are in alphabetical order > SRCS-y += xc_domain.c > SRCS-y += xc_evtchn.c > SRCS-y += xc_gnttab.c > diff --git a/tools/libs/ctrl/xc_overlay.c b/tools/libs/ctrl/xc_overlay.c > new file mode 100644 > index 0000000000..8fe780d75a > --- /dev/null > +++ b/tools/libs/ctrl/xc_overlay.c > @@ -0,0 +1,51 @@ > +/* > + * This blank line can be removed > + * Overlay control functions. > + * Copyright (C) 2021 Xilinx Inc. > + * Author Vikram Garhwal <fnu.vikram@xilinx.com> > + * > + * This library is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; > + * version 2.1 of the License. > + * > + * This library is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with this library; If not, see <http://www.gnu.org/licenses/>. > + */ > + > +#include "xc_bitops.h" > +#include "xc_private.h" > +#include <xen/hvm/hvm_op.h> > +#include <libfdt.h> > + > +int xc_dt_overlay(xc_interface *xch, void *overlay_fdt, int overlay_fdt_size, > + uint8_t overlay_op) > +{ > + int err; > + DECLARE_SYSCTL; > + > + DECLARE_HYPERCALL_BOUNCE(overlay_fdt, overlay_fdt_size, > + XC_HYPERCALL_BUFFER_BOUNCE_IN); XC_HYPERCALL_BUFFER_BOUNCE_IN can stay at the same level of overlay_fdt
Hi Vikram, On Tue, Mar 08, 2022 at 11:47:02AM -0800, Vikram Garhwal wrote: > diff --git a/tools/libs/ctrl/xc_overlay.c b/tools/libs/ctrl/xc_overlay.c > new file mode 100644 > index 0000000000..8fe780d75a > --- /dev/null > +++ b/tools/libs/ctrl/xc_overlay.c Could rename this new file? I don't think using "overlay" alone is going to be helpful to figure out what it is about. Renaming it "xc_dt_overlay.c" would already be better. > @@ -0,0 +1,51 @@ > +/* > + * > + * Overlay control functions. Maybe "Device Tree overlay functions" would be better. I'm not sure that "control" is useful in the file description. > + * Copyright (C) 2021 Xilinx Inc. > + * Author Vikram Garhwal <fnu.vikram@xilinx.com> > + * > + * This library is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; > + * version 2.1 of the License. > + * > + * This library is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with this library; If not, see <http://www.gnu.org/licenses/>. > + */ > + > +#include "xc_bitops.h" > +#include "xc_private.h" > +#include <xen/hvm/hvm_op.h> > +#include <libfdt.h> > + > +int xc_dt_overlay(xc_interface *xch, void *overlay_fdt, int overlay_fdt_size, > + uint8_t overlay_op) Shouldn't the function prototype match the types from the sysctl structure? There is "int" vs "uint32_t" for "overlay_fdt_size". > +{ > + int err; > + DECLARE_SYSCTL; > + > + DECLARE_HYPERCALL_BOUNCE(overlay_fdt, overlay_fdt_size, > + XC_HYPERCALL_BUFFER_BOUNCE_IN); > + > + if ( (err = xc_hypercall_bounce_pre(xch, overlay_fdt)) ) > + goto err; > + > + sysctl.cmd = XEN_SYSCTL_dt_overlay; > + sysctl.u.dt_overlay.overlay_op = overlay_op; > + sysctl.u.dt_overlay.overlay_fdt_size = overlay_fdt_size; > + > + set_xen_guest_handle(sysctl.u.dt_overlay.overlay_fdt, overlay_fdt); > + > + if ( (err = do_sysctl(xch, &sysctl)) != 0 ) > + PERROR("%s failed\n", __func__); The \n should be remove from the message. perror already adds a newline, and it also adds information about the error after the message so a newline in the middle will make it harder to read the error. > + > +err: > + xc_hypercall_bounce_post(xch, overlay_fdt); > + > + return err; > +} Thanks,
diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index 95bd5eca67..b7552d0d9c 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -2629,6 +2629,9 @@ int xc_livepatch_replace(xc_interface *xch, char *name, uint32_t timeout, uint32 int xc_domain_cacheflush(xc_interface *xch, uint32_t domid, xen_pfn_t start_pfn, xen_pfn_t nr_pfns); +int xc_dt_overlay(xc_interface *xch, void *overlay_fdt, int overlay_fdt_size, + uint8_t overlay_op); + /* Compat shims */ #include "xenctrl_compat.h" diff --git a/tools/libs/ctrl/Makefile b/tools/libs/ctrl/Makefile index ef7362327f..848a8737c7 100644 --- a/tools/libs/ctrl/Makefile +++ b/tools/libs/ctrl/Makefile @@ -3,6 +3,7 @@ include $(XEN_ROOT)/tools/Rules.mk SRCS-y += xc_altp2m.c SRCS-y += xc_cpupool.c +SRCS-y += xc_overlay.c SRCS-y += xc_domain.c SRCS-y += xc_evtchn.c SRCS-y += xc_gnttab.c diff --git a/tools/libs/ctrl/xc_overlay.c b/tools/libs/ctrl/xc_overlay.c new file mode 100644 index 0000000000..8fe780d75a --- /dev/null +++ b/tools/libs/ctrl/xc_overlay.c @@ -0,0 +1,51 @@ +/* + * + * Overlay control functions. + * Copyright (C) 2021 Xilinx Inc. + * Author Vikram Garhwal <fnu.vikram@xilinx.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; If not, see <http://www.gnu.org/licenses/>. + */ + +#include "xc_bitops.h" +#include "xc_private.h" +#include <xen/hvm/hvm_op.h> +#include <libfdt.h> + +int xc_dt_overlay(xc_interface *xch, void *overlay_fdt, int overlay_fdt_size, + uint8_t overlay_op) +{ + int err; + DECLARE_SYSCTL; + + DECLARE_HYPERCALL_BOUNCE(overlay_fdt, overlay_fdt_size, + XC_HYPERCALL_BUFFER_BOUNCE_IN); + + if ( (err = xc_hypercall_bounce_pre(xch, overlay_fdt)) ) + goto err; + + sysctl.cmd = XEN_SYSCTL_dt_overlay; + sysctl.u.dt_overlay.overlay_op = overlay_op; + sysctl.u.dt_overlay.overlay_fdt_size = overlay_fdt_size; + + set_xen_guest_handle(sysctl.u.dt_overlay.overlay_fdt, overlay_fdt); + + if ( (err = do_sysctl(xch, &sysctl)) != 0 ) + PERROR("%s failed\n", __func__); + +err: + xc_hypercall_bounce_post(xch, overlay_fdt); + + return err; +}
xc_dt_overlay() sends the device tree binary overlay, size of .dtbo and overlay operation type i.e. add or remove to xen. Signed-off-by: Vikram Garhwal <fnu.vikram@xilinx.com> --- tools/include/xenctrl.h | 3 +++ tools/libs/ctrl/Makefile | 1 + tools/libs/ctrl/xc_overlay.c | 51 ++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 tools/libs/ctrl/xc_overlay.c