From: Cyril Hrubis <chrubis@suse.cz>
To: Li Wang <liwang@redhat.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH 0/3] checkpoint: Refactor and unify shell/C reinit support
Date: Fri, 27 Jun 2025 09:49:40 +0200 [thread overview]
Message-ID: <aF5NFP5KpuebdkwV@yuki.lan> (raw)
In-Reply-To: <CAEemH2esWnKqv2q-UM3tHoTRfR6caLp-0yZN1yF6XCk79XSOyA@mail.gmail.com>
Hi!
> > I think that the root of the problem is that the shell function
> > _tst_init_checkpoints() does not create the IPC region with the magic.
> >
> > What about this patch:
> >
> > diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
> > index c32bd8b19..a310d3922 100644
> > --- a/testcases/lib/tst_test.sh
> > +++ b/testcases/lib/tst_test.sh
> > @@ -627,6 +627,7 @@ _tst_init_checkpoints()
> > tst_brk TBROK "tst_getconf PAGESIZE failed"
> > fi
> > ROD_SILENT dd if=/dev/zero of="$LTP_IPC_PATH" bs="$pagesize"
> > count=1
> > + ROD_SILENT printf LTPM | dd of="$LTP_IPC_PATH" bs=1 seek=0
> > conv=notrunc
> >
>
> No, I'm afraid this won't work as expected.
>
> The PEC failure wasn't caused by the shell checkpoint missing the "LTPM"
> magic. Instead, the root cause was that the reinitialization logic
> (tst_reinit())
> expected a different IPC format.
I do not think so, both the PEC C helpers and the tst_checkpoint.c call
tst_reinit() so as long as the function succeeds the memory layout will
be the same. The checkpoints will start at some offset in the page of
the IPC memory, but that was always the case.
And it turns out that the patch I've send yesterday does not work
because of endianity. The magic in the IPC region is MPTL on little
endian.
This patch actually works:
diff --git a/lib/tst_test.c b/lib/tst_test.c
index 495e022f7..17ce91932 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -52,7 +52,13 @@ const char *TCID __attribute__((weak));
#define CVE_DB_URL "https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-"
#define DEFAULT_TIMEOUT 30
-#define LTP_MAGIC 0x4C54504D /* Magic number is "LTPM" */
+
+/* Magic number is "LTPM" */
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+# define LTP_MAGIC 0x4C54504D
+#else
+# define LTP_MAGIC 0x4D50544C
+#endif
struct tst_test *tst_test;
diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index c32bd8b19..4be10a4f9 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -627,6 +627,7 @@ _tst_init_checkpoints()
tst_brk TBROK "tst_getconf PAGESIZE failed"
fi
ROD_SILENT dd if=/dev/zero of="$LTP_IPC_PATH" bs="$pagesize" count=1
+ ROD_SILENT "printf LTPM | dd of="$LTP_IPC_PATH" bs=1 seek=0 conv=notrunc"
ROD_SILENT chmod 600 "$LTP_IPC_PATH"
export LTP_IPC_PATH
}
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2025-06-27 7:49 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-16 10:26 [LTP] [PATCH 0/3] checkpoint: Refactor and unify shell/C reinit support Li Wang via ltp
2025-06-16 10:26 ` [LTP] [PATCH 1/3] shell/lib: refactor checkpoint with shared path for exec() support Li Wang via ltp
2025-06-17 12:18 ` Avinesh Kumar
2025-06-16 10:26 ` [LTP] [PATCH 2/3] kernel/pec: switch to new checkpoint wait/wake interface Li Wang via ltp
2025-06-16 10:26 ` [LTP] [PATCH 3/3] tst_checkpoint: Detect and reinit shell or C style checkpoint file Li Wang via ltp
2025-06-26 13:26 ` [LTP] [PATCH 0/3] checkpoint: Refactor and unify shell/C reinit support Cyril Hrubis
2025-06-26 15:09 ` Li Wang via ltp
2025-06-27 7:49 ` Cyril Hrubis [this message]
2025-06-27 9:25 ` Li Wang via ltp
2025-06-27 10:20 ` Cyril Hrubis
2025-06-27 10:28 ` Li Wang via ltp
2025-06-27 10:43 ` Cyril Hrubis
2025-06-27 10:49 ` Li Wang via ltp
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aF5NFP5KpuebdkwV@yuki.lan \
--to=chrubis@suse.cz \
--cc=liwang@redhat.com \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox