Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1026303ybb; Wed, 8 Apr 2020 14:57:47 -0700 (PDT) X-Google-Smtp-Source: APiQypJQSvTjxzZtyFiLIdY4J1K8cyFMOoVXO1F6nius3pcz3jUn+YRRmrt/IkZHXOOHtO4aKOd5 X-Received: by 2002:a4a:dbc7:: with SMTP id t7mr2011573oou.57.1586383067324; Wed, 08 Apr 2020 14:57:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586383067; cv=none; d=google.com; s=arc-20160816; b=qm/lVWk+hUnPokpp658mXvdmpdSPmxVXJhRRwzVzm5QuSmJmwtBzrBQPKsfyXsXM8Q HHUI2W8I4LD6/INrLSNV0fobGec6OYWMIYDkAltDuLrTFh2QPfkdbMKyNomhG622DxfB nf/l80rY58i2cIE7YaIAgi5OccoljowI/1nHdQkSFA1jKia2oLmXsgBTBUDXjMsJXU98 TfYZO8I9oXI81iOROLoVEp/eN3rmYavWIE7+AOeEclDpkuPWEUU+FZraHSVNJAvu0Y60 EXJ5NjgbV2gfkwINxfTFt2PTjnl+HOXsI/ZdF3jM3AbVDw/ghZMzMMEvbSfB9GO8YJG6 EvPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=151LHWUJtSDB+75+jyNegOreKhf7IJmTVrlaiuCLhsY=; b=YQpv53Jro8WiWqzQW786DtIaljUsRmDZ+CPnMZAdZ546csQNF83bPftcG2TmzWs8WZ ZTIrOuFLx2cJtLp0hnXXYv4A9PRZ0PJ1rndwWIlwXg4LfkdE27w7p9A+fY3ENLZ142KR 7g3OXaMgNf7PJFTjzUzX4Gp+vsup2CQjfrgJCwXDSa2xW1E5kzrpjdrm3+qcmiPTrXOB noL9qEReAbgwyogw2Df/wasUsxjkI43P7B7EdE92bsWVU/BJaF+EGeDQ64zM08AYJVM1 Hs/lsBUI1qAkLIj5046qaOM7VPNPwZIUCl7omHVzEFCbDf3JFGQ62v46cbDiCFfHl8hs 4OzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VHTztM8X; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y29si3357894ote.208.2020.04.08.14.57.34; Wed, 08 Apr 2020 14:57:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VHTztM8X; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728517AbgDHUec (ORCPT + 99 others); Wed, 8 Apr 2020 16:34:32 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:37181 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726891AbgDHUeb (ORCPT ); Wed, 8 Apr 2020 16:34:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1586378071; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=151LHWUJtSDB+75+jyNegOreKhf7IJmTVrlaiuCLhsY=; b=VHTztM8XIUAivj2mGaM5iTDHDnFz4iE5SEWxrxgpFWt522aJwxDxyGDkQHAs67NFTBXE0p PPBbrU/YHzVy2ooJiF8uHsiBWGANxpKXMYbcaGrNCirz3biMAEmNMZ3+OMmqgDRvBSKzuk 3Bkk2NfEOSpcETkmo/v/0qDfBeUXs0A= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-357-1QQRLG7LOPa-SnRwx8FAtA-1; Wed, 08 Apr 2020 16:34:27 -0400 X-MC-Unique: 1QQRLG7LOPa-SnRwx8FAtA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 16B04107B114; Wed, 8 Apr 2020 20:34:26 +0000 (UTC) Received: from horse.redhat.com (ovpn-115-85.rdu2.redhat.com [10.10.115.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id DAA125DA84; Wed, 8 Apr 2020 20:34:25 +0000 (UTC) Received: by horse.redhat.com (Postfix, from userid 10451) id 4583D2202B8; Wed, 8 Apr 2020 16:34:25 -0400 (EDT) Date: Wed, 8 Apr 2020 16:34:25 -0400 From: Vivek Goyal To: Thomas Gleixner Cc: Paolo Bonzini , Sean Christopherson , Andy Lutomirski , Peter Zijlstra , Andy Lutomirski , LKML , X86 ML , kvm list , stable Subject: Re: [PATCH v2] x86/kvm: Disable KVM_ASYNC_PF_SEND_ALWAYS Message-ID: <20200408203425.GD93547@redhat.com> References: <20200407172140.GB64635@redhat.com> <772A564B-3268-49F4-9AEA-CDA648F6131F@amacapital.net> <87eeszjbe6.fsf@nanos.tec.linutronix.de> <874ktukhku.fsf@nanos.tec.linutronix.de> <274f3d14-08ac-e5cc-0b23-e6e0274796c8@redhat.com> <20200408153413.GA11322@linux.intel.com> <87d08hc0vz.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87d08hc0vz.fsf@nanos.tec.linutronix.de> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 08, 2020 at 08:01:36PM +0200, Thomas Gleixner wrote: > Paolo Bonzini writes: > > On 08/04/20 17:34, Sean Christopherson wrote: > >> On Wed, Apr 08, 2020 at 10:23:58AM +0200, Paolo Bonzini wrote: > >>> Page-not-present async page faults are almost a perfect match for the > >>> hardware use of #VE (and it might even be possible to let the processor > >>> deliver the exceptions). > >> > >> My "async" page fault knowledge is limited, but if the desired behavior is > >> to reflect a fault into the guest for select EPT Violations, then yes, > >> enabling EPT Violation #VEs in hardware is doable. The big gotcha is that > >> KVM needs to set the suppress #VE bit for all EPTEs when allocating a new > >> MMU page, otherwise not-present faults on zero-initialized EPTEs will get > >> reflected. > >> > >> Attached a patch that does the prep work in the MMU. The VMX usage would be: > >> > >> kvm_mmu_set_spte_init_value(VMX_EPT_SUPPRESS_VE_BIT); > >> > >> when EPT Violation #VEs are enabled. It's 64-bit only as it uses stosq to > >> initialize EPTEs. 32-bit could also be supported by doing memcpy() from > >> a static page. > > > > The complication is that (at least according to the current ABI) we > > would not want #VE to kick if the guest currently has IF=0 (and possibly > > CPL=0). But the ABI is not set in stone, and anyway the #VE protocol is > > a decent one and worth using as a base for whatever PV protocol we design. > > Forget the current pf async semantics (or the lack of). You really want > to start from scratch and igore the whole thing. > > The charm of #VE is that the hardware can inject it and it's not nesting > until the guest cleared the second word in the VE information area. If > that word is not 0 then you get a regular vmexit where you suspend the > vcpu until the nested problem is solved. So IIUC, only one process on a vcpu could affort to relinquish cpu to another task. If next task also triggers EPT violation, that will result in VM exit (as previous #VE is not complete yet) and vcpu will be halted. > > So you really don't worry about the guest CPU state at all. The guest > side #VE handler has to decide what it wants from the host depending on > it's internal state: > > - Suspend me and resume once the EPT fail is solved > > - Let me park the failing task and tell me once you resolved the > problem. > > That's pretty straight forward and avoids the whole nonsense which the > current mess contains. It completely avoids the allocation stuff as well > as you need to use a PV page where the guest copies the VE information > to. > > The notification that a problem has been resolved needs to go through a > separate vector which still has the IF=1 requirement obviously. How is this vector decided between guest and host. Failure to fault in page will be communicated through same vector? Thanks Vivek