Re: [PATCH 1/1] selftests: livepatch: add test cases of stack_order sysfs interface
On Fri 2024-10-11 09:51:07, zhang warden wrote: > > > > On Oct 10, 2024, at 23:51, Josh Poimboeuf wrote: > > > > Maybe add a replace=[true|false] module parameter. > > > > How to do it? > Isn't the way we build modules using make? > How to set this replace value? You could find inspiration in tools/testing/selftests/livepatch/test-livepatch.sh, see load_lp $MOD_REPLACE replace=0 vs. load_lp $MOD_REPLACE replace=1 You could more or less copy the "multiple livepatches" and "atomic replace livepatch" self-tests. The new tests would check the "stack_order" sysfs value instread of checking whether /proc/cmdline and /proc/meminfo are livepatched. Best Regards, Petr
Re: [PATCH 1/1] selftests: livepatch: add test cases of stack_order sysfs interface
On Fri, Oct 11, 2024 at 09:51:07AM +0800, zhang warden wrote: > > > > On Oct 10, 2024, at 23:51, Josh Poimboeuf wrote: > > > > Maybe add a replace=[true|false] module parameter. > > > > How to do it? > Isn't the way we build modules using make? > How to set this replace value? See for example what tools/testing/selftests/livepatch/test_modules/test_klp_atomic_replace.c is already doing with its "replace" parameter. Just add replace=0 to the insmod args to disable replace mode. -- Josh
Re: [PATCH 1/1] selftests: livepatch: add test cases of stack_order sysfs interface
> On Oct 10, 2024, at 23:51, Josh Poimboeuf wrote: > > Maybe add a replace=[true|false] module parameter. > How to do it? Isn't the way we build modules using make? How to set this replace value? Regards Wardenjohn
Re: [PATCH 1/1] selftests: livepatch: add test cases of stack_order sysfs interface
On Thu, Oct 10, 2024 at 11:11:56PM +0800, zhang warden wrote: > > IIUC, you only need to test the stack order by loading LP modules. In > > this case you could use our currently existing LP testing module for > > that, right? That's what we currently do when testing different sysfs > > attributes. > > > > Yes, in fact, those three module I submitted is reuse the existing LP > testing module of 'test_klp_livepatch'. Because I found some module > in test module set "klp_replace" attribute true. If a module set this > attribute true, it will disable the previous module. > > What's more, testing this 'stack_order' attribute need more than one > module, hoping to change the same function. And breaking the '.replace' > value of existing module may not be a good way. So I decided to copy > more test module with '.replace=false' and this module is changing > the same function. Maybe add a replace=[true|false] module parameter. -- Josh
Re: [PATCH 1/1] selftests: livepatch: add test cases of stack_order sysfs interface
Hi, Marcos! > On Oct 10, 2024, at 20:31, Marcos Paulo de Souza wrote: > > On Tue, 2024-10-08 at 15:52 +0800, Wardenjohn wrote: >> Add selftest test cases to sysfs attribute 'stack_order'. >> >> Signed-off-by: Wardenjohn >> --- >> .../testing/selftests/livepatch/test-sysfs.sh | 71 >> +++ >> .../selftests/livepatch/test_modules/Makefile | 5 +- >> .../test_klp_livepatch_noreplace.c| 53 ++ >> .../test_klp_livepatch_noreplace2.c | 53 ++ >> .../test_klp_livepatch_noreplace3.c | 53 ++ >> 5 files changed, 234 insertions(+), 1 deletion(-) >> create mode 100644 >> tools/testing/selftests/livepatch/test_modules/test_klp_livepatch_nor >> eplace.c >> create mode 100644 >> tools/testing/selftests/livepatch/test_modules/test_klp_livepatch_nor >> eplace2.c >> create mode 100644 >> tools/testing/selftests/livepatch/test_modules/test_klp_livepatch_nor >> eplace3.c > > IIUC, you only need to test the stack order by loading LP modules. In > this case you could use our currently existing LP testing module for > that, right? That's what we currently do when testing different sysfs > attributes. > Yes, in fact, those three module I submitted is reuse the existing LP testing module of 'test_klp_livepatch'. Because I found some module in test module set "klp_replace" attribute true. If a module set this attribute true, it will disable the previous module. What's more, testing this 'stack_order' attribute need more than one module, hoping to change the same function. And breaking the '.replace' value of existing module may not be a good way. So I decided to copy more test module with '.replace=false' and this module is changing the same function. Regards. Wardenjohn.
Re: [PATCH 1/1] selftests: livepatch: add test cases of stack_order sysfs interface
On Tue, 2024-10-08 at 15:52 +0800, Wardenjohn wrote: > Add selftest test cases to sysfs attribute 'stack_order'. > > Signed-off-by: Wardenjohn > --- > .../testing/selftests/livepatch/test-sysfs.sh | 71 > +++ > .../selftests/livepatch/test_modules/Makefile | 5 +- > .../test_klp_livepatch_noreplace.c | 53 ++ > .../test_klp_livepatch_noreplace2.c | 53 ++ > .../test_klp_livepatch_noreplace3.c | 53 ++ > 5 files changed, 234 insertions(+), 1 deletion(-) > create mode 100644 > tools/testing/selftests/livepatch/test_modules/test_klp_livepatch_nor > eplace.c > create mode 100644 > tools/testing/selftests/livepatch/test_modules/test_klp_livepatch_nor > eplace2.c > create mode 100644 > tools/testing/selftests/livepatch/test_modules/test_klp_livepatch_nor > eplace3.c IIUC, you only need to test the stack order by loading LP modules. In this case you could use our currently existing LP testing module for that, right? That's what we currently do when testing different sysfs attributes. > > diff --git a/tools/testing/selftests/livepatch/test-sysfs.sh > b/tools/testing/selftests/livepatch/test-sysfs.sh > index 05a14f5a7bfb..a086b62fb488 100755 > --- a/tools/testing/selftests/livepatch/test-sysfs.sh > +++ b/tools/testing/selftests/livepatch/test-sysfs.sh > @@ -5,6 +5,9 @@ > . $(dirname $0)/functions.sh > > MOD_LIVEPATCH=test_klp_livepatch > +MOD_LIVEPATCH_NOREPLACE=test_klp_livepatch_noreplace > +MOD_LIVEPATCH_NOREPLACE2=test_klp_livepatch_noreplace2 > +MOD_LIVEPATCH_NOREPLACE3=test_klp_livepatch_noreplace3 > > setup_config > > @@ -131,4 +134,72 @@ livepatch: '$MOD_LIVEPATCH': completing > unpatching transition > livepatch: '$MOD_LIVEPATCH': unpatching complete > % rmmod $MOD_LIVEPATCH" > > +start_test "sysfs test stack_order read" > + > +load_lp $MOD_LIVEPATCH_NOREPLACE > + > +check_sysfs_rights "$MOD_LIVEPATCH_NOREPLACE" "stack_order" "-r--r-- > r--" > +check_sysfs_value "$MOD_LIVEPATCH_NOREPLACE" "stack_order" "1" > + > +load_lp $MOD_LIVEPATCH_NOREPLACE2 > + > +check_sysfs_rights "$MOD_LIVEPATCH_NOREPLACE2" "stack_order" "-r--r- > -r--" > +check_sysfs_value "$MOD_LIVEPATCH_NOREPLACE2" "stack_order" "2" > + > +load_lp $MOD_LIVEPATCH_NOREPLACE3 > + > +check_sysfs_rights "$MOD_LIVEPATCH_NOREPLACE3" "stack_order" "-r--r- > -r--" > +check_sysfs_value "$MOD_LIVEPATCH_NOREPLACE3" "stack_order" "3" > + > +disable_lp $MOD_LIVEPATCH_NOREPLACE2 > +unload_lp $MOD_LIVEPATCH_NOREPLACE2 > + > +check_sysfs_rights "$MOD_LIVEPATCH_NOREPLACE" "stack_order" "-r--r-- > r--" > +check_sysfs_value "$MOD_LIVEPATCH_NOREPLACE" "stack_order" "1" > +check_sysfs_rights "$MOD_LIVEPATCH_NOREPLACE3" "stack_order" "-r--r- > -r--" > +check_sysfs_value "$MOD_LIVEPATCH_NOREPLACE3" "stack_order" "2" > + > +disable_lp $MOD_LIVEPATCH_NOREPLACE3 > +unload_lp $MOD_LIVEPATCH_NOREPLACE3 > + > +disable_lp $MOD_LIVEPATCH_NOREPLACE > +unload_lp $MOD_LIVEPATCH_NOREPLACE > + > +check_result "% insmod test_modules/$MOD_LIVEPATCH_NOREPLACE.ko > +livepatch: enabling patch '$MOD_LIVEPATCH_NOREPLACE' > +livepatch: '$MOD_LIVEPATCH_NOREPLACE': initializing patching > transition > +livepatch: '$MOD_LIVEPATCH_NOREPLACE': starting patching transition > +livepatch: '$MOD_LIVEPATCH_NOREPLACE': completing patching > transition > +livepatch: '$MOD_LIVEPATCH_NOREPLACE': patching complete > +% insmod test_modules/$MOD_LIVEPATCH_NOREPLACE2.ko > +livepatch: enabling patch '$MOD_LIVEPATCH_NOREPLACE2' > +livepatch: '$MOD_LIVEPATCH_NOREPLACE2': initializing patching > transition > +livepatch: '$MOD_LIVEPATCH_NOREPLACE2': starting patching transition > +livepatch: '$MOD_LIVEPATCH_NOREPLACE2': completing patching > transition > +livepatch: '$MOD_LIVEPATCH_NOREPLACE2': patching complete > +% insmod test_modules/$MOD_LIVEPATCH_NOREPLACE3.ko > +livepatch: enabling patch '$MOD_LIVEPATCH_NOREPLACE3' > +livepatch: '$MOD_LIVEPATCH_NOREPLACE3': initializing patching > transition > +livepatch: '$MOD_LIVEPATCH_NOREPLACE3': starting patching transition > +livepatch: '$MOD_LIVEPATCH_NOREPLACE3': completing patching > transition > +livepatch: '$MOD_LIVEPATCH_NOREPLACE3': patching complete > +% echo 0 > /sys/kernel/livepatch/$MOD_LIVEPATCH_NOREPLACE2/enabled > +livepatch: '$MOD_LIVEPATCH_NOREPLACE2': initializing unpatching > transition > +livepatch: '$MOD_LIVEPATCH_NOREPLACE2': starting unpatching > transition > +livepatch: '$MOD_LIVEPATCH_NOREPLACE2': completing unpatching > transition > +livepatch: '$MOD_LIVEPATCH_NOREPLACE2': unpatching complete > +% rmmod $MOD_LIVEPATCH_NOREPLACE2 > +% echo 0 > /sys/kernel/livepatch/$MOD_LIVEPATCH_NOREPLACE3/enabled > +livepatch: '$MOD_LIVEPATCH_NOREPLACE3': initializing unpatching > transition > +livepatch: '$MOD_LIVEPATCH_NOREPLACE3': starting unpatching > transition > +livepatch: '$MOD_LIVEPATCH_NOREPLACE3': completing unpatching > transition > +livepatch: '$MOD_LIVEPATCH_NOREPLACE3': unpatching complete > +% rmmod $MOD_LIVEPATCH_NOREPLACE3 > +% ech

