Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:olh:xen-4.9
xen
xen.722f59d38c710a940ab05e542a83020eb5546dea.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File xen.722f59d38c710a940ab05e542a83020eb5546dea.patch of Package xen
From: Jan Beulich <jbeulich@suse.com> Date: Thu, 27 May 2021 14:40:29 +0200 Subject: 722f59d38c710a940ab05e542a83020eb5546dea MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit x86: make hypervisor build with gcc11 Gcc 11 looks to make incorrect assumptions about valid ranges that pointers may be used for addressing when they are derived from e.g. a plain constant. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100680. Utilize RELOC_HIDE() to work around the issue, which for x86 manifests in at least - mpparse.c:efi_check_config(), - tboot.c:tboot_probe(), - tboot.c:tboot_gen_frametable_integrity(), - x86_emulate.c:x86_emulate() (at -O2 only). The last case is particularly odd not just because it only triggers at higher optimization levels, but also because it only affects one of at least three similar constructs. Various "note" diagnostics claim the valid index range to be [0, 2⁶³-1]. Signed-off-by: Jan Beulich <jbeulich@suse.com> Tested-by: Jason Andryuk <jandryuk@gmail.com> Acked-by: Roger Pau Monné <roger.pau@citrix.com> --- tools/tests/x86_emulator/x86_emulate.c | 7 +++++++ xen/include/asm-x86/fixmap.h | 2 +- xen/include/xen/compiler.h | 6 ++++++ xen/include/xen/pdx.h | 2 +- 4 files changed, 15 insertions(+), 2 deletions(-) --- a/tools/tests/x86_emulator/x86_emulate.c +++ b/tools/tests/x86_emulator/x86_emulate.c @@ -1,16 +1,23 @@ #include "x86_emulate.h" #include <sys/mman.h> +/* See gcc bug 100680, but here don't bother making this version dependent. */ +#define gcc11_wrap(x) ({ \ + unsigned long x_; \ + __asm__ ( "" : "=g" (x_) : "0" (x) ); \ + (typeof(x))x_; \ +}) + #define cpu_has_amd_erratum(nr) 0 #define cpu_has_mpx false #define read_bndcfgu() 0 #define xstate_set_init(what) /* For generic assembly code: use macros to define operation/operand sizes. */ #ifdef __i386__ # define r(name) e ## name # define __OS "l" /* Operation Suffix */ # define __OP "e" /* Operand Prefix */ #else # define r(name) r ## name --- a/xen/include/asm-x86/fixmap.h +++ b/xen/include/asm-x86/fixmap.h @@ -67,25 +67,25 @@ enum fixed_addresses { extern void __set_fixmap( enum fixed_addresses idx, unsigned long mfn, unsigned long flags); #define set_fixmap(idx, phys) \ __set_fixmap(idx, (phys)>>PAGE_SHIFT, PAGE_HYPERVISOR) #define set_fixmap_nocache(idx, phys) \ __set_fixmap(idx, (phys)>>PAGE_SHIFT, PAGE_HYPERVISOR_NOCACHE) #define clear_fixmap(idx) __set_fixmap(idx, 0, 0) -#define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT)) +#define __fix_to_virt(x) gcc11_wrap(FIXADDR_TOP - ((x) << PAGE_SHIFT)) #define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT) #define fix_to_virt(x) (__fix_to_virt(x)) static inline unsigned long virt_to_fix(const unsigned long vaddr) { BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START); return __virt_to_fix(vaddr); } #endif /* __ASSEMBLY__ */ --- a/xen/include/xen/compiler.h +++ b/xen/include/xen/compiler.h @@ -88,24 +88,30 @@ shouldn't recognize the original var, and make assumptions about it */ /* * Versions of the ppc64 compiler before 4.1 had a bug where use of * RELOC_HIDE could trash r30. The bug can be worked around by changing * the inline assembly constraint from =g to =r, in this particular * case either is valid. */ #define RELOC_HIDE(ptr, off) \ ({ unsigned long __ptr; \ __asm__ ("" : "=r"(__ptr) : "0"(ptr)); \ (typeof(ptr)) (__ptr + (off)); }) +#if CONFIG_GCC_VERSION >= 110000 /* See gcc bug 100680. */ +# define gcc11_wrap(x) RELOC_HIDE(x, 0) +#else +# define gcc11_wrap(x) (x) +#endif + #ifdef __GCC_ASM_FLAG_OUTPUTS__ # define ASM_FLAG_OUT(yes, no) yes #else # define ASM_FLAG_OUT(yes, no) no #endif /* * NB: we need to disable the gcc-compat warnings for clang in some places or * else it will complain with: "'break' is bound to loop, GCC binds it to * switch" when a switch is used inside of a while expression inside of a * switch statement, ie: * --- a/xen/include/xen/pdx.h +++ b/xen/include/xen/pdx.h @@ -10,25 +10,25 @@ extern unsigned long pfn_hole_mask; extern unsigned long pfn_top_mask, ma_top_mask; #define PDX_GROUP_COUNT ((1 << PDX_GROUP_SHIFT) / \ (sizeof(*frame_table) & -sizeof(*frame_table))) extern unsigned long pdx_group_valid[]; extern u64 pdx_init_mask(u64 base_addr); extern u64 pdx_region_mask(u64 base, u64 len); extern void set_pdx_range(unsigned long smfn, unsigned long emfn); #define page_to_pdx(pg) ((pg) - frame_table) -#define pdx_to_page(pdx) (frame_table + (pdx)) +#define pdx_to_page(pdx) gcc11_wrap(frame_table + (pdx)) bool __mfn_valid(unsigned long mfn); static inline unsigned long pfn_to_pdx(unsigned long pfn) { return (pfn & pfn_pdx_bottom_mask) | ((pfn & pfn_top_mask) >> pfn_pdx_hole_shift); } static inline unsigned long pdx_to_pfn(unsigned long pdx) { return (pdx & pfn_pdx_bottom_mask) |
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor