Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4270138pxj; Wed, 12 May 2021 01:39:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyf22mmI4ZAEtos3/H0nRch943ByJfGtAAsfRmrptlUKjlWPTlnLN/RzxJKprXzECSYuGDd X-Received: by 2002:a17:907:3f1c:: with SMTP id hq28mr35934218ejc.349.1620808769454; Wed, 12 May 2021 01:39:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620808769; cv=none; d=google.com; s=arc-20160816; b=Du9Fj+DyT0E3ooRaFvxRIuCXMiJexK4t3S9qveDvkmdXyRzm5x2a46g9+bLl6imdhr 6sKxX2QCQ0Mwk7SshlBwyrgPofAXjGdBJ6Psb+2Jtgo+L/nxxpTyN4rvWfnUZJ4/Z4bg KD5CmshkObbM5if6YZX4GBKcRf7s7jHwFRV4gRpbNcgMfgL1d1GIVWGpGOiswSOb0VYx D2evpsrCptucYQRvHA2XyupUM1B2duJMB51MixrFd1E8OOY799ejnYSpNwaC0AhWPWod H1jnsJNdf4ZrOw0SeQkcEOLsveYhllWy5L4YJ1VZwjgyn03laBGldJ/Jj9/UxYghw5Tg zAFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=0ZkbwpyglBUEVnlRSc6P4qdlmv6l9ZJ02lqGnekzAIU=; b=iAMclzuB2enPbCkQvq+g9+1veSVG4Z2s22bP0YB+f86B9sAXEjBXy1ngtdjLwYkzfJ +q+0XNgmTJjt9OWHgnqfILr6ugoME43StKGonzOKbxlQIrq9bM0n5B8pGCdpQGWj2TkP WHDefzezLX1RAonzrCP6i76aI/f0jm/0it2/fn9i/d10Wn0kazML0XBGfHgWuUs9G5LU fhcGdQgdlBaQ8iRJwZyATLrDNede1JiaUadziDVRxHzF+flRmya9gckFJFwI0/5vAh+Y qVlzQLCqyR6x6C2gJc8qLOraHxnWn5VuqX7y9RV/4fqKRDltt0PKK6VcPAYSemJW3Xp+ pD7Q== 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 fi12si1338365ejb.474.2021.05.12.01.39.05; Wed, 12 May 2021 01:39:29 -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 S230370AbhELIit (ORCPT + 99 others); Wed, 12 May 2021 04:38:49 -0400 Received: from 8bytes.org ([81.169.241.247]:38784 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230096AbhELIiq (ORCPT ); Wed, 12 May 2021 04:38:46 -0400 Received: by theia.8bytes.org (Postfix, from userid 1000) id E8C872A5; Wed, 12 May 2021 10:37:37 +0200 (CEST) Date: Wed, 12 May 2021 10:37:34 +0200 From: 'Joerg Roedel' To: David Laight Cc: "x86@kernel.org" , Hyunwook Baek , Joerg Roedel , "stable@vger.kernel.org" , "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 , Arvind Sankar , "linux-coco@lists.linux.dev" , "linux-kernel@vger.kernel.org" , "kvm@vger.kernel.org" , "virtualization@lists.linux-foundation.org" Subject: Re: [PATCH 3/6] x86/sev-es: Use __put_user()/__get_user Message-ID: References: <20210512075445.18935-1-joro@8bytes.org> <20210512075445.18935-4-joro@8bytes.org> <0496626f018d4d27a8034a4822170222@AcuMS.aculab.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0496626f018d4d27a8034a4822170222@AcuMS.aculab.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 12, 2021 at 08:04:33AM +0000, David Laight wrote: > That can't be right at all. > __put/get_user() are only valid on user addresses and will try to > fault in a missing page - so can sleep. Yes, in general these functions can sleep, but not in this context. They are called in atomic context and the page-fault handler will notice that and goes down the __bad_area_nosemaphore() path and only do the fixup. I also thought about adding page_fault_disable()/page_fault_enable() calls, but being in atomic context is enough according to the faulthandler_disabled() implementation. This is exactly what is needed here. All I want to know is whether a fault happened or not, the page-fault handler must not try to fix the fault in any way. If a fault happens it is later fixed up in vc_forward_exception(). > At best this is abused the calls. Yes, but that is only due to the naming of these functions. In this case they do exactly what is needed. Regards, Joerg