From patchwork Thu Mar 13 15:30:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 14015297 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 693C0C282EC for ; Thu, 13 Mar 2025 15:32:39 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.912506.1318753 (Exim 4.92) (envelope-from ) id 1tskXu-00087t-GA; Thu, 13 Mar 2025 15:32:30 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 912506.1318753; Thu, 13 Mar 2025 15:32:30 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tskXu-00087m-CG; Thu, 13 Mar 2025 15:32:30 +0000 Received: by outflank-mailman (input) for mailman id 912506; Thu, 13 Mar 2025 15:32:29 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tskXt-0007tP-9d for xen-devel@lists.xenproject.org; Thu, 13 Mar 2025 15:32:29 +0000 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [2a00:1450:4864:20::52b]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 5f55f0ef-0020-11f0-9ab9-95dc52dad729; Thu, 13 Mar 2025 16:32:28 +0100 (CET) Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-5dc89df7eccso1813155a12.3 for ; Thu, 13 Mar 2025 08:32:28 -0700 (PDT) Received: from localhost ([84.78.159.3]) by smtp.gmail.com with UTF8SMTPSA id 4fb4d7f45d1cf-5e8169b896csm843516a12.44.2025.03.13.08.32.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Mar 2025 08:32:27 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 5f55f0ef-0020-11f0-9ab9-95dc52dad729 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1741879948; x=1742484748; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vReGhqfBJ4uK8Q3JcoYxiqLwitDEZqAnuu3xoPEvPbI=; b=q9FMDkoJEYR/KqH60ERIN8GNpQ0E7yUidjn1jPAEPWu7FMI2HTgfm+4HIvmKj1+ZiB oSeLrppwgWQn+rQ2lM3uQzzrXBVVzbpy/yHcHsc9lI5nwERkaqJfGZKCFPzRiuHjbt4P QaP0P4GUsD17lQgmLQO028ceRCDYY8632AuyM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741879948; x=1742484748; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vReGhqfBJ4uK8Q3JcoYxiqLwitDEZqAnuu3xoPEvPbI=; b=ZZerKUHWne9/Tc80/N1D8lVke5Vo0/ExnUlbIIme5Sb8Yl3e1ZlmGciS7olUs41ipb AfySwLqEcS0d0wG7Ra+AAUtJCTxEj/iUYKMdXa4DP1QAfEzFIdCEb+XxJqK2Qf3jMegq NwlGro8j0qWZgIobkFeigVCwqlKSMDE/izlpPMn7WU9uCg96mcwXb7NPxImzAY6iWAyq ar9EYbYwQlfUx8nY2W8pIZzd8M5emOCOsarZwQanyi9fsVRPt4rJ1+dXL6IDtRwMVJOn n2AI64QXYkHHDjpU5MGOHS8InvL+T89wpeCFurfhKV7Mh2ZVdFGq+AdcubGPWRGAMyY2 XlQg== X-Gm-Message-State: AOJu0YxsQNRbUvA5SML+Pt2uyGI6zSH4/8HO9ebwqpCKxfWGcuUkwh+T JCUdbR7ssOdV1G5Pv1/gkir/u+nNORcf6UmmghJSTVzmANV+rpo6ehZkjBMsqUYe0WH/ERn/Lra 5 X-Gm-Gg: ASbGncvDpm1Z7d8OxeDXRTDO8029hgvmi0XcM5yj1Ei4/dBDsmzhpRsojY/sSoNlGEG KNsm9q8mSkhoaQok2vETehpMJUzyVVJg0eEo4JAytSEkUSJHsiuNvAEXBKnmMNcE1VXy8vjEony RnS4xiLJG2iOSDS88eEGWTs3HZIh+v1c2OfpM+0MA6BoI8y7pG7ermKNfA5C+3DgQ0cIt5w4+kK FjNIDC+gFeSfEfJU66nyBlLAuKU0BVDdz+KxuMvdOIPW4Rhrmfy9hakZbmO1eA4msJw1+34iahq rS6p0U5PX+kpTjT4/U1YQhYk6My1rxPnz4uZsdOD6dK3kEa2Gg== X-Google-Smtp-Source: AGHT+IFbfEhj6MgxTlKULwwo1Wwd0a5nmj7+MHvWMfzojnaK99p1HyYC4BL4AwHBleG+iqcEYcl8SA== X-Received: by 2002:a05:6402:2550:b0:5e1:8604:9a2d with SMTP id 4fb4d7f45d1cf-5e5e229949amr31872827a12.4.1741879947944; Thu, 13 Mar 2025 08:32:27 -0700 (PDT) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , Stefano Stabellini Subject: [PATCH 1/7] xen/ubsan: provide helper for clang's -fsanitize=function Date: Thu, 13 Mar 2025 16:30:23 +0100 Message-ID: <20250313153029.93347-2-roger.pau@citrix.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250313153029.93347-1-roger.pau@citrix.com> References: <20250313153029.93347-1-roger.pau@citrix.com> MIME-Version: 1.0 clang's -fsanitize=function relies on the presence of __ubsan_handle_function_type_mismatch() to print the detection of indirect calls of a function through a function pointer of the wrong type. Implement the helper, inspired on the llvm ubsan lib implementation. Signed-off-by: Roger Pau Monné Reviewed-by: Andrew Cooper --- xen/common/ubsan/ubsan.c | 16 ++++++++++++++++ xen/common/ubsan/ubsan.h | 5 +++++ 2 files changed, 21 insertions(+) diff --git a/xen/common/ubsan/ubsan.c b/xen/common/ubsan/ubsan.c index e99370322b44..7ebe4bfc14dc 100644 --- a/xen/common/ubsan/ubsan.c +++ b/xen/common/ubsan/ubsan.c @@ -546,3 +546,19 @@ void __ubsan_handle_invalid_builtin(struct invalid_builtin_data *data) ubsan_epilogue(&flags); } + +void __ubsan_handle_function_type_mismatch( + struct function_type_mismatch_data *data, unsigned long val) +{ + unsigned long flags; + + if (suppress_report(&data->location)) + return; + + ubsan_prologue(&data->location, &flags); + + pr_err("call to function %ps through pointer to incorrect function type %s\n", + (void *)val, data->type->type_name); + + ubsan_epilogue(&flags); +} diff --git a/xen/common/ubsan/ubsan.h b/xen/common/ubsan/ubsan.h index 9c7f3b9b6c07..8987f9d45397 100644 --- a/xen/common/ubsan/ubsan.h +++ b/xen/common/ubsan/ubsan.h @@ -95,6 +95,11 @@ enum { kind_clz, }; +struct function_type_mismatch_data { + struct source_location location; + struct type_descriptor *type; +}; + #if defined(CONFIG_ARCH_SUPPORTS_INT128) && defined(__SIZEOF_INT128__) typedef __int128 s_max; typedef unsigned __int128 u_max; From patchwork Thu Mar 13 15:30:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 14015301 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0008CC35FF3 for ; Thu, 13 Mar 2025 15:32:43 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.912508.1318764 (Exim 4.92) (envelope-from ) id 1tskXy-0008Or-Od; Thu, 13 Mar 2025 15:32:34 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 912508.1318764; Thu, 13 Mar 2025 15:32:34 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tskXy-0008Oi-Ju; Thu, 13 Mar 2025 15:32:34 +0000 Received: by outflank-mailman (input) for mailman id 912508; Thu, 13 Mar 2025 15:32:33 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tskXx-0008Nv-Lc for xen-devel@lists.xenproject.org; Thu, 13 Mar 2025 15:32:33 +0000 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [2a00:1450:4864:20::635]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 5f82c228-0020-11f0-9898-31a8f345e629; Thu, 13 Mar 2025 16:32:29 +0100 (CET) Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-aaecf50578eso189733266b.2 for ; Thu, 13 Mar 2025 08:32:31 -0700 (PDT) Received: from localhost ([84.78.159.3]) by smtp.gmail.com with UTF8SMTPSA id a640c23a62f3a-ac31485bd4dsm92628466b.81.2025.03.13.08.32.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Mar 2025 08:32:28 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 5f82c228-0020-11f0-9898-31a8f345e629 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1741879950; x=1742484750; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iluUGVwmybl1uvmaup9n3VtNZWTX7tEEI+m9+ONsj+U=; b=q8rEVf+Ob+WCttZ+Rh4BoF2bAr5195efd8VzeaNfEuNFMyjkDbdreVM6NWekeKA/Dg h3G9fFzFTLkg6XUDFkIquQI4ZCAdced5qoXvvNg538Ow94rz4JuDz4EdNiaSfMvuaCBb B0AKEZ233MnBwtyAPSGP8PKvgBp20IMdJ4YF8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741879950; x=1742484750; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iluUGVwmybl1uvmaup9n3VtNZWTX7tEEI+m9+ONsj+U=; b=QDNwOsj03OggsgRjlQAQ/ndXde0GMNpYdASG66FTa41gWE/Czx9rpxlKZlUhIENvlW HpHqoDvQCfDByvZ3XJ9RgCODUaRNlr61/81MmV8fhvVd/xoBHjDJxkx6gB7JQkoH9UII m2M9OSD1QdzxWF5Pqevt3aD+mfgy0zO/LpFX5qH+0AAUSQoikt/pNA5zbt2aDaDdv2qe RzJ40xZKlYutpSZYQiOvmBm4G5bKeEvRIuuaZik5/hLF5u4mJI7CH6/L1H01kmxfIrOY YgBw2YpVumioFIdQn57dyEJqn8dYNZJar/4mGkoPkfc7ddc5+nxS4Ixdaz0bhCoeTvjj WOFw== X-Gm-Message-State: AOJu0YxGJcsRPU050f3tAlbMqnBaNtmiGxJvXm/JCwJJyEX/m8VWDwN1 e89NniEBEhy3pXt0dIasu0CiMY1OXj+q3Hn5CzQ8H4pwU22movvYzNw+HDUwy7cYV6IahN/K2+c i X-Gm-Gg: ASbGncudjxu+ReLbX5KdEYk9ENGAf5LiBIxwsKsSxi12BSRSxc4nlVKyE7PPWnGCYsm GQjh6zl5EiCOTDIuVNTkRc/M1B2pHyzuo17WOpvO/zYB/0wWxD8U/pxEpxMfPd128PYC9FWjMdb oDKEEBHEta6q+bUBF2wyG77eEaIMGNZFRuQHvsf8kWDuv/X/ox4YLRIXZUT9vBKn8pwkDrZjJst 6lgBZajXZJSBng/kydNePRyQC7zR4PMUXrk3LNutMIEYLAkDkMJJtROvhr35dipwCgZnUSGZons r2wGU0xRHM2gyoVSQWUb0y8OLUIXDhMcpcoD2+4Aqg7A3HqDbA== X-Google-Smtp-Source: AGHT+IEWRdiX/lHxQJn1GQzKfoYttXRxTb0u6BxSs7Pj8QR/2O92Sn67rPf1DLNoFI7M6Xa7Y1ij5Q== X-Received: by 2002:a17:907:9725:b0:ac2:d667:8d64 with SMTP id a640c23a62f3a-ac2d66790a7mr1057682366b.39.1741879949199; Thu, 13 Mar 2025 08:32:29 -0700 (PDT) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , Stefano Stabellini Subject: [PATCH 2/7] x86/wait: prevent duplicated assembly labels Date: Thu, 13 Mar 2025 16:30:24 +0100 Message-ID: <20250313153029.93347-3-roger.pau@citrix.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250313153029.93347-1-roger.pau@citrix.com> References: <20250313153029.93347-1-roger.pau@citrix.com> MIME-Version: 1.0 When enabling UBSAN with clang, the following error is triggered during the build: common/wait.c:154:9: error: symbol '.L_wq_resume' is already defined 154 | "push %%rbx; push %%rbp; push %%r12;" | ^ :1:121: note: instantiated into assembly here 1 | push %rbx; push %rbp; push %r12;push %r13; push %r14; push %r15;sub %esp,%ecx;cmp $4096, %ecx;ja .L_skip;mov %rsp,%rsi;.L_wq_resume: rep movsb;mov %rsp,%rsi;.L_skip:pop %r15; pop %r14; pop %r13;pop %r12; pop %rbp; pop %rbx | ^ common/wait.c:154:9: error: symbol '.L_skip' is already defined 154 | "push %%rbx; push %%rbp; push %%r12;" | ^ :1:159: note: instantiated into assembly here 1 | push %rbx; push %rbp; push %r12;push %r13; push %r14; push %r15;sub %esp,%ecx;cmp $4096, %ecx;ja .L_skip;mov %rsp,%rsi;.L_wq_resume: rep movsb;mov %rsp,%rsi;.L_skip:pop %r15; pop %r14; pop %r13;pop %r12; pop %rbp; pop %rbx | ^ 2 errors generated. The inline assembly block in __prepare_to_wait() is duplicated, thus leading to multiple definitions of the otherwise unique labels inside the assembly block. GCC extended-asm documentation notes the possibility of duplicating asm blocks: > Under certain circumstances, GCC may duplicate (or remove duplicates of) > your assembly code when optimizing. This can lead to unexpected duplicate > symbol errors during compilation if your asm code defines symbols or > labels. Using ‘%=’ (see AssemblerTemplate) may help resolve this problem. Move the assembly blocks that deal with saving and restoring the current CPU context into it's own explicitly non-inline functions. This prevents clang from duplicating the assembly blocks. Just using noinline attribute seems to be enough to prevent assembly duplication, in the future noclone might also be required if asm block duplication issues arise again. Additionally, add a small self-test to ensure the consistency of the context save and restore logic. Link: https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html Link: https://github.com/llvm/llvm-project/issues/92161 Signed-off-by: Roger Pau Monné --- xen/common/wait.c | 111 +++++++++++++++++++++++++++++++--------------- 1 file changed, 76 insertions(+), 35 deletions(-) diff --git a/xen/common/wait.c b/xen/common/wait.c index cb6f5ff3c20a..2fcbbe8d0c71 100644 --- a/xen/common/wait.c +++ b/xen/common/wait.c @@ -119,24 +119,16 @@ void wake_up_all(struct waitqueue_head *wq) #ifdef CONFIG_X86 -static void __prepare_to_wait(struct waitqueue_vcpu *wqv) +/* + * context_save() must strictly be noinline, as to avoid multiple callers from + * inlining the code, thus duplicating the label and triggering an assembler + * error about duplicated labels. + */ +static void noinline context_save(struct waitqueue_vcpu *wqv) { struct cpu_info *cpu_info = get_cpu_info(); - struct vcpu *curr = current; unsigned long dummy; - ASSERT(wqv->esp == NULL); - - /* Save current VCPU affinity; force wakeup on *this* CPU only. */ - if ( vcpu_temporary_affinity(curr, smp_processor_id(), VCPU_AFFINITY_WAIT) ) - { - gdprintk(XENLOG_ERR, "Unable to set vcpu affinity\n"); - domain_crash(curr->domain); - - for ( ; ; ) - do_softirq(); - } - /* * Hand-rolled setjmp(). * @@ -170,6 +162,54 @@ static void __prepare_to_wait(struct waitqueue_vcpu *wqv) : "0" (0), "1" (cpu_info), "2" (wqv->stack), [sz] "i" (PAGE_SIZE) : "memory", "rax", "rdx", "r8", "r9", "r10", "r11" ); +} + +/* + * Since context_save() is noinline, context_restore() must also be noinline, + * to balance the RET vs CALL instructions. + */ +static void noinline noreturn context_restore(struct waitqueue_vcpu *wqv) +{ + /* + * Hand-rolled longjmp(). + * + * check_wakeup_from_wait() is always called with a shallow stack, + * immediately after the vCPU has been rescheduled. + * + * Adjust %rsp to be the correct depth for the (deeper) stack we want to + * restore, then prepare %rsi, %rdi and %rcx such that when we rejoin the + * rep movs in __prepare_to_wait(), it copies from wqv->stack over the + * active stack. + * + * All other GPRs are available for use; They're restored from the stack, + * or explicitly clobbered. + */ + asm volatile ( "mov %%rdi, %%rsp;" + "jmp .L_wq_resume" + : + : "S" (wqv->stack), "D" (wqv->esp), + "c" ((char *)get_cpu_info() - (char *)wqv->esp) + : "memory" ); + unreachable(); +} + +static void __prepare_to_wait(struct waitqueue_vcpu *wqv) +{ + struct vcpu *curr = current; + + ASSERT(wqv->esp == NULL); + + /* Save current VCPU affinity; force wakeup on *this* CPU only. */ + if ( vcpu_temporary_affinity(curr, smp_processor_id(), VCPU_AFFINITY_WAIT) ) + { + gdprintk(XENLOG_ERR, "Unable to set vcpu affinity\n"); + domain_crash(curr->domain); + + for ( ; ; ) + do_softirq(); + } + + context_save(wqv); if ( unlikely(wqv->esp == NULL) ) { @@ -229,30 +269,31 @@ void check_wakeup_from_wait(void) * * Therefore, no actions are necessary here to maintain RSB safety. */ - - /* - * Hand-rolled longjmp(). - * - * check_wakeup_from_wait() is always called with a shallow stack, - * immediately after the vCPU has been rescheduled. - * - * Adjust %rsp to be the correct depth for the (deeper) stack we want to - * restore, then prepare %rsi, %rdi and %rcx such that when we rejoin the - * rep movs in __prepare_to_wait(), it copies from wqv->stack over the - * active stack. - * - * All other GPRs are available for use; They're restored from the stack, - * or explicitly clobbered. - */ - asm volatile ( "mov %%rdi, %%rsp;" - "jmp .L_wq_resume" - : - : "S" (wqv->stack), "D" (wqv->esp), - "c" ((char *)get_cpu_info() - (char *)wqv->esp) - : "memory" ); + context_restore(wqv); unreachable(); } +#ifdef CONFIG_SELF_TESTS +static void __init __constructor test_save_restore_ctx(void) +{ + static unsigned int __initdata count; + struct waitqueue_vcpu wqv = {}; + + wqv.stack = alloc_xenheap_page(); + if ( !wqv.stack ) + panic("unable to allocate memory for context selftest\n"); + + context_save(&wqv); + if ( !count++ ) + context_restore(&wqv); + + if ( count != 2 ) + panic("context save and restore not working as expected\n"); + + free_xenheap_page(wqv.stack); +} +#endif + #else /* !CONFIG_X86 */ #define __prepare_to_wait(wqv) ((void)0) From patchwork Thu Mar 13 15:30:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 14015300 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8D3A8C35FF4 for ; Thu, 13 Mar 2025 15:32:44 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.912511.1318787 (Exim 4.92) (envelope-from ) id 1tskY0-0000RW-VA; Thu, 13 Mar 2025 15:32:36 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 912511.1318787; Thu, 13 Mar 2025 15:32:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tskY0-0000Pa-ND; Thu, 13 Mar 2025 15:32:36 +0000 Received: by outflank-mailman (input) for mailman id 912511; Thu, 13 Mar 2025 15:32:35 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tskXz-0007tP-QY for xen-devel@lists.xenproject.org; Thu, 13 Mar 2025 15:32:35 +0000 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [2a00:1450:4864:20::62d]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 61e3d338-0020-11f0-9ab9-95dc52dad729; Thu, 13 Mar 2025 16:32:33 +0100 (CET) Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-ac2bfcd2a66so195988166b.0 for ; Thu, 13 Mar 2025 08:32:33 -0700 (PDT) Received: from localhost ([84.78.159.3]) by smtp.gmail.com with UTF8SMTPSA id a640c23a62f3a-ac3147e75f6sm94542466b.50.2025.03.13.08.32.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Mar 2025 08:32:30 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 61e3d338-0020-11f0-9ab9-95dc52dad729 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1741879952; x=1742484752; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0pnkqaluj8B9YBV7qcBYIqpLoiXoQSDu6pxVexTlitI=; b=NrAf98HlnJiNUst+0n8I9m+0aWIvQL/Ygzabp3Y97fyO21SQHYEWcTLEg+x8tOFNFo 6TV7rE4Y9wFJcadskO0ggEpugkvndhYFa7ib2nsoSiXLUyudi72DybQCyxUI1kaEF9kq ICoDrsfFg7Vj4tJtTQz5/iox824iUzaXEeu6Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741879952; x=1742484752; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0pnkqaluj8B9YBV7qcBYIqpLoiXoQSDu6pxVexTlitI=; b=eTucIz6jvyqM0/69gzNCZyI1HZOcITq0oFQ3914GBauppVLARw80kHiZ/zZx22sSIw ypLOdKTpn4X/4uextv+qQZdkP0ao9qFvsbnHvIcq1fQVlx/99YtARn5F2yVmiGfcQqwX kmLdo79QHxepJQpZSs4gKRw28wJkbKUlEwU/Pr4TjcVNV3s4pJz/2j4jmNTLVnwP0FX4 waUQza/99BvA1rKOFVWQXspDkuYwukiBwEbRdOonx4AK4kW9cRaVVRFUCPjewtjiwlv5 ZH7u0sBvuw53NGxU8EmYZgxQYwhmM6uh0cQoIIjPCq3V0C4yTmCnN08NyTBijzxKh29s bJmw== X-Gm-Message-State: AOJu0YwMjGuJ9IKGhaV3dvWSpixc3JfvILqHelOJGyHKO77QV+2JNR00 sxDt+61ymHs80iubFCTG9Otpb6+qoDhHaLjRna3DtkLz+qjGkQmllLo18B0cZxthYH4AAX4+y+/ v X-Gm-Gg: ASbGncsZMpEMjiwZGqFNOgxyPlxLwPDuJflnEv+bnvAVPQhfC0uBp0NwnuvZ/KKkzk1 Lw8yK6OJ48ida/+OGXEvgyTKwbNaq6NpLss7bElcbjA5I5xSRsBLSQti+5umk7EPP94wMIawPqW +FGoYrlCSHRg2dR0XydIPXOm4c8uEfwNAt4KStMIb1pyITHOwtf4cHt0+5YR0n9sE0c3QwUW+My e5ZDiGj1++vY/yGePhKD7qPn3VkF2Ccem0p9uAsmmlEBgwET2CDRZxpgD6Xv6Iw3/J8WcbyhSLt 1dSx/YZ9PrB7MUsbkDLNiMfVTPBqeoWjqE9d+8mqGUyInmSqXA== X-Google-Smtp-Source: AGHT+IGiOn2t/rq7mDNKUqoGOEzt+MuTENHsD8/W2dHi4WucDuFyXSyonSuzTfGfMEGBBvn8+slrPw== X-Received: by 2002:a17:907:2da6:b0:abf:6f44:bffa with SMTP id a640c23a62f3a-ac2b9ea39cdmr1744531166b.36.1741879950362; Thu, 13 Mar 2025 08:32:30 -0700 (PDT) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Jan Beulich , Andrew Cooper Subject: [PATCH 3/7] x86/dom0: placate GCC 12 compile-time errors with UBSAN and PVH_GUEST Date: Thu, 13 Mar 2025 16:30:25 +0100 Message-ID: <20250313153029.93347-4-roger.pau@citrix.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250313153029.93347-1-roger.pau@citrix.com> References: <20250313153029.93347-1-roger.pau@citrix.com> MIME-Version: 1.0 When building Xen with GCC 12 with UBSAN and PVH_GUEST both enabled the compiler emits the following errors: arch/x86/setup.c: In function '__start_xen': arch/x86/setup.c:1504:19: error: 'consider_modules' reading 40 bytes from a region of size 4 [-Werror=stringop-overread] 1504 | end = consider_modules(s, e, reloc_size + mask, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1505 | bi->mods, bi->nr_modules, -1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/x86/setup.c:1504:19: note: referencing argument 4 of type 'const struct boot_module[0]' arch/x86/setup.c:686:24: note: in a call to function 'consider_modules' 686 | static uint64_t __init consider_modules( | ^~~~~~~~~~~~~~~~ arch/x86/setup.c:1535:19: error: 'consider_modules' reading 40 bytes from a region of size 4 [-Werror=stringop-overread] 1535 | end = consider_modules(s, e, size, bi->mods, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1536 | bi->nr_modules + relocated, j); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/x86/setup.c:1535:19: note: referencing argument 4 of type 'const struct boot_module[0]' arch/x86/setup.c:686:24: note: in a call to function 'consider_modules' 686 | static uint64_t __init consider_modules( | ^~~~~~~~~~~~~~~~ This seems to be the result of some function manipulation done by UBSAN triggering GCC stringops related errors. Placate the errors by declaring the function parameter as `const struct *boot_module` instead of `const struct boot_module[]`. Note that GCC 13 seems to be fixed, and doesn't trigger the error when using `[]`. Signed-off-by: Roger Pau Monné Acked-by: Andrew Cooper --- xen/arch/x86/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 4a32d8491186..bde5d75ea6ab 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -684,7 +684,7 @@ static void __init noinline move_xen(void) #undef BOOTSTRAP_MAP_LIMIT static uint64_t __init consider_modules( - uint64_t s, uint64_t e, uint32_t size, const struct boot_module mods[], + uint64_t s, uint64_t e, uint32_t size, const struct boot_module *mods, unsigned int nr_mods, unsigned int this_mod) { unsigned int i; From patchwork Thu Mar 13 15:30:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 14015298 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B4B89C282EC for ; Thu, 13 Mar 2025 15:32:42 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.912509.1318773 (Exim 4.92) (envelope-from ) id 1tskXz-0000DF-Vb; Thu, 13 Mar 2025 15:32:35 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 912509.1318773; Thu, 13 Mar 2025 15:32:35 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tskXz-0000CR-Ro; Thu, 13 Mar 2025 15:32:35 +0000 Received: by outflank-mailman (input) for mailman id 912509; Thu, 13 Mar 2025 15:32:33 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tskXx-0007tP-QN for xen-devel@lists.xenproject.org; Thu, 13 Mar 2025 15:32:33 +0000 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [2a00:1450:4864:20::52d]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 61b9e35e-0020-11f0-9ab9-95dc52dad729; Thu, 13 Mar 2025 16:32:32 +0100 (CET) Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-5e6c18e2c7dso1920581a12.3 for ; Thu, 13 Mar 2025 08:32:32 -0700 (PDT) Received: from localhost ([84.78.159.3]) by smtp.gmail.com with UTF8SMTPSA id 4fb4d7f45d1cf-5e81692e64asm825684a12.4.2025.03.13.08.32.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Mar 2025 08:32:31 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 61b9e35e-0020-11f0-9ab9-95dc52dad729 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1741879951; x=1742484751; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tIV0lbRrLZFbQdSx0BrVvPIuenqWUkKeEWZTK4TAOBs=; b=qNPNh6cilg4xvwrSXRfw/4wWiKbZySsu3sStveUIMMyHFrFoFGBTzF8uXa6Bo1/NPP kRQIm+m+W+0nJE8Q9qBi9FxqLZrlSAnQsPw9gr49ZJ7tgzZL0lLiYAFtfcmaocXsTGhB tktFoa5ZquA0BfF7QbvR05CrI0+f0PluJ9c3Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741879951; x=1742484751; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tIV0lbRrLZFbQdSx0BrVvPIuenqWUkKeEWZTK4TAOBs=; b=hzIi/C+KJ6DV4brZWidMb54q1+498KVChuy/XxFLoELWMiFN7BcwITApXkpQIFFqOU MjagyabE5kjF7FtkpcoxK32FWkbzmN+8n0sbtsyaJc49pcJHGP9X7Ew9mwbu8V5bt/Qq sVy1QA/whIDQJsAmPXeVVdwV1G433BZO5PFxw3MebGplNezvmZ43sxDym2GGdOxk4o+e DYiTI6Fk+xUvs4rS0QNsZ9Xi5pgiRIPVrYnXD0b/6kuhX/00Is4gln7Z++c04XTodHC0 3izqFsgvT9y1gKZaJTVKJPx3Oy2p2M/291dW5V4hRlrcMTv8TJzJLI15cIAaSWgGPXOA Mz+Q== X-Gm-Message-State: AOJu0YxwS1ile/xUzrK9Ez0lvrS2brCslQe7IbSoNkRLUbo2qNM+piVd 7WG35F/BXUwi6rlCTueUM6A45yyUKThI6RdQ9gJNmpUQlA0nQNUaicanCV6zvg3KNwIMvAimw3x f X-Gm-Gg: ASbGnct5DvN/jkVJgGam5KrGo0bQv4XJ9WBVGQunz1kjyrx/UcSMvZDDOPukhaY58Cl GLkWoUfq1UvgoPsj2H0gWskWvxSTKS4LmMGUKZ2qkkfpPaboMokpME4Ey53/7mdYvc/qXDj0I19 EM+b9kYDnqOdG1e2eNdK/YIl/Xd5NIw9WaDY0LemRUvc4zFvQgTG92fPNOFPzpQDugbg3+OgINE t4rFIJt5DN2v3CThwqrHi95ELrPOzUnEDHLCMIXoZJ6TkELQVK1heQ5in9p4JD8wV8qHSpstOzC dEAtoxe0NeEWre1PARJ+f2RVbOjUjgiTCmNOQhGIvSGACiwNdA== X-Google-Smtp-Source: AGHT+IGSp33R1eWJEtY9rFEEoNQDrBjGvY13L37whLkeE+FLQVs6my06EgT5NpY7mSqCs6pPUI4sUg== X-Received: by 2002:a05:6402:42c4:b0:5e4:d192:2373 with SMTP id 4fb4d7f45d1cf-5e5e22bf631mr31125520a12.10.1741879951520; Thu, 13 Mar 2025 08:32:31 -0700 (PDT) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , Stefano Stabellini Subject: [PATCH 4/7] xen/ubsan: expand pointer overflow message printing Date: Thu, 13 Mar 2025 16:30:26 +0100 Message-ID: <20250313153029.93347-5-roger.pau@citrix.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250313153029.93347-1-roger.pau@citrix.com> References: <20250313153029.93347-1-roger.pau@citrix.com> MIME-Version: 1.0 Add messages about operations against the NULL pointer, or that result in a NULL pointer. Signed-off-by: Roger Pau Monné Reviewed-by: Andrew Cooper --- xen/common/ubsan/ubsan.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/xen/common/ubsan/ubsan.c b/xen/common/ubsan/ubsan.c index 7ebe4bfc14dc..20aa0cb598e1 100644 --- a/xen/common/ubsan/ubsan.c +++ b/xen/common/ubsan/ubsan.c @@ -517,9 +517,18 @@ void __ubsan_handle_pointer_overflow(struct pointer_overflow_data *data, ubsan_prologue(&data->location, &flags); - pr_err("pointer operation %s %p to %p\n", - base > result ? "overflowed" : "underflowed", - _p(base), _p(result)); + if (!base && !result) + pr_err("applying zero offset to null pointer\n"); + else if (!base && result) + pr_err("applying non-zero offset %p to null pointer\n", + _p(result)); + else if (base && !result) + pr_err("applying non-zero offset to non-null pointer %p produced null pointer\n", + _p(base)); + else + pr_err("pointer operation %s %p to %p\n", + base > result ? "overflowed" : "underflowed", + _p(base), _p(result)); ubsan_epilogue(&flags); } From patchwork Thu Mar 13 15:30:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 14015299 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 27510C282DE for ; Thu, 13 Mar 2025 15:32:43 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.912510.1318778 (Exim 4.92) (envelope-from ) id 1tskY0-0000F7-BY; Thu, 13 Mar 2025 15:32:36 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 912510.1318778; Thu, 13 Mar 2025 15:32:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tskY0-0000EF-3I; Thu, 13 Mar 2025 15:32:36 +0000 Received: by outflank-mailman (input) for mailman id 912510; Thu, 13 Mar 2025 15:32:34 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tskXy-0007tP-Qe for xen-devel@lists.xenproject.org; Thu, 13 Mar 2025 15:32:34 +0000 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [2a00:1450:4864:20::529]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 626fdbc8-0020-11f0-9ab9-95dc52dad729; Thu, 13 Mar 2025 16:32:34 +0100 (CET) Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-5e033c2f106so1590956a12.3 for ; Thu, 13 Mar 2025 08:32:34 -0700 (PDT) Received: from localhost ([84.78.159.3]) by smtp.gmail.com with UTF8SMTPSA id 4fb4d7f45d1cf-5e8169b1602sm847443a12.42.2025.03.13.08.32.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Mar 2025 08:32:32 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 626fdbc8-0020-11f0-9ab9-95dc52dad729 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1741879953; x=1742484753; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OJiaUgbH1bb2LG+KmsUrFx4m8JkQ4L5Ijprhg1pyXDY=; b=R/xRJXTh+F+GDoVYqG9r3flzV5OR5bQNPxZ5DqC6HHabrrqlzGzcipVVy2W+a8uhr+ B0kvCPyJ6Okq61scwedJnRe/Tc5qoblvNAS8R+tkG2osC1hnDrJCQ4zIw/rCUzizFTru ziohhKlNQMT8vREWuwUb6DMXRjT3Rs+234EEo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741879953; x=1742484753; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OJiaUgbH1bb2LG+KmsUrFx4m8JkQ4L5Ijprhg1pyXDY=; b=NdLpCNd6zV9X3vqALYjOQgOtmv8x8b1NqhEIuKMJGTPpMuaXcwq9iNH/PRTdXhv6G4 VDaqDRhnlQFjXF0rIw0Wlzls4olYPmv1XPTMp69Fol3H+L8zI84JJWi9h5dEjDUtyqRj vCSOdERFBELYzr24eWp9/v7H2GNa403ORt72qjaGlYfiaeERVbGgZCcNaSzt37ce8QNA sBaxYw07u3Egk2OptI+NosYgx6ixAKmR930mTWhSTftcNB5dwHih+QCubrsiO7CIegss AvUuWcGgj52bhOmbHFfo/MWOyerUSnwwwiWnzKJkt6cSr/hl3LCHcDrZd7ALrFnwuiTk /dAg== X-Gm-Message-State: AOJu0YxTOyRIKTRdUKl0oWEVoOSAdhutzYe/gmqyhhV0D7cY7O25dutT VEgzWx5fBlwPbWB1FdlJdAJ3CtVTPlT9dn/LVGp9j0VIpRJMOcM8wUXww4oIW1Fio6AulDCvJlH s X-Gm-Gg: ASbGncvC9WScYKGEeTDCGV3LINzIhgQEftcrUQm+qJR7abX8b2HWuvsRg9Q1YFb4Xw0 ExwNCbsqubFCC6sOd5ZVGT6cvQQjlReAgA7iPann18mvt2YLH7kLvoanoMDNQ4HVhJDJe/SBywc A80nVEnzKjXOuQc29KPPcoKI2oohRil7NOcwaBamD1arxb1o70fu6pDzOiR6pfj8iQ0VnPwCxb9 D+v36LXJYL3NHXUbLyGW27IIr4RysX3Wc4bH0So3ureGuU9y+EhI24e7TOaGP0vrHP7CqXH1TGr QrnM80trwP4BqXUDlv56IggfGUGwnyoCWR4CHHzD068m6dP7kA== X-Google-Smtp-Source: AGHT+IHze12pCIkh0Nd32znahSJbySON/JnsBZNJX5iscNiB4BYXAkwnogHpvwK6rlm7cKVbILuhbg== X-Received: by 2002:a05:6402:518a:b0:5e5:b572:a6d7 with SMTP id 4fb4d7f45d1cf-5e5e229bc4cmr61406221a12.6.1741879953150; Thu, 13 Mar 2025 08:32:33 -0700 (PDT) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Jan Beulich , Andrew Cooper Subject: [PATCH 5/7] x86/ioremap: prevent additions against the NULL pointer Date: Thu, 13 Mar 2025 16:30:27 +0100 Message-ID: <20250313153029.93347-6-roger.pau@citrix.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250313153029.93347-1-roger.pau@citrix.com> References: <20250313153029.93347-1-roger.pau@citrix.com> MIME-Version: 1.0 This was reported by clang UBSAN as: UBSAN: Undefined behaviour in arch/x86/mm.c:6297:40 applying zero offset to null pointer [...] Xen call trace: [] R common/ubsan/ubsan.c#ubsan_epilogue+0xa/0xc0 [] F __ubsan_handle_pointer_overflow+0xcb/0x100 [] F ioremap_wc+0xc8/0xe0 [] F video_init+0xd0/0x180 [] F console_init_preirq+0x3d/0x220 [] F __start_xen+0x68e/0x5530 [] F __high_start+0x8e/0x90 Fix bt_ioremap() and ioremap{,_wc}() to not add the offset if the returned pointer from __vmap() is NULL. Fixes: d0d4635d034f ('implement vmap()') Fixes: f390941a92f1 ('x86/DMI: fix table mapping when one lives above 1Mb') Fixes: 81d195c6c0e2 ('x86: introduce ioremap_wc()') Signed-off-by: Roger Pau Monné Reviewed-by: Andrew Cooper , with one style fix. --- xen/arch/x86/dmi_scan.c | 7 +++++-- xen/arch/x86/mm.c | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/dmi_scan.c b/xen/arch/x86/dmi_scan.c index 2fcc485295eb..a05492037519 100644 --- a/xen/arch/x86/dmi_scan.c +++ b/xen/arch/x86/dmi_scan.c @@ -112,6 +112,7 @@ static const void *__init bt_ioremap(paddr_t addr, unsigned int len) { mfn_t mfn = _mfn(PFN_DOWN(addr)); unsigned int offs = PAGE_OFFSET(addr); + void *va; if ( addr + len <= MB(1) ) return __va(addr); @@ -119,8 +120,10 @@ static const void *__init bt_ioremap(paddr_t addr, unsigned int len) if ( system_state < SYS_STATE_boot ) return __acpi_map_table(addr, len); - return __vmap(&mfn, PFN_UP(offs + len), 1, 1, PAGE_HYPERVISOR_RO, - VMAP_DEFAULT) + offs; + va = __vmap(&mfn, PFN_UP(offs + len), 1, 1, PAGE_HYPERVISOR_RO, + VMAP_DEFAULT); + + return va ? va + offs : NULL; } static void __init bt_iounmap(const void *ptr, unsigned int len) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index bfdc8fb01949..03b8319f7a9d 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -6277,7 +6277,9 @@ void __iomem *ioremap(paddr_t pa, size_t len) unsigned int offs = pa & (PAGE_SIZE - 1); unsigned int nr = PFN_UP(offs + len); - va = __vmap(&mfn, nr, 1, 1, PAGE_HYPERVISOR_UCMINUS, VMAP_DEFAULT) + offs; + va = __vmap(&mfn, nr, 1, 1, PAGE_HYPERVISOR_UCMINUS, VMAP_DEFAULT); + if ( va ) + va += offs; } return (void __force __iomem *)va; @@ -6294,7 +6296,7 @@ void __iomem *__init ioremap_wc(paddr_t pa, size_t len) va = __vmap(&mfn, nr, 1, 1, PAGE_HYPERVISOR_WC, VMAP_DEFAULT); - return (void __force __iomem *)(va + offs); + return (void __force __iomem *)(va ? va + offs : NULL); } int create_perdomain_mapping(struct domain *d, unsigned long va, From patchwork Thu Mar 13 15:30:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 14015303 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F1518C35FF3 for ; Thu, 13 Mar 2025 15:32:49 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.912514.1318803 (Exim 4.92) (envelope-from ) id 1tskY4-00014n-9Q; Thu, 13 Mar 2025 15:32:40 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 912514.1318803; Thu, 13 Mar 2025 15:32:40 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tskY4-00014T-3w; Thu, 13 Mar 2025 15:32:40 +0000 Received: by outflank-mailman (input) for mailman id 912514; Thu, 13 Mar 2025 15:32:38 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tskY2-0008Nv-EJ for xen-devel@lists.xenproject.org; Thu, 13 Mar 2025 15:32:38 +0000 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [2a00:1450:4864:20::62e]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 61e69c4f-0020-11f0-9898-31a8f345e629; Thu, 13 Mar 2025 16:32:33 +0100 (CET) Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-ac2af2f15d1so159697266b.1 for ; Thu, 13 Mar 2025 08:32:35 -0700 (PDT) Received: from localhost ([84.78.159.3]) by smtp.gmail.com with UTF8SMTPSA id a640c23a62f3a-ac314aa5a7csm92778366b.179.2025.03.13.08.32.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Mar 2025 08:32:34 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 61e69c4f-0020-11f0-9898-31a8f345e629 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1741879954; x=1742484754; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mxQEz2L+rAS29uG6w8hhOjnkgr3zrKSQWBxEvgdwtNw=; b=ppWqSMNGIsjVRGBehVaOaop8OcWDI18ZwG8Lzss+3p6KovtsRgCyMWBMy15aGZEWn1 D/JE3N+gD3gj7h+dpDF+s1g10r8KjREA1uKHPWkccdCEG4KDCxc0nSt+F2+8479z+inn s9Kk/uZIdhT8L/3MRP/5Nv5BTjv6t/jwkCzd8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741879954; x=1742484754; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mxQEz2L+rAS29uG6w8hhOjnkgr3zrKSQWBxEvgdwtNw=; b=fOLW3oIEwzdc35Z5vGHCWiyZS14wCXXeMfUo/n4/VM+T8Imk5sMcBiyFwYguBV5JXa h/UZw8XRqn7i/OCYudb8hCxrs/n5NEfkadVHOrtRNQJ0N/zGGGInqPnOFFEfCoUIrzbD 219Q+tDFE8D+wQCwhkoZ0Fsy6LSKX+/JiIjfU7Ln2srr9KA2DQhU1T6Oy8e2Fvf3rtgY eAi8UBlLuBSu2AZbymp/n0Sh60HFxqsP5uo9+rB5uSPPzXgtBDcnfmcK4NqcU/VhRqh0 i7Fh4gh8OkMtKpOVB+FAQ7vMGghKao3ojljU0ugnFIrHoSMlOOPYCz/w5aO+xJ2DCcbq 2DDQ== X-Gm-Message-State: AOJu0YxYjgT88O1rq9MmlCAffPNkYRExCbyPi4lmoabUJUflRda9EXJm DE/C6rxFS0dBIjaoU7phzXpEJdwH0Ur3RcnmhIYxkwWF5ECrn5FzQCsf/vd0OCIriqVdOL46Hly 7 X-Gm-Gg: ASbGncsisSOzYgkEmq2D4245aWeiENTosCaQXqJ4nbloMdbCZEJYC4PsWqoSd9LFciM 8smbOpEX2m9IJRYiNz0XA/ri56NuSx2hEIFTruQKnvz6rfQfq/XTFrGYaO45HJBDX2zLTyKVCpl +BPthzyZ1tmqWJkk5WvUPx7Tr9TRrsixHXNDA90NLMiCtOFRhocZRq7/DuJKsXdd68iaNaQ5kEi jrx0EGf68/kXs8fmT2A4kTWETzTR5AAtbtT7AD3592U3rK5mOn7MI6eaVT53DtsbtcsGz2WAwLn F+kSgDWBeJwURxpephrhzDyKy9tdGgW0FSky0LPrG04V6qDSUdJoqrEJAUP/ X-Google-Smtp-Source: AGHT+IFoBSbAfiuagyoHTygFOrP0LLqxreqoAAxy4q3gk+9V4N6Hs2DE4wTwgInSfSSLle6JNAc2WA== X-Received: by 2002:a17:907:c10:b0:ac2:7cf9:71a1 with SMTP id a640c23a62f3a-ac2b9ea16d2mr1782623166b.41.1741879954302; Thu, 13 Mar 2025 08:32:34 -0700 (PDT) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Jan Beulich , Andrew Cooper , Anthony PERARD , Michal Orzel , Julien Grall , Stefano Stabellini Subject: [PATCH 6/7] x86/vga: fix mapping of the VGA text buffer Date: Thu, 13 Mar 2025 16:30:28 +0100 Message-ID: <20250313153029.93347-7-roger.pau@citrix.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250313153029.93347-1-roger.pau@citrix.com> References: <20250313153029.93347-1-roger.pau@citrix.com> MIME-Version: 1.0 The call to ioremap_wc() in video_init() will always fail, because video_init() is called ahead of vm_init_type(), and so the underlying __vmap() call will fail to allocate the linear address space. Fix by reverting to the previous behavior and using the directmap entries in the low 1MB. Note the VGA text buffer directmap entries are also adjusted to map the VGA text buffer as WC instead of UC-. Fixes: 81d195c6c0e2 ('x86: introduce ioremap_wc()') Signed-off-by: Roger Pau Monné --- xen/arch/x86/boot/x86_64.S | 10 +++++++--- xen/arch/x86/include/asm/config.h | 5 +++++ xen/drivers/video/vga.c | 11 ++++++++--- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/boot/x86_64.S b/xen/arch/x86/boot/x86_64.S index 26b9d1c2df9a..07f4bdf46e31 100644 --- a/xen/arch/x86/boot/x86_64.S +++ b/xen/arch/x86/boot/x86_64.S @@ -84,15 +84,19 @@ ENTRY(__high_start) /* * Mapping of first 2 megabytes of memory. This is mapped with 4kB mappings * to avoid type conflicts with fixed-range MTRRs covering the lowest megabyte - * of physical memory. In any case the VGA hole should be mapped with type UC. + * of physical memory. VGA hole should be mapped with type UC, with the + * exception of the text buffer that uses WC. * Uses 1x 4k page. */ l1_directmap: pfn = 0 .rept L1_PAGETABLE_ENTRIES - /* VGA hole (0xa0000-0xc0000) should be mapped UC-. */ - .if pfn >= 0xa0 && pfn < 0xc0 + /* VGA hole (0xa0000-0xb8000) should be mapped UC-. */ + .if pfn >= 0xa0 && pfn < 0xb8 .quad (pfn << PAGE_SHIFT) | __PAGE_HYPERVISOR_UCMINUS | _PAGE_GLOBAL | MAP_SMALL_PAGES + /* VGA text buffer (0xb80000-0xc0000) should be mapped WC. */ + .elseif pfn >= 0xb8 && pfn < 0xc0 + .quad (pfn << PAGE_SHIFT) | __PAGE_HYPERVISOR_WC | _PAGE_GLOBAL | MAP_SMALL_PAGES .else .quad (pfn << PAGE_SHIFT) | PAGE_HYPERVISOR_RWX | MAP_SMALL_PAGES .endif diff --git a/xen/arch/x86/include/asm/config.h b/xen/arch/x86/include/asm/config.h index 19746f956ec3..a455bfb0df65 100644 --- a/xen/arch/x86/include/asm/config.h +++ b/xen/arch/x86/include/asm/config.h @@ -208,6 +208,11 @@ #endif #define DIRECTMAP_VIRT_END (DIRECTMAP_VIRT_START + DIRECTMAP_SIZE) +#define IS_DIRECTMAP_ADDR(x) ({ \ + unsigned long addr = (unsigned long)(x); \ + addr >= DIRECTMAP_VIRT_START && addr < DIRECTMAP_VIRT_END; \ +}) + #ifndef __ASSEMBLY__ #ifdef CONFIG_PV32 diff --git a/xen/drivers/video/vga.c b/xen/drivers/video/vga.c index b4d018326128..704d00034658 100644 --- a/xen/drivers/video/vga.c +++ b/xen/drivers/video/vga.c @@ -70,9 +70,13 @@ void __init video_init(void) switch ( vga_console_info.video_type ) { case XEN_VGATYPE_TEXT_MODE_3: - if ( page_is_ram_type(paddr_to_pfn(0xB8000), RAM_TYPE_CONVENTIONAL) || - ((video = ioremap_wc(0xB8000, 0x8000)) == NULL) ) + if ( page_is_ram_type(paddr_to_pfn(0xB8000), RAM_TYPE_CONVENTIONAL) ) return; + /* + * The first MB is always mapped, and the VGA text buffer uses the WC + * cache attribute. + */ + video = __va(0xB8000); outw(0x200a, 0x3d4); /* disable cursor */ columns = vga_console_info.u.text_mode_3.columns; lines = vga_console_info.u.text_mode_3.rows; @@ -158,7 +162,8 @@ void __init video_endboot(void) if ( !vgacon_keep ) { memset(video, 0, columns * lines * 2); - iounmap(video); + /* VGA text buffer uses a directmap mapping, don't try to unmap. */ + ASSERT(IS_DIRECTMAP_ADDR(video)); video = ZERO_BLOCK_PTR; } break; From patchwork Thu Mar 13 15:30:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 14015302 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 26B7FC282DE for ; Thu, 13 Mar 2025 15:32:48 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.912516.1318807 (Exim 4.92) (envelope-from ) id 1tskY4-00018S-La; Thu, 13 Mar 2025 15:32:40 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 912516.1318807; Thu, 13 Mar 2025 15:32:40 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tskY4-00017J-FA; Thu, 13 Mar 2025 15:32:40 +0000 Received: by outflank-mailman (input) for mailman id 912516; Thu, 13 Mar 2025 15:32:39 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tskY3-0008Nv-ET for xen-devel@lists.xenproject.org; Thu, 13 Mar 2025 15:32:39 +0000 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [2a00:1450:4864:20::62f]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 62931b43-0020-11f0-9898-31a8f345e629; Thu, 13 Mar 2025 16:32:34 +0100 (CET) Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-ac2ab99e16eso233239866b.0 for ; Thu, 13 Mar 2025 08:32:36 -0700 (PDT) Received: from localhost ([84.78.159.3]) by smtp.gmail.com with UTF8SMTPSA id a640c23a62f3a-ac3149d0bfbsm93599266b.95.2025.03.13.08.32.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Mar 2025 08:32:35 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 62931b43-0020-11f0-9898-31a8f345e629 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1741879955; x=1742484755; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gnMyX9kFHyXzrDrfsJ2RlCItrD8ia9EDnLZKJ/omKus=; b=GIPIRQOvE3hhiNoGpD34hgcMMkBoeRNEAWdi5vBfls6AiScmg1yNyx/G65rbgPyDTj 8+/mVP/Wsw/gF1xvqLFV5OHHnwP+f2k5qvo3HkomYulH+Dw/YSr6ZWxvP5LlLC1EGTK+ rwySg6vMnIlt0AbE8atOJ9Ze702g+V9on2EkQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741879955; x=1742484755; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gnMyX9kFHyXzrDrfsJ2RlCItrD8ia9EDnLZKJ/omKus=; b=IkULa+xuEu7dg9kwBGShTr1E/qWGstDctu3Ay6akHL+kmMu+bQ4kT6U0rMbtBiklUq eIcRg3jvoHVY3La3WSpywX3hlMMUubGFhFGz9Iq+McyQqb1WgGz3BrYjjNDPD2+ciArj DSypyzH92eGfbUkrk5GxxGt3H2WRu4tdAhP3AnjQIcL5O0UFubICVr8huH5hg0dMODK7 w8gNsSNHLkslVb1LY9cSDnrucq16LACa7fVFFrEGttJzYXeG40tuIIA9hmZJbyTCCExb xhj0vFkiXFmmHPT+VMiZMibBsVM70lI5osVcfZBBPBXwjoR9kBrqp3zOQwrOW786bC07 8WLw== X-Gm-Message-State: AOJu0YxoViB8wLYgxl2P2AqxQKQGKdyZ7/ISuNlhaEY+6Lr1CiJbRz0M an9FgSzrUYtQdAerLxZy+hSFefpbUZgrMQ7Thi9zVouWwfL5kMVDy6Mu08fmmmEhzQtSqTU7gYg s X-Gm-Gg: ASbGnct2Lldi5QMB34GywbH+DfbCVcIozpnwFeRdFMqYh2donAIVou1MwfaoTm+/MYo z4H686ey8a+C0spFQOTGVu4P7B4pzt5LQDfUdV/jWSQty0H7WAShiwoXZfDJkrZ5ae6DwHmr8dh Gy+r9+oq36X/4THLPViB4E5PhxdbxAQ0l2XihbHgSlMKlF/P/YDNm9fKUoF3K/CTk8AstBgWcZX mPIjX47++AXiiLdQYxBa3v7tvAjJCzLSyFLscFO9JQdMG+y1pgo95Gnx+gPNhWaHELfBWVC3XZ7 R5Kd8HtnJ8NgEfTWx9bDLAf8Qw9fiZcFiIVJc6H2Ub5FMiAQxg== X-Google-Smtp-Source: AGHT+IEy6NxcmWXZESHR0NTpVyBjvtdeWnjyAkUl4iE6wnO5CzM/jxUr7S1Yw5MDBj7Cuf+wfrmC0A== X-Received: by 2002:a17:906:4758:b0:ac2:7d72:c2ab with SMTP id a640c23a62f3a-ac27d72d558mr2103799466b.47.1741879955460; Thu, 13 Mar 2025 08:32:35 -0700 (PDT) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , Stefano Stabellini , Doug Goldstein Subject: [PATCH 7/7] kconfig/randconfig: enable UBSAN for randconfig Date: Thu, 13 Mar 2025 16:30:29 +0100 Message-ID: <20250313153029.93347-8-roger.pau@citrix.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250313153029.93347-1-roger.pau@citrix.com> References: <20250313153029.93347-1-roger.pau@citrix.com> MIME-Version: 1.0 Introduce an additional Kconfig check to only offer the option if the compiler supports -fsanitize=undefined. We no longer use Travis CI, so the original motivation for not enabling UBSAN might no longer present. Regardless, the option won't be present in the first place if the compiler doesn't support -fsanitize=undefined. Signed-off-by: Roger Pau Monné --- xen/Kconfig | 4 ++++ xen/Kconfig.debug | 2 +- xen/tools/kconfig/allrandom.config | 1 - 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/xen/Kconfig b/xen/Kconfig index 72fdb8376087..2128f0ccfc0b 100644 --- a/xen/Kconfig +++ b/xen/Kconfig @@ -37,6 +37,10 @@ config CC_HAS_VISIBILITY_ATTRIBUTE config CC_SPLIT_SECTIONS bool +# Compiler supports -fsanitize=undefined +config CC_HAS_UBSAN + def_bool $(cc-option,-fsanitize=undefined) + # Set code alignment. # # Allow setting on a boolean basis, and then convert such selection to an diff --git a/xen/Kconfig.debug b/xen/Kconfig.debug index c4a8d86912e0..f7cc5ffaabd7 100644 --- a/xen/Kconfig.debug +++ b/xen/Kconfig.debug @@ -98,7 +98,7 @@ config SCRUB_DEBUG config UBSAN bool "Undefined behaviour sanitizer" - depends on HAS_UBSAN + depends on HAS_UBSAN && CC_HAS_UBSAN help Enable undefined behaviour sanitizer. It uses compiler to insert code snippets so that undefined behaviours in C are detected during runtime. diff --git a/xen/tools/kconfig/allrandom.config b/xen/tools/kconfig/allrandom.config index 76f74320b5b0..c7753ac4addb 100644 --- a/xen/tools/kconfig/allrandom.config +++ b/xen/tools/kconfig/allrandom.config @@ -1,4 +1,3 @@ # Explicit option choices not subject to regular RANDCONFIG CONFIG_GCOV_FORMAT_AUTODETECT=y -CONFIG_UBSAN=n