From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.3 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9A2FC83000 for ; Tue, 28 Apr 2020 11:45:26 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 97AE2206D7 for ; Tue, 28 Apr 2020 11:45:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JYPyhmIY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 97AE2206D7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jTOfg-0006pL-4A; Tue, 28 Apr 2020 11:45:04 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jTOff-0006pG-P1 for xen-devel@lists.xenproject.org; Tue, 28 Apr 2020 11:45:03 +0000 X-Inumbo-ID: b2630ade-8945-11ea-ae69-bc764e2007e4 Received: from mail-qv1-xf42.google.com (unknown [2607:f8b0:4864:20::f42]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id b2630ade-8945-11ea-ae69-bc764e2007e4; Tue, 28 Apr 2020 11:45:02 +0000 (UTC) Received: by mail-qv1-xf42.google.com with SMTP id 59so8068808qva.13; Tue, 28 Apr 2020 04:45:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:from:to:cc:subject:date:in-reply-to:references :mime-version:content-transfer-encoding; bh=fd/M3Ffs7OwceegYsMYGTqbAvT1dTQERp72SccZnPBY=; b=JYPyhmIYgn8bTgIM0SaWBtvgEIJKI+Bpac4lm1AzE4bMxnjcc8+SGaOTlLbhU/Chkq hBUq326SK/Su6heJlXHBdUJp4ddB0PBZnbSNlUcyIw39KOvLayr1nmfRr7I/q50vtZdS cBdLP+icy9Z5ALxHub/yq9S6AbIqt3ffUk93G5RxvqlH41UtvIi1CcpIioel5VeQ31FO +MWm7mOoLG9jzOEXodi7+0cynz4b5Y10o8u4r11kpL5K6O3lMSvPVbvNnfs+pePUoJ0J je5trHddards1xLVs2+vlZhduttcoWuKFeB/5uJ+1AekQe+WRkX2sb52pTNwUUzIQdW3 Xanw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:from:to:cc:subject:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=fd/M3Ffs7OwceegYsMYGTqbAvT1dTQERp72SccZnPBY=; b=aRHERUPBBlkcjGAsuTQ1TVm4lgAmySWUFawlwSM/cdSB/r7mjtLbBAIggwvNDZlGyu pO1Bt9W47QvNt0DSLfzSqG7VMvNDUxoISRyD6vmvJGBBqgmUtm3C5jQfrJUdVgwhuMhr MQvmt2PGVrYi2LVnHNIjISJdZ+xYThXRhXcRdS6VnfdN26+bL2maG/krm7y/24gnqhKS Y1tebl/F7si8kek8aKJrx2fXLtnVbfGCAkeGdFlV7xKLajocQoGAs5s3j5uTKO+RmjTN lqyQxg0Ob5Md7XgNWJ2YcWbleUUsa1j0SZ2XXBcYr296v+tYFJLzEeG1jzKlWKGODx97 bOLQ== X-Gm-Message-State: AGi0PuaHVY+LeLAk1TNa72KXQnZ4AuOTWqOlzGTTc/A5pWNcAmqxg4j5 fxJx3cCCJXHfvfXdz2Lfz2w= X-Google-Smtp-Source: APiQypJ7BqPEg+ekb3cUEqbx6s21kP9AG6R4IzIL1zPHxr4AcZKRRps4r/ApG4naung0Pjzx+NKdkA== X-Received: by 2002:a0c:f1d0:: with SMTP id u16mr27874790qvl.160.1588074302277; Tue, 28 Apr 2020 04:45:02 -0700 (PDT) Received: from shine.lan ([2001:470:8:67e:15d1:d31e:91aa:b702]) by smtp.gmail.com with ESMTPSA id 205sm13055464qkj.1.2020.04.28.04.45.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2020 04:45:01 -0700 (PDT) Message-ID: <5ea8173d.1c69fb81.915ba.8400@mx.google.com> X-Google-Original-Message-ID: <3ed7eb87-070c-28ea-4f8a-aa4421cea93a@citrix.com> (raw) From: Jason Andryuk To: andrew.cooper3@citrix.com, Wei Liu , Jason Andryuk Subject: Re: [PATCH] mini-os: Avoid segfaults in tc{g,s}etattr Date: Tue, 28 Apr 2020 07:44:07 -0400 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200428111645.pa6xfs6t6rifu6fu@liuwe-devbox-debian-v2.j3c5onc20sse1dnehy4noqpfcg.zx.internal.cloudapp.net> References: <3ed7eb87-070c-28ea-4f8a-aa4421cea93a@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: minios-devel@lists.xenproject.org, samuel.thibault@ens-lyon.org, Stefan Bader , JBeulich@suse.com, xen-devel@lists.xenproject.org Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Andrew Cooper Andrew Cooper wrote: >On 28/04/2020 12:16, Wei Liu wrote: >>>>> --- >>>>> I can't get ioemu-stubdom to start without this. With this, the guest >>>>> just reboots immediately, but it does that with a non-stubdom >>>>> device_model_version="qemu-xen-traditional" . The same guest disk image >>>>> (cirros 0.5.1) boots with a linux stubdom or non-stubdom Ubuntu >>>>> qemu-system-x86_64. >>> Ubuntu gcc-9 adds -fcf-protection by default. Somehow that flag >>> caused rombios (I think) to restart. Setting -fcf-protection=none >>> like below (probably just the EMBEDDED_EXTRA_CFLAGS part) lets rombios >>> start properly. > >All it does is insert ENDBR{32,64} instructions, which are nops on older >processors. > >I suspect that it is not the -fcf-protection= directly, but some change >in alignment of a critical function. > >>> The hypervisor needs it as well via >>> EXTRA_CFLAGS_XEN_CORE=-fcf-protection=none and maybe also added to >>> xen/arch/x86/boot/build32.mk . >> Are you able to turn this into a proper patch? I suspect you will need >> to test the availability of this new (?) flag. >> >> Also Cc Jan and Andrew because it affects hypervisor build too. > >I need to chase this up. It is a GCC bug breaking the hypervisor build, >and I'm moderately disinclined to hack around it, seeing as >-fcf-protection is something we want in due course. > >The bug is that GCC falsely declares that -fcf-protection is >incompatible with -mindirect-thunk=extern, despite me spending a week >during the Spectre embargo period specifically arranging for the two to >be compatible, because we knew we'd want to build retpoline-safe >binaries which could also use CET on newer hardware. The gcc manual states: "Note that -mindirect-branch=thunk-extern is incompatible with -fcf-protection=branch since the external thunk cannot be modified to disable control-flow check." https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html Below is what I was preparing to submit as a patch. So, yes it hacks around it, but it isn't messy. --- Disable fcf-protection to build working binaries Ubuntu gcc-9 enables -fcf-protection by default, which conflicts with -mindirect-branch=extern and prevents building the hypervisor with CONFIG_INDIRECT_THUNK: xmalloc.h:81:1: error: ‘-mindirect-branch’ and ‘-fcf-protection’ are not compatible Stefan Bader also noticed that build32.mk requires -fcf-protection=none or else the hypervisor will not boot. https://bugs.launchpad.net/ubuntu/+source/gcc-9/+bug/1863260 Similarly, rombios reboots almost immediately without -fcf-protection=none. Both of those can be handled by setting it in EMBEDDED_EXTRA_CFLAGS. CC: Stefan Bader Signed-off-by: Jason Andryuk --- Config.mk | 1 + xen/arch/x86/Rules.mk | 1 + 2 files changed, 2 insertions(+) diff --git a/Config.mk b/Config.mk index 0f303c79b2..efb3d42bc4 100644 --- a/Config.mk +++ b/Config.mk @@ -205,6 +205,7 @@ APPEND_CFLAGS += $(foreach i, $(APPEND_INCLUDES), -I$(i)) EMBEDDED_EXTRA_CFLAGS := -nopie -fno-stack-protector -fno-stack-protector-all EMBEDDED_EXTRA_CFLAGS += -fno-exceptions +EMBEDDED_EXTRA_CFLAGS += -fcf-protection=none XEN_EXTFILES_URL ?= http://xenbits.xen.org/xen-extfiles # All the files at that location were downloaded from elsewhere on diff --git a/xen/arch/x86/Rules.mk b/xen/arch/x86/Rules.mk index 4b7ab78467..c3cbae69d2 100644 --- a/xen/arch/x86/Rules.mk +++ b/xen/arch/x86/Rules.mk @@ -69,6 +69,7 @@ CFLAGS += -mno-sse $(call cc-option,$(CC),-mskip-rax-setup) ifeq ($(CONFIG_INDIRECT_THUNK),y) CFLAGS += -mindirect-branch=thunk-extern -mindirect-branch-register CFLAGS += -fno-jump-tables +$(call cc-option-add,CFLAGS,CC,-fcf-protection=none) endif # If supported by the compiler, reduce stack alignment to 8 bytes. But allow -- 2.20.1