Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1705797ybh; Tue, 14 Jul 2020 05:19:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwI83iwOgZK3AtaJYY1NzuhttpyEgASB6gTn+AQYVwP/Kzc6l0rqkgus8RvX/dbYKRhLZpu X-Received: by 2002:a17:906:4c42:: with SMTP id d2mr4176914ejw.345.1594729183352; Tue, 14 Jul 2020 05:19:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594729183; cv=none; d=google.com; s=arc-20160816; b=uen2pJ5PafjlHKAPx+5Nu9XSJJqQGy5KOzGgZRcXGrtnlpLEuMkKkzatUMZ7XOBkbo bmJMpfMafKeN6mfo+SEdLd6welDVcf15yKxACx7P1dK06KQhw9XS6z6BUU4Tev1qebWp BosL1rtTLAx5xN6yQvAWPKDCRd6NNDm7LfmV8UlnobZsNigHs/HLIY7Zhd7ya6RO0Xpv V++Q10mF4DfTKZL0HB1++Aan5jDICv6hd3wMWv1bJM5IzPHQKpuyEeofs1jTUTcqEhYt +Mi7R41dn+R0XaoXL7WbSlARt+ciqvdeH7URgWL59HHHzrAj5XzDlbNr8zswt8+03pRv qQ6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Mlw99oP19X0aR7s6L677CtfNkGCJyzlBCcNuINUMbkg=; b=IfXakP6BR1b2NoBNOOlzqWM+o8pWojGuUmmrFPNgH6/8S9cItFdejeLYMUNwv2EDGV kJdYE1V10Zg0NwxCcJjU+OqlfKWv6XtN8Wop5t4ezg14HjoEqKcn9b30nGd21q6DL2NP 7oPqfpqb60WJNaT5IpfGTHVfmEkXhB0EODXjWjm5crmK2q0JfHj0GRKsEgy6y3xGBNnp PREt9fwmME2EdIV53m8dnD3mlnh0Wj93cUXLNVIA0fsTPpKJIYce+nJhmNWgtpFopvm9 dZlm0qtIiWhafu00zlG0M5kAQMJ9n+1CE6HjM2G33qE6MfbUaeDIhynDuFPO5XIQ2wZ3 YQMQ== 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 dt17si13913559ejc.457.2020.07.14.05.19.17; Tue, 14 Jul 2020 05:19:43 -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 S1728912AbgGNMP3 (ORCPT + 99 others); Tue, 14 Jul 2020 08:15:29 -0400 Received: from 8bytes.org ([81.169.241.247]:52886 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728305AbgGNMKx (ORCPT ); Tue, 14 Jul 2020 08:10:53 -0400 Received: from cap.home.8bytes.org (p5b006776.dip0.t-ipconnect.de [91.0.103.118]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by theia.8bytes.org (Postfix) with ESMTPSA id B421AE6C; Tue, 14 Jul 2020 14:10:50 +0200 (CEST) From: Joerg Roedel To: x86@kernel.org Cc: Joerg Roedel , Joerg Roedel , hpa@zytor.com, Andy Lutomirski , Dave Hansen , Peter Zijlstra , Jiri Slaby , Dan Williams , Tom Lendacky , Juergen Gross , Kees Cook , David Rientjes , Cfir Cohen , Erdem Aktas , Masami Hiramatsu , Mike Stunes , Sean Christopherson , Martin Radev , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: [PATCH v4 33/75] x86/head/64: Switch to initial stack earlier Date: Tue, 14 Jul 2020 14:08:35 +0200 Message-Id: <20200714120917.11253-34-joro@8bytes.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200714120917.11253-1-joro@8bytes.org> References: <20200714120917.11253-1-joro@8bytes.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joerg Roedel Make sure there is a stack once the kernel runs from virual addresses. At this stage any secondary CPU which boots will have lost its stack because the kernel switched to a new page-table which does not map the real-mode stack anymore. This is needed for handling early #VC exceptions caused by instructions like CPUID. Signed-off-by: Joerg Roedel --- arch/x86/kernel/head_64.S | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S index 61aa1e56fc9c..fcaa5dbd728a 100644 --- a/arch/x86/kernel/head_64.S +++ b/arch/x86/kernel/head_64.S @@ -195,6 +195,12 @@ SYM_CODE_START(secondary_startup_64) movl initial_gs+4(%rip),%edx wrmsr + /* + * Setup a boot time stack - Any secondary CPU will have lost its stack + * by now because the cr3-switch above unmaps the real-mode stack + */ + movq initial_stack(%rip), %rsp + /* Check if nx is implemented */ movl $0x80000001, %eax cpuid @@ -215,9 +221,6 @@ SYM_CODE_START(secondary_startup_64) /* Make changes effective */ movq %rax, %cr0 - /* Setup a boot time stack */ - movq initial_stack(%rip), %rsp - /* zero EFLAGS after setting rsp */ pushq $0 popfq -- 2.27.0