Re: [PATCH] xen/livepatch: fix livepatch tests
On Wed, Nov 29, 2023 at 10:32:32AM +, Ross Lagerwall wrote: > On Tue, Nov 28, 2023 at 5:41 PM Roger Pau Monne wrote: > > > > The current set of in-tree livepatch tests in xen/test/livepatch started > > failing after the constify of the payload funcs array, and the movement of > > the > > status data into a separate array. > > > > Fix the tests so they respect the constness of the funcs array and also make > > use of the new location of the per-func state data. > > > > Fixes: 82182ad7b46e ('livepatch: do not use .livepatch.funcs section to > > store internal state') > > Signed-off-by: Roger Pau Monné > > --- > > I will see about getting those tests build in gitlab, in the meantime we > > should > > take this fix in order to unblock osstest. > > --- > > xen/test/livepatch/xen_action_hooks.c | 12 +- > > xen/test/livepatch/xen_action_hooks_marker.c | 20 ++--- > > xen/test/livepatch/xen_action_hooks_noapply.c | 22 +++ > > xen/test/livepatch/xen_action_hooks_nofunc.c | 6 ++--- > > .../livepatch/xen_action_hooks_norevert.c | 22 +++ > > xen/test/livepatch/xen_prepost_hooks.c| 8 +++ > > xen/test/livepatch/xen_prepost_hooks_fail.c | 2 +- > > 7 files changed, 53 insertions(+), 39 deletions(-) > > > snip > > diff --git a/xen/test/livepatch/xen_action_hooks_norevert.c > > b/xen/test/livepatch/xen_action_hooks_norevert.c > > index ef77e720713e..1c4873f55640 100644 > > --- a/xen/test/livepatch/xen_action_hooks_norevert.c > > +++ b/xen/test/livepatch/xen_action_hooks_norevert.c > > @@ -25,9 +25,10 @@ static int pre_apply_hook(livepatch_payload_t *payload) > > > > for (i = 0; i < payload->nfuncs; i++) > > { > > -struct livepatch_func *func = >funcs[i]; > > +const struct livepatch_func *func = >funcs[i]; > > +struct livepatch_fstate *fstate = >fstate[i]; > > > > -BUG_ON(func->applied == LIVEPATCH_FUNC_APPLIED); > > +BUG_ON(fstate->applied == LIVEPATCH_FUNC_APPLIED); > > printk(KERN_DEBUG "%s: pre applied: %s\n", __func__, func->name); > > } > > > > @@ -44,9 +45,10 @@ static void post_apply_hook(livepatch_payload_t *payload) > > > > for (i = 0; i < payload->nfuncs; i++) > > { > > -struct livepatch_func *func = >funcs[i]; > > +const struct livepatch_func *func = >funcs[i]; > > +struct livepatch_fstate *fstate = >fstate[i]; > > > > -BUG_ON(func->applied != LIVEPATCH_FUNC_APPLIED); > > +BUG_ON(fstate->applied != LIVEPATCH_FUNC_APPLIED); > > printk(KERN_DEBUG "%s: post applied: %s\n", __func__, func->name); > > } > > > > @@ -62,8 +64,9 @@ static int pre_revert_hook(livepatch_payload_t *payload) > > for (i = 0; i < payload->nfuncs; i++) > > { > > struct livepatch_func *func = >funcs[i]; > > const here too? > > With that fixed... > Reviewed-by: Ross Lagerwall Oh, so that file is not even built. Will see about getting it built. Thanks, Roger.
Re: [PATCH] xen/livepatch: fix livepatch tests
On Tue, Nov 28, 2023 at 5:41 PM Roger Pau Monne wrote: > > The current set of in-tree livepatch tests in xen/test/livepatch started > failing after the constify of the payload funcs array, and the movement of the > status data into a separate array. > > Fix the tests so they respect the constness of the funcs array and also make > use of the new location of the per-func state data. > > Fixes: 82182ad7b46e ('livepatch: do not use .livepatch.funcs section to store > internal state') > Signed-off-by: Roger Pau Monné > --- > I will see about getting those tests build in gitlab, in the meantime we > should > take this fix in order to unblock osstest. > --- > xen/test/livepatch/xen_action_hooks.c | 12 +- > xen/test/livepatch/xen_action_hooks_marker.c | 20 ++--- > xen/test/livepatch/xen_action_hooks_noapply.c | 22 +++ > xen/test/livepatch/xen_action_hooks_nofunc.c | 6 ++--- > .../livepatch/xen_action_hooks_norevert.c | 22 +++ > xen/test/livepatch/xen_prepost_hooks.c| 8 +++ > xen/test/livepatch/xen_prepost_hooks_fail.c | 2 +- > 7 files changed, 53 insertions(+), 39 deletions(-) > snip > diff --git a/xen/test/livepatch/xen_action_hooks_norevert.c > b/xen/test/livepatch/xen_action_hooks_norevert.c > index ef77e720713e..1c4873f55640 100644 > --- a/xen/test/livepatch/xen_action_hooks_norevert.c > +++ b/xen/test/livepatch/xen_action_hooks_norevert.c > @@ -25,9 +25,10 @@ static int pre_apply_hook(livepatch_payload_t *payload) > > for (i = 0; i < payload->nfuncs; i++) > { > -struct livepatch_func *func = >funcs[i]; > +const struct livepatch_func *func = >funcs[i]; > +struct livepatch_fstate *fstate = >fstate[i]; > > -BUG_ON(func->applied == LIVEPATCH_FUNC_APPLIED); > +BUG_ON(fstate->applied == LIVEPATCH_FUNC_APPLIED); > printk(KERN_DEBUG "%s: pre applied: %s\n", __func__, func->name); > } > > @@ -44,9 +45,10 @@ static void post_apply_hook(livepatch_payload_t *payload) > > for (i = 0; i < payload->nfuncs; i++) > { > -struct livepatch_func *func = >funcs[i]; > +const struct livepatch_func *func = >funcs[i]; > +struct livepatch_fstate *fstate = >fstate[i]; > > -BUG_ON(func->applied != LIVEPATCH_FUNC_APPLIED); > +BUG_ON(fstate->applied != LIVEPATCH_FUNC_APPLIED); > printk(KERN_DEBUG "%s: post applied: %s\n", __func__, func->name); > } > > @@ -62,8 +64,9 @@ static int pre_revert_hook(livepatch_payload_t *payload) > for (i = 0; i < payload->nfuncs; i++) > { > struct livepatch_func *func = >funcs[i]; const here too? With that fixed... Reviewed-by: Ross Lagerwall
Re: [PATCH] xen/livepatch: fix livepatch tests
On 28/11/2023 5:41 pm, Roger Pau Monne wrote: > The current set of in-tree livepatch tests in xen/test/livepatch started > failing after the constify of the payload funcs array, and the movement of the > status data into a separate array. > > Fix the tests so they respect the constness of the funcs array and also make > use of the new location of the per-func state data. > > Fixes: 82182ad7b46e ('livepatch: do not use .livepatch.funcs section to store > internal state') > Signed-off-by: Roger Pau Monné Acked-by: Andrew Cooper
[PATCH] xen/livepatch: fix livepatch tests
The current set of in-tree livepatch tests in xen/test/livepatch started failing after the constify of the payload funcs array, and the movement of the status data into a separate array. Fix the tests so they respect the constness of the funcs array and also make use of the new location of the per-func state data. Fixes: 82182ad7b46e ('livepatch: do not use .livepatch.funcs section to store internal state') Signed-off-by: Roger Pau Monné --- I will see about getting those tests build in gitlab, in the meantime we should take this fix in order to unblock osstest. --- xen/test/livepatch/xen_action_hooks.c | 12 +- xen/test/livepatch/xen_action_hooks_marker.c | 20 ++--- xen/test/livepatch/xen_action_hooks_noapply.c | 22 +++ xen/test/livepatch/xen_action_hooks_nofunc.c | 6 ++--- .../livepatch/xen_action_hooks_norevert.c | 22 +++ xen/test/livepatch/xen_prepost_hooks.c| 8 +++ xen/test/livepatch/xen_prepost_hooks_fail.c | 2 +- 7 files changed, 53 insertions(+), 39 deletions(-) diff --git a/xen/test/livepatch/xen_action_hooks.c b/xen/test/livepatch/xen_action_hooks.c index 39b531302731..fa0b3ab35f38 100644 --- a/xen/test/livepatch/xen_action_hooks.c +++ b/xen/test/livepatch/xen_action_hooks.c @@ -26,9 +26,10 @@ static int apply_hook(livepatch_payload_t *payload) for (i = 0; i < payload->nfuncs; i++) { -struct livepatch_func *func = >funcs[i]; +const struct livepatch_func *func = >funcs[i]; +struct livepatch_fstate *fstate = >fstate[i]; -func->applied = LIVEPATCH_FUNC_APPLIED; +fstate->applied = LIVEPATCH_FUNC_APPLIED; apply_cnt++; printk(KERN_DEBUG "%s: applying: %s\n", __func__, func->name); @@ -47,9 +48,10 @@ static int revert_hook(livepatch_payload_t *payload) for (i = 0; i < payload->nfuncs; i++) { -struct livepatch_func *func = >funcs[i]; +const struct livepatch_func *func = >funcs[i]; +struct livepatch_fstate *fstate = >fstate[i]; -func->applied = LIVEPATCH_FUNC_NOT_APPLIED; +fstate->applied = LIVEPATCH_FUNC_NOT_APPLIED; revert_cnt++; printk(KERN_DEBUG "%s: reverting: %s\n", __func__, func->name); @@ -68,7 +70,7 @@ static void post_revert_hook(livepatch_payload_t *payload) for (i = 0; i < payload->nfuncs; i++) { -struct livepatch_func *func = >funcs[i]; +const struct livepatch_func *func = >funcs[i]; printk(KERN_DEBUG "%s: reverted: %s\n", __func__, func->name); } diff --git a/xen/test/livepatch/xen_action_hooks_marker.c b/xen/test/livepatch/xen_action_hooks_marker.c index 4f807a577f25..d2e22f70d1f4 100644 --- a/xen/test/livepatch/xen_action_hooks_marker.c +++ b/xen/test/livepatch/xen_action_hooks_marker.c @@ -23,9 +23,10 @@ static int pre_apply_hook(livepatch_payload_t *payload) for (i = 0; i < payload->nfuncs; i++) { -struct livepatch_func *func = >funcs[i]; +const struct livepatch_func *func = >funcs[i]; +struct livepatch_fstate *fstate = >fstate[i]; -BUG_ON(func->applied == LIVEPATCH_FUNC_APPLIED); +BUG_ON(fstate->applied == LIVEPATCH_FUNC_APPLIED); printk(KERN_DEBUG "%s: pre applied: %s\n", __func__, func->name); } @@ -42,9 +43,10 @@ static void post_apply_hook(livepatch_payload_t *payload) for (i = 0; i < payload->nfuncs; i++) { -struct livepatch_func *func = >funcs[i]; +const struct livepatch_func *func = >funcs[i]; +struct livepatch_fstate *fstate = >fstate[i]; -BUG_ON(func->applied != LIVEPATCH_FUNC_APPLIED); +BUG_ON(fstate->applied != LIVEPATCH_FUNC_APPLIED); printk(KERN_DEBUG "%s: post applied: %s\n", __func__, func->name); } @@ -59,9 +61,10 @@ static int pre_revert_hook(livepatch_payload_t *payload) for (i = 0; i < payload->nfuncs; i++) { -struct livepatch_func *func = >funcs[i]; +const struct livepatch_func *func = >funcs[i]; +struct livepatch_fstate *fstate = >fstate[i]; -BUG_ON(func->applied != LIVEPATCH_FUNC_APPLIED); +BUG_ON(fstate->applied != LIVEPATCH_FUNC_APPLIED); printk(KERN_DEBUG "%s: pre reverted: %s\n", __func__, func->name); } @@ -78,9 +81,10 @@ static void post_revert_hook(livepatch_payload_t *payload) for (i = 0; i < payload->nfuncs; i++) { -struct livepatch_func *func = >funcs[i]; +const struct livepatch_func *func = >funcs[i]; +struct livepatch_fstate *fstate = >fstate[i]; -BUG_ON(func->applied == LIVEPATCH_FUNC_APPLIED); +BUG_ON(fstate->applied == LIVEPATCH_FUNC_APPLIED); printk(KERN_DEBUG "%s: post reverted: %s\n", __func__, func->name); } diff --git a/xen/test/livepatch/xen_action_hooks_noapply.c b/xen/test/livepatch/xen_action_hooks_noapply.c index 4c55c156a621..646a5fd2f002 100644 ---