From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2081.outbound.protection.outlook.com [40.107.220.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D1E02FB2 for ; Wed, 25 Aug 2021 15:18:49 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MI9zaJqctj9DT/XvrDbFMDbJUXrY16+MkmFZHVW6hx137nC0mJpd8Z6mYI0Ti1kB4L1REY5N5/Taja9vkRJMFrqNRp25i7lN1tB098AHoc0FTQiKU4aOhDDwEQ2zDlsaiZCbjPti02F2SPoETSQ7YEohVSXJKlxqvXstECfOwA+l6nJUJ6hrJ0ZHihoXj2dKRgej8Xk/Hl3WcRlykzSRnr16K2V8egiAJTeTPIy8Xnslu8LZ831fbS0NpmsCxFuYKp0wr56rIUo8CQ58ZL390wMc3ZPPAMiuYCEsp3lIj2QkMBx4p+8HsOR1XGUW+MKfRd56gKGi0SxV81K40cxsCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3sZKvX4kWKcQ6r52UHNwDUGtvKa+ygMYOy/WhDv2Fh4=; b=XVhd5UDYqlc81BoSDrLc9SAYTQpSJQYv8zu7i6XvT0CG9oONPomcpGJfKBXSQPpwF5aMF7FgVAwUoO3BMipAgTTR/OSpTSmVLUm8QEs9ZvpNCy3mMoBB+X/9k1HzMzN/Q6ToG6qszX4KlXT7CJXthYLy34Ue2QVnTIru5NHZvs3PG9lIdzIGE2R3vvigSqg9+YITRwU+kZMxDgUZYV/AaL2M1MilSGCkHca/xdq3eiwiewmZU8c4Sw9p1TlH+sVf2Wf0Yww8ukjI8Y3VjOpka0vJE8AwqVuxeVGpWs7OfVWSGwPkCZ+YfDS6ybAbo8Af7EsSM9C3EXfzunlxPrFzgA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3sZKvX4kWKcQ6r52UHNwDUGtvKa+ygMYOy/WhDv2Fh4=; b=UQdkKHQwgWmT6Mh4vXxK//9qnMpunzWHlgDnsHlRH8l8teFlvcQxSeSWovjv6kWtwUDp0aCd/C6ggz5owwOvq/H7Rv5X1PqQtDPU2rhCe2ednMU2mH1o3Lp6tr+A7d0zKYKzvQVZTZaVi2qA9w8ad6rb4NkgF1EIqGBBYp1OzyQ= Authentication-Results: alien8.de; dkim=none (message not signed) header.d=none;alien8.de; dmarc=none action=none header.from=amd.com; Received: from CH2PR12MB4133.namprd12.prod.outlook.com (2603:10b6:610:7a::13) by CH2PR12MB3878.namprd12.prod.outlook.com (2603:10b6:610:2a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19; Wed, 25 Aug 2021 15:18:46 +0000 Received: from CH2PR12MB4133.namprd12.prod.outlook.com ([fe80::d19e:b657:5259:24d0]) by CH2PR12MB4133.namprd12.prod.outlook.com ([fe80::d19e:b657:5259:24d0%8]) with mapi id 15.20.4436.019; Wed, 25 Aug 2021 15:18:46 +0000 Date: Wed, 25 Aug 2021 10:18:35 -0500 From: Michael Roth To: Borislav Petkov Cc: Brijesh Singh , x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-efi@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-coco@lists.linux.dev, linux-mm@kvack.org, Thomas Gleixner , Ingo Molnar , Joerg Roedel , Tom Lendacky , "H. Peter Anvin" , Ard Biesheuvel , Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Andy Lutomirski , Dave Hansen , Sergio Lopez , Peter Gonda , Peter Zijlstra , Srinivas Pandruvada , David Rientjes , Dov Murik , Tobin Feldman-Fitzthum , Vlastimil Babka , "Kirill A . Shutemov" , Andi Kleen , tony.luck@intel.com, marcorr@google.com, sathyanarayanan.kuppuswamy@linux.intel.com Subject: Re: [PATCH Part1 v5 23/38] x86/head/64: set up a startup %gs for stack protector Message-ID: <20210825151835.wzgabnl7rbrge3a2@amd.com> References: <20210820151933.22401-1-brijesh.singh@amd.com> <20210820151933.22401-24-brijesh.singh@amd.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: SA0PR11CA0163.namprd11.prod.outlook.com (2603:10b6:806:1bb::18) To CH2PR12MB4133.namprd12.prod.outlook.com (2603:10b6:610:7a::13) Precedence: bulk X-Mailing-List: linux-coco@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost (76.251.165.188) by SA0PR11CA0163.namprd11.prod.outlook.com (2603:10b6:806:1bb::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Wed, 25 Aug 2021 15:18:45 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4fb37a8a-e7d9-407f-3799-08d967dba1b2 X-MS-TrafficTypeDiagnostic: CH2PR12MB3878: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /Hyw+i4c5KbcugAWvKk3Q+40yq852DLKoZk+2jxLbxLdfJnTKGwgL3wehYwNC+F8qtB9t6XiRuFMJCTUB5J5nQmKIJ49y9S3CrjThEZNXHtMSva78GTUXUejiSpZOeU1Cq5fQ4iCCrWntPKUeokJphNHtJmIIrLr6ndLefS/gRpDiEiuJ024Q0jtL5MH+0D43xijye7DPgcmVCSEv/UbsIGP9W8xM4n2Ss8eDaZSiQJuAYjeV29RlgvhooCBfs5Q6+HqGp3Yrn2MsINU9QokzwsmmdVPS95YzbN5tu1gKNa51LZ2eRtDGVHL6Jzca50Yc1emDam1iowQsTiC2JrIhtMmIY0p1CoJgYvfNo/NoUTTjVSLM5IFJciwHQ8HO9SqJ9nk+tYDua6tQUhqAf0c6z86rgi5JuPrKasObpVn3MDAXdohszT0ojBPSCfV5daiP9xF97qO+BrCBOvzQ8shmTJEnx0OZ1MME2uQpdt0J6Cqw7a276ZKFRm2wvXM17RmEcR116cDkFvpwr0WujP3RkDs4AFmcVPVyaeoaEg9bc4LDKlnk2M9oj/I7aQJz60IisaL9eao6z4F5B/wVQr9HQ4F3gIAjvp04AQhQgMN+EyJLkEbnxg8lZZE5ST/VDJRaDEV5pIGJbr+zj8GYD+pYiz40B6wI03F/Yrm6zFsT9loo7Pr2rpfDFkYMva1Zw/x X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH2PR12MB4133.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(39860400002)(376002)(136003)(346002)(366004)(2616005)(66556008)(2906002)(4326008)(6916009)(44832011)(956004)(83380400001)(36756003)(6486002)(66946007)(66476007)(86362001)(6666004)(54906003)(316002)(26005)(5660300002)(8936002)(1076003)(52116002)(38100700002)(38350700002)(6496006)(8676002)(478600001)(186003)(7416002)(7406005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Fr1ohqs5z2Qzy04libSMiGmzF+rq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qktgpVde+3M2HO5b2WDrPBQcl8ki/k5zCzV42PPz5UbugWwNiaUbshUZZbz?= =?us-ascii?Q?/Xlg+oqR9CH57Y8CbV7kEqp8n3v58K+9opVe70dEKnYs2ekpx+ME8ZyKgEYe?= =?us-ascii?Q?uPOd6A3xcq1yqjU3TjsK02K+uq1cFSt09+4sgh39vW9HXFJXSkHUJ6vIvYN2?= =?us-ascii?Q?FQgFfRmsbIH1SGwJMFtrr79jGD+sMsah9OMMX8Wl7hkES8lh5IsbcsSwjpOx?= =?us-ascii?Q?JMRhX19fYm/r4l6uME+kHIReLuVuPyqtAKYBxT1cHIuXMIw+MbwdFXkEqi/E?= =?us-ascii?Q?UyvA81qTgMJ3Hym1F7HlrAElwKOVH16j0d0DmD9zrYyLFBZw7oUzU8MbKxRw?= =?us-ascii?Q?C/HyB5jNItbeyxE7vL2V+W9q4xEUtokhGqs/IpWh/5tMI5takIwROz5x8O8H?= =?us-ascii?Q?5+pEbq6NsS7uXupwnHF5/jRz?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4fb37a8a-e7d9-407f-3799-08d967dba1b2 X-MS-Exchange-CrossTenant-AuthSource: CH2PR12MB4133.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2021 15:18:46.0216 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ojff3LW/fTu8/eZW+JAIFFbDFJ87oksWvi1ATRy835GWHAC516GymBhSG9wlobGKdZBQupu3978/eJNNvMaOlQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB3878 On Wed, Aug 25, 2021 at 04:29:13PM +0200, Borislav Petkov wrote: > On Fri, Aug 20, 2021 at 10:19:18AM -0500, Brijesh Singh wrote: > > From: Michael Roth > > > > As of commit 103a4908ad4d ("x86/head/64: Disable stack protection for > > head$(BITS).o") kernel/head64.c is compiled with -fno-stack-protector > > to allow a call to set_bringup_idt_handler(), which would otherwise > > have stack protection enabled with CONFIG_STACKPROTECTOR_STRONG. While > > sufficient for that case, this will still cause issues if we attempt to > > call out to any external functions that were compiled with stack > > protection enabled that in-turn make stack-protected calls, or if the > > exception handlers set up by set_bringup_idt_handler() make calls to > > stack-protected functions. > > > > Subsequent patches for SEV-SNP CPUID validation support will introduce > > both such cases. Attempting to disable stack protection for everything > > in scope to address that is prohibitive since much of the code, like > > SEV-ES #VC handler, is shared code that remains in use after boot and > > could benefit from having stack protection enabled. Attempting to inline > > calls is brittle and can quickly balloon out to library/helper code > > where that's not really an option. > > > > Instead, set up %gs to point a buffer that stack protector can use for > > canary values when needed. > > > > In doing so, it's likely we can stop using -no-stack-protector for > > head64.c, but that hasn't been tested yet, and head32.c would need a > > similar solution to be safe, so that is left as a potential follow-up. > > That... Argh! I had this fixed up but I think it got clobbered in the patch shuffle. I'll make sure to fix this, and remember to actually test without CONFIG_STACKPTROTECTOR this time. Sorry for the screw-up. > > > Signed-off-by: Michael Roth > > Signed-off-by: Brijesh Singh > > --- > > arch/x86/kernel/Makefile | 2 +- > > arch/x86/kernel/head64.c | 20 ++++++++++++++++++++ > > 2 files changed, 21 insertions(+), 1 deletion(-) > > > > diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile > > index 3e625c61f008..5abdfd0dbbc3 100644 > > --- a/arch/x86/kernel/Makefile > > +++ b/arch/x86/kernel/Makefile > > @@ -46,7 +46,7 @@ endif > > # non-deterministic coverage. > > KCOV_INSTRUMENT := n > > > > -CFLAGS_head$(BITS).o += -fno-stack-protector > > +CFLAGS_head32.o += -fno-stack-protector > > ... and that needs to be taken care of too. I didn't realize the the 32-bit path was something you were suggesting to have added in this patch, but I'll take a look at that as well.