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=-5.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no 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 9D39EC433E0 for ; Thu, 28 Jan 2021 13:19:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5882164DDE for ; Thu, 28 Jan 2021 13:19:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231743AbhA1NTH (ORCPT ); Thu, 28 Jan 2021 08:19:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229885AbhA1NTC (ORCPT ); Thu, 28 Jan 2021 08:19:02 -0500 Received: from theia.8bytes.org (8bytes.org [IPv6:2a01:238:4383:600:38bc:a715:4b6d:a889]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A8ECC061573 for ; Thu, 28 Jan 2021 05:18:21 -0800 (PST) Received: by theia.8bytes.org (Postfix, from userid 1000) id 8407751D; Thu, 28 Jan 2021 14:18:19 +0100 (CET) Date: Thu, 28 Jan 2021 14:18:18 +0100 From: Joerg Roedel To: Lai Jiangshan Cc: X86 ML , Joerg Roedel , "H. Peter Anvin" , 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 , LKML , kvm@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: Re: [PATCH v7 45/72] x86/entry/64: Add entry code for #VC handler Message-ID: <20210128131817.GP32671@8bytes.org> References: <20200907131613.12703-1-joro@8bytes.org> <20200907131613.12703-46-joro@8bytes.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Lai, On Sun, Jan 24, 2021 at 10:11:14PM +0800, Lai Jiangshan wrote: > > + > > + /* > > + * No need to switch back to the IST stack. The current stack is either > > + * identical to the stack in the IRET frame or the VC fall-back stack, > > + * so it is definitly mapped even with PTI enabled. > > + */ > > + jmp paranoid_exit > > + > > > > Hello > > I know we don't enable PTI on AMD, but the above comment doesn't align to the > next code. > > We assume PTI is enabled as the comments said "even with PTI enabled". > > When #VC happens after entry_SYSCALL_64 but before it switches to the > kernel CR3. vc_switch_off_ist() will switch the stack to the kernel stack > and paranoid_exit can't work when it switches to user CR3 on the kernel stack. > > The comment above lost information that the current stack is possible to be > the kernel stack which is mapped not user CR3. > > Maybe I missed something. You are right, the scenario above would cause problems for the current #VC entry code. With SEV-ES an #VC exception can't happen in the early syscall entry code, so I think its the best to update the comment reflecting this. In the future this might change and then the #VC entry code needs to take care of this case too. Thanks for pointing it out. Regards, Joerg 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=-5.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no 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 6D5C8C433DB for ; Thu, 28 Jan 2021 13:18:27 +0000 (UTC) Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (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 C755764DDE for ; Thu, 28 Jan 2021 13:18:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C755764DDE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=8bytes.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=virtualization-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 6E2AC8738C; Thu, 28 Jan 2021 13:18:26 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SJRMUJawTj7F; Thu, 28 Jan 2021 13:18:25 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id 07C57873AB; Thu, 28 Jan 2021 13:18:24 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id DB8E4C0FA7; Thu, 28 Jan 2021 13:18:24 +0000 (UTC) Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 3BBCDC013A for ; Thu, 28 Jan 2021 13:18:23 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 265DD86B92 for ; Thu, 28 Jan 2021 13:18:23 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vqINTdJYfnzj for ; Thu, 28 Jan 2021 13:18:21 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from theia.8bytes.org (8bytes.org [81.169.241.247]) by whitealder.osuosl.org (Postfix) with ESMTPS id ADE8786AE7 for ; Thu, 28 Jan 2021 13:18:21 +0000 (UTC) Received: by theia.8bytes.org (Postfix, from userid 1000) id 8407751D; Thu, 28 Jan 2021 14:18:19 +0100 (CET) Date: Thu, 28 Jan 2021 14:18:18 +0100 From: Joerg Roedel To: Lai Jiangshan Subject: Re: [PATCH v7 45/72] x86/entry/64: Add entry code for #VC handler Message-ID: <20210128131817.GP32671@8bytes.org> References: <20200907131613.12703-1-joro@8bytes.org> <20200907131613.12703-46-joro@8bytes.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Cc: Juergen Gross , Tom Lendacky , Dave Hansen , Mike Stunes , Kees Cook , kvm@vger.kernel.org, Peter Zijlstra , Cfir Cohen , X86 ML , LKML , Sean Christopherson , virtualization@lists.linux-foundation.org, Martin Radev , Joerg Roedel , Masami Hiramatsu , Andy Lutomirski , "H. Peter Anvin" , Erdem Aktas , David Rientjes , Dan Williams , Jiri Slaby X-BeenThere: virtualization@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux virtualization List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: virtualization-bounces@lists.linux-foundation.org Sender: "Virtualization" Hello Lai, On Sun, Jan 24, 2021 at 10:11:14PM +0800, Lai Jiangshan wrote: > > + > > + /* > > + * No need to switch back to the IST stack. The current stack is either > > + * identical to the stack in the IRET frame or the VC fall-back stack, > > + * so it is definitly mapped even with PTI enabled. > > + */ > > + jmp paranoid_exit > > + > > > > Hello > > I know we don't enable PTI on AMD, but the above comment doesn't align to the > next code. > > We assume PTI is enabled as the comments said "even with PTI enabled". > > When #VC happens after entry_SYSCALL_64 but before it switches to the > kernel CR3. vc_switch_off_ist() will switch the stack to the kernel stack > and paranoid_exit can't work when it switches to user CR3 on the kernel stack. > > The comment above lost information that the current stack is possible to be > the kernel stack which is mapped not user CR3. > > Maybe I missed something. You are right, the scenario above would cause problems for the current #VC entry code. With SEV-ES an #VC exception can't happen in the early syscall entry code, so I think its the best to update the comment reflecting this. In the future this might change and then the #VC entry code needs to take care of this case too. Thanks for pointing it out. Regards, Joerg _______________________________________________ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization