From nobody Fri Nov 29 23:37:22 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=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1621438806; cv=none; d=zohomail.com; s=zohoarc; b=CRnElrzfZEpgkkPClaMKdptZFgKieCzgQKqFnLkqGSimcMcICBSvX7TgJ3odsbanPi7AQNYLAu0C7x+wlRhoqAsP/1sWHgGz+vVY2bmi8ScV/RiVGDx0/DtgKzF0wnVTUadZ+XlRfjgm+oJMsuuuGytd76P2cikzGW2wBSZcd6I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621438806; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=wevaPow5YfXo4W6yF0r59ykU5BpQ+t1e1n7P7fEPngQ=; b=Zzg6Mw25ByyB6iLpLV9JKJd7ZiIRw2eEiGddcPVtO2I+AJZfwgjnduW85YpkOCxr/Y0MQKPCCzIfqzPME4+Qhf7TQ8Ki3D1UeMLyPGU9i1ak5UdwFYmuxhh65dsDgOkfMWDurLaQuIW76uY1pJiBbLJnUgGV2/9g8FZN7pRlN6U= 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=quarantine dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1621438805974373.3998879857945; Wed, 19 May 2021 08:40:05 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.130203.244032 (Exim 4.92) (envelope-from ) id 1ljOIb-0008Bt-0D; Wed, 19 May 2021 15:39:53 +0000 Received: by outflank-mailman (output) from mailman id 130203.244032; Wed, 19 May 2021 15:39:52 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ljOIa-0008Bm-TY; Wed, 19 May 2021 15:39:52 +0000 Received: by outflank-mailman (input) for mailman id 130203; Wed, 19 May 2021 15:39:51 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ljOIZ-0008Be-Hn for xen-devel@lists.xenproject.org; Wed, 19 May 2021 15:39:51 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 73546a6d-b89d-4d01-b144-87c20a559093; Wed, 19 May 2021 15:39:50 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id AB86BB01E; Wed, 19 May 2021 15:39:49 +0000 (UTC) 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: 73546a6d-b89d-4d01-b144-87c20a559093 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1621438789; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=wevaPow5YfXo4W6yF0r59ykU5BpQ+t1e1n7P7fEPngQ=; b=bazLB7xUhaavFfNGGvg1xlZkzkUVQ9wOE5MQAofz7SJML6Bwn1Lyb9LtsPiy3Wj7evK3jp Xr/cUUgF9+jLPJn+QddUYmDX03Tj0b/uV7WiJ1aKeFg19WjET5TtELVCECwnsEzHa7ixrI y9U65/Qtph7F17R4KMO/S0KaMNYXl20= To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , George Dunlap , Ian Jackson , Julien Grall , Stefano Stabellini , Wei Liu , =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= From: Jan Beulich Subject: [PATCH] x86: make hypervisor build with gcc11 Message-ID: Date: Wed, 19 May 2021 17:39:50 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) 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=3D100680. 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=E2=81=B6=C2=B3-1]. Signed-off-by: Jan Beulich Acked-by: Roger Pau Monn=C3=A9 Tested-by: Jason Andryuk --- a/tools/tests/x86_emulator/x86-emulate.c +++ b/tools/tests/x86_emulator/x86-emulate.c @@ -8,6 +8,13 @@ =20 #define ERR_PTR(val) NULL =20 +/* See gcc bug 100680, but here don't bother making this version dependent= . */ +#define gcc11_wrap(x) ({ \ + unsigned long x_; \ + __asm__ ( "" : "=3Dg" (x_) : "0" (x) ); \ + (typeof(x))x_; \ +}) + #define cpu_has_amd_erratum(nr) 0 #define cpu_has_mpx false #define read_bndcfgu() 0 --- a/xen/arch/x86/x86_emulate/x86_emulate.c +++ b/xen/arch/x86/x86_emulate/x86_emulate.c @@ -726,7 +726,7 @@ union vex { #define copy_VEX(ptr, vex) ({ \ if ( !mode_64bit() ) \ (vex).reg |=3D 8; \ - (ptr)[0 - PFX_BYTES] =3D ext < ext_8f08 ? 0xc4 : 0x8f; \ + gcc11_wrap(ptr)[0 - PFX_BYTES] =3D ext < ext_8f08 ? 0xc4 : 0x8f; \ (ptr)[1 - PFX_BYTES] =3D (vex).raw[0]; \ (ptr)[2 - PFX_BYTES] =3D (vex).raw[1]; \ container_of((ptr) + 1 - PFX_BYTES, typeof(vex), raw[0]); \ --- a/xen/include/asm-x86/fixmap.h +++ b/xen/include/asm-x86/fixmap.h @@ -78,7 +78,7 @@ extern void __set_fixmap( =20 #define clear_fixmap(idx) __set_fixmap(idx, 0, 0) =20 -#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) =20 #define fix_to_virt(x) ((void *)__fix_to_virt(x)) --- a/xen/include/xen/compiler.h +++ b/xen/include/xen/compiler.h @@ -140,6 +140,12 @@ __asm__ ("" : "=3Dr"(__ptr) : "0"(ptr)); \ (typeof(ptr)) (__ptr + (off)); }) =20 +#if CONFIG_GCC_VERSION >=3D 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 --- a/xen/include/xen/pdx.h +++ b/xen/include/xen/pdx.h @@ -19,7 +19,7 @@ extern u64 pdx_region_mask(u64 base, u64 extern void set_pdx_range(unsigned long smfn, unsigned long emfn); =20 #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)) =20 bool __mfn_valid(unsigned long mfn); =20