Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4270609ybz; Tue, 28 Apr 2020 08:30:25 -0700 (PDT) X-Google-Smtp-Source: APiQypImqn43SYEvCSO2U4VZCbak8uV62TqucspG4XZzKumI3zzsaE9nI1BB8CePmWhamquIFsHz X-Received: by 2002:aa7:d6c7:: with SMTP id x7mr10412029edr.313.1588087825376; Tue, 28 Apr 2020 08:30:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588087825; cv=none; d=google.com; s=arc-20160816; b=wui/+j4kRBmWymrE3lTNU4DN1lf2zPEAlOiHG8FGQ3qxCDBZJZ0xEF2flJ+F8+Oiec s5bqUrr+OwEzzFporeegv6JqF9JOfyRh+eBwTx0stuuRcNk/G3nYUg6QZ9q6zRvsITb2 P6ulweXWrCDDPnTMrDjM2L5OZ1ycZJL6C9KaagUtOoT33p3lwIeMWSDM+qJNH937vwNL dMQZrOW5ZuoQXre750GSzZOEn+ZMv8bYUUy85dbSpIDS9Vvk5LL//qwj6FKySbtTPgMm fkaE74VqCHCM2IyhtbTUWaIQGF4pgcUB3RrjYRw280lL8mYoVKriTFi1AdWDTzuC3u8X zzcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=Vhg7dlVXExBmk1hZuIyc9AFd0EK+oz2cB09QUvDhhoA=; b=IuPbclJZtcl+O7rWLpDv+XcvqYFcXMFbLHPclnB7UUbVTZ0H+a7UxPrc+Suq0oqW88 8fYcwYn78H27XQDrdPtA1dg9RDaXHwkqxEmEdWmY7QU9neQzQ/JRBc1L/9LPVqnCLq50 t/XF4utOVpRYQDlNPAsAY5mvwVokU6ApiF4w1rraa5vzQDfkmORWXdVttIHeKV4zk95H CSSHG6c84lQW1BrovX91LL1QM90SSHUyxc3LEXYXC9csufF11fjBrRfljdTutLQDMA8+ YGrWjl7okSMO+Mt1Ew/jczU5jxVvafnuXqcp690sjzuK2fuLyk7f2ah+hLHYHHEnGQLu idYw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c4si2141786ejb.189.2020.04.28.08.30.00; Tue, 28 Apr 2020 08:30:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728891AbgD1PYN (ORCPT + 99 others); Tue, 28 Apr 2020 11:24:13 -0400 Received: from 8bytes.org ([81.169.241.247]:37428 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728173AbgD1PRy (ORCPT ); Tue, 28 Apr 2020 11:17:54 -0400 Received: by theia.8bytes.org (Postfix, from userid 1000) id 1B48DCC0; Tue, 28 Apr 2020 17:17:44 +0200 (CEST) From: Joerg Roedel To: x86@kernel.org Cc: hpa@zytor.com, Andy Lutomirski , Dave Hansen , Peter Zijlstra , Thomas Hellstrom , Jiri Slaby , Dan Williams , Tom Lendacky , Juergen Gross , Kees Cook , David Rientjes , Cfir Cohen , Erdem Aktas , Masami Hiramatsu , Mike Stunes , Joerg Roedel , Joerg Roedel , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: [PATCH v3 11/75] x86/boot/compressed/64: Disable red-zone usage Date: Tue, 28 Apr 2020 17:16:21 +0200 Message-Id: <20200428151725.31091-12-joro@8bytes.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200428151725.31091-1-joro@8bytes.org> References: <20200428151725.31091-1-joro@8bytes.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joerg Roedel The x86-64 ABI defines a red-zone on the stack: The 128-byte area beyond the location pointed to by %rsp is considered to be reserved and shall not be modified by signal or interrupt handlers. Therefore, functions may use this area for temporary data that is not needed across function calls. In particular, leaf functions may use this area for their entire stack frame, rather than adjusting the stack pointer in the prologue and epilogue. This area is known as the red zone. This is not compatible with exception handling, because the IRET frame written by the hardware at the stack pointer and the functions to handle the exception will overwrite the temporary variables of the interrupted function, causing undefined behavior. So disable red-zones for the pre-decompression boot code. Signed-off-by: Joerg Roedel --- arch/x86/boot/Makefile | 2 +- arch/x86/boot/compressed/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile index e17be90ab312..93f1320fc7bf 100644 --- a/arch/x86/boot/Makefile +++ b/arch/x86/boot/Makefile @@ -65,7 +65,7 @@ clean-files += cpustr.h # --------------------------------------------------------------------------- -KBUILD_CFLAGS := $(REALMODE_CFLAGS) -D_SETUP +KBUILD_CFLAGS := $(REALMODE_CFLAGS) -D_SETUP -mno-red-zone KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__ KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=) KBUILD_CFLAGS += -fno-asynchronous-unwind-tables diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile index 5f7c262bcc99..085d5f083f50 100644 --- a/arch/x86/boot/compressed/Makefile +++ b/arch/x86/boot/compressed/Makefile @@ -30,7 +30,7 @@ KBUILD_CFLAGS := -m$(BITS) -O2 KBUILD_CFLAGS += -fno-strict-aliasing $(call cc-option, -fPIE, -fPIC) KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING cflags-$(CONFIG_X86_32) := -march=i386 -cflags-$(CONFIG_X86_64) := -mcmodel=small +cflags-$(CONFIG_X86_64) := -mcmodel=small -mno-red-zone KBUILD_CFLAGS += $(cflags-y) KBUILD_CFLAGS += -mno-mmx -mno-sse KBUILD_CFLAGS += $(call cc-option,-ffreestanding) -- 2.17.1