From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
"Oleksii Kurochko" <oleksii.kurochko@gmail.com>,
"Anthony PERARD" <anthony.perard@vates.tech>,
"Michal Orzel" <michal.orzel@amd.com>,
"Jan Beulich" <jbeulich@suse.com>,
"Julien Grall" <julien@xen.org>,
"Roger Pau Monné" <roger.pau@citrix.com>,
"Stefano Stabellini" <sstabellini@kernel.org>
Subject: [PATCH for-4.20 3/3] RISCV: Activate UBSAN in testing
Date: Fri, 7 Feb 2025 22:01:22 +0000 [thread overview]
Message-ID: <20250207220122.380214-4-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <20250207220122.380214-1-andrew.cooper3@citrix.com>
RISC-V has less complicated headers, so update ubsan.c to pull in everything
it needs. Provide dump_execution_state(), and update the printk() message to
make it more obvious that it's an outstanding task.
As with commit 8ef2ac727e21 ("automation: enable UBSAN for debug tests"),
enable UBSAN in RISC-V testing too.
No functional change.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Oleksii Kurochko <oleksii.kurochko@gmail.com>
CC: Anthony PERARD <anthony.perard@vates.tech>
CC: Michal Orzel <michal.orzel@amd.com>
CC: Jan Beulich <jbeulich@suse.com>
CC: Julien Grall <julien@xen.org>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
Testing of this series:
https://gitlab.com/xen-project/people/andyhhp/xen/-/jobs/9078817715
Sample run with an intentional UBSAN failure:
https://gitlab.com/xen-project/people/andyhhp/xen/-/jobs/9078570135
---
automation/gitlab-ci/build.yaml | 3 +++
xen/arch/riscv/Kconfig | 1 +
xen/arch/riscv/include/asm/processor.h | 2 ++
xen/arch/riscv/traps.c | 2 +-
xen/common/ubsan/ubsan.c | 5 ++++-
5 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/automation/gitlab-ci/build.yaml b/automation/gitlab-ci/build.yaml
index fb55d4ce5568..35e224366f62 100644
--- a/automation/gitlab-ci/build.yaml
+++ b/automation/gitlab-ci/build.yaml
@@ -359,6 +359,9 @@ debian-12-riscv64-gcc-debug:
CONTAINER: debian:12-riscv64
KBUILD_DEFCONFIG: tiny64_defconfig
HYPERVISOR_ONLY: y
+ EXTRA_XEN_CONFIG: |
+ CONFIG_UBSAN=y
+ CONFIG_UBSAN_FATAL=y
# Arm32 cross-build
diff --git a/xen/arch/riscv/Kconfig b/xen/arch/riscv/Kconfig
index 00f329054c94..fa95cd0a4213 100644
--- a/xen/arch/riscv/Kconfig
+++ b/xen/arch/riscv/Kconfig
@@ -4,6 +4,7 @@ config RISCV
select GENERIC_BUG_FRAME
select HAS_DEVICE_TREE
select HAS_PMAP
+ select HAS_UBSAN
select HAS_VMAP
config RISCV_64
diff --git a/xen/arch/riscv/include/asm/processor.h b/xen/arch/riscv/include/asm/processor.h
index 90b800956303..39696fb58dc6 100644
--- a/xen/arch/riscv/include/asm/processor.h
+++ b/xen/arch/riscv/include/asm/processor.h
@@ -91,6 +91,8 @@ static inline void sfence_vma(void)
asm volatile ( "sfence.vma" ::: "memory" );
}
+#define dump_execution_state() run_in_exception_handler(show_execution_state)
+
#endif /* __ASSEMBLY__ */
#endif /* ASM__RISCV__PROCESSOR_H */
diff --git a/xen/arch/riscv/traps.c b/xen/arch/riscv/traps.c
index d55a4a827b8c..ea3638a54fed 100644
--- a/xen/arch/riscv/traps.c
+++ b/xen/arch/riscv/traps.c
@@ -140,7 +140,7 @@ void vcpu_show_execution_state(struct vcpu *v)
void show_execution_state(const struct cpu_user_regs *regs)
{
- printk("implement show_execution_state(regs)\n");
+ printk("TODO: Implement show_execution_state(regs)\n");
}
void arch_hypercall_tasklet_result(struct vcpu *v, long res)
diff --git a/xen/common/ubsan/ubsan.c b/xen/common/ubsan/ubsan.c
index 7f73f94759db..e99370322b44 100644
--- a/xen/common/ubsan/ubsan.c
+++ b/xen/common/ubsan/ubsan.c
@@ -10,8 +10,11 @@
*
*/
-#include <xen/spinlock.h>
+#include <xen/bitops.h>
+#include <xen/kernel.h>
+#include <xen/lib.h>
#include <xen/percpu.h>
+#include <xen/spinlock.h>
#define __noreturn noreturn
#define pr_err(...) printk(XENLOG_ERR __VA_ARGS__)
--
2.39.5
next prev parent reply other threads:[~2025-02-07 22:01 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-07 22:01 [PATCH for-4.20 0/3] RISCV: Bugfixes and UBSAN Andrew Cooper
2025-02-07 22:01 ` [PATCH for-4.20 1/3] RISCV/boot: Run constructors during setup Andrew Cooper
2025-02-10 8:49 ` Oleksii Kurochko
2025-02-07 22:01 ` [PATCH for-4.20 2/3] RISCV/asm: Use CALL rather than JAL Andrew Cooper
2025-02-10 8:57 ` Oleksii Kurochko
2025-02-07 22:01 ` Andrew Cooper [this message]
2025-02-08 2:39 ` [PATCH for-4.20 3/3] RISCV: Activate UBSAN in testing Stefano Stabellini
2025-02-10 9:03 ` Oleksii Kurochko
2025-02-10 23:39 ` Andrew Cooper
2025-02-10 9:05 ` [PATCH for-4.20 0/3] RISCV: Bugfixes and UBSAN Oleksii Kurochko
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=20250207220122.380214-4-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=anthony.perard@vates.tech \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=michal.orzel@amd.com \
--cc=oleksii.kurochko@gmail.com \
--cc=roger.pau@citrix.com \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.