Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp978249pxb; Thu, 28 Jan 2021 05:22:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJz1vL6A1M+jP8YyhEFwOo+ghC9NWCyFk0YyrnBdOG0xjBKdKGVl+srB++qsCzpveK2mPYOS X-Received: by 2002:a17:906:6449:: with SMTP id l9mr11727192ejn.320.1611840168848; Thu, 28 Jan 2021 05:22:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611840168; cv=none; d=google.com; s=arc-20160816; b=SLChf07gNY1ePj89cpXS2dc3jklLRlb3rvdT9A6Bj0kFszwX/UdlnGNLh3vpK2ZGVg PJbgeB+ns0GbsQ3J5bNHepCGHrI0mzxcDw8NGiQQXOP8sx/o/WwblLsIlBIC/amYrAhY HWIHXN9T76OS7u3zlRftqBsqQTU7cdXIY0dNv8xPwoX4S5JqVvoEBTDO2PE0m1P0XlaP srJ4lC5+dQRHN7mlcEo9dN8vHx6JGwuT2At95ewJy8CJb8GUWDL4FtOsIdWPOYXDV0v6 hpE10gm4ATJGOlD4qLt0bh4ghpeoL+cnEYqjK/qhzDM+ZW05Skla0P6KmMt4OID0iKx6 F/Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=fWQSq/VvZzMjSMXhcf8bBRZGi/nN0L4H+sCaGeftmd8=; b=tyfXwfS88iJdHqwZCy3HH+efWwetJJ0WZXQVhNWWWNwN01WEjD3SyG3gbmarFBdwMF FywLl+kSehYbZnw2hKb8BCJK8Eqno7zOqT1/HTJviNt2ArvOPDrXM0fv50zGBD8TJdII jl1gteyTDYN9Pv4v5Wt4QWOTPdMZy+g3oVGgaKUDbl43ZnxAYeme/KroKDbBE6+Ssqky B6fw3b5AajvvAmegGZWeHFDZnketfRdO+6G6Zde4eOLLjmVc4fxXShZ0x8aQ1FkSm3wT yp1JaQn49C1w/babdXg4FeWotgs5G6RH8inkk5S3kbLyM7o/x4saXTJz0whyfl8z6m0Q r1gQ== 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 cy17si2903675edb.193.2021.01.28.05.22.23; Thu, 28 Jan 2021 05:22:48 -0800 (PST) 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 S231374AbhA1NTD (ORCPT + 99 others); Thu, 28 Jan 2021 08:19:03 -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