From nobody Sat May 11 07:53:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1680087110; cv=none; d=zohomail.com; s=zohoarc; b=ZEf5M2WhKH+izf1j7PjstFACuPrlZRFxlSNhC9EOUZ3qG4QdWBIYy1eckvhZ1JI84kzdu2xrnIVFzwbu8BeK3cPExwoTNuLtk9AKJBBdJ3X/ra5HHaNzrlmK+DC3I6BiMj04JLy9fbDQ1k0TMIKf9r+QJJo/V3iT55zYby/Spn8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1680087110; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=G+SyusVLNbqVMrW8ZRpmVQ40Jehx8sJ9+PJYZzoVhT8=; b=jKdsPv/yrlINd1jBRlnYAbHMFUZ1x+ziDEFiJSMExbs11FhVxyZdfJgKwJYYJtTY8g40pg0w06PL39hJ66YQFoxJhnKBOBtIoRCYdJPK9obdRF74PfTsHhhBG5S7KlO0KirjiDAyVnbqeT9SRn4Hz0GAbu80Hq+bAhHO44bNSy8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1680087110867638.9636041870579; Wed, 29 Mar 2023 03:51:50 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.516184.799907 (Exim 4.92) (envelope-from ) id 1phTOX-00081I-KQ; Wed, 29 Mar 2023 10:51:09 +0000 Received: by outflank-mailman (output) from mailman id 516184.799907; Wed, 29 Mar 2023 10:51:09 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1phTOX-00081B-HZ; Wed, 29 Mar 2023 10:51:09 +0000 Received: by outflank-mailman (input) for mailman id 516184; Wed, 29 Mar 2023 10:51:08 +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 1phTOW-0007lb-4E for xen-devel@lists.xenproject.org; Wed, 29 Mar 2023 10:51:08 +0000 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [2a00:1450:4864:20::12b]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 9b88ce0e-ce1f-11ed-85db-49a42c6b2330; Wed, 29 Mar 2023 12:51:06 +0200 (CEST) Received: by mail-lf1-x12b.google.com with SMTP id k37so19602307lfv.0 for ; Wed, 29 Mar 2023 03:51:06 -0700 (PDT) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id j17-20020ac253b1000000b004eb0f6b7ccfsm1173572lfh.134.2023.03.29.03.51.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Mar 2023 03:51:05 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 9b88ce0e-ce1f-11ed-85db-49a42c6b2330 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680087066; 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=G+SyusVLNbqVMrW8ZRpmVQ40Jehx8sJ9+PJYZzoVhT8=; b=S+Hrmaxf8pMC9LSHW+l8zJsFz405qpjG46TIID8rth8PoG/9eGviAuSsd5BfnRCdfi pKrDX4q6/vaOmqrcdiTPbMRrZbXKX5ziB/k4/RnxSybDALlRHEN+659Pob8QE3l6BrUS 0ouJyhypqznny50k3ZEXcZzk3+bUVeZPH+ZEsAHGJpqBco8JkkLyEyFwLEr4ljLi8eTb r4vZsi0ADPmqm11AgdrKG4XXw6IbJ0myCwgVvby36Bsj8Dv2ROUs/lXLClRsiOH6R5hn EEfHRY4HQC5bSAD6R+SFHtvH1XdwfuwT+4KWAiowfaFuG9jWFE/WyZgLlvxmLD54Wv1D Oesw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680087066; 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=G+SyusVLNbqVMrW8ZRpmVQ40Jehx8sJ9+PJYZzoVhT8=; b=hOwPUDKZZLI/E2VOUeoVOo71x8z+Sdyk9N+3ReBa2dvyjutzLyDW8vzNBjeb+OH6zt eS6iid0BYVSWUpsBT6Iy9g+MfTp3C7XHBgFjXLACZLjjRglH65KC+hWWaNamrHODxu7C FTmisusKhjs6vPWXiHS7XO6JrvODLbOdx8WWPPw5YvncSudM/xM5oZQg0H4lNlGEAbFN WZH58s5qMzWBTXFZX818nLz+7UOM0YLm0eUDOiKzhHSJxwcc3Or6t3oG7u+5HhB+kueM ORuxrUODCGoYvxcrkTnObnC6VveHad1X62Yr+qxLcpmlkrBVie9dw3TTqsRetCIOyQe6 IJyg== X-Gm-Message-State: AAQBX9egVdh5Qtkfn1IKfs/AgvqJF6esIqS6uMo8rvebChgw3tfgQ1Jb HVDtwSt/Jm9KNYSNoKgOkzqbYBeFDCo= X-Google-Smtp-Source: AKy350afs6RDHIFsWJidIx/0a45G1DYXY+mEijDW6N78rrBUHoDvE2SsAxa5nH0eoSQaUS90Ds0RuQ== X-Received: by 2002:ac2:490f:0:b0:4e8:4a9d:2ae1 with SMTP id n15-20020ac2490f000000b004e84a9d2ae1mr4551091lfi.32.1680087066129; Wed, 29 Mar 2023 03:51:06 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Julien Grall , Jan Beulich , Andrew Cooper , Stefano Stabellini , Gianluca Guida , Oleksii Kurochko , George Dunlap , Wei Liu Subject: [PATCH v9 1/5] xen: introduce CONFIG_GENERIC_BUG_FRAME Date: Wed, 29 Mar 2023 13:50:28 +0300 Message-Id: X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1680087111361100006 Content-Type: text/plain; charset="utf-8" A large part of the content of the bug.h is repeated among all architectures, so it was decided to create a new config CONFIG_GENERIC_BUG_FRAME. The version of from x86 was taken as the base version. The patch introduces the following stuff: * common bug.h header * generic implementation of do_bug_frame * new config CONFIG_GENERIC_BUG_FRAME Signed-off-by: Oleksii Kurochko Acked-by: Julien Grall Reviewed-by: Jan Beulich Tested-by: Julien Grall --- Changes in V9: * rename BUILD_BUG_ON_LINE_WIDTH to BUG_CHECK_LINE_WIDTH * Remove from as the patch were merged to staging which move all things used in from to more proper headers. * add "struct cpu_user_regs" to . * add explanation why is included in --- Changes in V8: * move BUILD_BUG_ON_LINE_WIDTH(line) to "ifndef BUG_FRAME_STRUCT" and add= #elif for "ifndef BUG_FRAME_STRUCT" to define stub for BUILD_BUG_ON_LINE_WIDTH. * move from to to fix compilati= on issue ( more details in the changes to the patch [xen/x86: switch x86 to use g= eneric implemetation of bug.h] ). --- Changes in V7: * fix code style. * Remove '#include ' from bug.c. it should be a part of . * move BUILD_BUG_ON_LINE_WIDTH to '#ifndef BUG_FRAME_STRUCT' and define dummy BUILD_BUG_ON_LINE_WIDTH when BUG_FRAME_STRUCT is defined. * remove update prototype of 'void (*fn)(const struct cpu_user_regs *)' to 'void (*fn)(struct cpu_user_regs *)'. * add code to to make sure the type used in run_in_exception_handler() matches the one used here. --- Changes in V6: * fix code style. * change -EINVAL to -ENOENT in case when bug_frame wasn't found in generic do_bug_frame() * change all 'return id' to 'break' inside switch/case of generic do_bug_f= rame() * move up "#ifndef __ASSEMBLY__" to include BUG_DEBUGGER_TRAP_FATAL * update the comment of BUG_ASM_CONST * make the line with 'BUILD_BUG_ON((line) >> (BUG_LINE_LO_WIDTH + BUG_LINE= _HI_WIDTH))' in BUG_FRAME macros more abstract * remove #ifndef BUG_FRAME_STRUCT around BUG_DISP_WIDTH, BUG_LINE_LO_WIDTH= as it is required to be defined before as it is used by x86's when the header is included in assembly code. --- Changes in V5: * Remove "#ifdef BUG_FN_REG..." from generic do_bug_frame() as ARM will use generic implementation fully. --- Changes in V4: * common/bug.c: - Use BUG_DEBUGGER_TRAP_FATAL(regs) mnacros instead of debugger_trap_fata= l(TRAP_invalid_op, regs) in as TRAP_invalid_op is x86-specific thereby BUG_DEBUGG= ER_TRAP_FATAL should be defined for each architecture. - add information about what do_bug_frame() returns. - invert the condition 'if ( region )' in do_bug_frame() to reduce the in= dention. - change type of variable i from 'unsigned int' to 'size_t' as it is com= pared with n_bugs which has type 'size_t' * xen/bug.h: - Introduce generic BUG_DEBUGGER_TRAP_FATAL(regs) mnacros which is used t= o deal with=20 debugger_trap_fatal(TRAP_invalid_op, regs) where TRAP_invalid_op is x86= -specific - remove '#include ' as it doesn't need any more after s= witch to x86 implementation. - remove '#include ' as it isn't needed any more - move bug_*() macros inside '#ifndef BUG_FRAME_STRUCT' - add to fix compile issue with BUILD_ON()... - Add documentation for BUG_ASM_CONST. * Update the commit message --- Changes in V3: * Add debugger_trap_fatal() to do_bug_frame(). It simplifies usage of do_bug_frame() for x86 so making handle_bug_frame() and find_bug_frame() not needed anymore. * Update do_bug_frame() to return -EINVAL if something goes wrong; otherwi= se id of bug_frame * Update _ASM_BUGFRAME_TEXT to make it more portable. * Drop unnecessary comments. * define stub value for TRAP_invalid_op in case if wasn't defined in arch-specific folders. --- Changes in V2: - Switch to x86 implementation as generic as it is more compact ( at least from the point of view of bug frame structure ). - Rename CONFIG_GENERIC_DO_BUG_FRAME to CONFIG_GENERIC_BUG_FRAME. - Change the macro bug_loc(b) to avoid the need for a cast: #define bug_loc(b) ((unsigned long)(b) + (b)->loc_disp) - Rename BUG_FRAME_STUFF to BUG_FRAME_STRUCT - Make macros related to bug frame structure more generic. - Introduce BUG_INSTR and MODIFIER to make _ASM_BUGFRAME_TEXT reusable between x86 and RISC-V. - Rework do_bug_frame() and introduce find_bug_frame() and handle_bug_fra= me() functions to make it reusable by x86. - code style fixes --- xen/common/Kconfig | 3 + xen/common/Makefile | 1 + xen/common/bug.c | 126 +++++++++++++++++++++++++++++++++ xen/include/xen/bug.h | 161 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 291 insertions(+) create mode 100644 xen/common/bug.c create mode 100644 xen/include/xen/bug.h diff --git a/xen/common/Kconfig b/xen/common/Kconfig index 855c843113..3d2123a783 100644 --- a/xen/common/Kconfig +++ b/xen/common/Kconfig @@ -29,6 +29,9 @@ config ALTERNATIVE_CALL config ARCH_MAP_DOMAIN_PAGE bool =20 +config GENERIC_BUG_FRAME + bool + config HAS_ALTERNATIVE bool =20 diff --git a/xen/common/Makefile b/xen/common/Makefile index bbd75b4be6..46049eac35 100644 --- a/xen/common/Makefile +++ b/xen/common/Makefile @@ -1,5 +1,6 @@ obj-$(CONFIG_ARGO) +=3D argo.o obj-y +=3D bitmap.o +obj-$(CONFIG_GENERIC_BUG_FRAME) +=3D bug.o obj-$(CONFIG_HYPFS_CONFIG) +=3D config_data.o obj-$(CONFIG_CORE_PARKING) +=3D core_parking.o obj-y +=3D cpu.o diff --git a/xen/common/bug.c b/xen/common/bug.c new file mode 100644 index 0000000000..680269b49a --- /dev/null +++ b/xen/common/bug.c @@ -0,0 +1,126 @@ +#include +/* + * Ideally should be included in + * but an issue with compilation can occur as uses + * BUG/ASSERT/etc macros inside but they will be defined later in + * after return from inclusion of : + *=20 + * : + * ... + * : + * ... + * -> some of included header in it uses BUG/ASSERT/e= tc + * ... + * ... + * #define BUG() ... + * ... + * #define ASSERT() ... + * ... + */ +#include +#include +#include +#include +#include +#include +#include + +struct cpu_user_regs; + +/* + * Returns a negative value in case of an error otherwise + * BUGFRAME_{run_fn, warn, bug, assert} + */ +int do_bug_frame(struct cpu_user_regs *regs, unsigned long pc) +{ + const struct bug_frame *bug =3D NULL; + const struct virtual_region *region; + const char *prefix =3D "", *filename, *predicate; + unsigned long fixup; + unsigned int id, lineno; + + region =3D find_text_region(pc); + if ( !region ) + return -EINVAL; + + for ( id =3D 0; id < BUGFRAME_NR; id++ ) + { + const struct bug_frame *b; + size_t i; + + for ( i =3D 0, b =3D region->frame[id].bugs; + i < region->frame[id].n_bugs; b++, i++ ) + { + if ( bug_loc(b) =3D=3D pc ) + { + bug =3D b; + goto found; + } + } + } + + found: + if ( !bug ) + return -ENOENT; + + if ( id =3D=3D BUGFRAME_run_fn ) + { + void (*fn)(struct cpu_user_regs *) =3D bug_ptr(bug); + + fn(regs); + + /* Re-enforce consistent types, because of the casts involved. */ + if ( false ) + run_in_exception_handler(fn); + + return id; + } + + /* WARN, BUG or ASSERT: decode the filename pointer and line number. */ + filename =3D bug_ptr(bug); + if ( !is_kernel(filename) && !is_patch(filename) ) + return -EINVAL; + fixup =3D strlen(filename); + if ( fixup > 50 ) + { + filename +=3D fixup - 47; + prefix =3D "..."; + } + lineno =3D bug_line(bug); + + switch ( id ) + { + case BUGFRAME_warn: + printk("Xen WARN at %s%s:%d\n", prefix, filename, lineno); + show_execution_state(regs); + + break; + + case BUGFRAME_bug: + printk("Xen BUG at %s%s:%d\n", prefix, filename, lineno); + + if ( BUG_DEBUGGER_TRAP_FATAL(regs) ) + break; + + show_execution_state(regs); + panic("Xen BUG at %s%s:%d\n", prefix, filename, lineno); + + case BUGFRAME_assert: + /* ASSERT: decode the predicate string pointer. */ + predicate =3D bug_msg(bug); + if ( !is_kernel(predicate) && !is_patch(predicate) ) + predicate =3D ""; + + printk("Assertion '%s' failed at %s%s:%d\n", + predicate, prefix, filename, lineno); + + if ( BUG_DEBUGGER_TRAP_FATAL(regs) ) + break; + + show_execution_state(regs); + panic("Assertion '%s' failed at %s%s:%d\n", + predicate, prefix, filename, lineno); + } + + return id; +} diff --git a/xen/include/xen/bug.h b/xen/include/xen/bug.h new file mode 100644 index 0000000000..4438b31ee2 --- /dev/null +++ b/xen/include/xen/bug.h @@ -0,0 +1,161 @@ +#ifndef __XEN_BUG_H__ +#define __XEN_BUG_H__ + +#define BUGFRAME_run_fn 0 +#define BUGFRAME_warn 1 +#define BUGFRAME_bug 2 +#define BUGFRAME_assert 3 + +#define BUGFRAME_NR 4 + +#define BUG_DISP_WIDTH 24 +#define BUG_LINE_LO_WIDTH (31 - BUG_DISP_WIDTH) +#define BUG_LINE_HI_WIDTH (31 - BUG_DISP_WIDTH) + +#include + +#ifndef __ASSEMBLY__ + +#ifndef BUG_DEBUGGER_TRAP_FATAL +#define BUG_DEBUGGER_TRAP_FATAL(regs) 0 +#endif + +#include + +#ifndef BUG_FRAME_STRUCT + +struct bug_frame { + signed int loc_disp:BUG_DISP_WIDTH; + unsigned int line_hi:BUG_LINE_HI_WIDTH; + signed int ptr_disp:BUG_DISP_WIDTH; + unsigned int line_lo:BUG_LINE_LO_WIDTH; + signed int msg_disp[]; +}; + +#define bug_loc(b) ((unsigned long)(b) + (b)->loc_disp) + +#define bug_ptr(b) ((const void *)(b) + (b)->ptr_disp) + +#define bug_line(b) (((((b)->line_hi + ((b)->loc_disp < 0)) & = \ + ((1 << BUG_LINE_HI_WIDTH) - 1)) << = \ + BUG_LINE_LO_WIDTH) + = \ + (((b)->line_lo + ((b)->ptr_disp < 0)) & = \ + ((1 << BUG_LINE_LO_WIDTH) - 1))) + +#define bug_msg(b) ((const char *)(b) + (b)->msg_disp[1]) + +#define BUG_CHECK_LINE_WIDTH(line) \ + BUILD_BUG_ON((line) >> (BUG_LINE_LO_WIDTH + BUG_LINE_HI_WIDTH)) + +#elif !defined(BUG_CHECK_LINE_WIDTH) + +#define BUG_CHECK_LINE_WIDTH(line) ((void)(line) + +#endif /* BUG_FRAME_STRUCT */ + + +/* + * Some architectures mark immediate instruction operands in a special way. + * In such cases the special marking may need omitting when specifying + * directive operands. Allow architectures to specify a suitable + * modifier. + */ +#ifndef BUG_ASM_CONST +#define BUG_ASM_CONST "" +#endif + +#ifndef _ASM_BUGFRAME_TEXT + +#define _ASM_BUGFRAME_TEXT(second_frame) = \ + ".Lbug%=3D:"BUG_INSTR"\n" = \ + " .pushsection .bug_frames.%"BUG_ASM_CONST"[bf_type], \"a\", %%progb= its\n" \ + " .p2align 2\n" = \ + ".Lfrm%=3D:\n" = \ + " .long (.Lbug%=3D - .Lfrm%=3D) + %"BUG_ASM_CONST"[bf_line_hi]\n" = \ + " .long (%"BUG_ASM_CONST"[bf_ptr] - .Lfrm%=3D) + %"BUG_ASM_CONST"[bf= _line_lo]\n"\ + " .if " #second_frame "\n" = \ + " .long 0, %"BUG_ASM_CONST"[bf_msg] - .Lfrm%=3D\n" = \ + " .endif\n" = \ + " .popsection\n" + +#define _ASM_BUGFRAME_INFO(type, line, ptr, msg) = \ + [bf_type] "i" (type), = \ + [bf_ptr] "i" (ptr), = \ + [bf_msg] "i" (msg), = \ + [bf_line_lo] "i" ((line & ((1 << BUG_LINE_LO_WIDTH) - 1)) = \ + << BUG_DISP_WIDTH), = \ + [bf_line_hi] "i" (((line) >> BUG_LINE_LO_WIDTH) << BUG_DISP_WIDTH) + +#endif /* _ASM_BUGFRAME_TEXT */ + +#ifndef BUG_FRAME + +#define BUG_FRAME(type, line, ptr, second_frame, msg) do { = \ + BUG_CHECK_LINE_WIDTH(line); \ + BUILD_BUG_ON((type) >=3D BUGFRAME_NR); = \ + asm volatile ( _ASM_BUGFRAME_TEXT(second_frame) = \ + :: _ASM_BUGFRAME_INFO(type, line, ptr, msg) ); = \ +} while ( false ) + +#endif + +#ifndef run_in_exception_handler + +/* + * TODO: untangle header dependences, break BUILD_BUG_ON() out of xen/lib.= h, + * and use a real static inline here to get proper type checking of fn(). + */ +#define run_in_exception_handler(fn) do { \ + (void)((fn) =3D=3D (void (*)(struct cpu_user_regs *))NULL); \ + BUG_FRAME(BUGFRAME_run_fn, 0, fn, 0, NULL); \ +} while ( false ) + +#endif /* run_in_exception_handler */ + +#ifndef WARN +#define WARN() BUG_FRAME(BUGFRAME_warn, __LINE__, __FILE__, 0, NULL) +#endif + +#ifndef BUG +#define BUG() do { \ + BUG_FRAME(BUGFRAME_bug, __LINE__, __FILE__, 0, NULL); \ + unreachable(); \ +} while ( false ) +#endif + +#ifndef assert_failed +#define assert_failed(msg) do { \ + BUG_FRAME(BUGFRAME_assert, __LINE__, __FILE__, 1, msg); \ + unreachable(); \ +} while ( false ) +#endif + +#ifdef CONFIG_GENERIC_BUG_FRAME + +struct cpu_user_regs; + +/* + * Returns a negative value in case of an error otherwise + * BUGFRAME_{run_fn, warn, bug, assert} + */ +int do_bug_frame(struct cpu_user_regs *regs, unsigned long pc); + +#endif /* CONFIG_GENERIC_BUG_FRAME */ + +extern const struct bug_frame __start_bug_frames[], + __stop_bug_frames_0[], + __stop_bug_frames_1[], + __stop_bug_frames_2[], + __stop_bug_frames_3[]; + +#endif /* !__ASSEMBLY__ */ + +#endif /* __XEN_BUG_H__ */ +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ --=20 2.39.2 From nobody Sat May 11 07:53:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1680087106; cv=none; d=zohomail.com; s=zohoarc; b=VVTGQmO2tUb2M1/o4RcuGMEcBL5uaQH3+bbfssxQFWN/KQ+Nj5MYVGhJLdTeqAirnKENS/d0q4R+lOKNaU3KaBrPIHWDWF1UDg1q94jSLWu1e4KOOtOF0VEQ1QMIxb62VOJObvl1/ibtsYCxOqlYpq5s+cHsynKDkmbpig6CFyU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1680087106; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DldPskHzgYoIvAYeHKpbfRQwsqZOEaBiKKquVpoPiN4=; b=BzP4TgA+AHwjejRmQxUPzmxgz/vVICGFJ902J3vKSngLohL33LKCw1eCbthRf52Q0WG2J3aD7oXkC2pXdOjpBLTzMbStbxr4i7d7bP9v9Pgwjjm7Zqz7t54zp5WvMobG/6b6fsKNksmgDsJE8zXqql7xVrG24ol9vVYPf2KcQF8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1680087106411283.0952204111827; Wed, 29 Mar 2023 03:51:46 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.516185.799918 (Exim 4.92) (envelope-from ) id 1phTOZ-0008HT-2Q; Wed, 29 Mar 2023 10:51:11 +0000 Received: by outflank-mailman (output) from mailman id 516185.799918; Wed, 29 Mar 2023 10:51:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1phTOY-0008HL-VI; Wed, 29 Mar 2023 10:51:10 +0000 Received: by outflank-mailman (input) for mailman id 516185; Wed, 29 Mar 2023 10:51:09 +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 1phTOX-0007lb-4Y for xen-devel@lists.xenproject.org; Wed, 29 Mar 2023 10:51:09 +0000 Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [2a00:1450:4864:20::233]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 9c23af94-ce1f-11ed-85db-49a42c6b2330; Wed, 29 Mar 2023 12:51:07 +0200 (CEST) Received: by mail-lj1-x233.google.com with SMTP id t14so15603741ljd.5 for ; Wed, 29 Mar 2023 03:51:07 -0700 (PDT) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id j17-20020ac253b1000000b004eb0f6b7ccfsm1173572lfh.134.2023.03.29.03.51.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Mar 2023 03:51:06 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 9c23af94-ce1f-11ed-85db-49a42c6b2330 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680087067; 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=DldPskHzgYoIvAYeHKpbfRQwsqZOEaBiKKquVpoPiN4=; b=NGek71g98vpT7REoy4T6NLVHYWa68X4Sp3dnCziNewPw/8I4LGvQLcnxihy/InMOyo YrEhUXAluKiWfKjoJzJeQDxWx0dC3kN0xeL7pzXwZEyGl+YHRtBybg42ZqaKEluXQnuE LEagycEAyZbURb9D6g4YFgUJzc077QUgllUFaKPJsOkQTKCWeLWnBZ4gHYn7wGBobAP/ E02g8aLkxMS2RLgfYCJYlV+03uo0SR4zw8p9vNCqk3jZ1xODCOkybo7woq6cK+A+ooGu guIMDxW6U2tE2/JYI8loW0fRjeQylRadX9d6uSIjdfvQkuykeixeGK6T8IOLSaY9YFM8 OQ0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680087067; 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=DldPskHzgYoIvAYeHKpbfRQwsqZOEaBiKKquVpoPiN4=; b=bz9L22UYRgJVXG1vdLbUKlTr/Yp+QxS708BUpH27bYgKEeLWSeY7E6KK6v4LD9kHKw ezoFDDV795mYeAFUopwWIs91Re6T/DxAND+//F0qm7ECfSrG6fF1+lwHva0ZmUY2iLCR dsd7MzSuNkeVGEa5UZYDsn80ltI+JIo11zodsFEz8CQBzcbWr73f0/0EgqOVPZB+T0n9 uLu10jpOcm3/ciVMVsq3eJURAiI3rRP+J6ymDqwxdBSoZjdafUAN7qHPw9PU8AsUvWme qhPIKrY/K0oJ9sjBSrwwZAOwY1gxj976c9AvQYrPBc7Fja60/70bO8aZ1zbnSJX+kQms gVKw== X-Gm-Message-State: AAQBX9dOw2/7cIACxwkAbRyayi8uZlK/yB78WK6dOjC7hLvUGIyF/T8/ mrhs590wyzFiEE1sDUAKRmvdxENVxMw= X-Google-Smtp-Source: AKy350Z616Thnf37B8Qxl0dFhprg4uBVFFk/qBOlc5ZzDA8BzpZbYqD1+zq/MIFZ3gzv6fFLTudzSw== X-Received: by 2002:a2e:80d6:0:b0:29d:d0b:7a78 with SMTP id r22-20020a2e80d6000000b0029d0d0b7a78mr5996097ljg.21.1680087067008; Wed, 29 Mar 2023 03:51:07 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Julien Grall , Jan Beulich , Andrew Cooper , Stefano Stabellini , Gianluca Guida , Oleksii Kurochko , Bertrand Marquis , Volodymyr Babchuk Subject: [PATCH v9 2/5] xen/arm: remove unused defines in Date: Wed, 29 Mar 2023 13:50:29 +0300 Message-Id: X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1680087107277100001 Content-Type: text/plain; charset="utf-8" The following defines BUG_DISP_WIDTH, BUG_LINE_LO_WIDTH, BUG_LINE_HI_WIDTH aren't used in ARM so could be purged as unused. Requested-by: Jan Beulich Signed-off-by: Oleksii Kurochko Reviewed-by: Jan Beulich Acked-by: Julien Grall --- Changes in V9: * Nothing changed --- Changes in V8: * Update the commit message with Requested-by and Reviewed-by --- xen/arch/arm/include/asm/bug.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/xen/arch/arm/include/asm/bug.h b/xen/arch/arm/include/asm/bug.h index f4088d0913..d6c98505bf 100644 --- a/xen/arch/arm/include/asm/bug.h +++ b/xen/arch/arm/include/asm/bug.h @@ -9,10 +9,6 @@ # error "unknown ARM variant" #endif =20 -#define BUG_DISP_WIDTH 24 -#define BUG_LINE_LO_WIDTH (31 - BUG_DISP_WIDTH) -#define BUG_LINE_HI_WIDTH (31 - BUG_DISP_WIDTH) - struct bug_frame { signed int loc_disp; /* Relative address to the bug address */ signed int file_disp; /* Relative address to the filename */ --=20 2.39.2 From nobody Sat May 11 07:53:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1680087108; cv=none; d=zohomail.com; s=zohoarc; b=cBU31xxatcbhmHhHFB0Plv9gxTmiOyYOK+yq8sLid/EPmg8wvFELkn0NBy05ZuJ9jwvKuQBbqelAToG9IAnK8eTwNW0o9jTK705TtFK7rxRe+RJqEVNOBH2lGuWiWe5HTwdm6j1zKvZCNqLYwCKzCvutNUHCh/bty97bCVpgbuY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1680087108; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1s1r6KRhx39jhndI0y/4b14T4ESIUvQbe+DJRtNyGyY=; b=VO9LVhxkVIxNq7aGQ5pxZ5MvW4cMmqaUUu2NLs+Vux7of+m6ErMY4qNumbEHzAAhpR5rNSGWQX4QjkbYk6XwMAK7n1GXnRPCVUdq3msl6qPxGVY1HGjGQ+5hWdoaLqhJUVW/8ZpaP7ZFQl+xzj6IFnys5HSX6a+IVkKrnpiSN5k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1680087108587345.16990959114764; Wed, 29 Mar 2023 03:51:48 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.516187.799930 (Exim 4.92) (envelope-from ) id 1phTOZ-0008RV-Up; Wed, 29 Mar 2023 10:51:11 +0000 Received: by outflank-mailman (output) from mailman id 516187.799930; Wed, 29 Mar 2023 10:51:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1phTOZ-0008QB-Kg; Wed, 29 Mar 2023 10:51:11 +0000 Received: by outflank-mailman (input) for mailman id 516187; Wed, 29 Mar 2023 10:51:10 +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 1phTOY-0008D9-Kb for xen-devel@lists.xenproject.org; Wed, 29 Mar 2023 10:51:10 +0000 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [2a00:1450:4864:20::12f]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 9c7dd214-ce1f-11ed-b464-930f4c7d94ae; Wed, 29 Mar 2023 12:51:08 +0200 (CEST) Received: by mail-lf1-x12f.google.com with SMTP id g19so6432096lfr.9 for ; Wed, 29 Mar 2023 03:51:08 -0700 (PDT) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id j17-20020ac253b1000000b004eb0f6b7ccfsm1173572lfh.134.2023.03.29.03.51.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Mar 2023 03:51:07 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 9c7dd214-ce1f-11ed-b464-930f4c7d94ae DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680087068; 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=1s1r6KRhx39jhndI0y/4b14T4ESIUvQbe+DJRtNyGyY=; b=FIFosA7GknH4flXYa8J1UMBlQWtHrSLkM4Vu3/eXeVMrIXYZtwJ2y7IZj4nTKjVzQR LD2/Hx6V9CN9FqhHxavXETXQ96vynLflIo4fpyJQUkvRiTpU0TcgVS+qS1ec/pqT5WEk kaiRkho9aywL5rY4d53MlWCdVSd88tHl6d88hu3+NBzWl2fMOHDhJxe8DkjX77+LTnOa TATmB0gFmkySlAAklbJ+4E//bo4dd/+LDFDL0fqbRVAIH8iY0PIi986/zHRs03pKr94g 7l7y10gUC00oWNCu/0uFH63lRVGsDgP/+zhI3ep9Uy03C/0eZ9gihqbMb80Dtqr2TIW3 CDdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680087068; 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=1s1r6KRhx39jhndI0y/4b14T4ESIUvQbe+DJRtNyGyY=; b=NyJw853Qj73dmBa/4Er1ea5XsgfAahedC4fH1dF4TtJ5CvZXn8xRX4xN7cpP6sy7EG 7RN/bQsp0fmy09/YRqlkGF/XcAXUKhN6wHRo1FPtyHSUW86iq6dNHhNdMZuUlA9bKWbF 4E/vssJOVZ1cLdbcnyTdEUBJ33iHrhPYfaiTs/k/Ts+x28RS9RWzXZmWvuSvRW49nOMG RlRFRwpCLkUU2Ik0IkZJCgOYBI/WBMjp7gsBtII2cVfdFDKIo78l6oSNJQ2kFQxMsKtb 56LxqD7XumZZ//sJvDSXcMk7rZwfVVOeigxkUFaiTx/mnP6PYnXHYsnXJV8MZgoh1SdK zn5Q== X-Gm-Message-State: AAQBX9dKFmnhPcoIEWNQAYMQQsGFSlMJQuts/a1PhpsfIdFuUZNnPzuA ym7SDzO3utuePMSj8PMUNQ7CIXSOsJU= X-Google-Smtp-Source: AKy350bIGBtupeLsdA/Kna4fNOQJTLfgJ6kdr7w5t16OPdln2pa7VcDzfhcKAwypAUb4RJBVsFbT8w== X-Received: by 2002:ac2:5681:0:b0:4e9:7931:809f with SMTP id 1-20020ac25681000000b004e97931809fmr5290721lfr.61.1680087067853; Wed, 29 Mar 2023 03:51:07 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Julien Grall , Jan Beulich , Andrew Cooper , Stefano Stabellini , Gianluca Guida , Oleksii Kurochko , Bertrand Marquis , Volodymyr Babchuk , George Dunlap , Wei Liu , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v9 3/5] xen: change to Date: Wed, 29 Mar 2023 13:50:30 +0300 Message-Id: <67e4c153cecb5757c7b55a4cffc8c7bb6b10c0d0.1680086655.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1680087109422100002 Content-Type: text/plain; charset="utf-8" The idea of the patch is to change all to and keep Xen compilable with adding only minimal amount of changes: 1. It was added "#include " to ARM's "" as it uses uint_{16,32}t in 'struct bug_frame'. 2. It was added '#define BUG_FRAME_STRUCT' which means that ARM hasn't been switched to generic implementation yet. 3. It was added '#define BUG_FRAME_STRUCT' which means that x86 hasn't been switched to generic implementation yet. 4. BUGFRAME_* and _start_bug_frame[], _stop_bug_frame_*[] were removed for ARM & x86 to deal with compilation errors such as: redundant redeclaration of ... 5. Remove BUG_DISP_WIDTH, BUG_LINE_LO_WIDTH, BUG_LINE_HI_WIDTH from x86's to not to produce #undef for them and #define again with the same values as in . These #undef and #define will be anyway removed in the patch [2] 6. Remove from and as nothing from are used in <*/cpufreq.c> In the following two patches x86 and ARM archictectures will be switched fully: [1] xen/arm: switch ARM to use generic implementation of bug.h [2] xen/x86: switch x86 to use generic implemetation of bug.h Signed-off-by: Oleksii Kurochko Reviewed-by: Jan Beulich Acked-by: Julien Grall --- Changes in V9: * Nothing changed --- Changes in V8: * remove from and as nothing from are used in <*/cpufreq.c> * update the commit message --- Changes in V7: * Remove #undef {BUG_DISP_WIDTH, BUG_LINE_LO_WIDTH, BUG_LINE_HI_WIDTH} from ARM and x86: * for ARM was created separate patch where the defines are removed as unused. * for x86, the defines were removed now not to produce #undef of them to= remove them again in the following-up patch * Update commit message * Add Reviewed-by: Jan Beulich --- Changes in V6: - change the inclusion order of . - add #undef of BUG_DISP_WIDTH, BUG_LINE_LO_WIDTH for ARM & x86 as they were introduced unconditionally in . - update the commit message --- Changes in V5: - Nothing changed --- Changes in V4: - defines BUG_DISP_WIDTH, BUG_LINE_LO_WIDTH, BUG_LINE_HI_WIDTH were moved = into "ifndef BUG_FRAME_STRUCT" in as they are specific for 'struc= t bug_frame' and so should co-exist together. So the defines were back to until BUG_FRA= ME_STRUCT will be defined in . - Update the comment message. --- Changes in V3: * Update patch 2 not to break compilation: move some parts from patches 3 = and 4 to patch 2: * move some generic parts from to * add define BUG_FRAME_STRUCT in ARM's --- Changes in V2: * Put [PATCH v1 4/4] xen: change to as second patc= h, update the patch to change all to among the whol= e project to not break build. * Update the commit message. --- xen/arch/arm/include/asm/bug.h | 17 ++++------------- xen/arch/arm/include/asm/div64.h | 2 +- xen/arch/arm/vgic/vgic-v2.c | 2 +- xen/arch/arm/vgic/vgic.c | 2 +- xen/arch/x86/acpi/cpufreq/cpufreq.c | 1 - xen/arch/x86/include/asm/asm_defns.h | 2 +- xen/arch/x86/include/asm/bug.h | 19 ++----------------- xen/drivers/cpufreq/cpufreq.c | 1 - xen/include/xen/lib.h | 2 +- 9 files changed, 11 insertions(+), 37 deletions(-) diff --git a/xen/arch/arm/include/asm/bug.h b/xen/arch/arm/include/asm/bug.h index d6c98505bf..cacaf014ab 100644 --- a/xen/arch/arm/include/asm/bug.h +++ b/xen/arch/arm/include/asm/bug.h @@ -1,6 +1,8 @@ #ifndef __ARM_BUG_H__ #define __ARM_BUG_H__ =20 +#include + #if defined(CONFIG_ARM_32) # include #elif defined(CONFIG_ARM_64) @@ -9,6 +11,8 @@ # error "unknown ARM variant" #endif =20 +#define BUG_FRAME_STRUCT + struct bug_frame { signed int loc_disp; /* Relative address to the bug address */ signed int file_disp; /* Relative address to the filename */ @@ -22,13 +26,6 @@ struct bug_frame { #define bug_line(b) ((b)->line) #define bug_msg(b) ((const char *)(b) + (b)->msg_disp) =20 -#define BUGFRAME_run_fn 0 -#define BUGFRAME_warn 1 -#define BUGFRAME_bug 2 -#define BUGFRAME_assert 3 - -#define BUGFRAME_NR 4 - /* Many versions of GCC doesn't support the asm %c parameter which would * be preferable to this unpleasantness. We use mergeable string * sections to avoid multiple copies of the string appearing in the @@ -85,12 +82,6 @@ struct bug_frame { unreachable(); \ } while (0) =20 -extern const struct bug_frame __start_bug_frames[], - __stop_bug_frames_0[], - __stop_bug_frames_1[], - __stop_bug_frames_2[], - __stop_bug_frames_3[]; - #endif /* __ARM_BUG_H__ */ /* * Local variables: diff --git a/xen/arch/arm/include/asm/div64.h b/xen/arch/arm/include/asm/di= v64.h index 1cd58bc51a..fc667a80f9 100644 --- a/xen/arch/arm/include/asm/div64.h +++ b/xen/arch/arm/include/asm/div64.h @@ -74,7 +74,7 @@ =20 #elif __GNUC__ >=3D 4 =20 -#include +#include =20 /* * If the divisor happens to be constant, we determine the appropriate diff --git a/xen/arch/arm/vgic/vgic-v2.c b/xen/arch/arm/vgic/vgic-v2.c index 1a99d3a8b4..c90e88fddb 100644 --- a/xen/arch/arm/vgic/vgic-v2.c +++ b/xen/arch/arm/vgic/vgic-v2.c @@ -16,8 +16,8 @@ */ =20 #include -#include #include +#include #include #include =20 diff --git a/xen/arch/arm/vgic/vgic.c b/xen/arch/arm/vgic/vgic.c index f0f2ea5021..b9463a5f27 100644 --- a/xen/arch/arm/vgic/vgic.c +++ b/xen/arch/arm/vgic/vgic.c @@ -15,9 +15,9 @@ * along with this program. If not, see . */ =20 +#include #include #include -#include #include #include =20 diff --git a/xen/arch/x86/acpi/cpufreq/cpufreq.c b/xen/arch/x86/acpi/cpufre= q/cpufreq.c index c27cbb2304..2e0067fbe5 100644 --- a/xen/arch/x86/acpi/cpufreq/cpufreq.c +++ b/xen/arch/x86/acpi/cpufreq/cpufreq.c @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include diff --git a/xen/arch/x86/include/asm/asm_defns.h b/xen/arch/x86/include/as= m/asm_defns.h index d9431180cf..baaaccb26e 100644 --- a/xen/arch/x86/include/asm/asm_defns.h +++ b/xen/arch/x86/include/asm/asm_defns.h @@ -6,8 +6,8 @@ /* NB. Auto-generated from arch/.../asm-offsets.c */ #include #endif -#include #include +#include #include #include #include diff --git a/xen/arch/x86/include/asm/bug.h b/xen/arch/x86/include/asm/bug.h index b7265bdfbe..4b3e7b019d 100644 --- a/xen/arch/x86/include/asm/bug.h +++ b/xen/arch/x86/include/asm/bug.h @@ -1,19 +1,10 @@ #ifndef __X86_BUG_H__ #define __X86_BUG_H__ =20 -#define BUG_DISP_WIDTH 24 -#define BUG_LINE_LO_WIDTH (31 - BUG_DISP_WIDTH) -#define BUG_LINE_HI_WIDTH (31 - BUG_DISP_WIDTH) - -#define BUGFRAME_run_fn 0 -#define BUGFRAME_warn 1 -#define BUGFRAME_bug 2 -#define BUGFRAME_assert 3 - -#define BUGFRAME_NR 4 - #ifndef __ASSEMBLY__ =20 +#define BUG_FRAME_STRUCT + struct bug_frame { signed int loc_disp:BUG_DISP_WIDTH; unsigned int line_hi:BUG_LINE_HI_WIDTH; @@ -80,12 +71,6 @@ struct bug_frame { unreachable(); \ } while (0) =20 -extern const struct bug_frame __start_bug_frames[], - __stop_bug_frames_0[], - __stop_bug_frames_1[], - __stop_bug_frames_2[], - __stop_bug_frames_3[]; - #else /* !__ASSEMBLY__ */ =20 /* diff --git a/xen/drivers/cpufreq/cpufreq.c b/xen/drivers/cpufreq/cpufreq.c index a94520ee57..2321c7dd07 100644 --- a/xen/drivers/cpufreq/cpufreq.c +++ b/xen/drivers/cpufreq/cpufreq.c @@ -39,7 +39,6 @@ #include #include #include -#include #include #include =20 diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h index 05ee1e18af..e914ccade0 100644 --- a/xen/include/xen/lib.h +++ b/xen/include/xen/lib.h @@ -24,12 +24,12 @@ =20 #ifndef __ASSEMBLY__ =20 +#include #include #include #include #include #include -#include =20 #define BUG_ON(p) do { if (unlikely(p)) BUG(); } while (0) #define WARN_ON(p) ({ \ --=20 2.39.2 From nobody Sat May 11 07:53:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1680087110; cv=none; d=zohomail.com; s=zohoarc; b=mKj4DGE+2u/OkdfMUQJoew/U/MaKBK9Ve7+zhWqYTOlUUTpdZ6mChEcaAKS4tt4yatkYYVhXDmNfibyyGFfYndj+2VIdnZScPTNH6gS74sf9KDawlPrp8wdtjGoHM/ad8dnnEVPLOousfVZ/i9+aJAtYHM87EV16GMiqFwQXRUM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1680087110; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=W4hm0NhPYtnVD8krpgBcFgSPSXUb/9KSDjrwyawhzs4=; b=drlzOlmjrMs4i81KzSro9Gqc/T4OH2+gT2n+YvQDkipytUEIw6UbrvmAcFV+DlOX4mVQLATHFXK81ZF1oHOdL3lmVf7u6zZmY2h+V0zllvxRYCrNHHLD7ezcUBDsw85jdXNo7jQylBbol7FuCq/HctIOBozlra6GRLKRP02Q240= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1680087110770636.1889654874451; Wed, 29 Mar 2023 03:51:50 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.516186.799925 (Exim 4.92) (envelope-from ) id 1phTOZ-0008Kz-HP; Wed, 29 Mar 2023 10:51:11 +0000 Received: by outflank-mailman (output) from mailman id 516186.799925; Wed, 29 Mar 2023 10:51:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1phTOZ-0008Jm-7b; Wed, 29 Mar 2023 10:51:11 +0000 Received: by outflank-mailman (input) for mailman id 516186; Wed, 29 Mar 2023 10:51:10 +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 1phTOY-0007lb-4i for xen-devel@lists.xenproject.org; Wed, 29 Mar 2023 10:51:10 +0000 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [2a00:1450:4864:20::136]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 9cf3b944-ce1f-11ed-85db-49a42c6b2330; Wed, 29 Mar 2023 12:51:09 +0200 (CEST) Received: by mail-lf1-x136.google.com with SMTP id j11so19519676lfg.13 for ; Wed, 29 Mar 2023 03:51:09 -0700 (PDT) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id j17-20020ac253b1000000b004eb0f6b7ccfsm1173572lfh.134.2023.03.29.03.51.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Mar 2023 03:51:08 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 9cf3b944-ce1f-11ed-85db-49a42c6b2330 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680087068; 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=W4hm0NhPYtnVD8krpgBcFgSPSXUb/9KSDjrwyawhzs4=; b=Ti4IqCK97MPndFrP8PVZIVu+Q79yqwYq68VMR0d21qgNXnLwL7LGvNW3ziw7+ueBjt TiosmseI0q4zvaBg6HdYGos65WBPDgPSMRCdB6fdDrF9r45+t625/SWX74lonnILo6Jg FYSvAxs6UeUEd3IkRYevF9th4/ZdvQ8ySzs+p/hI5hzptw4lRfqDaaPrmExAvTgSaKM6 1+L6uoYywk5Vaz4+0FEXh0M8GB6qv7jFQUsfJlyC64zaVbYoaOb5wv44rU/s1+ErGo/F Qj1KJRhZqbWyRuZb727X0O3A9UnkEaejZbDr7EigZBBzWUkmUCDGCsRacC7sZTaVn9l1 2IBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680087068; 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=W4hm0NhPYtnVD8krpgBcFgSPSXUb/9KSDjrwyawhzs4=; b=3Prvovyl4BZ8Xs8CEKrDupSJAz1iN/pC4TKeahbquVs1AmoTzCPBf/Y4S8HkV8u3n/ xZ05gSxSORxW1JIFuPnyF1ass3c3T4Hr1xWs43ZhF3pkRd2Y+i6kxjqvazLJwlPAyA+1 Vwl8Tv36PKAmLtArLMw14K25VugtfhIR4JwVuEcj43T5CnwbMTiBjjImme+sImQcFhDD dzJ2Gdf8gdPxSa7WTnnF4i4Jp38GbaJlq0HvcxbF7hJa2yS5SVTF9tB7GWlDYSimJL8Q Sa3SvL1b5Wk1TZndJfwmSgMrHNmH3a89OJUi4moFwl48XSr5/K89FrcYt+IizMrqrLO2 Mo/w== X-Gm-Message-State: AAQBX9ezZ5K6IH0kNzYp7FGfsvqBAJHgwERElVDWxhPn890q+6VlkMrD Np+6JL1LbDGJ/A7eqq9udixqFr716WE= X-Google-Smtp-Source: AKy350aZ+yRz5s1d6x6XlDfDtkrtemdQFAaW9oZQdezm35Wzno1h/TZqKTfQeeqfRruQK3WnqPMkcA== X-Received: by 2002:a19:f602:0:b0:4e8:a093:5eea with SMTP id x2-20020a19f602000000b004e8a0935eeamr577637lfe.11.1680087068545; Wed, 29 Mar 2023 03:51:08 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Julien Grall , Jan Beulich , Andrew Cooper , Stefano Stabellini , Gianluca Guida , Oleksii Kurochko , Bertrand Marquis , Volodymyr Babchuk Subject: [PATCH v9 4/5] xen/arm: switch ARM to use generic implementation of bug.h Date: Wed, 29 Mar 2023 13:50:31 +0300 Message-Id: <8fdb98350ae4fc6029738d0aabe13a57e1945a50.1680086655.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1680087111347100005 Content-Type: text/plain; charset="utf-8" The following changes were made: * make GENERIC_BUG_FRAME mandatory for ARM * As do_bug_frame() returns -EINVAL in case something goes wrong otherwise id of bug frame. Thereby 'if' cases where do_bug_frame() was updated to check if the returned value is less than 0 * Switch ARM's implementation of bug.h macros to generic one Signed-off-by: Oleksii Kurochko --- Changes in V9: * add additional explanation to header --- Changes in V8: * Nothing changed. --- Changes in V7: * Rebase the patch. --- Changes in V6: * Update the "changes in v5" * Rebase on top of the patch [xen: introduce CONFIG_GENERIC_BUG_FRAME] as there were minor changes. --- Changes in V5: * common/bug.c changes were removed after rebase (the patch [xen: introduce CONFIG_GENERIC_BUG_FRAME] was reworked to make ARM implementation to use generic do_bug_frame()) --- Changes in V4: * Switch ARM implementation to generic one * Remove BUG_FN_REG from arm{16,32}/bug.h as it isn't needed after switch = to generic implementation * Update commit message --- Changes in V3: * As prototype and what do_bug_frame() returns was changed so patch 3 and 4 was updated to use a new version of do_bug_frame --- Changes in V2: * Rename bug_file() in ARM implementation to bug_ptr() as generic do_bug_frame() uses bug_ptr(). * Remove generic parts from bug.h * Remove declaration of 'int do_bug_frame(...)' from as it was introduced in --- xen/arch/arm/Kconfig | 1 + xen/arch/arm/arm32/traps.c | 2 +- xen/arch/arm/include/asm/arm32/bug.h | 2 - xen/arch/arm/include/asm/arm64/bug.h | 2 - xen/arch/arm/include/asm/bug.h | 89 ++++++---------------------- xen/arch/arm/include/asm/traps.h | 2 - xen/arch/arm/traps.c | 81 +------------------------ 7 files changed, 22 insertions(+), 157 deletions(-) diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig index 239d3aed3c..aad6644a7b 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -12,6 +12,7 @@ config ARM_64 =20 config ARM def_bool y + select GENERIC_BUG_FRAME select HAS_ALTERNATIVE select HAS_DEVICE_TREE select HAS_PASSTHROUGH diff --git a/xen/arch/arm/arm32/traps.c b/xen/arch/arm/arm32/traps.c index a2fc1c22cb..61c61132c7 100644 --- a/xen/arch/arm/arm32/traps.c +++ b/xen/arch/arm/arm32/traps.c @@ -48,7 +48,7 @@ void do_trap_undefined_instruction(struct cpu_user_regs *= regs) if ( instr !=3D BUG_OPCODE ) goto die; =20 - if ( do_bug_frame(regs, pc) ) + if ( do_bug_frame(regs, pc) < 0 ) goto die; =20 regs->pc +=3D 4; diff --git a/xen/arch/arm/include/asm/arm32/bug.h b/xen/arch/arm/include/as= m/arm32/bug.h index 25cce151dc..3e66f35969 100644 --- a/xen/arch/arm/include/asm/arm32/bug.h +++ b/xen/arch/arm/include/asm/arm32/bug.h @@ -10,6 +10,4 @@ =20 #define BUG_INSTR ".word " __stringify(BUG_OPCODE) =20 -#define BUG_FN_REG r0 - #endif /* __ARM_ARM32_BUG_H__ */ diff --git a/xen/arch/arm/include/asm/arm64/bug.h b/xen/arch/arm/include/as= m/arm64/bug.h index 5e11c0dfd5..59f664d7de 100644 --- a/xen/arch/arm/include/asm/arm64/bug.h +++ b/xen/arch/arm/include/asm/arm64/bug.h @@ -6,6 +6,4 @@ =20 #define BUG_INSTR "brk " __stringify(BRK_BUG_FRAME_IMM) =20 -#define BUG_FN_REG x0 - #endif /* __ARM_ARM64_BUG_H__ */ diff --git a/xen/arch/arm/include/asm/bug.h b/xen/arch/arm/include/asm/bug.h index cacaf014ab..3fb0471a9b 100644 --- a/xen/arch/arm/include/asm/bug.h +++ b/xen/arch/arm/include/asm/bug.h @@ -1,6 +1,24 @@ #ifndef __ARM_BUG_H__ #define __ARM_BUG_H__ =20 +/* + * Please do not include in the header any header that might + * use BUG/ASSERT/etc maros asthey will be defined later after + * the return to from the current header: + *=20 + * : + * ... + * : + * ... + * + * ... + * ... + * #define BUG() ... + * ... + * #define ASSERT() ... + * ... + */ + #include =20 #if defined(CONFIG_ARM_32) @@ -11,76 +29,7 @@ # error "unknown ARM variant" #endif =20 -#define BUG_FRAME_STRUCT - -struct bug_frame { - signed int loc_disp; /* Relative address to the bug address */ - signed int file_disp; /* Relative address to the filename */ - signed int msg_disp; /* Relative address to the predicate (for ASSE= RT) */ - uint16_t line; /* Line number */ - uint32_t pad0:16; /* Padding for 8-bytes align */ -}; - -#define bug_loc(b) ((const void *)(b) + (b)->loc_disp) -#define bug_file(b) ((const void *)(b) + (b)->file_disp); -#define bug_line(b) ((b)->line) -#define bug_msg(b) ((const char *)(b) + (b)->msg_disp) - -/* Many versions of GCC doesn't support the asm %c parameter which would - * be preferable to this unpleasantness. We use mergeable string - * sections to avoid multiple copies of the string appearing in the - * Xen image. BUGFRAME_run_fn needs to be handled separately. - */ -#define BUG_FRAME(type, line, file, has_msg, msg) do { = \ - BUILD_BUG_ON((line) >> 16); = \ - BUILD_BUG_ON((type) >=3D BUGFRAME_NR); = \ - asm ("1:"BUG_INSTR"\n" = \ - ".pushsection .rodata.str, \"aMS\", %progbits, 1\n" = \ - "2:\t.asciz " __stringify(file) "\n" = \ - "3:\n" = \ - ".if " #has_msg "\n" = \ - "\t.asciz " #msg "\n" = \ - ".endif\n" = \ - ".popsection\n" = \ - ".pushsection .bug_frames." __stringify(type) ", \"a\", %progbits= \n"\ - "4:\n" = \ - ".p2align 2\n" = \ - ".long (1b - 4b)\n" = \ - ".long (2b - 4b)\n" = \ - ".long (3b - 4b)\n" = \ - ".hword " __stringify(line) ", 0\n" = \ - ".popsection"); = \ -} while (0) - -/* - * GCC will not allow to use "i" when PIE is enabled (Xen doesn't set the - * flag but instead rely on the default value from the compiler). So the - * easiest way to implement run_in_exception_handler() is to pass the to - * be called function in a fixed register. - */ -#define run_in_exception_handler(fn) do { = \ - asm ("mov " __stringify(BUG_FN_REG) ", %0\n" = \ - "1:"BUG_INSTR"\n" = \ - ".pushsection .bug_frames." __stringify(BUGFRAME_run_fn) "," = \ - " \"a\", %%progbits\n" = \ - "2:\n" = \ - ".p2align 2\n" = \ - ".long (1b - 2b)\n" = \ - ".long 0, 0, 0\n" = \ - ".popsection" :: "r" (fn) : __stringify(BUG_FN_REG) ); = \ -} while (0) - -#define WARN() BUG_FRAME(BUGFRAME_warn, __LINE__, __FILE__, 0, "") - -#define BUG() do { \ - BUG_FRAME(BUGFRAME_bug, __LINE__, __FILE__, 0, ""); \ - unreachable(); \ -} while (0) - -#define assert_failed(msg) do { \ - BUG_FRAME(BUGFRAME_assert, __LINE__, __FILE__, 1, msg); \ - unreachable(); \ -} while (0) +#define BUG_ASM_CONST "c" =20 #endif /* __ARM_BUG_H__ */ /* diff --git a/xen/arch/arm/include/asm/traps.h b/xen/arch/arm/include/asm/tr= aps.h index 883dae368e..c6518008ec 100644 --- a/xen/arch/arm/include/asm/traps.h +++ b/xen/arch/arm/include/asm/traps.h @@ -69,8 +69,6 @@ void do_cp(struct cpu_user_regs *regs, const union hsr hs= r); void do_trap_smc(struct cpu_user_regs *regs, const union hsr hsr); void do_trap_hvc_smccc(struct cpu_user_regs *regs); =20 -int do_bug_frame(const struct cpu_user_regs *regs, vaddr_t pc); - void noreturn do_unexpected_trap(const char *msg, const struct cpu_user_regs *regs); void do_trap_hyp_sync(struct cpu_user_regs *regs); diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 061c92acbd..9c6eb66422 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -1197,85 +1197,6 @@ void do_unexpected_trap(const char *msg, const struc= t cpu_user_regs *regs) panic("CPU%d: Unexpected Trap: %s\n", smp_processor_id(), msg); } =20 -int do_bug_frame(const struct cpu_user_regs *regs, vaddr_t pc) -{ - const struct bug_frame *bug =3D NULL; - const char *prefix =3D "", *filename, *predicate; - unsigned long fixup; - int id =3D -1, lineno; - const struct virtual_region *region; - - region =3D find_text_region(pc); - if ( region ) - { - for ( id =3D 0; id < BUGFRAME_NR; id++ ) - { - const struct bug_frame *b; - unsigned int i; - - for ( i =3D 0, b =3D region->frame[id].bugs; - i < region->frame[id].n_bugs; b++, i++ ) - { - if ( ((vaddr_t)bug_loc(b)) =3D=3D pc ) - { - bug =3D b; - goto found; - } - } - } - } - found: - if ( !bug ) - return -ENOENT; - - if ( id =3D=3D BUGFRAME_run_fn ) - { - void (*fn)(const struct cpu_user_regs *) =3D (void *)regs->BUG_FN_= REG; - - fn(regs); - return 0; - } - - /* WARN, BUG or ASSERT: decode the filename pointer and line number. */ - filename =3D bug_file(bug); - if ( !is_kernel(filename) ) - return -EINVAL; - fixup =3D strlen(filename); - if ( fixup > 50 ) - { - filename +=3D fixup - 47; - prefix =3D "..."; - } - lineno =3D bug_line(bug); - - switch ( id ) - { - case BUGFRAME_warn: - printk("Xen WARN at %s%s:%d\n", prefix, filename, lineno); - show_execution_state(regs); - return 0; - - case BUGFRAME_bug: - printk("Xen BUG at %s%s:%d\n", prefix, filename, lineno); - show_execution_state(regs); - panic("Xen BUG at %s%s:%d\n", prefix, filename, lineno); - - case BUGFRAME_assert: - /* ASSERT: decode the predicate string pointer. */ - predicate =3D bug_msg(bug); - if ( !is_kernel(predicate) ) - predicate =3D ""; - - printk("Assertion '%s' failed at %s%s:%d\n", - predicate, prefix, filename, lineno); - show_execution_state(regs); - panic("Assertion '%s' failed at %s%s:%d\n", - predicate, prefix, filename, lineno); - } - - return -EINVAL; -} - #ifdef CONFIG_ARM_64 static void do_trap_brk(struct cpu_user_regs *regs, const union hsr hsr) { @@ -1292,7 +1213,7 @@ static void do_trap_brk(struct cpu_user_regs *regs, c= onst union hsr hsr) switch ( hsr.brk.comment ) { case BRK_BUG_FRAME_IMM: - if ( do_bug_frame(regs, regs->pc) ) + if ( do_bug_frame(regs, regs->pc) < 0 ) goto die; =20 regs->pc +=3D 4; --=20 2.39.2 From nobody Sat May 11 07:53:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1680087111; cv=none; d=zohomail.com; s=zohoarc; b=JgIM/YSQIBEkFHHqLe+EkhD9UtbhTRFg/U6HcLkm1nxxYKHeoQdafMY1kI10cIgbdEQn1EbFvX8GH9GoaaecjZwfySn6zjPsAkExCSkxmsmOXytjsjTGo4HtQNQrsG2sQ8JdvbSShd+7meJVtXR78laWDiCU/af0bs+7hTjDT8A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1680087111; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=OIBTQ+/gJzftoYOKQxHsDF5nCeh3hAxpIqkYkUYYTMY=; b=I+zX/RYSSCVNmpGxVGwbHhEDkEYWOig87N14Fi3/Enp3cLgDgooMJVfccAG3WitN0S4A0pUKdLoX1X3hufXu4yGhlw0FM7elkMAZ/no7PKD9s4ZSgCdhy+LAc8f4kzD/K92BKIMdv+42CfpepCYVueG3QfxVAAuA8s+rHEs8wQU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 168008711117814.725141373350311; Wed, 29 Mar 2023 03:51:51 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.516188.799939 (Exim 4.92) (envelope-from ) id 1phTOa-0000FH-Kk; Wed, 29 Mar 2023 10:51:12 +0000 Received: by outflank-mailman (output) from mailman id 516188.799939; Wed, 29 Mar 2023 10:51:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1phTOa-0000Bu-B6; Wed, 29 Mar 2023 10:51:12 +0000 Received: by outflank-mailman (input) for mailman id 516188; Wed, 29 Mar 2023 10:51:11 +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 1phTOZ-0007lb-4v for xen-devel@lists.xenproject.org; Wed, 29 Mar 2023 10:51:11 +0000 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [2a00:1450:4864:20::12d]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 9d5fdfb1-ce1f-11ed-85db-49a42c6b2330; Wed, 29 Mar 2023 12:51:09 +0200 (CEST) Received: by mail-lf1-x12d.google.com with SMTP id y20so19584158lfj.2 for ; Wed, 29 Mar 2023 03:51:09 -0700 (PDT) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id j17-20020ac253b1000000b004eb0f6b7ccfsm1173572lfh.134.2023.03.29.03.51.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Mar 2023 03:51:09 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 9d5fdfb1-ce1f-11ed-85db-49a42c6b2330 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680087069; 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=OIBTQ+/gJzftoYOKQxHsDF5nCeh3hAxpIqkYkUYYTMY=; b=pKJwHoFeJf4Co42bNQ5W2ghNeKhv63JzLkAc+zxHSA7GSrDe8ZHt7xNxn3m6zGAwzp SClf5sDPvpSTTDvcSqZxa3HMgw8h2KexmVkDPnOONrAIOBkVBNOF2mdQx4WIYvsRGMuS NnPoWS4hk40zgII3NeWl6vLJCzHR8lCgoENncATiJxNV2SVibPopB0V6HdFFmM194XBk gzkTbwP6Z8MMo+tCl+rqnZCHQKhnz7NAr5X63U47aBAyzI9BDHmGC80YteFm5aOnQpYb l5N9FvNtiCIJoOfqTamImdt0KBhFb9zGRGEjZ4CUBf9UKO3XdCpvLmRqWmM2Hip6jHmH aYLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680087069; 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=OIBTQ+/gJzftoYOKQxHsDF5nCeh3hAxpIqkYkUYYTMY=; b=fnXQ6EC2t0VkfuhkqBHnQ2oNfuYindWevkUV1ab0hTFLXRinN6r+bhXSp7vWJ6M2l0 j2RVAfjU37RjMIH00/myKWzRqWg5DuVPJceOdE225GdkNqtidVlZinq1uBvz0Km5teWI 1SS2Z4ZvBuIb9VJhPvsflFmiV+jWopAvlhwxZPLX7nGHYMmGih0lOfj49bdc+Gt6MUgK h44ZXppl0AoU484rxXYxduT1MXLEPMT6OLwAGqYMd24FKDZsvDUMn7/WTKUcQ2F+vEWv PBRkgUFg17XYdGeTOgjr22gaaFs+tTYgBa4PTivFouqeRlc+LRBMSgz3foBg2NpSPlf4 hAgQ== X-Gm-Message-State: AAQBX9f/CtSaflBZ0ko33QenrokiWw1v9I0zFQnbVFnagg234M5jf25s yKhIB9bFHogHn1B3vIEvt5ceV6sgSyk= X-Google-Smtp-Source: AKy350ZNeIHeMYGuilMAahLbuTiRVF+c5zy4VfaaE4cnemjYkZDyiwrRWCC3HmTVTQBmo53NkUYngA== X-Received: by 2002:ac2:5df2:0:b0:4a4:68b7:d64b with SMTP id z18-20020ac25df2000000b004a468b7d64bmr4782586lfq.50.1680087069326; Wed, 29 Mar 2023 03:51:09 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Julien Grall , Jan Beulich , Andrew Cooper , Stefano Stabellini , Gianluca Guida , Oleksii Kurochko , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH v9 5/5] xen/x86: switch x86 to use generic implemetation of bug.h Date: Wed, 29 Mar 2023 13:50:32 +0300 Message-Id: X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1680087113323100009 Content-Type: text/plain; charset="utf-8" The following changes were made: * Make GENERIC_BUG_FRAME mandatory for X86 * Update asm/bug.h using generic implementation in * Update do_invalid_op using generic do_bug_frame() * Define BUG_DEBUGGER_TRAP_FATAL to debugger_trap_fatal(X86_EXC_GP,regs) * type of eip variable was changed to 'const void *' Signed-off-by: Oleksii Kurochko Reviewed-by: Jan Beulich --- Changes in V9: * update the commit message * add additional explanation to header --- Changes in V8: * move from to to fix compilati= on issue. The following compilation issue occurs: In file included from ./arch/x86/include/asm/smp.h:10, from ./include/xen/smp.h:4, from ./arch/x86/include/asm/processor.h:10, from ./arch/x86/include/asm/system.h:6, from ./arch/x86/include/asm/atomic.h:5, from ./include/xen/gdbstub.h:24, from ./arch/x86/include/asm/debugger.h:10, from ./include/xen/debugger.h:24, from ./arch/x86/include/asm/bug.h:7, from ./include/xen/bug.h:15, from ./include/xen/lib.h:27, from ./include/xen/perfc.h:6, from arch/x86/x86_64/asm-offsets.c:9: ./include/xen/cpumask.h: In function 'cpumask_check': ./include/xen/cpumask.h:84:9: error: implicit declaration of function = 'ASSERT' [-Werror=3Dimplicit-function-declaration] 84 | ASSERT(cpu < nr_cpu_ids); It happens in case when CONFIG_CRASH_DEBUG is enabled and the reason for= that is when is included in :9 the "layout" of would be the following: #include : #include : #include : .... cpumask.h: .... ASSERT(cpu < nr_cpu_ids); return cpu; ....=20 .... #define ASSERT ... .... Thereby ASSERT is defined after it was used in . * Rebase the patch series on the top of the latest staging: it was a merge= conflict inisde x86/Kconfig. --- Changes in V7: * update the commit message * make eip 'const void *' * change [eip =3D (unsigned char *)eip + sizeof(bug_insn);] to [eip +=3D s= izeof(bug_insn);] * add '#include ' to * add Reviewed-by: Jan Beulich --- Changes in V6: * update the commit message * update the type of eip to 'void *' in do_invalid_op() * fix the logic of do_invalid_op() * move macros BUG_DEBUGGER_TRAP_FATAL under #ifndef __ASSEMBLY__ as it is not necessary to be in assembly code. --- Changes in V5: * Nothing changed --- Changes in V4: * Back comment /* !__ASSEMBLY__ */ for #else case in * Remove changes related to x86/.../asm/debuger.h as do_bug_frame() protot= ype was updated and cpu_user_regs isn't const any more. --- Changes in V3: * As prototype and what do_bug_frame() returns was changed so patch 3 and 4 was updated to use a new version of do_bug_frame * MODIFIER was change to BUG_ASM_CONST to align with generic implementation --- Changes in V2: * Remove all unnecessary things from as they were introduced = in . * Define BUG_INSTR =3D 'ud2' and MODIFIER =3D 'c' ( it is needed to skip = '$' when use an imidiate in x86 assembly ) * Update do_invalid_op() to re-use handle_bug_frame() and find_bug_frame() from generic implemetation of CONFIG_GENERIC_BUG_FRAME * Code style fixes. --- xen/arch/x86/Kconfig | 1 + xen/arch/x86/include/asm/bug.h | 87 ++++++++-------------------------- xen/arch/x86/traps.c | 81 ++++--------------------------- 3 files changed, 30 insertions(+), 139 deletions(-) diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig index 2a5c3304e2..406445a358 100644 --- a/xen/arch/x86/Kconfig +++ b/xen/arch/x86/Kconfig @@ -11,6 +11,7 @@ config X86 select ARCH_MAP_DOMAIN_PAGE select ARCH_SUPPORTS_INT128 imply CORE_PARKING + select GENERIC_BUG_FRAME select HAS_ALTERNATIVE select HAS_COMPAT select HAS_CPUFREQ diff --git a/xen/arch/x86/include/asm/bug.h b/xen/arch/x86/include/asm/bug.h index 4b3e7b019d..7fe879a8cc 100644 --- a/xen/arch/x86/include/asm/bug.h +++ b/xen/arch/x86/include/asm/bug.h @@ -1,75 +1,30 @@ #ifndef __X86_BUG_H__ #define __X86_BUG_H__ =20 -#ifndef __ASSEMBLY__ - -#define BUG_FRAME_STRUCT - -struct bug_frame { - signed int loc_disp:BUG_DISP_WIDTH; - unsigned int line_hi:BUG_LINE_HI_WIDTH; - signed int ptr_disp:BUG_DISP_WIDTH; - unsigned int line_lo:BUG_LINE_LO_WIDTH; - signed int msg_disp[]; -}; - -#define bug_loc(b) ((const void *)(b) + (b)->loc_disp) -#define bug_ptr(b) ((const void *)(b) + (b)->ptr_disp) -#define bug_line(b) (((((b)->line_hi + ((b)->loc_disp < 0)) & = \ - ((1 << BUG_LINE_HI_WIDTH) - 1)) << = \ - BUG_LINE_LO_WIDTH) + = \ - (((b)->line_lo + ((b)->ptr_disp < 0)) & = \ - ((1 << BUG_LINE_LO_WIDTH) - 1))) -#define bug_msg(b) ((const char *)(b) + (b)->msg_disp[1]) - -#define _ASM_BUGFRAME_TEXT(second_frame) = \ - ".Lbug%=3D: ud2\n" = \ - ".pushsection .bug_frames.%c[bf_type], \"a\", @progbits\n" = \ - ".p2align 2\n" = \ - ".Lfrm%=3D:\n" = \ - ".long (.Lbug%=3D - .Lfrm%=3D) + %c[bf_line_hi]\n" = \ - ".long (%c[bf_ptr] - .Lfrm%=3D) + %c[bf_line_lo]\n" = \ - ".if " #second_frame "\n" = \ - ".long 0, %c[bf_msg] - .Lfrm%=3D\n" = \ - ".endif\n" = \ - ".popsection\n" = \ - -#define _ASM_BUGFRAME_INFO(type, line, ptr, msg) = \ - [bf_type] "i" (type), = \ - [bf_ptr] "i" (ptr), = \ - [bf_msg] "i" (msg), = \ - [bf_line_lo] "i" ((line & ((1 << BUG_LINE_LO_WIDTH) - 1)) = \ - << BUG_DISP_WIDTH), = \ - [bf_line_hi] "i" (((line) >> BUG_LINE_LO_WIDTH) << BUG_DISP_WIDTH) - -#define BUG_FRAME(type, line, ptr, second_frame, msg) do { = \ - BUILD_BUG_ON((line) >> (BUG_LINE_LO_WIDTH + BUG_LINE_HI_WIDTH)); = \ - BUILD_BUG_ON((type) >=3D BUGFRAME_NR); = \ - asm volatile ( _ASM_BUGFRAME_TEXT(second_frame) = \ - :: _ASM_BUGFRAME_INFO(type, line, ptr, msg) ); = \ -} while (0) - - -#define WARN() BUG_FRAME(BUGFRAME_warn, __LINE__, __FILE__, 0, NULL) -#define BUG() do { \ - BUG_FRAME(BUGFRAME_bug, __LINE__, __FILE__, 0, NULL); \ - unreachable(); \ -} while (0) - /* - * TODO: untangle header dependences, break BUILD_BUG_ON() out of xen/lib.= h, - * and use a real static inline here to get proper type checking of fn(). + * Please do not include in the header any header that might + * use BUG/ASSERT/etc maros asthey will be defined later after + * the return to from the current header: + *=20 + * : + * ... + * : + * ... + * + * ... + * ... + * #define BUG() ... + * ... + * #define ASSERT() ... + * ... */ -#define run_in_exception_handler(fn) \ - do { \ - (void)((fn) =3D=3D (void (*)(struct cpu_user_regs *))NULL); \ - BUG_FRAME(BUGFRAME_run_fn, 0, fn, 0, NULL); \ - } while ( 0 ) =20 -#define assert_failed(msg) do { \ - BUG_FRAME(BUGFRAME_assert, __LINE__, __FILE__, 1, msg); \ - unreachable(); \ -} while (0) +#ifndef __ASSEMBLY__ + +#define BUG_DEBUGGER_TRAP_FATAL(regs) debugger_trap_fatal(X86_EXC_GP,regs) + +#define BUG_INSTR "ud2" +#define BUG_ASM_CONST "c" =20 #else /* !__ASSEMBLY__ */ =20 diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index cade9e12f8..c36e3f855b 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -24,6 +24,7 @@ * Gareth Hughes , May 2000 */ =20 +#include #include #include #include @@ -1166,12 +1167,9 @@ void cpuid_hypervisor_leaves(const struct vcpu *v, u= int32_t leaf, =20 void do_invalid_op(struct cpu_user_regs *regs) { - const struct bug_frame *bug =3D NULL; u8 bug_insn[2]; - const char *prefix =3D "", *filename, *predicate, *eip =3D (char *)reg= s->rip; - unsigned long fixup; - int id =3D -1, lineno; - const struct virtual_region *region; + const void *eip =3D (const void *)regs->rip; + int id; =20 if ( likely(guest_mode(regs)) ) { @@ -1185,83 +1183,20 @@ void do_invalid_op(struct cpu_user_regs *regs) memcmp(bug_insn, "\xf\xb", sizeof(bug_insn)) ) goto die; =20 - region =3D find_text_region(regs->rip); - if ( region ) - { - for ( id =3D 0; id < BUGFRAME_NR; id++ ) - { - const struct bug_frame *b; - unsigned int i; - - for ( i =3D 0, b =3D region->frame[id].bugs; - i < region->frame[id].n_bugs; b++, i++ ) - { - if ( bug_loc(b) =3D=3D eip ) - { - bug =3D b; - goto found; - } - } - } - } - - found: - if ( !bug ) + id =3D do_bug_frame(regs, regs->rip); + if ( id < 0 ) goto die; - eip +=3D sizeof(bug_insn); - if ( id =3D=3D BUGFRAME_run_fn ) - { - void (*fn)(struct cpu_user_regs *) =3D bug_ptr(bug); - - fn(regs); - fixup_exception_return(regs, (unsigned long)eip); - return; - } =20 - /* WARN, BUG or ASSERT: decode the filename pointer and line number. */ - filename =3D bug_ptr(bug); - if ( !is_kernel(filename) && !is_patch(filename) ) - goto die; - fixup =3D strlen(filename); - if ( fixup > 50 ) - { - filename +=3D fixup - 47; - prefix =3D "..."; - } - lineno =3D bug_line(bug); + eip +=3D sizeof(bug_insn); =20 switch ( id ) { + case BUGFRAME_run_fn: case BUGFRAME_warn: - printk("Xen WARN at %s%s:%d\n", prefix, filename, lineno); - show_execution_state(regs); fixup_exception_return(regs, (unsigned long)eip); - return; - case BUGFRAME_bug: - printk("Xen BUG at %s%s:%d\n", prefix, filename, lineno); - - if ( debugger_trap_fatal(TRAP_invalid_op, regs) ) - return; - - show_execution_state(regs); - panic("Xen BUG at %s%s:%d\n", prefix, filename, lineno); - case BUGFRAME_assert: - /* ASSERT: decode the predicate string pointer. */ - predicate =3D bug_msg(bug); - if ( !is_kernel(predicate) && !is_patch(predicate) ) - predicate =3D ""; - - printk("Assertion '%s' failed at %s%s:%d\n", - predicate, prefix, filename, lineno); - - if ( debugger_trap_fatal(TRAP_invalid_op, regs) ) - return; - - show_execution_state(regs); - panic("Assertion '%s' failed at %s%s:%d\n", - predicate, prefix, filename, lineno); + return; } =20 die: --=20 2.39.2